From b14418bb90b985fe954f67e9f8b1049838af1e0c Mon Sep 17 00:00:00 2001 From: Richard Reukema Date: Sat, 18 Dec 2021 10:23:09 -0800 Subject: [PATCH] Update to .NET6 and C#10 - barebones effort to update the library and corrected two tests TestAddGrant/ TestAddGrants. Suppressed errors for XML only, there are some null reference exceptions --- src/Twilio/Base/IOptions.cs | 132 +- src/Twilio/Base/Page.cs | 320 +- src/Twilio/Base/Resource.cs | 4 +- src/Twilio/Base/ResourceSet.cs | 214 +- src/Twilio/Clients/ITwilioRestClient.cs | 70 +- src/Twilio/Clients/TwilioRestClient.cs | 496 +-- src/Twilio/Converters/HttpMethodConverter.cs | 130 +- src/Twilio/Converters/MarshalConverter.cs | 28 +- src/Twilio/Converters/PhoneNumberConverter.cs | 88 +- .../Converters/PrefixedCollapsibleMap.cs | 94 +- src/Twilio/Converters/Promoter.cs | 48 +- src/Twilio/Converters/Serializers.cs | 86 +- src/Twilio/Converters/StringEnumConverter.cs | 170 +- src/Twilio/Converters/TwimlConverter.cs | 88 +- src/Twilio/Exceptions/ApiException.cs | 122 +- .../CertificateValidationException.cs | 78 +- src/Twilio/Exceptions/RestException.cs | 148 +- src/Twilio/Exceptions/TwilioException.cs | 98 +- src/Twilio/Http/HttpClient.cs | 92 +- src/Twilio/Http/HttpMethod.cs | 176 +- src/Twilio/Http/Request.cs | 528 +-- src/Twilio/Http/Response.cs | 64 +- src/Twilio/Http/SystemNetHttpClient.cs | 212 +- src/Twilio/JWT/AccessToken/ChatGrant.cs | 140 +- .../JWT/AccessToken/ConversationsGrant.cs | 70 +- src/Twilio/JWT/AccessToken/IGrant.cs | 32 +- .../JWT/AccessToken/IpMessagingGrant.cs | 124 +- src/Twilio/JWT/AccessToken/PlaybackGrant.cs | 70 +- src/Twilio/JWT/AccessToken/SyncGrant.cs | 86 +- src/Twilio/JWT/AccessToken/Token.cs | 262 +- src/Twilio/JWT/AccessToken/VideoGrant.cs | 114 +- src/Twilio/JWT/AccessToken/VoiceGrant.cs | 166 +- src/Twilio/JWT/Client/ClientCapability.cs | 114 +- src/Twilio/JWT/Client/EventStreamScope.cs | 106 +- src/Twilio/JWT/Client/IScope.cs | 18 +- src/Twilio/JWT/Client/IncomingClientScope.cs | 58 +- src/Twilio/JWT/Client/OutgoingClientScope.cs | 136 +- src/Twilio/JWT/Taskrouter/Policy.cs | 128 +- src/Twilio/JWT/Taskrouter/PolicyUtils.cs | 42 +- .../JWT/Taskrouter/TaskRouterCapability.cs | 172 +- src/Twilio/Properties/AssemblyInfo.cs | 4 +- .../Accounts/V1/AuthTokenPromotionOptions.cs | 30 +- .../Accounts/V1/AuthTokenPromotionResource.cs | 244 +- .../Rest/Accounts/V1/Credential/AwsOptions.cs | 367 +- .../Accounts/V1/Credential/AwsResource.cs | 936 ++-- .../V1/Credential/PublicKeyOptions.cs | 362 +- .../V1/Credential/PublicKeyResource.cs | 932 ++-- .../Accounts/V1/SecondaryAuthTokenOptions.cs | 54 +- .../Accounts/V1/SecondaryAuthTokenResource.cs | 364 +- .../Address/DependentPhoneNumberOptions.cs | 74 +- .../Address/DependentPhoneNumberResource.cs | 670 +-- .../Rest/Api/V2010/Account/AddressOptions.cs | 688 +-- .../Rest/Api/V2010/Account/AddressResource.cs | 1192 ++--- .../Api/V2010/Account/ApplicationOptions.cs | 838 ++-- .../Api/V2010/Account/ApplicationResource.cs | 1348 +++--- .../Account/AuthorizedConnectAppOptions.cs | 110 +- .../Account/AuthorizedConnectAppResource.cs | 602 +-- .../LocalOptions.cs | 400 +- .../LocalResource.cs | 624 +-- .../MachineToMachineOptions.cs | 400 +- .../MachineToMachineResource.cs | 628 +-- .../MobileOptions.cs | 400 +- .../MobileResource.cs | 624 +-- .../NationalOptions.cs | 400 +- .../NationalResource.cs | 624 +-- .../SharedCostOptions.cs | 400 +- .../SharedCostResource.cs | 624 +-- .../TollFreeOptions.cs | 400 +- .../TollFreeResource.cs | 624 +-- .../VoipOptions.cs | 400 +- .../VoipResource.cs | 624 +-- .../AvailablePhoneNumberCountryOptions.cs | 112 +- .../AvailablePhoneNumberCountryResource.cs | 532 +-- .../Rest/Api/V2010/Account/BalanceOptions.cs | 40 +- .../Rest/Api/V2010/Account/BalanceResource.cs | 228 +- .../Api/V2010/Account/Call/EventOptions.cs | 74 +- .../Api/V2010/Account/Call/EventResource.cs | 350 +- .../Api/V2010/Account/Call/FeedbackOptions.cs | 274 +- .../V2010/Account/Call/FeedbackResource.cs | 620 +-- .../Account/Call/FeedbackSummaryOptions.cs | 280 +- .../Account/Call/FeedbackSummaryResource.cs | 688 +-- .../V2010/Account/Call/NotificationOptions.cs | 224 +- .../Account/Call/NotificationResource.cs | 688 +-- .../Api/V2010/Account/Call/PaymentOptions.cs | 534 +-- .../Api/V2010/Account/Call/PaymentResource.cs | 760 ++-- .../V2010/Account/Call/RecordingOptions.cs | 578 +-- .../V2010/Account/Call/RecordingResource.cs | 1284 +++--- .../Api/V2010/Account/Call/SiprecOptions.cs | 3818 ++++++++--------- .../Api/V2010/Account/Call/SiprecResource.cs | 2124 ++++----- .../Rest/Api/V2010/Account/CallOptions.cs | 1288 +++--- .../Rest/Api/V2010/Account/CallResource.cs | 1716 ++++---- .../Account/Conference/ParticipantOptions.cs | 1358 +++--- .../Account/Conference/ParticipantResource.cs | 1594 +++---- .../Account/Conference/RecordingOptions.cs | 404 +- .../Account/Conference/RecordingResource.cs | 1078 ++--- .../Api/V2010/Account/ConferenceOptions.cs | 384 +- .../Api/V2010/Account/ConferenceResource.cs | 902 ++-- .../Api/V2010/Account/ConnectAppOptions.cs | 386 +- .../Api/V2010/Account/ConnectAppResource.cs | 950 ++-- .../AssignedAddOnExtensionOptions.cs | 180 +- .../AssignedAddOnExtensionResource.cs | 596 +-- .../AssignedAddOnOptions.cs | 330 +- .../AssignedAddOnResource.cs | 898 ++-- .../IncomingPhoneNumber/LocalOptions.cs | 592 +-- .../IncomingPhoneNumber/LocalResource.cs | 1154 ++--- .../IncomingPhoneNumber/MobileOptions.cs | 592 +-- .../IncomingPhoneNumber/MobileResource.cs | 1154 ++--- .../IncomingPhoneNumber/TollFreeOptions.cs | 592 +-- .../IncomingPhoneNumber/TollFreeResource.cs | 1154 ++--- .../Account/IncomingPhoneNumberOptions.cs | 1198 +++--- .../Account/IncomingPhoneNumberResource.cs | 1786 ++++---- .../Rest/Api/V2010/Account/KeyOptions.cs | 252 +- .../Rest/Api/V2010/Account/KeyResource.cs | 794 ++-- .../V2010/Account/Message/FeedbackOptions.cs | 82 +- .../V2010/Account/Message/FeedbackResource.cs | 296 +- .../Api/V2010/Account/Message/MediaOptions.cs | 286 +- .../V2010/Account/Message/MediaResource.cs | 728 ++-- .../Rest/Api/V2010/Account/MessageOptions.cs | 720 ++-- .../Rest/Api/V2010/Account/MessageResource.cs | 1492 +++---- .../Rest/Api/V2010/Account/NewKeyOptions.cs | 56 +- .../Rest/Api/V2010/Account/NewKeyResource.cs | 250 +- .../Api/V2010/Account/NewSigningKeyOptions.cs | 56 +- .../V2010/Account/NewSigningKeyResource.cs | 250 +- .../Api/V2010/Account/NotificationOptions.cs | 186 +- .../Api/V2010/Account/NotificationResource.cs | 672 +-- .../V2010/Account/OutgoingCallerIdOptions.cs | 296 +- .../V2010/Account/OutgoingCallerIdResource.cs | 850 ++-- .../Api/V2010/Account/Queue/MemberOptions.cs | 268 +- .../Api/V2010/Account/Queue/MemberResource.cs | 710 +-- .../Rest/Api/V2010/Account/QueueOptions.cs | 368 +- .../Rest/Api/V2010/Account/QueueResource.cs | 1004 ++--- .../Recording/AddOnResult/PayloadOptions.cs | 270 +- .../Recording/AddOnResult/PayloadResource.cs | 780 ++-- .../Account/Recording/AddOnResultOptions.cs | 222 +- .../Account/Recording/AddOnResultResource.cs | 774 ++-- .../Account/Recording/TranscriptionOptions.cs | 222 +- .../Recording/TranscriptionResource.cs | 796 ++-- .../Api/V2010/Account/RecordingOptions.cs | 266 +- .../Api/V2010/Account/RecordingResource.cs | 896 ++-- .../Api/V2010/Account/ShortCodeOptions.cs | 322 +- .../Api/V2010/Account/ShortCodeResource.cs | 794 ++-- .../Api/V2010/Account/SigningKeyOptions.cs | 252 +- .../Api/V2010/Account/SigningKeyResource.cs | 794 ++-- .../Sip/CredentialList/CredentialOptions.cs | 440 +- .../Sip/CredentialList/CredentialResource.cs | 1044 ++--- .../Account/Sip/CredentialListOptions.cs | 336 +- .../Account/Sip/CredentialListResource.cs | 974 ++--- .../AuthCallsCredentialListMappingOptions.cs | 314 +- .../AuthCallsCredentialListMappingResource.cs | 852 ++-- ...hCallsIpAccessControlListMappingOptions.cs | 314 +- ...CallsIpAccessControlListMappingResource.cs | 854 ++-- ...gistrationsCredentialListMappingOptions.cs | 314 +- ...istrationsCredentialListMappingResource.cs | 858 ++-- .../Domain/CredentialListMappingOptions.cs | 318 +- .../Domain/CredentialListMappingResource.cs | 874 ++-- .../IpAccessControlListMappingOptions.cs | 314 +- .../IpAccessControlListMappingResource.cs | 866 ++-- .../Api/V2010/Account/Sip/DomainOptions.cs | 764 ++-- .../Api/V2010/Account/Sip/DomainResource.cs | 1306 +++--- .../IpAccessControlList/IpAddressOptions.cs | 486 +-- .../IpAccessControlList/IpAddressResource.cs | 1104 ++--- .../Account/Sip/IpAccessControlListOptions.cs | 336 +- .../Sip/IpAccessControlListResource.cs | 984 ++--- .../Rest/Api/V2010/Account/TokenOptions.cs | 56 +- .../Rest/Api/V2010/Account/TokenResource.cs | 266 +- .../Api/V2010/Account/TranscriptionOptions.cs | 172 +- .../V2010/Account/TranscriptionResource.cs | 768 ++-- .../Account/Usage/Record/AllTimeOptions.cs | 120 +- .../Account/Usage/Record/AllTimeResource.cs | 1008 ++--- .../Account/Usage/Record/DailyOptions.cs | 120 +- .../Account/Usage/Record/DailyResource.cs | 1008 ++--- .../Account/Usage/Record/LastMonthOptions.cs | 120 +- .../Account/Usage/Record/LastMonthResource.cs | 1008 ++--- .../Account/Usage/Record/MonthlyOptions.cs | 120 +- .../Account/Usage/Record/MonthlyResource.cs | 1008 ++--- .../Account/Usage/Record/ThisMonthOptions.cs | 120 +- .../Account/Usage/Record/ThisMonthResource.cs | 1008 ++--- .../Account/Usage/Record/TodayOptions.cs | 120 +- .../Account/Usage/Record/TodayResource.cs | 1008 ++--- .../Account/Usage/Record/YearlyOptions.cs | 120 +- .../Account/Usage/Record/YearlyResource.cs | 1008 ++--- .../Account/Usage/Record/YesterdayOptions.cs | 120 +- .../Account/Usage/Record/YesterdayResource.cs | 1008 ++--- .../Api/V2010/Account/Usage/RecordOptions.cs | 120 +- .../Api/V2010/Account/Usage/RecordResource.cs | 1008 ++--- .../Api/V2010/Account/Usage/TriggerOptions.cs | 530 +-- .../V2010/Account/Usage/TriggerResource.cs | 1714 ++++---- .../V2010/Account/ValidationRequestOptions.cs | 164 +- .../Account/ValidationRequestResource.cs | 294 +- src/Twilio/Rest/Api/V2010/AccountOptions.cs | 230 +- src/Twilio/Rest/Api/V2010/AccountResource.cs | 908 ++-- .../Autopilot/V1/Assistant/DefaultsOptions.cs | 140 +- .../V1/Assistant/DefaultsResource.cs | 374 +- .../Autopilot/V1/Assistant/DialogueOptions.cs | 74 +- .../V1/Assistant/DialogueResource.cs | 246 +- .../Assistant/FieldType/FieldValueOptions.cs | 420 +- .../Assistant/FieldType/FieldValueResource.cs | 926 ++-- .../V1/Assistant/FieldTypeOptions.cs | 434 +- .../V1/Assistant/FieldTypeResource.cs | 1004 ++--- .../V1/Assistant/ModelBuildOptions.cs | 412 +- .../V1/Assistant/ModelBuildResource.cs | 1044 ++--- .../Autopilot/V1/Assistant/QueryOptions.cs | 536 +-- .../Autopilot/V1/Assistant/QueryResource.cs | 1106 ++--- .../V1/Assistant/StyleSheetOptions.cs | 140 +- .../V1/Assistant/StyleSheetResource.cs | 374 +- .../V1/Assistant/Task/FieldOptions.cs | 392 +- .../V1/Assistant/Task/FieldResource.cs | 916 ++-- .../V1/Assistant/Task/SampleOptions.cs | 552 +-- .../V1/Assistant/Task/SampleResource.cs | 1106 ++--- .../V1/Assistant/Task/TaskActionsOptions.cs | 168 +- .../V1/Assistant/Task/TaskActionsResource.cs | 410 +- .../Assistant/Task/TaskStatisticsOptions.cs | 74 +- .../Assistant/Task/TaskStatisticsResource.cs | 260 +- .../Autopilot/V1/Assistant/TaskOptions.cs | 496 +-- .../Autopilot/V1/Assistant/TaskResource.cs | 1054 ++--- .../Autopilot/V1/Assistant/WebhookOptions.cs | 504 +-- .../Autopilot/V1/Assistant/WebhookResource.cs | 1046 ++--- .../Rest/Autopilot/V1/AssistantOptions.cs | 528 +-- .../Rest/Autopilot/V1/AssistantResource.cs | 1108 ++--- .../Autopilot/V1/RestoreAssistantOptions.cs | 72 +- .../Autopilot/V1/RestoreAssistantResource.cs | 310 +- .../Rest/Bulkexports/V1/Export/DayOptions.cs | 132 +- .../Rest/Bulkexports/V1/Export/DayResource.cs | 522 +-- .../V1/Export/ExportCustomJobOptions.cs | 246 +- .../V1/Export/ExportCustomJobResource.cs | 678 +-- .../Rest/Bulkexports/V1/Export/JobOptions.cs | 110 +- .../Rest/Bulkexports/V1/Export/JobResource.cs | 480 +-- .../V1/ExportConfigurationOptions.cs | 164 +- .../V1/ExportConfigurationResource.cs | 404 +- .../Rest/Bulkexports/V1/ExportOptions.cs | 56 +- .../Rest/Bulkexports/V1/ExportResource.cs | 220 +- src/Twilio/Rest/Chat/V1/CredentialOptions.cs | 480 +-- src/Twilio/Rest/Chat/V1/CredentialResource.cs | 1066 ++--- .../Chat/V1/Service/Channel/InviteOptions.cs | 368 +- .../Chat/V1/Service/Channel/InviteResource.cs | 902 ++-- .../Chat/V1/Service/Channel/MemberOptions.cs | 474 +- .../Chat/V1/Service/Channel/MemberResource.cs | 1084 ++--- .../Chat/V1/Service/Channel/MessageOptions.cs | 490 +-- .../V1/Service/Channel/MessageResource.cs | 1134 ++--- .../Rest/Chat/V1/Service/ChannelOptions.cs | 464 +- .../Rest/Chat/V1/Service/ChannelResource.cs | 1114 ++--- .../Rest/Chat/V1/Service/RoleOptions.cs | 420 +- .../Rest/Chat/V1/Service/RoleResource.cs | 1032 ++--- .../V1/Service/User/UserChannelOptions.cs | 78 +- .../V1/Service/User/UserChannelResource.cs | 440 +- .../Rest/Chat/V1/Service/UserOptions.cs | 456 +- .../Rest/Chat/V1/Service/UserResource.cs | 1078 ++--- src/Twilio/Rest/Chat/V1/ServiceOptions.cs | 1242 +++--- src/Twilio/Rest/Chat/V1/ServiceResource.cs | 1664 +++---- src/Twilio/Rest/Chat/V2/CredentialOptions.cs | 480 +-- src/Twilio/Rest/Chat/V2/CredentialResource.cs | 1066 ++--- .../Rest/Chat/V2/Service/BindingOptions.cs | 238 +- .../Rest/Chat/V2/Service/BindingResource.cs | 768 ++-- .../Chat/V2/Service/Channel/InviteOptions.cs | 368 +- .../Chat/V2/Service/Channel/InviteResource.cs | 902 ++-- .../Chat/V2/Service/Channel/MemberOptions.cs | 754 ++-- .../Chat/V2/Service/Channel/MemberResource.cs | 1224 +++--- .../Chat/V2/Service/Channel/MessageOptions.cs | 748 ++-- .../V2/Service/Channel/MessageResource.cs | 1278 +++--- .../Chat/V2/Service/Channel/WebhookOptions.cs | 636 +-- .../V2/Service/Channel/WebhookResource.cs | 1190 ++--- .../Rest/Chat/V2/Service/ChannelOptions.cs | 690 +-- .../Rest/Chat/V2/Service/ChannelResource.cs | 1216 +++--- .../Rest/Chat/V2/Service/RoleOptions.cs | 420 +- .../Rest/Chat/V2/Service/RoleResource.cs | 1032 ++--- .../V2/Service/User/UserBindingOptions.cs | 254 +- .../V2/Service/User/UserBindingResource.cs | 786 ++-- .../V2/Service/User/UserChannelOptions.cs | 374 +- .../V2/Service/User/UserChannelResource.cs | 986 ++--- .../Rest/Chat/V2/Service/UserOptions.cs | 520 +-- .../Rest/Chat/V2/Service/UserResource.cs | 1120 ++--- src/Twilio/Rest/Chat/V2/ServiceOptions.cs | 828 ++-- src/Twilio/Rest/Chat/V2/ServiceResource.cs | 1400 +++--- .../V1/Configuration/WebhookOptions.cs | 162 +- .../V1/Configuration/WebhookResource.cs | 478 +-- .../Conversations/V1/ConfigurationOptions.cs | 128 +- .../Conversations/V1/ConfigurationResource.cs | 430 +- .../Message/DeliveryReceiptOptions.cs | 156 +- .../Message/DeliveryReceiptResource.cs | 630 +-- .../V1/Conversation/MessageOptions.cs | 652 +-- .../V1/Conversation/MessageResource.cs | 1198 +++--- .../V1/Conversation/ParticipantOptions.cs | 740 ++-- .../V1/Conversation/ParticipantResource.cs | 1208 +++--- .../V1/Conversation/WebhookOptions.cs | 546 +-- .../V1/Conversation/WebhookResource.cs | 1116 ++--- .../Conversations/V1/ConversationOptions.cs | 668 +-- .../Conversations/V1/ConversationResource.cs | 1214 +++--- .../Conversations/V1/CredentialOptions.cs | 498 +-- .../Conversations/V1/CredentialResource.cs | 1074 ++--- .../V1/ParticipantConversationOptions.cs | 78 +- .../V1/ParticipantConversationResource.cs | 538 +-- .../Rest/Conversations/V1/RoleOptions.cs | 336 +- .../Rest/Conversations/V1/RoleResource.cs | 990 ++--- .../V1/Service/BindingOptions.cs | 238 +- .../V1/Service/BindingResource.cs | 758 ++-- .../Configuration/NotificationOptions.cs | 346 +- .../Configuration/NotificationResource.cs | 540 +-- .../Service/Configuration/WebhookOptions.cs | 192 +- .../Service/Configuration/WebhookResource.cs | 476 +- .../V1/Service/ConfigurationOptions.cs | 182 +- .../V1/Service/ConfigurationResource.cs | 440 +- .../Message/DeliveryReceiptOptions.cs | 186 +- .../Message/DeliveryReceiptResource.cs | 656 +-- .../V1/Service/Conversation/MessageOptions.cs | 712 +-- .../Service/Conversation/MessageResource.cs | 1252 +++--- .../Conversation/ParticipantOptions.cs | 802 ++-- .../Conversation/ParticipantResource.cs | 1262 +++--- .../V1/Service/Conversation/WebhookOptions.cs | 616 +-- .../Service/Conversation/WebhookResource.cs | 1174 ++--- .../V1/Service/ConversationOptions.cs | 758 ++-- .../V1/Service/ConversationResource.cs | 1252 +++--- .../Service/ParticipantConversationOptions.cs | 104 +- .../ParticipantConversationResource.cs | 546 +-- .../Conversations/V1/Service/RoleOptions.cs | 420 +- .../Conversations/V1/Service/RoleResource.cs | 1032 ++--- .../Service/User/UserConversationOptions.cs | 374 +- .../Service/User/UserConversationResource.cs | 1052 ++--- .../Conversations/V1/Service/UserOptions.cs | 556 +-- .../Conversations/V1/Service/UserResource.cs | 1122 ++--- .../Rest/Conversations/V1/ServiceOptions.cs | 210 +- .../Rest/Conversations/V1/ServiceResource.cs | 784 ++-- .../V1/User/UserConversationOptions.cs | 324 +- .../V1/User/UserConversationResource.cs | 1016 ++--- .../Rest/Conversations/V1/UserOptions.cs | 480 +-- .../Rest/Conversations/V1/UserResource.cs | 1084 ++--- src/Twilio/Rest/Domain.cs | 88 +- src/Twilio/Rest/Events/V1/EventTypeOptions.cs | 120 +- .../Rest/Events/V1/EventTypeResource.cs | 526 +-- .../Events/V1/Schema/SchemaVersionOptions.cs | 140 +- .../Events/V1/Schema/SchemaVersionResource.cs | 514 +-- src/Twilio/Rest/Events/V1/SchemaOptions.cs | 60 +- src/Twilio/Rest/Events/V1/SchemaResource.cs | 240 +- .../Rest/Events/V1/Sink/SinkTestOptions.cs | 60 +- .../Rest/Events/V1/Sink/SinkTestResource.cs | 200 +- .../Events/V1/Sink/SinkValidateOptions.cs | 82 +- .../Events/V1/Sink/SinkValidateResource.cs | 206 +- src/Twilio/Rest/Events/V1/SinkOptions.cs | 394 +- src/Twilio/Rest/Events/V1/SinkResource.cs | 1040 ++--- .../V1/Subscription/SubscribedEventOptions.cs | 404 +- .../Subscription/SubscribedEventResource.cs | 964 ++--- .../Rest/Events/V1/SubscriptionOptions.cs | 388 +- .../Rest/Events/V1/SubscriptionResource.cs | 974 ++--- src/Twilio/Rest/Fax/V1/Fax/FaxMediaOptions.cs | 210 +- .../Rest/Fax/V1/Fax/FaxMediaResource.cs | 672 +-- src/Twilio/Rest/Fax/V1/FaxOptions.cs | 524 +-- src/Twilio/Rest/Fax/V1/FaxResource.cs | 1262 +++--- src/Twilio/Rest/FlexApi/V1/ChannelOptions.cs | 394 +- src/Twilio/Rest/FlexApi/V1/ChannelResource.cs | 868 ++-- .../Rest/FlexApi/V1/ConfigurationOptions.cs | 100 +- .../Rest/FlexApi/V1/ConfigurationResource.cs | 896 ++-- src/Twilio/Rest/FlexApi/V1/FlexFlowOptions.cs | 894 ++-- .../Rest/FlexApi/V1/FlexFlowResource.cs | 1330 +++--- .../Rest/FlexApi/V1/WebChannelOptions.cs | 414 +- .../Rest/FlexApi/V1/WebChannelResource.cs | 992 ++--- .../Rest/FrontlineApi/V1/UserOptions.cs | 190 +- .../Rest/FrontlineApi/V1/UserResource.cs | 456 +- .../Insights/V1/Call/CallSummaryOptions.cs | 74 +- .../Insights/V1/Call/CallSummaryResource.cs | 510 +-- .../Rest/Insights/V1/Call/EventOptions.cs | 90 +- .../Rest/Insights/V1/Call/EventResource.cs | 508 +-- .../Rest/Insights/V1/Call/MetricOptions.cs | 108 +- .../Rest/Insights/V1/Call/MetricResource.cs | 494 +-- src/Twilio/Rest/Insights/V1/CallOptions.cs | 62 +- src/Twilio/Rest/Insights/V1/CallResource.cs | 220 +- .../Rest/Insights/V1/CallSummariesOptions.cs | 366 +- .../Rest/Insights/V1/CallSummariesResource.cs | 858 ++-- .../Insights/V1/Room/ParticipantOptions.cs | 140 +- .../Insights/V1/Room/ParticipantResource.cs | 780 ++-- src/Twilio/Rest/Insights/V1/RoomOptions.cs | 210 +- src/Twilio/Rest/Insights/V1/RoomResource.cs | 1012 ++--- src/Twilio/Rest/Insights/V1/SettingOptions.cs | 130 +- .../Rest/Insights/V1/SettingResource.cs | 382 +- .../Rest/IpMessaging/V1/CredentialOptions.cs | 480 +-- .../Rest/IpMessaging/V1/CredentialResource.cs | 1058 ++--- .../V1/Service/Channel/InviteOptions.cs | 368 +- .../V1/Service/Channel/InviteResource.cs | 902 ++-- .../V1/Service/Channel/MemberOptions.cs | 474 +- .../V1/Service/Channel/MemberResource.cs | 1080 ++--- .../V1/Service/Channel/MessageOptions.cs | 490 +-- .../V1/Service/Channel/MessageResource.cs | 1134 ++--- .../IpMessaging/V1/Service/ChannelOptions.cs | 464 +- .../IpMessaging/V1/Service/ChannelResource.cs | 1114 ++--- .../IpMessaging/V1/Service/RoleOptions.cs | 420 +- .../IpMessaging/V1/Service/RoleResource.cs | 1032 ++--- .../V1/Service/User/UserChannelOptions.cs | 78 +- .../V1/Service/User/UserChannelResource.cs | 440 +- .../IpMessaging/V1/Service/UserOptions.cs | 456 +- .../IpMessaging/V1/Service/UserResource.cs | 1078 ++--- .../Rest/IpMessaging/V1/ServiceOptions.cs | 1242 +++--- .../Rest/IpMessaging/V1/ServiceResource.cs | 1492 +++---- .../Rest/IpMessaging/V2/CredentialOptions.cs | 480 +-- .../Rest/IpMessaging/V2/CredentialResource.cs | 1058 ++--- .../IpMessaging/V2/Service/BindingOptions.cs | 238 +- .../IpMessaging/V2/Service/BindingResource.cs | 768 ++-- .../V2/Service/Channel/InviteOptions.cs | 368 +- .../V2/Service/Channel/InviteResource.cs | 902 ++-- .../V2/Service/Channel/MemberOptions.cs | 754 ++-- .../V2/Service/Channel/MemberResource.cs | 1212 +++--- .../V2/Service/Channel/MessageOptions.cs | 748 ++-- .../V2/Service/Channel/MessageResource.cs | 1278 +++--- .../V2/Service/Channel/WebhookOptions.cs | 634 +-- .../V2/Service/Channel/WebhookResource.cs | 1178 ++--- .../IpMessaging/V2/Service/ChannelOptions.cs | 690 +-- .../IpMessaging/V2/Service/ChannelResource.cs | 1216 +++--- .../IpMessaging/V2/Service/RoleOptions.cs | 420 +- .../IpMessaging/V2/Service/RoleResource.cs | 1032 ++--- .../V2/Service/User/UserBindingOptions.cs | 254 +- .../V2/Service/User/UserBindingResource.cs | 786 ++-- .../V2/Service/User/UserChannelOptions.cs | 374 +- .../V2/Service/User/UserChannelResource.cs | 978 ++--- .../IpMessaging/V2/Service/UserOptions.cs | 520 +-- .../IpMessaging/V2/Service/UserResource.cs | 1120 ++--- .../Rest/IpMessaging/V2/ServiceOptions.cs | 828 ++-- .../Rest/IpMessaging/V2/ServiceResource.cs | 1328 +++--- .../Rest/Lookups/V1/PhoneNumberOptions.cs | 132 +- .../Rest/Lookups/V1/PhoneNumberResource.cs | 324 +- .../Rest/Media/V1/MediaProcessorOptions.cs | 370 +- .../Rest/Media/V1/MediaProcessorResource.cs | 988 ++--- .../V1/PlayerStreamer/PlaybackGrantOptions.cs | 148 +- .../PlayerStreamer/PlaybackGrantResource.cs | 396 +- .../Rest/Media/V1/PlayerStreamerOptions.cs | 288 +- .../Rest/Media/V1/PlayerStreamerResource.cs | 988 ++--- .../BrandRegistration/BrandVettingOptions.cs | 256 +- .../BrandRegistration/BrandVettingResource.cs | 754 ++-- .../Messaging/V1/BrandRegistrationOptions.cs | 244 +- .../Messaging/V1/BrandRegistrationResource.cs | 918 ++-- .../Rest/Messaging/V1/DeactivationsOptions.cs | 48 +- .../Messaging/V1/DeactivationsResource.cs | 200 +- .../Messaging/V1/ExternalCampaignOptions.cs | 92 +- .../Messaging/V1/ExternalCampaignResource.cs | 250 +- .../V1/Service/AlphaSenderOptions.cs | 290 +- .../V1/Service/AlphaSenderResource.cs | 822 ++-- .../V1/Service/PhoneNumberOptions.cs | 290 +- .../V1/Service/PhoneNumberResource.cs | 838 ++-- .../Messaging/V1/Service/ShortCodeOptions.cs | 290 +- .../Messaging/V1/Service/ShortCodeResource.cs | 832 ++-- .../V1/Service/UsAppToPersonOptions.cs | 420 +- .../V1/Service/UsAppToPersonResource.cs | 966 ++--- .../V1/Service/UsAppToPersonUsecaseOptions.cs | 78 +- .../Service/UsAppToPersonUsecaseResource.cs | 212 +- .../Rest/Messaging/V1/ServiceOptions.cs | 848 ++-- .../Rest/Messaging/V1/ServiceResource.cs | 1428 +++--- .../Rest/Messaging/V1/UsecaseOptions.cs | 32 +- .../Rest/Messaging/V1/UsecaseResource.cs | 194 +- src/Twilio/Rest/Monitor/V1/AlertOptions.cs | 148 +- src/Twilio/Rest/Monitor/V1/AlertResource.cs | 664 +-- src/Twilio/Rest/Monitor/V1/EventOptions.cs | 202 +- src/Twilio/Rest/Monitor/V1/EventResource.cs | 636 +-- .../Rest/Notify/V1/CredentialOptions.cs | 500 +-- .../Rest/Notify/V1/CredentialResource.cs | 1074 ++--- .../Rest/Notify/V1/Service/BindingOptions.cs | 490 +-- .../Rest/Notify/V1/Service/BindingResource.cs | 1004 ++--- .../Notify/V1/Service/NotificationOptions.cs | 394 +- .../Notify/V1/Service/NotificationResource.cs | 580 +-- src/Twilio/Rest/Notify/V1/ServiceOptions.cs | 776 ++-- src/Twilio/Rest/Notify/V1/ServiceResource.cs | 1300 +++--- .../Bundle/BundleCopyOptions.cs | 80 +- .../Bundle/BundleCopyResource.cs | 370 +- .../Bundle/EvaluationOptions.cs | 186 +- .../Bundle/EvaluationResource.cs | 704 +-- .../Bundle/ItemAssignmentOptions.cs | 274 +- .../Bundle/ItemAssignmentResource.cs | 804 ++-- .../Bundle/ReplaceItemsOptions.cs | 86 +- .../Bundle/ReplaceItemsResource.cs | 374 +- .../V2/RegulatoryCompliance/BundleOptions.cs | 540 +-- .../V2/RegulatoryCompliance/BundleResource.cs | 1154 ++--- .../V2/RegulatoryCompliance/EndUserOptions.cs | 346 +- .../RegulatoryCompliance/EndUserResource.cs | 992 ++--- .../EndUserTypeOptions.cs | 92 +- .../EndUserTypeResource.cs | 498 +-- .../RegulatoryCompliance/RegulationOptions.cs | 148 +- .../RegulationResource.cs | 570 +-- .../SupportingDocumentOptions.cs | 346 +- .../SupportingDocumentResource.cs | 1032 ++--- .../SupportingDocumentTypeOptions.cs | 92 +- .../SupportingDocumentTypeResource.cs | 506 +-- .../Preview/BulkExports/Export/DayOptions.cs | 144 +- .../Preview/BulkExports/Export/DayResource.cs | 522 +-- .../Export/ExportCustomJobOptions.cs | 258 +- .../Export/ExportCustomJobResource.cs | 620 +-- .../Preview/BulkExports/Export/JobOptions.cs | 122 +- .../Preview/BulkExports/Export/JobResource.cs | 422 +- .../BulkExports/ExportConfigurationOptions.cs | 176 +- .../ExportConfigurationResource.cs | 404 +- .../Rest/Preview/BulkExports/ExportOptions.cs | 62 +- .../Preview/BulkExports/ExportResource.cs | 220 +- .../Fleet/CertificateOptions.cs | 474 +- .../Fleet/CertificateResource.cs | 1036 ++--- .../Fleet/DeploymentOptions.cs | 434 +- .../Fleet/DeploymentResource.cs | 1010 ++--- .../DeployedDevices/Fleet/DeviceOptions.cs | 532 +-- .../DeployedDevices/Fleet/DeviceResource.cs | 1098 ++--- .../DeployedDevices/Fleet/KeyOptions.cs | 452 +- .../DeployedDevices/Fleet/KeyResource.cs | 1028 ++--- .../Preview/DeployedDevices/FleetOptions.cs | 314 +- .../Preview/DeployedDevices/FleetResource.cs | 964 ++--- .../DependentHostedNumberOrderOptions.cs | 162 +- .../DependentHostedNumberOrderResource.cs | 660 +-- .../AuthorizationDocumentOptions.cs | 518 +-- .../AuthorizationDocumentResource.cs | 968 ++--- .../HostedNumbers/HostedNumberOrderOptions.cs | 872 ++-- .../HostedNumberOrderResource.cs | 1416 +++--- .../AvailableAddOnExtensionOptions.cs | 144 +- .../AvailableAddOnExtensionResource.cs | 534 +-- .../Marketplace/AvailableAddOnOptions.cs | 104 +- .../Marketplace/AvailableAddOnResource.cs | 520 +-- .../InstalledAddOnExtensionOptions.cs | 238 +- .../InstalledAddOnExtensionResource.cs | 698 +-- .../Marketplace/InstalledAddOnOptions.cs | 398 +- .../Marketplace/InstalledAddOnResource.cs | 994 ++--- .../Document/DocumentPermissionOptions.cs | 420 +- .../Document/DocumentPermissionResource.cs | 900 ++-- .../Preview/Sync/Service/DocumentOptions.cs | 452 +- .../Preview/Sync/Service/DocumentResource.cs | 1024 ++--- .../Service/SyncList/SyncListItemOptions.cs | 588 +-- .../Service/SyncList/SyncListItemResource.cs | 1140 ++--- .../SyncList/SyncListPermissionOptions.cs | 420 +- .../SyncList/SyncListPermissionResource.cs | 900 ++-- .../Preview/Sync/Service/SyncListOptions.cs | 294 +- .../Preview/Sync/Service/SyncListResource.cs | 846 ++-- .../Service/SyncMap/SyncMapItemOptions.cs | 610 +-- .../Service/SyncMap/SyncMapItemResource.cs | 1146 ++--- .../SyncMap/SyncMapPermissionOptions.cs | 420 +- .../SyncMap/SyncMapPermissionResource.cs | 898 ++-- .../Preview/Sync/Service/SyncMapOptions.cs | 294 +- .../Preview/Sync/Service/SyncMapResource.cs | 846 ++-- .../Rest/Preview/Sync/ServiceOptions.cs | 412 +- .../Rest/Preview/Sync/ServiceResource.cs | 1008 ++--- .../BrandedChannel/ChannelOptions.cs | 84 +- .../BrandedChannel/ChannelResource.cs | 270 +- .../TrustedComms/BrandedChannelOptions.cs | 62 +- .../TrustedComms/BrandedChannelResource.cs | 250 +- .../TrustedComms/BrandsInformationOptions.cs | 72 +- .../TrustedComms/BrandsInformationResource.cs | 230 +- .../Rest/Preview/TrustedComms/CpsOptions.cs | 72 +- .../Rest/Preview/TrustedComms/CpsResource.cs | 220 +- .../TrustedComms/CurrentCallOptions.cs | 92 +- .../TrustedComms/CurrentCallResource.cs | 348 +- .../AssistantFallbackActionsOptions.cs | 140 +- .../AssistantFallbackActionsResource.cs | 378 +- .../AssistantInitiationActionsOptions.cs | 140 +- .../AssistantInitiationActionsResource.cs | 378 +- .../Understand/Assistant/DialogueOptions.cs | 74 +- .../Understand/Assistant/DialogueResource.cs | 246 +- .../Assistant/FieldType/FieldValueOptions.cs | 414 +- .../Assistant/FieldType/FieldValueResource.cs | 918 ++-- .../Understand/Assistant/FieldTypeOptions.cs | 436 +- .../Understand/Assistant/FieldTypeResource.cs | 1064 ++--- .../Understand/Assistant/ModelBuildOptions.cs | 412 +- .../Assistant/ModelBuildResource.cs | 1048 ++--- .../Understand/Assistant/QueryOptions.cs | 538 +-- .../Understand/Assistant/QueryResource.cs | 1112 ++--- .../Understand/Assistant/StyleSheetOptions.cs | 140 +- .../Assistant/StyleSheetResource.cs | 374 +- .../Understand/Assistant/Task/FieldOptions.cs | 380 +- .../Assistant/Task/FieldResource.cs | 892 ++-- .../Assistant/Task/SampleOptions.cs | 544 +-- .../Assistant/Task/SampleResource.cs | 1102 ++--- .../Assistant/Task/TaskActionsOptions.cs | 164 +- .../Assistant/Task/TaskActionsResource.cs | 398 +- .../Assistant/Task/TaskStatisticsOptions.cs | 74 +- .../Assistant/Task/TaskStatisticsResource.cs | 260 +- .../Understand/Assistant/TaskOptions.cs | 498 +-- .../Understand/Assistant/TaskResource.cs | 1070 ++--- .../Preview/Understand/AssistantOptions.cs | 546 +-- .../Preview/Understand/AssistantResource.cs | 1140 ++--- .../Rest/Preview/Wireless/CommandOptions.cs | 362 +- .../Rest/Preview/Wireless/CommandResource.cs | 774 ++-- .../Rest/Preview/Wireless/RatePlanOptions.cs | 490 +-- .../Rest/Preview/Wireless/RatePlanResource.cs | 1080 ++--- .../Rest/Preview/Wireless/Sim/UsageOptions.cs | 98 +- .../Preview/Wireless/Sim/UsageResource.cs | 298 +- .../Rest/Preview/Wireless/SimOptions.cs | 544 +-- .../Rest/Preview/Wireless/SimResource.cs | 980 ++--- .../Pricing/V1/Messaging/CountryOptions.cs | 92 +- .../Pricing/V1/Messaging/CountryResource.cs | 508 +-- .../Pricing/V1/PhoneNumber/CountryOptions.cs | 92 +- .../Pricing/V1/PhoneNumber/CountryResource.cs | 498 +-- .../Rest/Pricing/V1/Voice/CountryOptions.cs | 92 +- .../Rest/Pricing/V1/Voice/CountryResource.cs | 508 +-- .../Rest/Pricing/V1/Voice/NumberOptions.cs | 56 +- .../Rest/Pricing/V1/Voice/NumberResource.cs | 262 +- src/Twilio/Rest/Pricing/V2/CountryOptions.cs | 92 +- src/Twilio/Rest/Pricing/V2/CountryResource.cs | 508 +-- src/Twilio/Rest/Pricing/V2/NumberOptions.cs | 74 +- src/Twilio/Rest/Pricing/V2/NumberResource.cs | 284 +- .../Rest/Pricing/V2/Voice/CountryOptions.cs | 92 +- .../Rest/Pricing/V2/Voice/CountryResource.cs | 508 +-- .../Rest/Pricing/V2/Voice/NumberOptions.cs | 74 +- .../Rest/Pricing/V2/Voice/NumberResource.cs | 284 +- .../Proxy/V1/Service/PhoneNumberOptions.cs | 422 +- .../Proxy/V1/Service/PhoneNumberResource.cs | 1044 ++--- .../V1/Service/Session/InteractionOptions.cs | 246 +- .../V1/Service/Session/InteractionResource.cs | 922 ++-- .../Participant/MessageInteractionOptions.cs | 324 +- .../Participant/MessageInteractionResource.cs | 990 ++--- .../V1/Service/Session/ParticipantOptions.cs | 422 +- .../V1/Service/Session/ParticipantResource.cs | 968 ++--- .../Rest/Proxy/V1/Service/SessionOptions.cs | 538 +-- .../Rest/Proxy/V1/Service/SessionResource.cs | 1202 +++--- .../Rest/Proxy/V1/Service/ShortCodeOptions.cs | 390 +- .../Proxy/V1/Service/ShortCodeResource.cs | 1006 ++--- src/Twilio/Rest/Proxy/V1/ServiceOptions.cs | 554 +-- src/Twilio/Rest/Proxy/V1/ServiceResource.cs | 1180 ++--- .../V1/Service/Asset/AssetVersionOptions.cs | 168 +- .../V1/Service/Asset/AssetVersionResource.cs | 602 +-- .../Serverless/V1/Service/AssetOptions.cs | 390 +- .../Serverless/V1/Service/AssetResource.cs | 974 ++--- .../Serverless/V1/Service/BuildOptions.cs | 350 +- .../Serverless/V1/Service/BuildResource.cs | 952 ++-- .../Service/Environment/DeploymentOptions.cs | 252 +- .../Service/Environment/DeploymentResource.cs | 714 +-- .../V1/Service/Environment/LogOptions.cs | 218 +- .../V1/Service/Environment/LogResource.cs | 656 +-- .../V1/Service/Environment/VariableOptions.cs | 478 +-- .../Service/Environment/VariableResource.cs | 1052 ++--- .../V1/Service/EnvironmentOptions.cs | 314 +- .../V1/Service/EnvironmentResource.cs | 864 ++-- .../FunctionVersionContentOptions.cs | 86 +- .../FunctionVersionContentResource.cs | 274 +- .../Function/FunctionVersionOptions.cs | 168 +- .../Function/FunctionVersionResource.cs | 614 +-- .../Serverless/V1/Service/FunctionOptions.cs | 390 +- .../Serverless/V1/Service/FunctionResource.cs | 974 ++--- .../Rest/Serverless/V1/ServiceOptions.cs | 402 +- .../Rest/Serverless/V1/ServiceResource.cs | 1014 ++--- .../Engagement/EngagementContextOptions.cs | 68 +- .../Engagement/EngagementContextResource.cs | 250 +- .../Engagement/Step/StepContextOptions.cs | 80 +- .../Engagement/Step/StepContextResource.cs | 268 +- .../Studio/V1/Flow/Engagement/StepOptions.cs | 156 +- .../Studio/V1/Flow/Engagement/StepResource.cs | 602 +-- .../Rest/Studio/V1/Flow/EngagementOptions.cs | 322 +- .../Rest/Studio/V1/Flow/EngagementResource.cs | 908 ++-- .../Flow/Execution/ExecutionContextOptions.cs | 68 +- .../Execution/ExecutionContextResource.cs | 250 +- .../ExecutionStepContextOptions.cs | 80 +- .../ExecutionStepContextResource.cs | 270 +- .../V1/Flow/Execution/ExecutionStepOptions.cs | 156 +- .../Flow/Execution/ExecutionStepResource.cs | 604 +-- .../Rest/Studio/V1/Flow/ExecutionOptions.cs | 450 +- .../Rest/Studio/V1/Flow/ExecutionResource.cs | 1072 ++--- src/Twilio/Rest/Studio/V1/FlowOptions.cs | 146 +- src/Twilio/Rest/Studio/V1/FlowResource.cs | 698 +-- .../Flow/Execution/ExecutionContextOptions.cs | 68 +- .../Execution/ExecutionContextResource.cs | 250 +- .../ExecutionStepContextOptions.cs | 80 +- .../ExecutionStepContextResource.cs | 270 +- .../V2/Flow/Execution/ExecutionStepOptions.cs | 156 +- .../Flow/Execution/ExecutionStepResource.cs | 604 +-- .../Rest/Studio/V2/Flow/ExecutionOptions.cs | 450 +- .../Rest/Studio/V2/Flow/ExecutionResource.cs | 1062 ++--- .../Studio/V2/Flow/FlowRevisionOptions.cs | 132 +- .../Studio/V2/Flow/FlowRevisionResource.cs | 612 +-- .../Studio/V2/Flow/FlowTestUserOptions.cs | 132 +- .../Studio/V2/Flow/FlowTestUserResource.cs | 360 +- src/Twilio/Rest/Studio/V2/FlowOptions.cs | 408 +- src/Twilio/Rest/Studio/V2/FlowResource.cs | 1086 ++--- .../Rest/Studio/V2/FlowValidateOptions.cs | 128 +- .../Rest/Studio/V2/FlowValidateResource.cs | 252 +- src/Twilio/Rest/Supersim/V1/CommandOptions.cs | 282 +- .../Rest/Supersim/V1/CommandResource.cs | 784 ++-- src/Twilio/Rest/Supersim/V1/FleetOptions.cs | 516 +-- src/Twilio/Rest/Supersim/V1/FleetResource.cs | 1082 ++--- .../Rest/Supersim/V1/IpCommandOptions.cs | 344 +- .../Rest/Supersim/V1/IpCommandResource.cs | 874 ++-- .../NetworkAccessProfileNetworkOptions.cs | 298 +- .../NetworkAccessProfileNetworkResource.cs | 836 ++-- .../V1/NetworkAccessProfileOptions.cs | 260 +- .../V1/NetworkAccessProfileResource.cs | 818 ++-- src/Twilio/Rest/Supersim/V1/NetworkOptions.cs | 156 +- .../Rest/Supersim/V1/NetworkResource.cs | 522 +-- .../Supersim/V1/Sim/BillingPeriodOptions.cs | 66 +- .../Supersim/V1/Sim/BillingPeriodResource.cs | 432 +- src/Twilio/Rest/Supersim/V1/SimOptions.cs | 420 +- src/Twilio/Rest/Supersim/V1/SimResource.cs | 962 ++--- .../Rest/Supersim/V1/SmsCommandOptions.cs | 282 +- .../Rest/Supersim/V1/SmsCommandResource.cs | 784 ++-- .../Rest/Supersim/V1/UsageRecordOptions.cs | 188 +- .../Rest/Supersim/V1/UsageRecordResource.cs | 570 +-- .../Document/DocumentPermissionOptions.cs | 402 +- .../Document/DocumentPermissionResource.cs | 912 ++-- .../Rest/Sync/V1/Service/DocumentOptions.cs | 452 +- .../Rest/Sync/V1/Service/DocumentResource.cs | 1058 ++--- .../Service/SyncList/SyncListItemOptions.cs | 664 +-- .../Service/SyncList/SyncListItemResource.cs | 1206 +++--- .../SyncList/SyncListPermissionOptions.cs | 402 +- .../SyncList/SyncListPermissionResource.cs | 912 ++-- .../Rest/Sync/V1/Service/SyncListOptions.cs | 416 +- .../Rest/Sync/V1/Service/SyncListResource.cs | 1032 ++--- .../V1/Service/SyncMap/SyncMapItemOptions.cs | 684 +-- .../V1/Service/SyncMap/SyncMapItemResource.cs | 1212 +++--- .../SyncMap/SyncMapPermissionOptions.cs | 402 +- .../SyncMap/SyncMapPermissionResource.cs | 910 ++-- .../Rest/Sync/V1/Service/SyncMapOptions.cs | 416 +- .../Rest/Sync/V1/Service/SyncMapResource.cs | 1032 ++--- .../SyncStream/StreamMessageOptions.cs | 92 +- .../SyncStream/StreamMessageResource.cs | 232 +- .../Rest/Sync/V1/Service/SyncStreamOptions.cs | 380 +- .../Sync/V1/Service/SyncStreamResource.cs | 1006 ++--- src/Twilio/Rest/Sync/V1/ServiceOptions.cs | 480 +-- src/Twilio/Rest/Sync/V1/ServiceResource.cs | 1128 ++--- .../V1/Workspace/ActivityOptions.cs | 422 +- .../V1/Workspace/ActivityResource.cs | 1016 ++--- .../Taskrouter/V1/Workspace/EventOptions.cs | 334 +- .../Taskrouter/V1/Workspace/EventResource.cs | 720 ++-- .../V1/Workspace/Task/ReservationOptions.cs | 1256 +++--- .../V1/Workspace/Task/ReservationResource.cs | 1382 +++--- .../V1/Workspace/TaskChannelOptions.cs | 424 +- .../V1/Workspace/TaskChannelResource.cs | 1030 ++--- .../Taskrouter/V1/Workspace/TaskOptions.cs | 744 ++-- .../TaskQueueCumulativeStatisticsOptions.cs | 158 +- .../TaskQueueCumulativeStatisticsResource.cs | 466 +- .../TaskQueueRealTimeStatisticsOptions.cs | 86 +- .../TaskQueueRealTimeStatisticsResource.cs | 350 +- .../TaskQueue/TaskQueueStatisticsOptions.cs | 158 +- .../TaskQueue/TaskQueueStatisticsResource.cs | 306 +- .../TaskQueue/TaskQueuesStatisticsOptions.cs | 174 +- .../TaskQueue/TaskQueuesStatisticsResource.cs | 430 +- .../V1/Workspace/TaskQueueOptions.cs | 602 +-- .../V1/Workspace/TaskQueueResource.cs | 1208 +++--- .../Taskrouter/V1/Workspace/TaskResource.cs | 1308 +++--- .../V1/Workspace/Worker/ReservationOptions.cs | 1224 +++--- .../Workspace/Worker/ReservationResource.cs | 1346 +++--- .../Workspace/Worker/WorkerChannelOptions.cs | 276 +- .../Workspace/Worker/WorkerChannelResource.cs | 782 ++-- .../Worker/WorkerStatisticsOptions.cs | 140 +- .../Worker/WorkerStatisticsResource.cs | 282 +- .../WorkersCumulativeStatisticsOptions.cs | 128 +- .../WorkersCumulativeStatisticsResource.cs | 346 +- .../WorkersRealTimeStatisticsOptions.cs | 74 +- .../WorkersRealTimeStatisticsResource.cs | 252 +- .../Worker/WorkersStatisticsOptions.cs | 182 +- .../Worker/WorkersStatisticsResource.cs | 298 +- .../Taskrouter/V1/Workspace/WorkerOptions.cs | 656 +-- .../Taskrouter/V1/Workspace/WorkerResource.cs | 1144 ++--- .../WorkflowCumulativeStatisticsOptions.cs | 160 +- .../WorkflowCumulativeStatisticsResource.cs | 470 +- .../WorkflowRealTimeStatisticsOptions.cs | 88 +- .../WorkflowRealTimeStatisticsResource.cs | 304 +- .../Workflow/WorkflowStatisticsOptions.cs | 160 +- .../Workflow/WorkflowStatisticsResource.cs | 310 +- .../V1/Workspace/WorkflowOptions.cs | 542 +-- .../V1/Workspace/WorkflowResource.cs | 1124 ++--- .../WorkspaceCumulativeStatisticsOptions.cs | 146 +- .../WorkspaceCumulativeStatisticsResource.cs | 448 +- .../WorkspaceRealTimeStatisticsOptions.cs | 74 +- .../WorkspaceRealTimeStatisticsResource.cs | 302 +- .../Workspace/WorkspaceStatisticsOptions.cs | 146 +- .../Workspace/WorkspaceStatisticsResource.cs | 288 +- .../Rest/Taskrouter/V1/WorkspaceOptions.cs | 500 +-- .../Rest/Taskrouter/V1/WorkspaceResource.cs | 1150 ++--- .../V1/Trunk/CredentialListOptions.cs | 274 +- .../V1/Trunk/CredentialListResource.cs | 818 ++-- .../V1/Trunk/IpAccessControlListOptions.cs | 276 +- .../V1/Trunk/IpAccessControlListResource.cs | 830 ++-- .../V1/Trunk/OriginationUrlOptions.cs | 530 +-- .../V1/Trunk/OriginationUrlResource.cs | 1082 ++--- .../Trunking/V1/Trunk/PhoneNumberOptions.cs | 276 +- .../Trunking/V1/Trunk/PhoneNumberResource.cs | 1050 ++--- .../Trunking/V1/Trunk/RecordingOptions.cs | 146 +- .../Trunking/V1/Trunk/RecordingResource.cs | 424 +- src/Twilio/Rest/Trunking/V1/TrunkOptions.cs | 516 +-- src/Twilio/Rest/Trunking/V1/TrunkResource.cs | 1210 +++--- ...rofilesChannelEndpointAssignmentOptions.cs | 344 +- ...ofilesChannelEndpointAssignmentResource.cs | 866 ++-- ...ustomerProfilesEntityAssignmentsOptions.cs | 274 +- ...stomerProfilesEntityAssignmentsResource.cs | 828 ++-- .../CustomerProfilesEvaluationsOptions.cs | 208 +- .../CustomerProfilesEvaluationsResource.cs | 728 ++-- .../Trusthub/V1/CustomerProfilesOptions.cs | 460 +- .../Trusthub/V1/CustomerProfilesResource.cs | 1116 ++--- src/Twilio/Rest/Trusthub/V1/EndUserOptions.cs | 346 +- .../Rest/Trusthub/V1/EndUserResource.cs | 964 ++--- .../Rest/Trusthub/V1/EndUserTypeOptions.cs | 92 +- .../Rest/Trusthub/V1/EndUserTypeResource.cs | 498 +-- .../Rest/Trusthub/V1/PoliciesOptions.cs | 92 +- .../Rest/Trusthub/V1/PoliciesResource.cs | 514 +-- .../Trusthub/V1/SupportingDocumentOptions.cs | 346 +- .../Trusthub/V1/SupportingDocumentResource.cs | 1032 ++--- .../V1/SupportingDocumentTypeOptions.cs | 92 +- .../V1/SupportingDocumentTypeResource.cs | 506 +-- ...roductsChannelEndpointAssignmentOptions.cs | 344 +- ...oductsChannelEndpointAssignmentResource.cs | 866 ++-- .../TrustProductsEntityAssignmentsOptions.cs | 274 +- .../TrustProductsEntityAssignmentsResource.cs | 826 ++-- .../TrustProductsEvaluationsOptions.cs | 208 +- .../TrustProductsEvaluationsResource.cs | 728 ++-- .../Rest/Trusthub/V1/TrustProductsOptions.cs | 460 +- .../Rest/Trusthub/V1/TrustProductsResource.cs | 1114 ++--- src/Twilio/Rest/Verify/V2/FormOptions.cs | 60 +- src/Twilio/Rest/Verify/V2/FormResource.cs | 256 +- .../Verify/V2/Service/AccessTokenOptions.cs | 126 +- .../Verify/V2/Service/AccessTokenResource.cs | 250 +- .../Entity/Challenge/NotificationOptions.cs | 102 +- .../Entity/Challenge/NotificationResource.cs | 306 +- .../V2/Service/Entity/ChallengeOptions.cs | 502 +-- .../V2/Service/Entity/ChallengeResource.cs | 1144 ++--- .../Verify/V2/Service/Entity/FactorOptions.cs | 490 +-- .../V2/Service/Entity/FactorResource.cs | 1090 ++--- .../V2/Service/Entity/NewFactorOptions.cs | 322 +- .../V2/Service/Entity/NewFactorResource.cs | 546 +-- .../Rest/Verify/V2/Service/EntityOptions.cs | 290 +- .../Rest/Verify/V2/Service/EntityResource.cs | 822 ++-- .../Service/MessagingConfigurationOptions.cs | 392 +- .../Service/MessagingConfigurationResource.cs | 992 ++--- .../V2/Service/RateLimit/BucketOptions.cs | 468 +- .../V2/Service/RateLimit/BucketResource.cs | 1052 ++--- .../Verify/V2/Service/RateLimitOptions.cs | 384 +- .../Verify/V2/Service/RateLimitResource.cs | 996 ++--- .../V2/Service/VerificationCheckOptions.cs | 150 +- .../V2/Service/VerificationCheckResource.cs | 376 +- .../Verify/V2/Service/VerificationOptions.cs | 476 +- .../Verify/V2/Service/VerificationResource.cs | 798 ++-- .../Rest/Verify/V2/Service/WebhookOptions.cs | 532 +-- .../Rest/Verify/V2/Service/WebhookResource.cs | 1166 ++--- src/Twilio/Rest/Verify/V2/ServiceOptions.cs | 864 ++-- src/Twilio/Rest/Verify/V2/ServiceResource.cs | 1304 +++--- src/Twilio/Rest/Verify/V2/TemplateOptions.cs | 58 +- src/Twilio/Rest/Verify/V2/TemplateResource.cs | 362 +- .../Verify/V2/VerificationAttemptOptions.cs | 148 +- .../Verify/V2/VerificationAttemptResource.cs | 630 +-- .../Rest/Video/V1/CompositionHookOptions.cs | 698 +-- .../Rest/Video/V1/CompositionHookResource.cs | 1256 +++--- .../Rest/Video/V1/CompositionOptions.cs | 436 +- .../Rest/Video/V1/CompositionResource.cs | 1066 ++--- .../Video/V1/CompositionSettingsOptions.cs | 182 +- .../Video/V1/CompositionSettingsResource.cs | 444 +- src/Twilio/Rest/Video/V1/RecordingOptions.cs | 272 +- src/Twilio/Rest/Video/V1/RecordingResource.cs | 908 ++-- .../Rest/Video/V1/RecordingSettingsOptions.cs | 182 +- .../Video/V1/RecordingSettingsResource.cs | 442 +- .../Room/Participant/PublishedTrackOptions.cs | 158 +- .../Participant/PublishedTrackResource.cs | 612 +-- .../Room/Participant/SubscribeRulesOptions.cs | 152 +- .../Participant/SubscribeRulesResource.cs | 402 +- .../Participant/SubscribedTrackOptions.cs | 158 +- .../Participant/SubscribedTrackResource.cs | 624 +-- .../Rest/Video/V1/Room/ParticipantOptions.cs | 294 +- .../Rest/Video/V1/Room/ParticipantResource.cs | 794 ++-- .../Video/V1/Room/RecordingRulesOptions.cs | 128 +- .../Video/V1/Room/RecordingRulesResource.cs | 370 +- .../Video/V1/Room/RoomRecordingOptions.cs | 270 +- .../Video/V1/Room/RoomRecordingResource.cs | 926 ++-- src/Twilio/Rest/Video/V1/RoomOptions.cs | 538 +-- src/Twilio/Rest/Video/V1/RoomResource.cs | 1202 +++--- .../Rest/Voice/V1/ArchivedCallOptions.cs | 72 +- .../Rest/Voice/V1/ArchivedCallResource.cs | 226 +- src/Twilio/Rest/Voice/V1/ByocTrunkOptions.cs | 588 +-- src/Twilio/Rest/Voice/V1/ByocTrunkResource.cs | 1168 ++--- .../ConnectionPolicyTargetOptions.cs | 502 +-- .../ConnectionPolicyTargetResource.cs | 1096 ++--- .../Rest/Voice/V1/ConnectionPolicyOptions.cs | 264 +- .../Rest/Voice/V1/ConnectionPolicyResource.cs | 932 ++-- .../BulkCountryUpdateOptions.cs | 74 +- .../BulkCountryUpdateResource.cs | 220 +- .../Country/HighriskSpecialPrefixOptions.cs | 74 +- .../Country/HighriskSpecialPrefixResource.cs | 346 +- .../V1/DialingPermissions/CountryOptions.cs | 214 +- .../V1/DialingPermissions/CountryResource.cs | 598 +-- .../V1/DialingPermissions/SettingsOptions.cs | 86 +- .../V1/DialingPermissions/SettingsResource.cs | 342 +- src/Twilio/Rest/Voice/V1/IpRecordOptions.cs | 324 +- src/Twilio/Rest/Voice/V1/IpRecordResource.cs | 960 ++--- .../Rest/Voice/V1/SourceIpMappingOptions.cs | 308 +- .../Rest/Voice/V1/SourceIpMappingResource.cs | 928 ++-- src/Twilio/Rest/Wireless/V1/CommandOptions.cs | 396 +- .../Rest/Wireless/V1/CommandResource.cs | 1034 ++--- .../Rest/Wireless/V1/RatePlanOptions.cs | 478 +-- .../Rest/Wireless/V1/RatePlanResource.cs | 1158 ++--- .../Wireless/V1/Sim/DataSessionOptions.cs | 66 +- .../Wireless/V1/Sim/DataSessionResource.cs | 482 +-- .../Wireless/V1/Sim/UsageRecordOptions.cs | 120 +- .../Wireless/V1/Sim/UsageRecordResource.cs | 424 +- src/Twilio/Rest/Wireless/V1/SimOptions.cs | 620 +-- src/Twilio/Rest/Wireless/V1/SimResource.cs | 1228 +++--- .../Rest/Wireless/V1/UsageRecordOptions.cs | 94 +- .../Rest/Wireless/V1/UsageRecordResource.cs | 406 +- src/Twilio/Security/RequestValidator.cs | 308 +- src/Twilio/TwiML/Fax/Receive.cs | 244 +- src/Twilio/TwiML/FaxResponse.cs | 122 +- src/Twilio/TwiML/Messaging/Body.cs | 92 +- src/Twilio/TwiML/Messaging/Media.cs | 92 +- src/Twilio/TwiML/Messaging/Message.cs | 308 +- src/Twilio/TwiML/Messaging/Redirect.cs | 130 +- src/Twilio/TwiML/MessagingResponse.cs | 172 +- src/Twilio/TwiML/Text.cs | 30 +- src/Twilio/TwiML/TwiML.cs | 336 +- src/Twilio/TwiML/Video/Room.cs | 94 +- src/Twilio/TwiML/Voice/Autopilot.cs | 92 +- src/Twilio/TwiML/Voice/Client.cs | 340 +- src/Twilio/TwiML/Voice/Conference.cs | 766 ++-- src/Twilio/TwiML/Voice/Connect.cs | 332 +- src/Twilio/TwiML/Voice/Dial.cs | 1238 +++--- src/Twilio/TwiML/Voice/Echo.cs | 62 +- src/Twilio/TwiML/Voice/Enqueue.cs | 270 +- src/Twilio/TwiML/Voice/Gather.cs | 962 ++--- src/Twilio/TwiML/Voice/Hangup.cs | 62 +- src/Twilio/TwiML/Voice/Identity.cs | 92 +- src/Twilio/TwiML/Voice/Leave.cs | 62 +- src/Twilio/TwiML/Voice/Number.cs | 294 +- src/Twilio/TwiML/Voice/Parameter.cs | 122 +- src/Twilio/TwiML/Voice/Pause.cs | 102 +- src/Twilio/TwiML/Voice/Pay.cs | 806 ++-- src/Twilio/TwiML/Voice/Play.cs | 150 +- src/Twilio/TwiML/Voice/Prompt.cs | 426 +- src/Twilio/TwiML/Voice/Queue.cs | 198 +- src/Twilio/TwiML/Voice/Record.cs | 400 +- src/Twilio/TwiML/Voice/Redirect.cs | 130 +- src/Twilio/TwiML/Voice/Refer.cs | 186 +- src/Twilio/TwiML/Voice/ReferSip.cs | 92 +- src/Twilio/TwiML/Voice/Reject.cs | 128 +- src/Twilio/TwiML/Voice/Room.cs | 130 +- src/Twilio/TwiML/Voice/Say.cs | 1158 ++--- src/Twilio/TwiML/Voice/Sim.cs | 92 +- src/Twilio/TwiML/Voice/Sip.cs | 294 +- src/Twilio/TwiML/Voice/Siprec.cs | 216 +- src/Twilio/TwiML/Voice/Sms.cs | 220 +- src/Twilio/TwiML/Voice/SsmlBreak.cs | 158 +- src/Twilio/TwiML/Voice/SsmlEmphasis.cs | 746 ++-- src/Twilio/TwiML/Voice/SsmlLang.cs | 920 ++-- src/Twilio/TwiML/Voice/SsmlP.cs | 740 ++-- src/Twilio/TwiML/Voice/SsmlPhoneme.cs | 176 +- src/Twilio/TwiML/Voice/SsmlProsody.cs | 904 ++-- src/Twilio/TwiML/Voice/SsmlS.cs | 676 +-- src/Twilio/TwiML/Voice/SsmlSayAs.cs | 246 +- src/Twilio/TwiML/Voice/SsmlSub.cs | 132 +- src/Twilio/TwiML/Voice/SsmlW.cs | 576 +-- src/Twilio/TwiML/Voice/Start.cs | 234 +- src/Twilio/TwiML/Voice/Stop.cs | 174 +- src/Twilio/TwiML/Voice/Stream.cs | 312 +- src/Twilio/TwiML/Voice/Task.cs | 152 +- src/Twilio/TwiML/Voice/VirtualAgent.cs | 168 +- src/Twilio/TwiML/VoiceResponse.cs | 1426 +++--- src/Twilio/Twilio.cs | 376 +- src/Twilio/Twilio.csproj | 91 +- src/Twilio/Types/Client.cs | 62 +- src/Twilio/Types/EmptyUrl.cs | 17 +- src/Twilio/Types/FeedbackIssue.cs | 70 +- src/Twilio/Types/IEndpoint.cs | 20 +- src/Twilio/Types/IceServer.cs | 85 +- src/Twilio/Types/InboundCallPrice.cs | 145 +- src/Twilio/Types/InboundSmsPrice.cs | 145 +- src/Twilio/Types/OutboundCallPrice.cs | 56 +- .../Types/OutboundCallPriceWithOrigin.cs | 74 +- src/Twilio/Types/OutboundPrefixPrice.cs | 96 +- .../Types/OutboundPrefixPriceWithOrigin.cs | 114 +- src/Twilio/Types/OutboundSmsPrice.cs | 96 +- src/Twilio/Types/PhoneNumber.cs | 68 +- src/Twilio/Types/PhoneNumberCapabilities.cs | 86 +- src/Twilio/Types/PhoneNumberPrice.cs | 143 +- src/Twilio/Types/RecordingRule.cs | 122 +- src/Twilio/Types/RecordingRulesUpdate.cs | 26 +- src/Twilio/Types/StringEnum.cs | 160 +- src/Twilio/Types/SubscribeRule.cs | 156 +- src/Twilio/Types/SubscribeRulesUpdate.cs | 26 +- src/Twilio/Types/Twiml.cs | 68 +- .../Http/SystemNetHttpClientTest.cs | 2 +- .../Jwt/AccessToken/AccessTokenTest.cs | 489 +-- test/Twilio.Test/Program.cs | 26 +- test/Twilio.Test/Twilio.Test.csproj | 56 +- 961 files changed, 251756 insertions(+), 251776 deletions(-) diff --git a/src/Twilio/Base/IOptions.cs b/src/Twilio/Base/IOptions.cs index b966f47cd..dd632c148 100644 --- a/src/Twilio/Base/IOptions.cs +++ b/src/Twilio/Base/IOptions.cs @@ -2,74 +2,74 @@ using System.Collections.Generic; namespace Twilio.Base -{ +{ + /// + /// Interface to wrap parameters of a resource + /// + /// Resource type + public interface IOptions where T : Resource + { /// - /// Interface to wrap parameters of a resource + /// Generate the list of parameters for the request /// - /// Resource type - public interface IOptions where T : Resource - { - /// - /// Generate the list of parameters for the request - /// - /// - /// List of parameters for the request - List> GetParams(); - } - + /// + /// List of parameters for the request + List> GetParams(); + } + + /// + /// Parameters that are passed when reading resources + /// + /// Resource type + public abstract class ReadOptions : IOptions where T : Resource + { + private int? _pageSize; + /// - /// Parameters that are passed when reading resources + /// Page size to read /// - /// Resource type - public abstract class ReadOptions : IOptions where T : Resource - { - private int? _pageSize; - - /// - /// Page size to read - /// - public int? PageSize - { - get { return _pageSize; } - set - { - if (value == null) - { - return; - } - - _pageSize = value.Value; - } - } - - private long? _limit; - - /// - /// Maximum number of records to read - /// - public long? Limit - { - get { return _limit; } - set - { - if (value == null) - { - return; - } - - _limit = value; - if (_pageSize == null) - { - _pageSize = (int) value.Value; - } - } - } - - /// - /// Generate the list of parameters for the request - /// - /// - /// List of parameters for the request - public abstract List> GetParams(); - } + public int? PageSize + { + get { return _pageSize; } + set + { + if (value == null) + { + return; + } + + _pageSize = value.Value; + } + } + + private long? _limit; + + /// + /// Maximum number of records to read + /// + public long? Limit + { + get { return _limit; } + set + { + if (value == null) + { + return; + } + + _limit = value; + if (_pageSize == null) + { + _pageSize = (int)value.Value; + } + } + } + + /// + /// Generate the list of parameters for the request + /// + /// + /// List of parameters for the request + public abstract List> GetParams(); + } } diff --git a/src/Twilio/Base/Page.cs b/src/Twilio/Base/Page.cs index cf1a72234..18aa6d031 100644 --- a/src/Twilio/Base/Page.cs +++ b/src/Twilio/Base/Page.cs @@ -1,160 +1,160 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Twilio.Rest; -using static System.String; - -namespace Twilio.Base -{ - /// - /// Page of resources - /// - /// Resource type - public class Page where T : Resource - { - /// - /// Records for this page - /// - public List Records { get; } - - /// - /// Page size - /// - public int PageSize { get; } - - private readonly string _uri; - private readonly string _url; - private readonly string _firstPageUri; - private readonly string _firstPageUrl; - private readonly string _nextPageUri; - private readonly string _nextPageUrl; - private readonly string _previousPageUri; - private readonly string _previousPageUrl; - - private Page( - List records, - int pageSize, - string uri = null, - string url = null, - string firstPageUri = null, - string firstPageUrl = null, - string previousPageUri = null, - string previousPageUrl = null, - string nextPageUri = null, - string nextPageUrl = null - ) - { - Records = records; - PageSize = pageSize; - _uri = uri; - _url = url; - _firstPageUri = firstPageUri; - _firstPageUrl = firstPageUrl; - _nextPageUri = nextPageUri; - _nextPageUrl = nextPageUrl; - _previousPageUri = previousPageUri; - _previousPageUrl = previousPageUrl; - } - - private static string UrlFromUri(Domain domain, string uri) - { - return "https://" + domain + ".twilio.com" + uri; - } - - /// - /// Generate the first page URL - /// - /// Twilio subdomain - /// URL for the first page of results - public string GetFirstPageUrl(Domain domain) - { - return _firstPageUrl ?? UrlFromUri(domain, _firstPageUri); - } - - /// - /// Get the next page URL - /// - /// Twilio subdomain - /// URL for the next page of results - public string GetNextPageUrl(Domain domain) - { - return _nextPageUrl ?? UrlFromUri(domain, _nextPageUri); - } - - /// - /// Get the previous page URL - /// - /// Twilio subdomain - /// URL for the previous page of results - public string GetPreviousPageUrl(Domain domain) - { - return _previousPageUrl ?? UrlFromUri(domain, _previousPageUri); - } - - /// - /// Get the URL for the current page - /// - /// Twilio subdomain - /// URL for the current page of results - public string GetUrl(Domain domain) - { - return _url ?? UrlFromUri(domain, _uri); - } - - /// - /// Determines if there is another page of results - /// - /// true if there is a next page; false otherwise - public bool HasNextPage() - { - return !IsNullOrEmpty(_nextPageUrl) || !IsNullOrEmpty(_nextPageUri); - } - - /// - /// Converts a JSON payload to a Page of results - /// - /// JSON key where the records are - /// JSON payload - /// Page of results - public static Page FromJson(string recordKey, string json) - { - var root = JObject.Parse(json); - var records = root[recordKey]; - var parsedRecords = records.Children().Select( - record => JsonConvert.DeserializeObject(record.ToString()) - ).ToList(); - - var uriNode = root["uri"]; - if (uriNode != null) - { - JToken pageSize; - JToken firstPageUri; - JToken nextPageUri; - JToken previousPageUri; - - // v2010 API - return new Page( - parsedRecords, - root.TryGetValue("page_size", out pageSize) ? root["page_size"].Value() : parsedRecords.Count, - uri: uriNode.Value(), - firstPageUri: root.TryGetValue("first_page_uri", out firstPageUri) ? root["first_page_uri"].Value() : null, - nextPageUri: root.TryGetValue("next_page_uri", out nextPageUri) ? root["next_page_uri"].Value() : null, - previousPageUri: root.TryGetValue("previous_page_uri", out previousPageUri) ? root["previous_page_uri"].Value() : null - ); - } - - // next-gen API - var meta = root["meta"]; - return new Page( - parsedRecords, - meta["page_size"].Value(), - url: meta["url"].Value(), - firstPageUrl: meta["first_page_url"].Value(), - nextPageUrl: meta["next_page_url"].Value(), - previousPageUrl: meta["previous_page_url"].Value() - ); - } - } -} +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Twilio.Rest; +using static System.String; + +namespace Twilio.Base +{ + /// + /// Page of resources + /// + /// Resource type + public class Page where T : Resource + { + /// + /// Records for this page + /// + public List Records { get; } + + /// + /// Page size + /// + public int PageSize { get; } + + private readonly string _uri; + private readonly string _url; + private readonly string _firstPageUri; + private readonly string _firstPageUrl; + private readonly string _nextPageUri; + private readonly string _nextPageUrl; + private readonly string _previousPageUri; + private readonly string _previousPageUrl; + + private Page( + List records, + int pageSize, + string uri = null, + string url = null, + string firstPageUri = null, + string firstPageUrl = null, + string previousPageUri = null, + string previousPageUrl = null, + string nextPageUri = null, + string nextPageUrl = null + ) + { + Records = records; + PageSize = pageSize; + _uri = uri; + _url = url; + _firstPageUri = firstPageUri; + _firstPageUrl = firstPageUrl; + _nextPageUri = nextPageUri; + _nextPageUrl = nextPageUrl; + _previousPageUri = previousPageUri; + _previousPageUrl = previousPageUrl; + } + + private static string UrlFromUri(Domain domain, string uri) + { + return "https://" + domain + ".twilio.com" + uri; + } + + /// + /// Generate the first page URL + /// + /// Twilio subdomain + /// URL for the first page of results + public string GetFirstPageUrl(Domain domain) + { + return _firstPageUrl ?? UrlFromUri(domain, _firstPageUri); + } + + /// + /// Get the next page URL + /// + /// Twilio subdomain + /// URL for the next page of results + public string GetNextPageUrl(Domain domain) + { + return _nextPageUrl ?? UrlFromUri(domain, _nextPageUri); + } + + /// + /// Get the previous page URL + /// + /// Twilio subdomain + /// URL for the previous page of results + public string GetPreviousPageUrl(Domain domain) + { + return _previousPageUrl ?? UrlFromUri(domain, _previousPageUri); + } + + /// + /// Get the URL for the current page + /// + /// Twilio subdomain + /// URL for the current page of results + public string GetUrl(Domain domain) + { + return _url ?? UrlFromUri(domain, _uri); + } + + /// + /// Determines if there is another page of results + /// + /// true if there is a next page; false otherwise + public bool HasNextPage() + { + return !IsNullOrEmpty(_nextPageUrl) || !IsNullOrEmpty(_nextPageUri); + } + + /// + /// Converts a JSON payload to a Page of results + /// + /// JSON key where the records are + /// JSON payload + /// Page of results + public static Page FromJson(string recordKey, string json) + { + var root = JObject.Parse(json); + var records = root[recordKey]; + var parsedRecords = records.Children().Select( + record => JsonConvert.DeserializeObject(record.ToString()) + ).ToList(); + + var uriNode = root["uri"]; + if (uriNode != null) + { + JToken pageSize; + JToken firstPageUri; + JToken nextPageUri; + JToken previousPageUri; + + // v2010 API + return new Page( + parsedRecords, + root.TryGetValue("page_size", out pageSize) ? root["page_size"].Value() : parsedRecords.Count, + uri: uriNode.Value(), + firstPageUri: root.TryGetValue("first_page_uri", out firstPageUri) ? root["first_page_uri"].Value() : null, + nextPageUri: root.TryGetValue("next_page_uri", out nextPageUri) ? root["next_page_uri"].Value() : null, + previousPageUri: root.TryGetValue("previous_page_uri", out previousPageUri) ? root["previous_page_uri"].Value() : null + ); + } + + // next-gen API + var meta = root["meta"]; + return new Page( + parsedRecords, + meta["page_size"].Value(), + url: meta["url"].Value(), + firstPageUrl: meta["first_page_url"].Value(), + nextPageUrl: meta["next_page_url"].Value(), + previousPageUrl: meta["previous_page_url"].Value() + ); + } + } +} diff --git a/src/Twilio/Base/Resource.cs b/src/Twilio/Base/Resource.cs index 69354a900..0f0ae89a4 100644 --- a/src/Twilio/Base/Resource.cs +++ b/src/Twilio/Base/Resource.cs @@ -1,4 +1,4 @@ namespace Twilio.Base -{ - public abstract class Resource {} +{ + public abstract class Resource { } } \ No newline at end of file diff --git a/src/Twilio/Base/ResourceSet.cs b/src/Twilio/Base/ResourceSet.cs index 15110b7d8..d64879b1e 100644 --- a/src/Twilio/Base/ResourceSet.cs +++ b/src/Twilio/Base/ResourceSet.cs @@ -4,118 +4,118 @@ using Twilio.Clients; namespace Twilio.Base -{ +{ + /// + /// A collection of resources of type T + /// + /// + /// Resource Type + public class ResourceSet : IEnumerable where T : Resource + { /// - /// A collection of resources of type T + /// Automatically iterate through pages of results + /// + public bool AutoPaging { get; set; } + + private readonly ITwilioRestClient _client; + private readonly ReadOptions _options; + private readonly long _pageLimit; + + private long _pages; + private long _processed; + private Page _page; + private IEnumerator _iterator; + + /// + /// Create a new resource set /// /// - /// Resource Type - public class ResourceSet : IEnumerable where T : Resource - { - /// - /// Automatically iterate through pages of results - /// - public bool AutoPaging { get; set; } - - private readonly ITwilioRestClient _client; - private readonly ReadOptions _options; - private readonly long _pageLimit; - - private long _pages; - private long _processed; - private Page _page; - private IEnumerator _iterator; - - /// - /// Create a new resource set - /// - /// - /// Page of resources - /// Read options - /// Client to make requests - public ResourceSet(Page page, ReadOptions options, ITwilioRestClient client) - { - _page = page; - _options = options; - _client = client; - - _iterator = page.Records.GetEnumerator(); - _processed = 0; - _pages = 1; - _pageLimit = long.MaxValue; - - AutoPaging = true; - - if (_options.Limit != null) - { - _pageLimit = (long) (Math.Ceiling((double) _options.Limit.Value / page.PageSize)); - } - } - - /// - /// Get iterator for resources - /// - /// - /// IEnumerator of resources - public IEnumerator GetEnumerator() - { - while (_page != null) - { - _iterator.Reset(); - while (_iterator.MoveNext()) - { - // Exit if we've reached item limit - if (_options.Limit != null && _processed > _options.Limit.Value) - { - yield break; - } - - _processed++; - yield return _iterator.Current; - } - - if (AutoPaging && _page.HasNextPage()) - { - FetchNextPage(); - } - else - { - break; - } - } - } - - /// - /// Get iterator for resources - /// - /// - /// IEnumerator of resources - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - private void FetchNextPage() - { - if (!_page.HasNextPage() || _pages >= _pageLimit) - { - _page = null; - _iterator = null; - return; - } - - _pages++; - _page = (Page)GetNextPage().Invoke(null, new object[]{ _page, _client }); - _iterator = _page.Records.GetEnumerator(); - } - - private static MethodInfo GetNextPage() - { + /// Page of resources + /// Read options + /// Client to make requests + public ResourceSet(Page page, ReadOptions options, ITwilioRestClient client) + { + _page = page; + _options = options; + _client = client; + + _iterator = page.Records.GetEnumerator(); + _processed = 0; + _pages = 1; + _pageLimit = long.MaxValue; + + AutoPaging = true; + + if (_options.Limit != null) + { + _pageLimit = (long)(Math.Ceiling((double)_options.Limit.Value / page.PageSize)); + } + } + + /// + /// Get iterator for resources + /// + /// + /// IEnumerator of resources + public IEnumerator GetEnumerator() + { + while (_page != null) + { + _iterator.Reset(); + while (_iterator.MoveNext()) + { + // Exit if we've reached item limit + if (_options.Limit != null && _processed > _options.Limit.Value) + { + yield break; + } + + _processed++; + yield return _iterator.Current; + } + + if (AutoPaging && _page.HasNextPage()) + { + FetchNextPage(); + } + else + { + break; + } + } + } + + /// + /// Get iterator for resources + /// + /// + /// IEnumerator of resources + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + private void FetchNextPage() + { + if (!_page.HasNextPage() || _pages >= _pageLimit) + { + _page = null; + _iterator = null; + return; + } + + _pages++; + _page = (Page)GetNextPage().Invoke(null, new object[] { _page, _client }); + _iterator = _page.Records.GetEnumerator(); + } + + private static MethodInfo GetNextPage() + { #if !NET35 - return typeof(T).GetRuntimeMethod("NextPage", new[]{ typeof(Page), typeof(ITwilioRestClient) }); + return typeof(T).GetRuntimeMethod("NextPage", new[] { typeof(Page), typeof(ITwilioRestClient) }); #else return typeof(T).GetMethod("NextPage", new[]{ typeof(Page), typeof(ITwilioRestClient) }); #endif - } - } + } + } } diff --git a/src/Twilio/Clients/ITwilioRestClient.cs b/src/Twilio/Clients/ITwilioRestClient.cs index 496c03f9f..958f87a17 100644 --- a/src/Twilio/Clients/ITwilioRestClient.cs +++ b/src/Twilio/Clients/ITwilioRestClient.cs @@ -1,44 +1,44 @@ using Twilio.Http; namespace Twilio.Clients -{ +{ + /// + /// Interface for a Twilio Client + /// + public interface ITwilioRestClient + { /// - /// Interface for a Twilio Client + /// Get the account sid all requests are made against /// - public interface ITwilioRestClient - { - /// - /// Get the account sid all requests are made against - /// - string AccountSid { get; } - - /// - /// Get the region requests are made against - /// - string Region { get; } - - /// - /// Get the http client that makes requests - /// - HttpClient HttpClient { get; } - - /// - /// Make a request to Twilio - /// - /// - /// Request to make - /// response of the request - Response Request(Request request); - + string AccountSid { get; } + + /// + /// Get the region requests are made against + /// + string Region { get; } + + /// + /// Get the http client that makes requests + /// + HttpClient HttpClient { get; } + + /// + /// Make a request to Twilio + /// + /// + /// Request to make + /// response of the request + Response Request(Request request); + #if !NET35 - /// - /// Make a request to Twilio - /// - /// - /// Request to make - /// response of the request - System.Threading.Tasks.Task RequestAsync(Request request); + /// + /// Make a request to Twilio + /// + /// + /// Request to make + /// response of the request + System.Threading.Tasks.Task RequestAsync(Request request); #endif - } + } } diff --git a/src/Twilio/Clients/TwilioRestClient.cs b/src/Twilio/Clients/TwilioRestClient.cs index 641050a2d..139d60335 100644 --- a/src/Twilio/Clients/TwilioRestClient.cs +++ b/src/Twilio/Clients/TwilioRestClient.cs @@ -14,261 +14,261 @@ #endif namespace Twilio.Clients -{ +{ + /// + /// Implementation of a TwilioRestClient. + /// + public class TwilioRestClient : ITwilioRestClient + { /// - /// Implementation of a TwilioRestClient. + /// Client to make HTTP requests /// - public class TwilioRestClient : ITwilioRestClient - { - /// - /// Client to make HTTP requests - /// - public HttpClient HttpClient { get; } - - /// - /// Account SID to use for requests - /// - public string AccountSid { get; } - - /// - /// Twilio region to make requests to - /// - public string Region { get; } - - /// - /// Twilio edge to make requests to - /// - public string Edge { get; set; } - - /// - /// Log level for logging - /// - public string LogLevel { get; set; } = Environment.GetEnvironmentVariable("TWILIO_LOG_LEVEL"); - private readonly string _username; - private readonly string _password; - - /// - /// Constructor for a TwilioRestClient - /// - /// - /// username for requests - /// password for requests - /// account sid to make requests for - /// region to make requests for - /// http client used to make the requests - /// edge to make requests for - public TwilioRestClient( - string username, - string password, - string accountSid = null, - string region = null, - HttpClient httpClient = null, - string edge = null - ) - { - _username = username; - _password = password; - - AccountSid = accountSid ?? username; - HttpClient = httpClient ?? DefaultClient(); - - Region = region; - Edge = edge; - } - - /// - /// Make a request to the Twilio API - /// - /// - /// request to make - /// response of the request - public Response Request(Request request) - { - request.SetAuth(_username, _password); - - if (LogLevel == "debug") - LogRequest(request); - - if (Region != null) - request.Region = Region; - - if (Edge != null) - request.Edge = Edge; - - Response response; - try - { - response = HttpClient.MakeRequest(request); - if (LogLevel == "debug") - { - Console.WriteLine("response.status: " + response.StatusCode); - Console.WriteLine("response.headers: " + response.Headers); - } - } - catch (Exception clientException) - { - throw new ApiConnectionException( - "Connection Error: " + request.Method + request.ConstructUrl(), - clientException - ); - } - return ProcessResponse(response); - } - + public HttpClient HttpClient { get; } + + /// + /// Account SID to use for requests + /// + public string AccountSid { get; } + + /// + /// Twilio region to make requests to + /// + public string Region { get; } + + /// + /// Twilio edge to make requests to + /// + public string Edge { get; set; } + + /// + /// Log level for logging + /// + public string LogLevel { get; set; } = Environment.GetEnvironmentVariable("TWILIO_LOG_LEVEL"); + private readonly string _username; + private readonly string _password; + + /// + /// Constructor for a TwilioRestClient + /// + /// + /// username for requests + /// password for requests + /// account sid to make requests for + /// region to make requests for + /// http client used to make the requests + /// edge to make requests for + public TwilioRestClient( + string username, + string password, + string accountSid = null, + string region = null, + HttpClient httpClient = null, + string edge = null + ) + { + _username = username; + _password = password; + + AccountSid = accountSid ?? username; + HttpClient = httpClient ?? DefaultClient(); + + Region = region; + Edge = edge; + } + + /// + /// Make a request to the Twilio API + /// + /// + /// request to make + /// response of the request + public Response Request(Request request) + { + request.SetAuth(_username, _password); + + if (LogLevel == "debug") + LogRequest(request); + + if (Region != null) + request.Region = Region; + + if (Edge != null) + request.Edge = Edge; + + Response response; + try + { + response = HttpClient.MakeRequest(request); + if (LogLevel == "debug") + { + Console.WriteLine("response.status: " + response.StatusCode); + Console.WriteLine("response.headers: " + response.Headers); + } + } + catch (Exception clientException) + { + throw new ApiConnectionException( + "Connection Error: " + request.Method + request.ConstructUrl(), + clientException + ); + } + return ProcessResponse(response); + } + #if !NET35 - /// - /// Make a request to the Twilio API - /// - /// - /// request to make - /// Task that resolves to the response of the request - public async Task RequestAsync(Request request) - { - request.SetAuth(_username, _password); - - if (Region != null) - request.Region = Region; - - if (Edge != null) - request.Edge = Edge; - - Response response; - try - { - response = await HttpClient.MakeRequestAsync(request); - } - catch (Exception clientException) - { - throw new ApiConnectionException( - "Connection Error: " + request.Method + request.ConstructUrl(), - clientException - ); - } - return ProcessResponse(response); - } - - private static HttpClient DefaultClient() - { - return new SystemNetHttpClient(); - } + /// + /// Make a request to the Twilio API + /// + /// + /// request to make + /// Task that resolves to the response of the request + public async Task RequestAsync(Request request) + { + request.SetAuth(_username, _password); + + if (Region != null) + request.Region = Region; + + if (Edge != null) + request.Edge = Edge; + + Response response; + try + { + response = await HttpClient.MakeRequestAsync(request); + } + catch (Exception clientException) + { + throw new ApiConnectionException( + "Connection Error: " + request.Method + request.ConstructUrl(), + clientException + ); + } + return ProcessResponse(response); + } + + private static HttpClient DefaultClient() + { + return new SystemNetHttpClient(); + } #else private static HttpClient DefaultClient() { return new WebRequestClient(); } #endif - - private static Response ProcessResponse(Response response) - { - if (response == null) - { - throw new ApiConnectionException("Connection Error: No response received."); - } - - if (response.StatusCode >= HttpStatusCode.OK && response.StatusCode < HttpStatusCode.BadRequest) - { - return response; - } - - // Deserialize and throw exception - RestException restException = null; - try - { - restException = RestException.FromJson(response.Content); - } - catch (JsonReaderException) { /* Allow null check below to handle */ } - - if (restException == null) - { - throw new ApiException("Api Error: " + response.StatusCode + " - " + (response.Content ?? "[no content]")); - } - - throw new ApiException( - restException.Code, - (int)response.StatusCode, - restException.Message ?? "Unable to make request, " + response.StatusCode, - restException.MoreInfo, - restException.Details - ); - } - - /// - /// Test that this application can use updated SSL certificates on - /// api.twilio.com:8443. It's a bit easier to call this method from - /// TwilioClient.ValidateSslCertificate(). - /// - public static void ValidateSslCertificate() - { - ValidateSslCertificate(DefaultClient()); - } - - /// - /// Test that this application can use updated SSL certificates on - /// api.twilio.com:8443. Generally, you'll want to use the version of this - /// function that takes no parameters unless you have a reason not to. - /// - /// - /// HTTP Client to use for testing the request - public static void ValidateSslCertificate(HttpClient client) - { - Request request = new Request("GET", "api", ":8443/", null); - - try - { - Response response = client.MakeRequest(request); - - if (!response.StatusCode.Equals(HttpStatusCode.OK)) - { - throw new CertificateValidationException( - "Unexpected response from certificate endpoint", - request, - response - ); - } - } - catch (CertificateValidationException e) - { - throw e; - } - catch (Exception e) - { - throw new CertificateValidationException( - "Connection to api.twilio.com:8443 failed", - e, - request - ); - } - } - - /// - /// Format request information when LogLevel is set to debug - /// - /// - /// HTTP request - private static void LogRequest(Request request) - { - Console.WriteLine("-- BEGIN Twilio API Request --"); - Console.WriteLine("request.method: " + request.Method); - Console.WriteLine("request.URI: " + request.Uri); - - if (request.QueryParams != null) - { - request.QueryParams.ForEach(parameter => Console.WriteLine(parameter.Key + ":" + parameter.Value)); - } - - if (request.HeaderParams != null) - { - for (int i = 0; i < request.HeaderParams.Count; i++) - { - var lowercaseHeader = request.HeaderParams[i].Key.ToLower(); - if (lowercaseHeader.Contains("authorization") == false) - { - Console.WriteLine(request.HeaderParams[i].Key + ":" + request.HeaderParams[i].Value); - } - } - } - - Console.WriteLine("-- END Twilio API Request --"); - } - } + + private static Response ProcessResponse(Response response) + { + if (response == null) + { + throw new ApiConnectionException("Connection Error: No response received."); + } + + if (response.StatusCode >= HttpStatusCode.OK && response.StatusCode < HttpStatusCode.BadRequest) + { + return response; + } + + // Deserialize and throw exception + RestException restException = null; + try + { + restException = RestException.FromJson(response.Content); + } + catch (JsonReaderException) { /* Allow null check below to handle */ } + + if (restException == null) + { + throw new ApiException("Api Error: " + response.StatusCode + " - " + (response.Content ?? "[no content]")); + } + + throw new ApiException( + restException.Code, + (int)response.StatusCode, + restException.Message ?? "Unable to make request, " + response.StatusCode, + restException.MoreInfo, + restException.Details + ); + } + + /// + /// Test that this application can use updated SSL certificates on + /// api.twilio.com:8443. It's a bit easier to call this method from + /// TwilioClient.ValidateSslCertificate(). + /// + public static void ValidateSslCertificate() + { + ValidateSslCertificate(DefaultClient()); + } + + /// + /// Test that this application can use updated SSL certificates on + /// api.twilio.com:8443. Generally, you'll want to use the version of this + /// function that takes no parameters unless you have a reason not to. + /// + /// + /// HTTP Client to use for testing the request + public static void ValidateSslCertificate(HttpClient client) + { + Request request = new Request("GET", "api", ":8443/", null); + + try + { + Response response = client.MakeRequest(request); + + if (!response.StatusCode.Equals(HttpStatusCode.OK)) + { + throw new CertificateValidationException( + "Unexpected response from certificate endpoint", + request, + response + ); + } + } + catch (CertificateValidationException e) + { + throw e; + } + catch (Exception e) + { + throw new CertificateValidationException( + "Connection to api.twilio.com:8443 failed", + e, + request + ); + } + } + + /// + /// Format request information when LogLevel is set to debug + /// + /// + /// HTTP request + private static void LogRequest(Request request) + { + Console.WriteLine("-- BEGIN Twilio API Request --"); + Console.WriteLine("request.method: " + request.Method); + Console.WriteLine("request.URI: " + request.Uri); + + if (request.QueryParams != null) + { + request.QueryParams.ForEach(parameter => Console.WriteLine(parameter.Key + ":" + parameter.Value)); + } + + if (request.HeaderParams != null) + { + for (int i = 0; i < request.HeaderParams.Count; i++) + { + var lowercaseHeader = request.HeaderParams[i].Key.ToLower(); + if (lowercaseHeader.Contains("authorization") == false) + { + Console.WriteLine(request.HeaderParams[i].Key + ":" + request.HeaderParams[i].Value); + } + } + } + + Console.WriteLine("-- END Twilio API Request --"); + } + } } diff --git a/src/Twilio/Converters/HttpMethodConverter.cs b/src/Twilio/Converters/HttpMethodConverter.cs index 4aea19539..4c1616125 100644 --- a/src/Twilio/Converters/HttpMethodConverter.cs +++ b/src/Twilio/Converters/HttpMethodConverter.cs @@ -3,72 +3,72 @@ using Newtonsoft.Json.Linq; namespace Twilio.Converters -{ +{ + /// + /// Convert between strings and HttpMethod + /// + public class HttpMethodConverter : JsonConverter + { /// - /// Convert between strings and HttpMethod + /// Write the HTTP method out to json /// - public class HttpMethodConverter : JsonConverter - { - /// - /// Write the HTTP method out to json - /// - /// - /// json writer - /// value to write serialize - /// json serialize - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var t = JToken.FromObject(value.ToString()); - t.WriteTo(writer); - } - - /// - /// Deserialize a string into a HttpMethod - /// - /// - /// json reader - /// type of object - /// - /// - /// - /// Deserialized HttpMethod - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - var token = reader.Value as string; - if (token == null) - { - return null; - } - - switch (token.ToLower()) - { - case "get": - return Http.HttpMethod.Get; - - case "post": - return Http.HttpMethod.Post; - - case "put": - return Http.HttpMethod.Put; - - case "delete": - return Http.HttpMethod.Delete; - - default: - return null; - } - } - - /// - /// Determine if an object can be converted to HttpMethod - /// - /// - /// object type - /// true if the type is an HttpMethod; false otherwise - public override bool CanConvert(Type objectType) - { - return objectType == typeof(Http.HttpMethod); - } - } + /// + /// json writer + /// value to write serialize + /// json serialize + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var t = JToken.FromObject(value.ToString()); + t.WriteTo(writer); + } + + /// + /// Deserialize a string into a HttpMethod + /// + /// + /// json reader + /// type of object + /// + /// + /// + /// Deserialized HttpMethod + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + var token = reader.Value as string; + if (token == null) + { + return null; + } + + switch (token.ToLower()) + { + case "get": + return Http.HttpMethod.Get; + + case "post": + return Http.HttpMethod.Post; + + case "put": + return Http.HttpMethod.Put; + + case "delete": + return Http.HttpMethod.Delete; + + default: + return null; + } + } + + /// + /// Determine if an object can be converted to HttpMethod + /// + /// + /// object type + /// true if the type is an HttpMethod; false otherwise + public override bool CanConvert(Type objectType) + { + return objectType == typeof(Http.HttpMethod); + } + } } diff --git a/src/Twilio/Converters/MarshalConverter.cs b/src/Twilio/Converters/MarshalConverter.cs index 2e7f8d3f1..d4bbe5e9a 100644 --- a/src/Twilio/Converters/MarshalConverter.cs +++ b/src/Twilio/Converters/MarshalConverter.cs @@ -1,21 +1,21 @@ using System; namespace Twilio.Converters -{ +{ + /// + /// Convert strings to objects + /// + public class MarshalConverter + { /// - /// Convert strings to objects + /// Convert a date time string to a DateTime object /// - public class MarshalConverter - { - /// - /// Convert a date time string to a DateTime object - /// - /// date time string to convert - /// Converted DateTime object - public static DateTime DateTimeFromString(string dateTimeString) - { - return DateTime.Parse(dateTimeString); - } - } + /// date time string to convert + /// Converted DateTime object + public static DateTime DateTimeFromString(string dateTimeString) + { + return DateTime.Parse(dateTimeString); + } + } } diff --git a/src/Twilio/Converters/PhoneNumberConverter.cs b/src/Twilio/Converters/PhoneNumberConverter.cs index ba158463d..7a744c59f 100644 --- a/src/Twilio/Converters/PhoneNumberConverter.cs +++ b/src/Twilio/Converters/PhoneNumberConverter.cs @@ -3,50 +3,50 @@ using Newtonsoft.Json.Linq; namespace Twilio.Converters -{ +{ + /// + /// Convert between strings and a PhoneNumber + /// + public class PhoneNumberConverter : JsonConverter + { /// - /// Convert between strings and a PhoneNumber + /// Write value to JsonWriter /// - public class PhoneNumberConverter : JsonConverter - { - /// - /// Write value to JsonWriter - /// - /// Writer to write to - /// Value to write - /// unsued - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var t = JToken.FromObject(value.ToString()); - t.WriteTo(writer); - } - - /// - /// Convert a string to a PhoneNumber - /// - /// JsonReader to read from - /// unused - /// unused - /// unsued - /// Converted PhoneNumber - public override object ReadJson( - JsonReader reader, - Type objectType, - object existingValue, - JsonSerializer serializer - ) - { - return new Types.PhoneNumber(reader.Value as string); - } - - /// - /// Determines if an object converted to a PhoneNumber - /// - /// Type of object - /// true if an object can be converted; false otherwise - public override bool CanConvert(Type objectType) - { - return objectType == typeof(Enum); - } - } + /// Writer to write to + /// Value to write + /// unsued + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var t = JToken.FromObject(value.ToString()); + t.WriteTo(writer); + } + + /// + /// Convert a string to a PhoneNumber + /// + /// JsonReader to read from + /// unused + /// unused + /// unsued + /// Converted PhoneNumber + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) + { + return new Types.PhoneNumber(reader.Value as string); + } + + /// + /// Determines if an object converted to a PhoneNumber + /// + /// Type of object + /// true if an object can be converted; false otherwise + public override bool CanConvert(Type objectType) + { + return objectType == typeof(Enum); + } + } } diff --git a/src/Twilio/Converters/PrefixedCollapsibleMap.cs b/src/Twilio/Converters/PrefixedCollapsibleMap.cs index 5ca7bb96a..c5e5cf09d 100644 --- a/src/Twilio/Converters/PrefixedCollapsibleMap.cs +++ b/src/Twilio/Converters/PrefixedCollapsibleMap.cs @@ -2,54 +2,54 @@ using System.Linq; namespace Twilio.Converters -{ +{ + /// + /// Flatten nested maps and give all entries a prefix + /// + public class PrefixedCollapsibleMap + { + private static Dictionary Flatten( + Dictionary dict, + Dictionary result, + List previous + ) + { + foreach (var entry in dict) + { + var next = new List(previous) { entry.Key }; + + if (entry.Value.GetType() == typeof(Dictionary)) + { + Flatten((Dictionary)entry.Value, result, next); + } + else + { + result.Add(string.Join(".", next.ToArray()), entry.Value.ToString()); + } + } + + return result; + } + /// - /// Flatten nested maps and give all entries a prefix + /// Flatten Dictionary separating nested keys with a . /// - public class PrefixedCollapsibleMap - { - private static Dictionary Flatten( - Dictionary dict, - Dictionary result, - List previous - ) - { - foreach (var entry in dict) - { - var next = new List(previous) { entry.Key }; - - if (entry.Value.GetType() == typeof(Dictionary)) - { - Flatten((Dictionary)entry.Value, result, next); - } - else - { - result.Add(string.Join(".", next.ToArray()), entry.Value.ToString()); - } - } - - return result; - } - - /// - /// Flatten Dictionary separating nested keys with a . - /// - /// Dictionary to flatten - /// Prefix to give all entries - /// Flattened Dictionary - public static Dictionary Serialize( - Dictionary inputDict, - string prefix - ) - { - if (inputDict == null || !inputDict.Any()) - { - return new Dictionary(); - } - - var flattened = Flatten(inputDict, new Dictionary(), new List()); - return flattened.ToDictionary(entry => prefix + "." + entry.Key, entry => entry.Value); - } - } + /// Dictionary to flatten + /// Prefix to give all entries + /// Flattened Dictionary + public static Dictionary Serialize( + Dictionary inputDict, + string prefix + ) + { + if (inputDict == null || !inputDict.Any()) + { + return new Dictionary(); + } + + var flattened = Flatten(inputDict, new Dictionary(), new List()); + return flattened.ToDictionary(entry => prefix + "." + entry.Key, entry => entry.Value); + } + } } diff --git a/src/Twilio/Converters/Promoter.cs b/src/Twilio/Converters/Promoter.cs index 04d62ce8c..c675e7e14 100644 --- a/src/Twilio/Converters/Promoter.cs +++ b/src/Twilio/Converters/Promoter.cs @@ -2,31 +2,31 @@ using System.Collections.Generic; namespace Twilio.Converters -{ +{ + /// + /// Promote objects + /// + public class Promoter + { /// - /// Promote objects + /// Convert a string URL to a Uri object /// - public class Promoter - { - /// - /// Convert a string URL to a Uri object - /// - /// URL to convert - /// Converted Uri - public static Uri UriFromString(string url) - { - return new Uri(url); - } - - /// - /// Promote a single entry to a List of one - /// - /// single entry to promote - /// List of the single object - public static List ListOfOne(T one) - { - return new List {one}; - } - } + /// URL to convert + /// Converted Uri + public static Uri UriFromString(string url) + { + return new Uri(url); + } + + /// + /// Promote a single entry to a List of one + /// + /// single entry to promote + /// List of the single object + public static List ListOfOne(T one) + { + return new List { one }; + } + } } diff --git a/src/Twilio/Converters/Serializers.cs b/src/Twilio/Converters/Serializers.cs index f5360c35d..23a7c78ac 100644 --- a/src/Twilio/Converters/Serializers.cs +++ b/src/Twilio/Converters/Serializers.cs @@ -3,49 +3,49 @@ using Newtonsoft.Json; namespace Twilio.Converters -{ +{ + /// + /// Serialization methods for various datatypes before making requests to the API + /// + public class Serializers + { + /// - /// Serialization methods for various datatypes before making requests to the API + /// Produce a json string from input if possible /// - public class Serializers - { - - /// - /// Produce a json string from input if possible - /// - /// Object to serialize to json - /// A json string - public static string JsonObject(object input) - { - return (input is string) ? (string) input : JsonConvert.SerializeObject(input); - } - - /// - /// Produce a ISO 8601 UTC compatible string from input if possible - /// - /// DateTime instance to serialize to string - /// A string - public static string DateTimeIso8601(DateTime? input) - { - if (input == null) return null; - - return input.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"); - } - - public static string Url(Uri input) - { - if (input == null) - { - return null; - } - - string originalString = input.OriginalString; - if (input is Types.EmptyUri && Types.EmptyUri.Uri.Equals(originalString)) - { - return string.Empty; - } - - return originalString; - } - } + /// Object to serialize to json + /// A json string + public static string JsonObject(object input) + { + return (input is string) ? (string)input : JsonConvert.SerializeObject(input); + } + + /// + /// Produce a ISO 8601 UTC compatible string from input if possible + /// + /// DateTime instance to serialize to string + /// A string + public static string DateTimeIso8601(DateTime? input) + { + if (input == null) return null; + + return input.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"); + } + + public static string Url(Uri input) + { + if (input == null) + { + return null; + } + + string originalString = input.OriginalString; + if (input is Types.EmptyUri && Types.EmptyUri.Uri.Equals(originalString)) + { + return string.Empty; + } + + return originalString; + } + } } diff --git a/src/Twilio/Converters/StringEnumConverter.cs b/src/Twilio/Converters/StringEnumConverter.cs index deb44ac00..071650819 100644 --- a/src/Twilio/Converters/StringEnumConverter.cs +++ b/src/Twilio/Converters/StringEnumConverter.cs @@ -6,105 +6,105 @@ using Twilio.Types; namespace Twilio.Converters -{ +{ + /// + /// Converts between enums and strings + /// + public class StringEnumConverter : JsonConverter + { /// - /// Converts between enums and strings + /// Writes value to a JsonWriter /// - public class StringEnumConverter : JsonConverter - { - /// - /// Writes value to a JsonWriter - /// - /// JsonWriter to use - /// value to write - /// unused - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var t = JToken.FromObject(value.ToString()); - t.WriteTo(writer); - } - - /// - /// Converts string to an enum - /// - /// JsonReader to read from - /// unused - /// unused - /// unused - /// Converted object - public override object ReadJson( - JsonReader reader, - Type objectType, - object existingValue, - JsonSerializer serializer - ) - { - if (reader.Value == null) - { - // Value is null for 'Null' tokens and 'StartArray' tokens. If it's the former, stop now! - if (reader.TokenType == JsonToken.Null) - { - return null; - } + /// JsonWriter to use + /// value to write + /// unused + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var t = JToken.FromObject(value.ToString()); + t.WriteTo(writer); + } + + /// + /// Converts string to an enum + /// + /// JsonReader to read from + /// unused + /// unused + /// unused + /// Converted object + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) + { + if (reader.Value == null) + { + // Value is null for 'Null' tokens and 'StartArray' tokens. If it's the former, stop now! + if (reader.TokenType == JsonToken.Null) + { + return null; + } #if !NET35 - if (objectType.GenericTypeArguments.Length == 0) + if (objectType.GenericTypeArguments.Length == 0) #else if (objectType.GetGenericArguments().Length == 0) #endif - { - return null; - } - var constructedListType = MakeGenericType(objectType); - var results = (IList) Activator.CreateInstance(constructedListType); - reader.Read(); - - while (reader.Value != null) - { - var e = CreateEnum(objectType); - e.FromString(reader.Value as string); - results.Add(e); - reader.Read(); - } - - return results; - } - - var instance = (StringEnum) Activator.CreateInstance(objectType); - instance.FromString(reader.Value as string); - - return instance; - } - - /// - /// Determines if an object can be converted - /// - /// Object type to convert - /// true if it can be converted; false otherwise - public override bool CanConvert(Type objectType) - { - return objectType == typeof(Enum); - } - - private static Type MakeGenericType(Type objectType) - { - var listType = typeof(List<>); - + { + return null; + } + var constructedListType = MakeGenericType(objectType); + var results = (IList)Activator.CreateInstance(constructedListType); + reader.Read(); + + while (reader.Value != null) + { + var e = CreateEnum(objectType); + e.FromString(reader.Value as string); + results.Add(e); + reader.Read(); + } + + return results; + } + + var instance = (StringEnum)Activator.CreateInstance(objectType); + instance.FromString(reader.Value as string); + + return instance; + } + + /// + /// Determines if an object can be converted + /// + /// Object type to convert + /// true if it can be converted; false otherwise + public override bool CanConvert(Type objectType) + { + return objectType == typeof(Enum); + } + + private static Type MakeGenericType(Type objectType) + { + var listType = typeof(List<>); + #if !NET35 - return listType.MakeGenericType(objectType.GenericTypeArguments[0]); + return listType.MakeGenericType(objectType.GenericTypeArguments[0]); #else return listType.MakeGenericType(objectType.GetGenericArguments()[0]); #endif - } - - private static StringEnum CreateEnum(Type objectType) - { + } + + private static StringEnum CreateEnum(Type objectType) + { #if !NET35 - return (StringEnum) Activator.CreateInstance(objectType.GenericTypeArguments[0]); + return (StringEnum)Activator.CreateInstance(objectType.GenericTypeArguments[0]); #else return (StringEnum) Activator.CreateInstance(objectType.GetGenericArguments()[0]); #endif - } - } + } + } } diff --git a/src/Twilio/Converters/TwimlConverter.cs b/src/Twilio/Converters/TwimlConverter.cs index b99b8a154..38a1613d5 100644 --- a/src/Twilio/Converters/TwimlConverter.cs +++ b/src/Twilio/Converters/TwimlConverter.cs @@ -3,50 +3,50 @@ using Newtonsoft.Json.Linq; namespace Twilio.Converters -{ +{ + /// + /// Convert between strings and a Twiml + /// + public class TwimlConverter : JsonConverter + { /// - /// Convert between strings and a Twiml + /// Write value to JsonWriter /// - public class TwimlConverter : JsonConverter - { - /// - /// Write value to JsonWriter - /// - /// Writer to write to - /// Value to write - /// unused - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var t = JToken.FromObject(value.ToString()); - t.WriteTo(writer); - } - - /// - /// Convert a string to a Twiml - /// - /// JsonReader to read from - /// unused - /// unused - /// unused - /// Converted Twiml - public override object ReadJson( - JsonReader reader, - Type objectType, - object existingValue, - JsonSerializer serializer - ) - { - return new Types.Twiml(reader.Value as string); - } - - /// - /// Determines if an object converted to a Twiml - /// - /// Type of object - /// true if an object can be converted; false otherwise - public override bool CanConvert(Type objectType) - { - return objectType == typeof(Enum); - } - } + /// Writer to write to + /// Value to write + /// unused + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var t = JToken.FromObject(value.ToString()); + t.WriteTo(writer); + } + + /// + /// Convert a string to a Twiml + /// + /// JsonReader to read from + /// unused + /// unused + /// unused + /// Converted Twiml + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) + { + return new Types.Twiml(reader.Value as string); + } + + /// + /// Determines if an object converted to a Twiml + /// + /// Type of object + /// true if an object can be converted; false otherwise + public override bool CanConvert(Type objectType) + { + return objectType == typeof(Enum); + } + } } diff --git a/src/Twilio/Exceptions/ApiException.cs b/src/Twilio/Exceptions/ApiException.cs index e9433dead..348ed4a46 100644 --- a/src/Twilio/Exceptions/ApiException.cs +++ b/src/Twilio/Exceptions/ApiException.cs @@ -2,67 +2,67 @@ using System.Collections.Generic; namespace Twilio.Exceptions -{ +{ + /// + /// POCO to represent an API Exception + /// + public class ApiException : TwilioException + { /// - /// POCO to represent an API Exception + /// Twilio error code /// - public class ApiException : TwilioException - { - /// - /// Twilio error code - /// - public int Code { get; } - - /// - /// HTTP status code - /// - public int Status { get; } - - /// - /// More info if any was provided - /// - public string MoreInfo { get; } - - /// - /// Any more details about the error, if any were provided - /// - public Dictionary Details { get; } - - /// - /// Create a ApiException with message - /// - /// Exception message - public ApiException(string message) : base(message) {} - - /// - /// Create an ApiException from another Exception - /// - /// Exception message - /// Exception to copy detatils from - public ApiException(string message, Exception exception) : base(message, exception) {} - - /// - /// Create an ApiException - /// - /// Twilio error code - /// HTTP status code - /// Error message - /// More info if provided - /// Details if provided - /// Original exception - public ApiException( - int code, - int status, - string message, - string moreInfo, - Dictionary details = null, - Exception exception = null - ) : base(message, exception) - { - Code = code; - Status = status; - MoreInfo = moreInfo; - Details = details; - } - } + public int Code { get; } + + /// + /// HTTP status code + /// + public int Status { get; } + + /// + /// More info if any was provided + /// + public string MoreInfo { get; } + + /// + /// Any more details about the error, if any were provided + /// + public Dictionary Details { get; } + + /// + /// Create a ApiException with message + /// + /// Exception message + public ApiException(string message) : base(message) { } + + /// + /// Create an ApiException from another Exception + /// + /// Exception message + /// Exception to copy detatils from + public ApiException(string message, Exception exception) : base(message, exception) { } + + /// + /// Create an ApiException + /// + /// Twilio error code + /// HTTP status code + /// Error message + /// More info if provided + /// Details if provided + /// Original exception + public ApiException( + int code, + int status, + string message, + string moreInfo, + Dictionary details = null, + Exception exception = null + ) : base(message, exception) + { + Code = code; + Status = status; + MoreInfo = moreInfo; + Details = details; + } + } } diff --git a/src/Twilio/Exceptions/CertificateValidationException.cs b/src/Twilio/Exceptions/CertificateValidationException.cs index f966384a5..0e0c0c028 100644 --- a/src/Twilio/Exceptions/CertificateValidationException.cs +++ b/src/Twilio/Exceptions/CertificateValidationException.cs @@ -2,45 +2,45 @@ using Twilio.Http; namespace Twilio.Exceptions -{ +{ + /// + /// Error thrown specifically when validating SSL connection + /// + public class CertificateValidationException : TwilioException + { /// - /// Error thrown specifically when validating SSL connection + /// Request object that triggered the exception /// - public class CertificateValidationException : TwilioException - { - /// - /// Request object that triggered the exception - /// - public Request Request { get; } - - /// - /// Response object that triggered the exception, if available - /// - public Response Response { get; } - - /// - /// Construct a CertificateValidationException - /// - /// Error message - /// The Request that triggered the exception - /// The Response (if available) that triggered the exception - public CertificateValidationException(string message, Request request, Response response) - : base(message) - { - Request = request; - Response = response; - } - - /// - /// Construct a CertificateValidationException - /// - /// Error message - /// The parent exception - /// The Request that triggered the exception - public CertificateValidationException(string message, Exception exception, Request request) - : base(message, exception) - { - Request = request; - } - } + public Request Request { get; } + + /// + /// Response object that triggered the exception, if available + /// + public Response Response { get; } + + /// + /// Construct a CertificateValidationException + /// + /// Error message + /// The Request that triggered the exception + /// The Response (if available) that triggered the exception + public CertificateValidationException(string message, Request request, Response response) + : base(message) + { + Request = request; + Response = response; + } + + /// + /// Construct a CertificateValidationException + /// + /// Error message + /// The parent exception + /// The Request that triggered the exception + public CertificateValidationException(string message, Exception exception, Request request) + : base(message, exception) + { + Request = request; + } + } } diff --git a/src/Twilio/Exceptions/RestException.cs b/src/Twilio/Exceptions/RestException.cs index af6b5942b..8c12b285b 100644 --- a/src/Twilio/Exceptions/RestException.cs +++ b/src/Twilio/Exceptions/RestException.cs @@ -2,83 +2,85 @@ using System.Collections.Generic; namespace Twilio.Exceptions -{ +{ + /// + /// Exception from Twilio API + /// + [JsonObject(MemberSerialization.OptIn)] + public class RestException : TwilioException + { /// - /// Exception from Twilio API + /// Twilio error code /// - [JsonObject(MemberSerialization.OptIn)] - public class RestException : TwilioException - { - /// - /// Twilio error code - /// - [JsonProperty("code")] - public int Code { get; private set; } - - /// - /// HTTP status code - /// + [JsonProperty("code")] + public int Code { get; private set; } + + /// + /// HTTP status code + /// + [JsonProperty("status")] + public int Status { get; private set; } + + /// + /// Error message + /// + public override string Message + { + get + { + return _message; + } + } + + [JsonProperty("message")] + private string _message + { + get; set; + } + + /// + /// More info if provided + /// + [JsonProperty("more_info")] + public string MoreInfo { get; private set; } + + /// + /// Details if provided + /// + [JsonProperty("details")] + public Dictionary Details { get; private set; } + + /// + /// Create an empty RestException + /// + public RestException() { } + private RestException( [JsonProperty("status")] - public int Status { get; private set; } - - /// - /// Error message - /// - public override string Message { - get - { - return _message; - } - } - + int status, [JsonProperty("message")] - private string _message - { - get; set; - } - - /// - /// More info if provided - /// + string message, + [JsonProperty("code")] + int code, [JsonProperty("more_info")] - public string MoreInfo { get; private set; } - - /// - /// Details if provided - /// + string moreInfo, [JsonProperty("details")] - public Dictionary Details { get; private set; } - - /// - /// Create an empty RestException - /// - public RestException() {} - private RestException( - [JsonProperty("status")] - int status, - [JsonProperty("message")] - string message, - [JsonProperty("code")] - int code, - [JsonProperty("more_info")] - string moreInfo, - [JsonProperty("details")] - Dictionary details - ) { - Status = status; - Code = code; - _message = message; - MoreInfo = moreInfo; - Details = details; - } - - /// - /// Create a RestException from a JSON payload - /// - /// JSON string to parse - public static RestException FromJson(string json) - { - return JsonConvert.DeserializeObject(json); - } - } + Dictionary details + ) + { + Status = status; + Code = code; + _message = message; + MoreInfo = moreInfo; + Details = details; + } + + /// + /// Create a RestException from a JSON payload + /// + /// JSON string to parse + public static RestException FromJson(string json) + { + return JsonConvert.DeserializeObject(json); + } + } } diff --git a/src/Twilio/Exceptions/TwilioException.cs b/src/Twilio/Exceptions/TwilioException.cs index 0693d62a2..3dd41a86a 100644 --- a/src/Twilio/Exceptions/TwilioException.cs +++ b/src/Twilio/Exceptions/TwilioException.cs @@ -1,60 +1,60 @@ using System; namespace Twilio.Exceptions -{ +{ + /// + /// Base TwilioException + /// + public class TwilioException : Exception + { /// - /// Base TwilioException + /// Create an empty TwilioException /// - public class TwilioException : Exception - { - /// - /// Create an empty TwilioException - /// - public TwilioException() {} - - /// - /// Create a TwilioException from an error message - /// - /// Error message - public TwilioException (string message) : base(message) {} - - /// - /// Create a TwilioException from message and another exception - /// - /// Error message - /// Original Exception - public TwilioException(string message, Exception exception) : base(message, exception) {} - } - + public TwilioException() { } + /// - /// Exception related to connection errors + /// Create a TwilioException from an error message /// - public class ApiConnectionException : TwilioException - { - /// - /// Create an ApiConnectionException from a message - /// - /// Error message - public ApiConnectionException(string message) : base(message) {} - - /// - /// Create an ApiConnectionException from a message and another Exception - /// - /// Error message - /// Original Exception - public ApiConnectionException(string message, Exception exception) : base(message, exception) {} - } - + /// Error message + public TwilioException(string message) : base(message) { } + + /// + /// Create a TwilioException from message and another exception + /// + /// Error message + /// Original Exception + public TwilioException(string message, Exception exception) : base(message, exception) { } + } + + /// + /// Exception related to connection errors + /// + public class ApiConnectionException : TwilioException + { + /// + /// Create an ApiConnectionException from a message + /// + /// Error message + public ApiConnectionException(string message) : base(message) { } + + /// + /// Create an ApiConnectionException from a message and another Exception + /// + /// Error message + /// Original Exception + public ApiConnectionException(string message, Exception exception) : base(message, exception) { } + } + + /// + /// Exception related to Authentication Errors + /// + public class AuthenticationException : TwilioException + { /// - /// Exception related to Authentication Errors + /// Create AuthenticationException from an error messsage /// - public class AuthenticationException : TwilioException - { - /// - /// Create AuthenticationException from an error messsage - /// - /// Error message - public AuthenticationException(string message) : base(message) {} - } + /// Error message + public AuthenticationException(string message) : base(message) { } + } } diff --git a/src/Twilio/Http/HttpClient.cs b/src/Twilio/Http/HttpClient.cs index 674ab133e..dd01c37d7 100644 --- a/src/Twilio/Http/HttpClient.cs +++ b/src/Twilio/Http/HttpClient.cs @@ -1,54 +1,54 @@ using System; namespace Twilio.Http -{ +{ + /// + /// Base http client used to make Twilio requests + /// + public abstract class HttpClient + { /// - /// Base http client used to make Twilio requests + /// The last request made by this client /// - public abstract class HttpClient - { - /// - /// The last request made by this client - /// - public Request LastRequest { get; protected set; } - - /// - /// The last response received by this client - /// - public Response LastResponse { get; protected set; } - - /// - /// Make a request to Twilio, returns non-2XX responses as well - /// - /// - /// request to make - /// throws exception on network or connection errors. - /// response of the request - public abstract Response MakeRequest(Request request); - + public Request LastRequest { get; protected set; } + + /// + /// The last response received by this client + /// + public Response LastResponse { get; protected set; } + + /// + /// Make a request to Twilio, returns non-2XX responses as well + /// + /// + /// request to make + /// throws exception on network or connection errors. + /// response of the request + public abstract Response MakeRequest(Request request); + #if !NET35 - /// - /// Make an async request to Twilio, returns non-2XX responses as well - /// - /// - /// request to make - /// throws exception on network or connection errors. - /// response of the request - public abstract System.Threading.Tasks.Task MakeRequestAsync(Request request); + /// + /// Make an async request to Twilio, returns non-2XX responses as well + /// + /// + /// request to make + /// throws exception on network or connection errors. + /// response of the request + public abstract System.Threading.Tasks.Task MakeRequestAsync(Request request); #endif - - /// - /// Set the authentication string for the request - /// - /// - /// username of the request - /// password of the request - /// authentication string - public string Authentication(string username, string password) - { - var credentials = username + ":" + password; - var encoded = System.Text.Encoding.UTF8.GetBytes(credentials); - return Convert.ToBase64String(encoded); - } - } + + /// + /// Set the authentication string for the request + /// + /// + /// username of the request + /// password of the request + /// authentication string + public string Authentication(string username, string password) + { + var credentials = username + ":" + password; + var encoded = System.Text.Encoding.UTF8.GetBytes(credentials); + return Convert.ToBase64String(encoded); + } + } } diff --git a/src/Twilio/Http/HttpMethod.cs b/src/Twilio/Http/HttpMethod.cs index ed4e23820..c60a76f68 100644 --- a/src/Twilio/Http/HttpMethod.cs +++ b/src/Twilio/Http/HttpMethod.cs @@ -1,93 +1,93 @@ namespace Twilio.Http -{ +{ + /// + /// Represents an HTTP Method + /// + public class HttpMethod + { /// - /// Represents an HTTP Method + /// Constant for GET method /// - public class HttpMethod - { - /// - /// Constant for GET method - /// - public static readonly HttpMethod Get = new HttpMethod("GET"); - - /// - /// Constant for POST method - /// - public static readonly HttpMethod Post = new HttpMethod("POST"); - - /// - /// Constant for PUT method - /// - public static readonly HttpMethod Put = new HttpMethod("PUT"); - - /// - /// Constant for DELETE method - /// - public static readonly HttpMethod Delete = new HttpMethod("DELETE"); - - private readonly string _value; - - /// - /// Create a method from a string - /// - /// Method name - public HttpMethod(string method) - { - _value = method.ToUpper(); - } - - /// - /// Convert from string to HttpMethod - /// - /// value to convert - public static implicit operator HttpMethod(string value) - { - return new HttpMethod(value); - } - - /// - /// Compare HttpMethod - /// - /// object to compare with - /// true if the HttpMethod are equal; false otherwise - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != typeof(HttpMethod)) - { - return false; - } - - var other = (HttpMethod)obj; - return _value == other._value; - } - - /// - /// Get the hash code of the HttpMethod - /// - /// the hash code of the HttpMethod - public override int GetHashCode() - { - unchecked { return _value?.GetHashCode () ?? 0; } - } - - /// - /// Get the string representation of the HttpMethod - /// - /// string representation of the HttpMethod - public override string ToString() - { - return _value; - } - } + public static readonly HttpMethod Get = new HttpMethod("GET"); + + /// + /// Constant for POST method + /// + public static readonly HttpMethod Post = new HttpMethod("POST"); + + /// + /// Constant for PUT method + /// + public static readonly HttpMethod Put = new HttpMethod("PUT"); + + /// + /// Constant for DELETE method + /// + public static readonly HttpMethod Delete = new HttpMethod("DELETE"); + + private readonly string _value; + + /// + /// Create a method from a string + /// + /// Method name + public HttpMethod(string method) + { + _value = method.ToUpper(); + } + + /// + /// Convert from string to HttpMethod + /// + /// value to convert + public static implicit operator HttpMethod(string value) + { + return new HttpMethod(value); + } + + /// + /// Compare HttpMethod + /// + /// object to compare with + /// true if the HttpMethod are equal; false otherwise + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != typeof(HttpMethod)) + { + return false; + } + + var other = (HttpMethod)obj; + return _value == other._value; + } + + /// + /// Get the hash code of the HttpMethod + /// + /// the hash code of the HttpMethod + public override int GetHashCode() + { + unchecked { return _value?.GetHashCode() ?? 0; } + } + + /// + /// Get the string representation of the HttpMethod + /// + /// string representation of the HttpMethod + public override string ToString() + { + return _value; + } + } } diff --git a/src/Twilio/Http/Request.cs b/src/Twilio/Http/Request.cs index 148572885..efa1bab5a 100644 --- a/src/Twilio/Http/Request.cs +++ b/src/Twilio/Http/Request.cs @@ -11,274 +11,274 @@ #endif namespace Twilio.Http -{ +{ + /// + /// Twilio request object + /// + public class Request + { + private static readonly string DEFAULT_REGION = "us1"; + /// - /// Twilio request object + /// HTTP Method /// - public class Request - { - private static readonly string DEFAULT_REGION = "us1"; - - /// - /// HTTP Method - /// - public HttpMethod Method { get; } - - public Uri Uri { get; private set; } - - /// - /// Auth username - /// - public string Username { get; set; } - - /// - /// Auth password - /// - public string Password { get; set; } - - /// - /// Twilio region - /// - public string Region { get; set; } - - /// - /// Twilio edge - /// - public string Edge { get; set; } - - /// - /// Query params - /// - public List> QueryParams { get; private set; } - - /// - /// Post params - /// - public List> PostParams { get; private set; } - - /// - /// Header params - /// - public List> HeaderParams { get; private set; } - - /// - /// Create a new Twilio request - /// - /// HTTP Method - /// Request URL - public Request(HttpMethod method, string url) - { - Method = method; - Uri = new Uri(url); - QueryParams = new List>(); - PostParams = new List>(); - HeaderParams = new List>(); - } - - /// - /// Create a new Twilio request - /// - /// HTTP method - /// Twilio subdomain - /// Request URI - /// Twilio region - /// Query parameters - /// Post data - /// Twilio edge - /// Custom header data - public Request( - HttpMethod method, - Domain domain, - string uri, - string region = null, - List> queryParams = null, - List> postParams = null, - string edge = null, - List> headerParams = null - ) - { - Method = method; - Uri = new Uri("https://" + domain + ".twilio.com" + uri); - Region = region; - Edge = edge; - - QueryParams = queryParams ?? new List>(); - PostParams = postParams ?? new List>(); - HeaderParams = headerParams ?? new List>(); - } - - /// - /// Construct the request URL - /// - /// Built URL including query parameters - public Uri ConstructUrl() - { - var uri = buildUri(); - return QueryParams.Count > 0 ? - new Uri(uri.AbsoluteUri + "?" + EncodeParameters(QueryParams)) : - new Uri(uri.AbsoluteUri); - } - - public Uri buildUri() - { - if (Region != null || Edge != null) - { - var uriBuilder = new UriBuilder(Uri); - var pieces = uriBuilder.Host.Split('.'); - var product = pieces[0]; - var domain = String.Join(".", pieces.Skip(pieces.Length - 2).ToArray()); - - var region = Region; - var edge = Edge; - - if (pieces.Length == 4) // product.region.twilio.com - { - region = region ?? pieces[1]; - } - else if (pieces.Length == 5) // product.edge.region.twilio.com - { - edge = edge ?? pieces[1]; - region = region ?? pieces[2]; - } - - if (edge != null && region == null) - region = DEFAULT_REGION; - - string[] parts = { product, edge, region, domain }; - - uriBuilder.Host = String.Join(".", Array.FindAll(parts, part => !string.IsNullOrEmpty(part))); - return uriBuilder.Uri; - } - - return Uri; - } - - /// - /// Set auth for the request - /// - /// Auth username - /// Auth password - public void SetAuth(string username, string password) - { - Username = username; - Password = password; - } - - private static string EncodeParameters(IEnumerable> data) - { - var result = ""; - var first = true; - foreach (var pair in data) - { - if (first) - { - first = false; - } - else - { - result += "&"; - } - + public HttpMethod Method { get; } + + public Uri Uri { get; private set; } + + /// + /// Auth username + /// + public string Username { get; set; } + + /// + /// Auth password + /// + public string Password { get; set; } + + /// + /// Twilio region + /// + public string Region { get; set; } + + /// + /// Twilio edge + /// + public string Edge { get; set; } + + /// + /// Query params + /// + public List> QueryParams { get; private set; } + + /// + /// Post params + /// + public List> PostParams { get; private set; } + + /// + /// Header params + /// + public List> HeaderParams { get; private set; } + + /// + /// Create a new Twilio request + /// + /// HTTP Method + /// Request URL + public Request(HttpMethod method, string url) + { + Method = method; + Uri = new Uri(url); + QueryParams = new List>(); + PostParams = new List>(); + HeaderParams = new List>(); + } + + /// + /// Create a new Twilio request + /// + /// HTTP method + /// Twilio subdomain + /// Request URI + /// Twilio region + /// Query parameters + /// Post data + /// Twilio edge + /// Custom header data + public Request( + HttpMethod method, + Domain domain, + string uri, + string region = null, + List> queryParams = null, + List> postParams = null, + string edge = null, + List> headerParams = null + ) + { + Method = method; + Uri = new Uri("https://" + domain + ".twilio.com" + uri); + Region = region; + Edge = edge; + + QueryParams = queryParams ?? new List>(); + PostParams = postParams ?? new List>(); + HeaderParams = headerParams ?? new List>(); + } + + /// + /// Construct the request URL + /// + /// Built URL including query parameters + public Uri ConstructUrl() + { + var uri = buildUri(); + return QueryParams.Count > 0 ? + new Uri(uri.AbsoluteUri + "?" + EncodeParameters(QueryParams)) : + new Uri(uri.AbsoluteUri); + } + + public Uri buildUri() + { + if (Region != null || Edge != null) + { + var uriBuilder = new UriBuilder(Uri); + var pieces = uriBuilder.Host.Split('.'); + var product = pieces[0]; + var domain = String.Join(".", pieces.Skip(pieces.Length - 2).ToArray()); + + var region = Region; + var edge = Edge; + + if (pieces.Length == 4) // product.region.twilio.com + { + region = region ?? pieces[1]; + } + else if (pieces.Length == 5) // product.edge.region.twilio.com + { + edge = edge ?? pieces[1]; + region = region ?? pieces[2]; + } + + if (edge != null && region == null) + region = DEFAULT_REGION; + + string[] parts = { product, edge, region, domain }; + + uriBuilder.Host = String.Join(".", Array.FindAll(parts, part => !string.IsNullOrEmpty(part))); + return uriBuilder.Uri; + } + + return Uri; + } + + /// + /// Set auth for the request + /// + /// Auth username + /// Auth password + public void SetAuth(string username, string password) + { + Username = username; + Password = password; + } + + private static string EncodeParameters(IEnumerable> data) + { + var result = ""; + var first = true; + foreach (var pair in data) + { + if (first) + { + first = false; + } + else + { + result += "&"; + } + #if !NET35 - result += WebUtility.UrlEncode(pair.Key) + "=" + WebUtility.UrlEncode(pair.Value); + result += WebUtility.UrlEncode(pair.Key) + "=" + WebUtility.UrlEncode(pair.Value); #else result += HttpUtility.UrlEncode(pair.Key) + "=" + HttpUtility.UrlEncode(pair.Value); #endif - } - - return result; - } - - /// - /// Encode POST data for transfer - /// - /// Encoded byte array - public byte[] EncodePostParams() - { - return Encoding.UTF8.GetBytes(EncodeParameters(PostParams)); - } - - /// - /// Add query parameter to request - /// - /// name of parameter - /// value of parameter - public void AddQueryParam(string name, string value) - { - AddParam(QueryParams, name, value); - } - - /// - /// Add a parameter to the request payload - /// - /// name of parameter - /// value of parameter - public void AddPostParam(string name, string value) - { - AddParam(PostParams, name, value); - } - - /// - /// Add a header parameter - /// - /// name of parameter - /// value of parameter - public void AddHeaderParam(string name, string value) - { - AddParam(HeaderParams, name, value); - } - - private static void AddParam(ICollection> list, string name, string value) - { - list.Add(new KeyValuePair(name, value)); - } - - /// - /// Compare request - /// - /// object to compare to - /// true if requests are equal; false otherwise - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - if (obj.GetType() != typeof(Request)) - { - return false; - } - - var other = (Request)obj; - return Method.Equals(other.Method) && - buildUri().Equals(other.buildUri()) && - QueryParams.All(other.QueryParams.Contains) && - other.QueryParams.All(QueryParams.Contains) && - PostParams.All(other.PostParams.Contains) && - other.PostParams.All(PostParams.Contains) && - HeaderParams.All(other.HeaderParams.Contains) && - other.HeaderParams.All(HeaderParams.Contains); - } - - /// - /// Generate hash code for request - /// - /// generated hash code - public override int GetHashCode() - { - unchecked - { - return (Method?.GetHashCode() ?? 0) ^ - (buildUri()?.GetHashCode() ?? 0) ^ - (QueryParams?.GetHashCode() ?? 0) ^ - (PostParams?.GetHashCode() ?? 0) ^ - (HeaderParams?.GetHashCode() ?? 0); - } - } - } + } + + return result; + } + + /// + /// Encode POST data for transfer + /// + /// Encoded byte array + public byte[] EncodePostParams() + { + return Encoding.UTF8.GetBytes(EncodeParameters(PostParams)); + } + + /// + /// Add query parameter to request + /// + /// name of parameter + /// value of parameter + public void AddQueryParam(string name, string value) + { + AddParam(QueryParams, name, value); + } + + /// + /// Add a parameter to the request payload + /// + /// name of parameter + /// value of parameter + public void AddPostParam(string name, string value) + { + AddParam(PostParams, name, value); + } + + /// + /// Add a header parameter + /// + /// name of parameter + /// value of parameter + public void AddHeaderParam(string name, string value) + { + AddParam(HeaderParams, name, value); + } + + private static void AddParam(ICollection> list, string name, string value) + { + list.Add(new KeyValuePair(name, value)); + } + + /// + /// Compare request + /// + /// object to compare to + /// true if requests are equal; false otherwise + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof(Request)) + { + return false; + } + + var other = (Request)obj; + return Method.Equals(other.Method) && + buildUri().Equals(other.buildUri()) && + QueryParams.All(other.QueryParams.Contains) && + other.QueryParams.All(QueryParams.Contains) && + PostParams.All(other.PostParams.Contains) && + other.PostParams.All(PostParams.Contains) && + HeaderParams.All(other.HeaderParams.Contains) && + other.HeaderParams.All(HeaderParams.Contains); + } + + /// + /// Generate hash code for request + /// + /// generated hash code + public override int GetHashCode() + { + unchecked + { + return (Method?.GetHashCode() ?? 0) ^ + (buildUri()?.GetHashCode() ?? 0) ^ + (QueryParams?.GetHashCode() ?? 0) ^ + (PostParams?.GetHashCode() ?? 0) ^ + (HeaderParams?.GetHashCode() ?? 0); + } + } + } } diff --git a/src/Twilio/Http/Response.cs b/src/Twilio/Http/Response.cs index 4e19fef1e..dca9d6ff3 100644 --- a/src/Twilio/Http/Response.cs +++ b/src/Twilio/Http/Response.cs @@ -7,38 +7,38 @@ #endif namespace Twilio.Http -{ +{ + /// + /// Twilio response + /// + public class Response + { /// - /// Twilio response + /// HTTP status code /// - public class Response - { - /// - /// HTTP status code - /// - public HttpStatusCode StatusCode { get; } - - /// - /// Content string - /// - public string Content { get; } - - /// - /// Headers - /// - public Headers Headers { get; } - - /// - /// Create a new Response - /// - /// HTTP status code - /// Content string - /// Headers - public Response(HttpStatusCode statusCode, string content, Headers headers = null) - { - StatusCode = statusCode; - Content = content; - Headers = headers; - } - } + public HttpStatusCode StatusCode { get; } + + /// + /// Content string + /// + public string Content { get; } + + /// + /// Headers + /// + public Headers Headers { get; } + + /// + /// Create a new Response + /// + /// HTTP status code + /// Content string + /// Headers + public Response(HttpStatusCode statusCode, string content, Headers headers = null) + { + StatusCode = statusCode; + Content = content; + Headers = headers; + } + } } diff --git a/src/Twilio/Http/SystemNetHttpClient.cs b/src/Twilio/Http/SystemNetHttpClient.cs index 724d4fb62..56251c84c 100644 --- a/src/Twilio/Http/SystemNetHttpClient.cs +++ b/src/Twilio/Http/SystemNetHttpClient.cs @@ -1,106 +1,106 @@ -#if !NET35 -using System; -using System.IO; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using System.Runtime.InteropServices; - -namespace Twilio.Http -{ - /// - /// Sample client to make HTTP requests - /// - public class SystemNetHttpClient : HttpClient - { -#if NET451 - private string PlatVersion = " (.NET Framework 4.5.1+)"; -#else - private string PlatVersion = $" ({RuntimeInformation.FrameworkDescription})"; -#endif - - private readonly System.Net.Http.HttpClient _httpClient; - - /// - /// Create new HttpClient - /// - /// HTTP client to use - public SystemNetHttpClient(System.Net.Http.HttpClient httpClient = null) - { - _httpClient = httpClient ?? new System.Net.Http.HttpClient(new HttpClientHandler() { AllowAutoRedirect = false }); - } - - /// - /// Make a synchronous request - /// - /// Twilio request - /// Twilio response - public override Response MakeRequest(Request request) - { - try - { - var task = MakeRequestAsync(request); - task.Wait(); - return task.Result; - } - catch (AggregateException ae) - { - // Combine nested AggregateExceptions - ae = ae.Flatten(); - throw ae.InnerExceptions[0]; - } - } - - /// - /// Make an asynchronous request - /// - /// Twilio response - /// Task that resolves to the response - public override async Task MakeRequestAsync(Request request) - { - var httpRequest = BuildHttpRequest(request); - if (!Equals(request.Method, HttpMethod.Get)) - { - httpRequest.Content = new FormUrlEncodedContent(request.PostParams); - } - - this.LastRequest = request; - this.LastResponse = null; - - var httpResponse = await _httpClient.SendAsync(httpRequest).ConfigureAwait(false); - var reader = new StreamReader(await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)); - - // Create and return a new Response. Keep a reference to the last - // response for debugging, but don't return it as it may be shared - // among threads. - var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers); - this.LastResponse = response; - return response; - } - - private HttpRequestMessage BuildHttpRequest(Request request) - { - var httpRequest = new HttpRequestMessage( - new System.Net.Http.HttpMethod(request.Method.ToString()), - request.ConstructUrl() - ); - - var authBytes = Authentication(request.Username, request.Password); - httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Basic", authBytes); - - httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - httpRequest.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("utf-8")); - - var libraryVersion = "twilio-csharp/" + AssemblyInfomation.AssemblyInformationalVersion + PlatVersion; - httpRequest.Headers.TryAddWithoutValidation("User-Agent", libraryVersion); - - foreach (var header in request.HeaderParams) - { - httpRequest.Headers.TryAddWithoutValidation(header.Key, header.Value); - } - - return httpRequest; - } - } -} -#endif +#if !NET35 +using System; +using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using System.Runtime.InteropServices; + +namespace Twilio.Http +{ + /// + /// Sample client to make HTTP requests + /// + public class SystemNetHttpClient : HttpClient + { +#if NET451 + private string PlatVersion = " (.NET Framework 4.5.1+)"; +#else + private string PlatVersion = $" ({RuntimeInformation.FrameworkDescription})"; +#endif + + private readonly System.Net.Http.HttpClient _httpClient; + + /// + /// Create new HttpClient + /// + /// HTTP client to use + public SystemNetHttpClient(System.Net.Http.HttpClient httpClient = null) + { + _httpClient = httpClient ?? new System.Net.Http.HttpClient(new HttpClientHandler() { AllowAutoRedirect = false }); + } + + /// + /// Make a synchronous request + /// + /// Twilio request + /// Twilio response + public override Response MakeRequest(Request request) + { + try + { + var task = MakeRequestAsync(request); + task.Wait(); + return task.Result; + } + catch (AggregateException ae) + { + // Combine nested AggregateExceptions + ae = ae.Flatten(); + throw ae.InnerExceptions[0]; + } + } + + /// + /// Make an asynchronous request + /// + /// Twilio response + /// Task that resolves to the response + public override async Task MakeRequestAsync(Request request) + { + var httpRequest = BuildHttpRequest(request); + if (!Equals(request.Method, HttpMethod.Get)) + { + httpRequest.Content = new FormUrlEncodedContent(request.PostParams); + } + + this.LastRequest = request; + this.LastResponse = null; + + var httpResponse = await _httpClient.SendAsync(httpRequest).ConfigureAwait(false); + var reader = new StreamReader(await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)); + + // Create and return a new Response. Keep a reference to the last + // response for debugging, but don't return it as it may be shared + // among threads. + var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers); + this.LastResponse = response; + return response; + } + + private HttpRequestMessage BuildHttpRequest(Request request) + { + var httpRequest = new HttpRequestMessage( + new System.Net.Http.HttpMethod(request.Method.ToString()), + request.ConstructUrl() + ); + + var authBytes = Authentication(request.Username, request.Password); + httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Basic", authBytes); + + httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + httpRequest.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("utf-8")); + + var libraryVersion = "twilio-csharp/" + AssemblyInfomation.AssemblyInformationalVersion + PlatVersion; + httpRequest.Headers.TryAddWithoutValidation("User-Agent", libraryVersion); + + foreach (var header in request.HeaderParams) + { + httpRequest.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + + return httpRequest; + } + } +} +#endif diff --git a/src/Twilio/JWT/AccessToken/ChatGrant.cs b/src/Twilio/JWT/AccessToken/ChatGrant.cs index bc3e57221..d7eb05817 100644 --- a/src/Twilio/JWT/AccessToken/ChatGrant.cs +++ b/src/Twilio/JWT/AccessToken/ChatGrant.cs @@ -1,76 +1,76 @@ using System.Collections.Generic; namespace Twilio.Jwt.AccessToken -{ +{ + /// + /// Grant to use for Twilio Chat + /// + public class ChatGrant : IGrant + { /// - /// Grant to use for Twilio Chat + /// Service SID /// - public class ChatGrant : IGrant - { - /// - /// Service SID - /// - public string ServiceSid { get; set; } - - /// - /// Endpoint ID - /// - public string EndpointId { get; set; } - - /// - /// Deployment role SID - /// - public string DeploymentRoleSid { get; set; } - - /// - /// Push credential SID - /// - public string PushCredentialSid { get; set; } - - /// - /// Get the grant name - /// - /// - /// name of the grant - public string Key - { - get - { - return "chat"; - } - } - - /// - /// Get the grant payload - /// - /// - /// payload of the grant - public object Payload - { - get - { - var payload = new Dictionary(); - - if (ServiceSid != null) - { - payload.Add("service_sid", ServiceSid); - } - if (EndpointId != null) - { - payload.Add("endpoint_id", EndpointId); - } - if (DeploymentRoleSid != null) - { - payload.Add("deployment_role_sid", DeploymentRoleSid); - } - if (PushCredentialSid != null) - { - payload.Add("push_credential_sid", PushCredentialSid); - } - - return payload; - } - } - - } + public string ServiceSid { get; set; } + + /// + /// Endpoint ID + /// + public string EndpointId { get; set; } + + /// + /// Deployment role SID + /// + public string DeploymentRoleSid { get; set; } + + /// + /// Push credential SID + /// + public string PushCredentialSid { get; set; } + + /// + /// Get the grant name + /// + /// + /// name of the grant + public string Key + { + get + { + return "chat"; + } + } + + /// + /// Get the grant payload + /// + /// + /// payload of the grant + public object Payload + { + get + { + var payload = new Dictionary(); + + if (ServiceSid != null) + { + payload.Add("service_sid", ServiceSid); + } + if (EndpointId != null) + { + payload.Add("endpoint_id", EndpointId); + } + if (DeploymentRoleSid != null) + { + payload.Add("deployment_role_sid", DeploymentRoleSid); + } + if (PushCredentialSid != null) + { + payload.Add("push_credential_sid", PushCredentialSid); + } + + return payload; + } + } + + } } diff --git a/src/Twilio/JWT/AccessToken/ConversationsGrant.cs b/src/Twilio/JWT/AccessToken/ConversationsGrant.cs index 4f13c7784..aa6390eb2 100644 --- a/src/Twilio/JWT/AccessToken/ConversationsGrant.cs +++ b/src/Twilio/JWT/AccessToken/ConversationsGrant.cs @@ -2,47 +2,47 @@ namespace Twilio.Jwt.AccessToken { + /// + /// Grant to use for Twilio Conversations + /// + [System.Obsolete("ConversationsGrant is deprecated, use VideoGrant instead")] + public class ConversationsGrant : IGrant + { /// - /// Grant to use for Twilio Conversations + /// Configuration profile SID for the grant /// - [System.Obsolete("ConversationsGrant is deprecated, use VideoGrant instead")] - public class ConversationsGrant : IGrant + public string ConfigurationProfileSid { get; set; } + + /// + /// Get the grant key + /// + /// + /// grant key + public string Key { - /// - /// Configuration profile SID for the grant - /// - public string ConfigurationProfileSid { get; set; } + get + { + return "rtc"; + } + } - /// - /// Get the grant key - /// - /// - /// grant key - public string Key + /// + /// Get the grant payload + /// + /// + /// grant payload + public object Payload + { + get + { + var payload = new Dictionary(); + if (ConfigurationProfileSid != null) { - get - { - return "rtc"; - } + payload.Add("configuration_profile_sid", ConfigurationProfileSid); } - /// - /// Get the grant payload - /// - /// - /// grant payload - public object Payload - { - get - { - var payload = new Dictionary(); - if (ConfigurationProfileSid != null) - { - payload.Add("configuration_profile_sid", ConfigurationProfileSid); - } - - return payload; - } - } + return payload; + } } + } } diff --git a/src/Twilio/JWT/AccessToken/IGrant.cs b/src/Twilio/JWT/AccessToken/IGrant.cs index 179beac30..2644f03b7 100644 --- a/src/Twilio/JWT/AccessToken/IGrant.cs +++ b/src/Twilio/JWT/AccessToken/IGrant.cs @@ -1,22 +1,22 @@ namespace Twilio.Jwt.AccessToken { + /// + /// Grant used in Access Tokens + /// + public interface IGrant + { /// - /// Grant used in Access Tokens + /// Get the name of the grant. /// - public interface IGrant - { - /// - /// Get the name of the grant. - /// - /// - /// String - the name of the grant - string Key { get; } + /// + /// String - the name of the grant + string Key { get; } - /// - /// Get the data of the grant - /// - /// - /// Object - the data of the grant - object Payload { get; } - } + /// + /// Get the data of the grant + /// + /// + /// Object - the data of the grant + object Payload { get; } + } } diff --git a/src/Twilio/JWT/AccessToken/IpMessagingGrant.cs b/src/Twilio/JWT/AccessToken/IpMessagingGrant.cs index 06b95fb78..7aac3fdb2 100644 --- a/src/Twilio/JWT/AccessToken/IpMessagingGrant.cs +++ b/src/Twilio/JWT/AccessToken/IpMessagingGrant.cs @@ -2,76 +2,76 @@ namespace Twilio.Jwt.AccessToken { + /// + /// Grant to use for IP Messaging + /// + [System.Obsolete("IpMessagingGrant is deprecated, use ChatGrant instead")] + public class IpMessagingGrant : IGrant + { /// - /// Grant to use for IP Messaging + /// Service SID /// - [System.Obsolete("IpMessagingGrant is deprecated, use ChatGrant instead")] - public class IpMessagingGrant : IGrant + public string ServiceSid { get; set; } + + /// + /// Endpoint ID + /// + public string EndpointId { get; set; } + + /// + /// Deployment role SID + /// + public string DeploymentRoleSid { get; set; } + + /// + /// Push credential SID + /// + public string PushCredentialSid { get; set; } + + /// + /// Get the grant name + /// + /// + /// name of the grant + public string Key { - /// - /// Service SID - /// - public string ServiceSid { get; set; } - - /// - /// Endpoint ID - /// - public string EndpointId { get; set; } - - /// - /// Deployment role SID - /// - public string DeploymentRoleSid { get; set; } - - /// - /// Push credential SID - /// - public string PushCredentialSid { get; set; } + get + { + return "ip_messaging"; + } + } - /// - /// Get the grant name - /// - /// - /// name of the grant - public string Key + /// + /// Get the grant payload + /// + /// + /// payload of the grant + public object Payload + { + get + { + var payload = new Dictionary(); + + if (ServiceSid != null) { - get - { - return "ip_messaging"; - } + payload.Add("service_sid", ServiceSid); } - - /// - /// Get the grant payload - /// - /// - /// payload of the grant - public object Payload + if (EndpointId != null) { - get - { - var payload = new Dictionary(); - - if (ServiceSid != null) - { - payload.Add("service_sid", ServiceSid); - } - if (EndpointId != null) - { - payload.Add("endpoint_id", EndpointId); - } - if (DeploymentRoleSid != null) - { - payload.Add("deployment_role_sid", DeploymentRoleSid); - } - if (PushCredentialSid != null) - { - payload.Add("push_credential_sid", PushCredentialSid); - } - - return payload; - } + payload.Add("endpoint_id", EndpointId); + } + if (DeploymentRoleSid != null) + { + payload.Add("deployment_role_sid", DeploymentRoleSid); + } + if (PushCredentialSid != null) + { + payload.Add("push_credential_sid", PushCredentialSid); } + return payload; + } } + + } } diff --git a/src/Twilio/JWT/AccessToken/PlaybackGrant.cs b/src/Twilio/JWT/AccessToken/PlaybackGrant.cs index 067beb400..5a7e7dc68 100644 --- a/src/Twilio/JWT/AccessToken/PlaybackGrant.cs +++ b/src/Twilio/JWT/AccessToken/PlaybackGrant.cs @@ -1,41 +1,41 @@ using System.Collections.Generic; namespace Twilio.Jwt.AccessToken -{ +{ + /// + /// Grant to expose Twilio Live + /// + public class PlaybackGrant : IGrant + { /// - /// Grant to expose Twilio Live + /// Grant payload /// - public class PlaybackGrant : IGrant - { - /// - /// Grant payload - /// - public Dictionary Grant { get; set; } - - /// - /// Get the playback grant key - /// - /// - /// the playback grant key - public string Key - { - get - { - return "player"; - } - } - - /// - /// Get the playback grant payload - /// - /// - /// the video grant payload - public object Payload - { - get - { - return Grant; - } - } - } + public Dictionary Grant { get; set; } + + /// + /// Get the playback grant key + /// + /// + /// the playback grant key + public string Key + { + get + { + return "player"; + } + } + + /// + /// Get the playback grant payload + /// + /// + /// the video grant payload + public object Payload + { + get + { + return Grant; + } + } + } } diff --git a/src/Twilio/JWT/AccessToken/SyncGrant.cs b/src/Twilio/JWT/AccessToken/SyncGrant.cs index 81ab11ae1..47e9266fa 100755 --- a/src/Twilio/JWT/AccessToken/SyncGrant.cs +++ b/src/Twilio/JWT/AccessToken/SyncGrant.cs @@ -2,57 +2,57 @@ namespace Twilio.Jwt.AccessToken { + /// + /// Grant for Twilio Sync + /// + public class SyncGrant : IGrant + { /// - /// Grant for Twilio Sync + /// Sync service SID /// - public class SyncGrant : IGrant + public string ServiceSid { get; set; } + + /// + /// Endpoint ID + /// + public string EndpointId { get; set; } + + /// + /// Get the grant key + /// + /// + /// the grant key + public string Key { - /// - /// Sync service SID - /// - public string ServiceSid { get; set; } - - /// - /// Endpoint ID - /// - public string EndpointId { get; set; } + get + { + return "data_sync"; + } + } - /// - /// Get the grant key - /// - /// - /// the grant key - public string Key + /// + /// Get the grant payload + /// + /// + /// the grant payload + public object Payload + { + get + { + var payload = new Dictionary(); + + if (ServiceSid != null) { - get - { - return "data_sync"; - } + payload.Add("service_sid", ServiceSid); } - /// - /// Get the grant payload - /// - /// - /// the grant payload - public object Payload + if (EndpointId != null) { - get - { - var payload = new Dictionary(); - - if (ServiceSid != null) - { - payload.Add("service_sid", ServiceSid); - } - - if (EndpointId != null) - { - payload.Add("endpoint_id", EndpointId); - } - - return payload; - } + payload.Add("endpoint_id", EndpointId); } + + return payload; + } } + } } diff --git a/src/Twilio/JWT/AccessToken/Token.cs b/src/Twilio/JWT/AccessToken/Token.cs index 0786ed39b..11372e9d6 100644 --- a/src/Twilio/JWT/AccessToken/Token.cs +++ b/src/Twilio/JWT/AccessToken/Token.cs @@ -2,137 +2,137 @@ using System.Collections.Generic; namespace Twilio.Jwt.AccessToken -{ +{ + /// + /// Access Token for Twilio resources + /// + public class Token : BaseJwt + { + private readonly string _id; + private readonly string _accountSid; + private readonly string _identity; + private readonly DateTime? _nbf; + private readonly HashSet _grants; + private readonly string _region; + /// - /// Access Token for Twilio resources + /// Create a new Access Token /// - public class Token : BaseJwt - { - private readonly string _id; - private readonly string _accountSid; - private readonly string _identity; - private readonly DateTime? _nbf; - private readonly HashSet _grants; - private readonly string _region; - - /// - /// Create a new Access Token - /// - /// Account SID - /// Signing key SID - /// Secret to encode with - /// Token identity - /// Token expiration - /// Token nbf - /// Token grants - /// Token region - public Token( - string accountSid, - string signingKeySid, - string secret, - string identity = null, - DateTime? expiration = null, - DateTime? nbf = null, - HashSet grants = null, - string region = null - ) : base(secret, signingKeySid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) - { - var now = BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow); - this._id = signingKeySid + "-" + now; - this._accountSid = accountSid; - this._identity = identity; - this._nbf = nbf; - this._grants = grants; - this._region = region; - } - - /// - /// Token ID - /// - public override string Id - { - get - { - return _id; - } - } - - /// - /// Access token subject - /// - public override string Subject - { - get - { - return _accountSid; - } - } - - /// - /// Token not before time - /// - public override DateTime? Nbf - { - get - { - return _nbf; - } - } - - /// - /// The region associated with this account - /// - public string Region - { - get - { - return _region; - } - } - - /// - /// Headers for an Access Token - /// - public override Dictionary Headers - { - get - { - var headers = new Dictionary { { "cty", "twilio-fpa;v=1" } }; - - if (_region != null) - { - headers.Add("twr", _region); - } - - return headers; - } - } - - /// - /// Populate claims for the Access Token - /// - /// - public override Dictionary Claims - { - get - { - var grants = new Dictionary(); - if (_identity != null) - { - grants.Add("identity", _identity); - } - - if (_grants != null) - { - foreach (var grant in _grants) - { - grants.Add(grant.Key, grant.Payload); - } - } - - return new Dictionary { { "grants", grants } }; - } - } - - } + /// Account SID + /// Signing key SID + /// Secret to encode with + /// Token identity + /// Token expiration + /// Token nbf + /// Token grants + /// Token region + public Token( + string accountSid, + string signingKeySid, + string secret, + string identity = null, + DateTime? expiration = null, + DateTime? nbf = null, + HashSet grants = null, + string region = null + ) : base(secret, signingKeySid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) + { + var now = BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow); + this._id = signingKeySid + "-" + now; + this._accountSid = accountSid; + this._identity = identity; + this._nbf = nbf; + this._grants = grants; + this._region = region; + } + + /// + /// Token ID + /// + public override string Id + { + get + { + return _id; + } + } + + /// + /// Access token subject + /// + public override string Subject + { + get + { + return _accountSid; + } + } + + /// + /// Token not before time + /// + public override DateTime? Nbf + { + get + { + return _nbf; + } + } + + /// + /// The region associated with this account + /// + public string Region + { + get + { + return _region; + } + } + + /// + /// Headers for an Access Token + /// + public override Dictionary Headers + { + get + { + var headers = new Dictionary { { "cty", "twilio-fpa;v=1" } }; + + if (_region != null) + { + headers.Add("twr", _region); + } + + return headers; + } + } + + /// + /// Populate claims for the Access Token + /// + /// + public override Dictionary Claims + { + get + { + var grants = new Dictionary(); + if (_identity != null) + { + grants.Add("identity", _identity); + } + + if (_grants != null) + { + foreach (var grant in _grants) + { + grants.Add(grant.Key, grant.Payload); + } + } + + return new Dictionary { { "grants", grants } }; + } + } + + } } diff --git a/src/Twilio/JWT/AccessToken/VideoGrant.cs b/src/Twilio/JWT/AccessToken/VideoGrant.cs index 75d64b755..d122df2ab 100644 --- a/src/Twilio/JWT/AccessToken/VideoGrant.cs +++ b/src/Twilio/JWT/AccessToken/VideoGrant.cs @@ -1,57 +1,57 @@ -using System.Collections.Generic; - -namespace Twilio.Jwt.AccessToken -{ - /// - /// Grant to expose Twilio Video - /// - public class VideoGrant : IGrant - { - /// - /// Configuration profile SID - /// - [System.Obsolete("ConfigurationProfileSid is deprecated, use Room instead")] - public string ConfigurationProfileSid { get; set; } - - /// - /// Roome SID or name - /// - public string Room { get; set; } - - /// - /// Get the Video grant key - /// - /// - /// the video grant key - public string Key - { - get - { - return "video"; - } - } - - /// - /// Get the video grant payload - /// - /// - /// the video grant payload - public object Payload - { - get - { - var payload = new Dictionary(); - if (ConfigurationProfileSid != null) - { - payload.Add("configuration_profile_sid", ConfigurationProfileSid); - } - if (Room != null) - { - payload.Add("room", Room); - } - - return payload; - } - } - } -} +using System.Collections.Generic; + +namespace Twilio.Jwt.AccessToken +{ + /// + /// Grant to expose Twilio Video + /// + public class VideoGrant : IGrant + { + /// + /// Configuration profile SID + /// + [System.Obsolete("ConfigurationProfileSid is deprecated, use Room instead")] + public string ConfigurationProfileSid { get; set; } + + /// + /// Roome SID or name + /// + public string Room { get; set; } + + /// + /// Get the Video grant key + /// + /// + /// the video grant key + public string Key + { + get + { + return "video"; + } + } + + /// + /// Get the video grant payload + /// + /// + /// the video grant payload + public object Payload + { + get + { + var payload = new Dictionary(); + if (ConfigurationProfileSid != null) + { + payload.Add("configuration_profile_sid", ConfigurationProfileSid); + } + if (Room != null) + { + payload.Add("room", Room); + } + + return payload; + } + } + } +} diff --git a/src/Twilio/JWT/AccessToken/VoiceGrant.cs b/src/Twilio/JWT/AccessToken/VoiceGrant.cs index 360c1bdbd..3a2e40c98 100644 --- a/src/Twilio/JWT/AccessToken/VoiceGrant.cs +++ b/src/Twilio/JWT/AccessToken/VoiceGrant.cs @@ -1,89 +1,89 @@ using System.Collections.Generic; namespace Twilio.Jwt.AccessToken -{ +{ + /// + /// Grant to expose Twilio Voice + /// + public class VoiceGrant : IGrant + { /// - /// Grant to expose Twilio Voice + /// Whether incoming connections are allowed (JS Client) /// - public class VoiceGrant : IGrant - { - /// - /// Whether incoming connections are allowed (JS Client) - /// - public bool IncomingAllow { get; set; } - - /// - /// Outgoing application SID - /// - public string OutgoingApplicationSid { get; set; } - - /// - /// Parameters to send to the outgoing application - /// - public Dictionary OutgoingApplicationParams { get; set; } - - /// - /// Push credential SID - /// - public string PushCredentialSid { get; set; } - - /// - /// Endpoint ID - /// - public string EndpointId { get; set; } - - /// - /// Get the grant key - /// - /// - /// the grant key - public string Key - { - get - { - return "voice"; - } - } - - /// - /// Get the grant payload - /// - /// - /// the grant payload - public object Payload - { - get - { - var payload = new Dictionary(); - if (IncomingAllow == true) - { - var incoming = new Dictionary { { "allow", true } }; - payload.Add("incoming", incoming); - } - - if (OutgoingApplicationSid != null) - { - var outgoing = new Dictionary { { "application_sid", OutgoingApplicationSid } }; - if (OutgoingApplicationParams != null) - { - outgoing.Add("params", OutgoingApplicationParams); - } - - payload.Add("outgoing", outgoing); - } - - if (PushCredentialSid != null) - { - payload.Add("push_credential_sid", PushCredentialSid); - } - - if (EndpointId != null) - { - payload.Add("endpoint_id", EndpointId); - } - - return payload; - } - } - } + public bool IncomingAllow { get; set; } + + /// + /// Outgoing application SID + /// + public string OutgoingApplicationSid { get; set; } + + /// + /// Parameters to send to the outgoing application + /// + public Dictionary OutgoingApplicationParams { get; set; } + + /// + /// Push credential SID + /// + public string PushCredentialSid { get; set; } + + /// + /// Endpoint ID + /// + public string EndpointId { get; set; } + + /// + /// Get the grant key + /// + /// + /// the grant key + public string Key + { + get + { + return "voice"; + } + } + + /// + /// Get the grant payload + /// + /// + /// the grant payload + public object Payload + { + get + { + var payload = new Dictionary(); + if (IncomingAllow == true) + { + var incoming = new Dictionary { { "allow", true } }; + payload.Add("incoming", incoming); + } + + if (OutgoingApplicationSid != null) + { + var outgoing = new Dictionary { { "application_sid", OutgoingApplicationSid } }; + if (OutgoingApplicationParams != null) + { + outgoing.Add("params", OutgoingApplicationParams); + } + + payload.Add("outgoing", outgoing); + } + + if (PushCredentialSid != null) + { + payload.Add("push_credential_sid", PushCredentialSid); + } + + if (EndpointId != null) + { + payload.Add("endpoint_id", EndpointId); + } + + return payload; + } + } + } } diff --git a/src/Twilio/JWT/Client/ClientCapability.cs b/src/Twilio/JWT/Client/ClientCapability.cs index 1b264b803..233262289 100644 --- a/src/Twilio/JWT/Client/ClientCapability.cs +++ b/src/Twilio/JWT/Client/ClientCapability.cs @@ -2,63 +2,63 @@ using System.Collections.Generic; namespace Twilio.Jwt -{ +{ + /// + /// JWT for Twilio Client + /// + public class ClientCapability : BaseJwt + { + private readonly HashSet _scopes; + /// - /// JWT for Twilio Client + /// Create a new Client JWT /// - public class ClientCapability : BaseJwt - { - private readonly HashSet _scopes; - - /// - /// Create a new Client JWT - /// - /// Twilio Account SID - /// Twilio auth token - /// JWT expiration - /// Scopes to give access to - public ClientCapability( - string accountSid, - string authToken, - DateTime? expiration = null, - HashSet scopes = null - ) : base (authToken, accountSid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) - { - this._scopes = scopes; - } - - /// - /// JWT headers - /// - public override Dictionary Headers - { - get - { - return new Dictionary(); - } - } - - /// - /// Get the JWT claims in JSON format - /// - public override Dictionary Claims - { - get - { - var claims = new Dictionary(); - if (_scopes != null) - { - var scopes = new List(); - foreach (var scope in _scopes) - { - scopes.Add(scope.Payload); - } - - claims.Add("scope", String.Join(" ", scopes.ToArray())); - } - - return claims; - } - } - } + /// Twilio Account SID + /// Twilio auth token + /// JWT expiration + /// Scopes to give access to + public ClientCapability( + string accountSid, + string authToken, + DateTime? expiration = null, + HashSet scopes = null + ) : base(authToken, accountSid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) + { + this._scopes = scopes; + } + + /// + /// JWT headers + /// + public override Dictionary Headers + { + get + { + return new Dictionary(); + } + } + + /// + /// Get the JWT claims in JSON format + /// + public override Dictionary Claims + { + get + { + var claims = new Dictionary(); + if (_scopes != null) + { + var scopes = new List(); + foreach (var scope in _scopes) + { + scopes.Add(scope.Payload); + } + + claims.Add("scope", String.Join(" ", scopes.ToArray())); + } + + return claims; + } + } + } } diff --git a/src/Twilio/JWT/Client/EventStreamScope.cs b/src/Twilio/JWT/Client/EventStreamScope.cs index 2b4987d8e..6016b5879 100644 --- a/src/Twilio/JWT/Client/EventStreamScope.cs +++ b/src/Twilio/JWT/Client/EventStreamScope.cs @@ -8,63 +8,63 @@ #endif namespace Twilio.Jwt.Client -{ +{ + /// + /// Event stream scope for client capabilities + /// + public class EventStreamScope : IScope + { + private static readonly string Scope = "scope:stream:subscribe"; + + private readonly Dictionary _filters; + /// - /// Event stream scope for client capabilities + /// Create a new EventStreamScope /// - public class EventStreamScope : IScope - { - private static readonly string Scope = "scope:stream:subscribe"; - - private readonly Dictionary _filters; - - /// - /// Create a new EventStreamScope - /// - /// filters to use - public EventStreamScope(Dictionary filters = null) - { - this._filters = filters; - } - - /// - /// Generate scope payload - /// - public string Payload - { - get - { - var queryArgs = new List(); - queryArgs.Add("path=/2010-04-01/Events"); - - if (_filters != null) - { - queryArgs.Add(BuildParameter("appParams", GetFilterParams())); - } - - var queryString = String.Join("&", queryArgs.ToArray()); - return Scope + "?" + queryString; - } - } - - private string GetFilterParams() - { - var queryParams = new List(); - foreach (var entry in _filters) - { - queryParams.Add(BuildParameter(entry.Key, entry.Value)); - } - - return String.Join("&", queryParams.ToArray()); - } - - private string BuildParameter(string k, string v) - { + /// filters to use + public EventStreamScope(Dictionary filters = null) + { + this._filters = filters; + } + + /// + /// Generate scope payload + /// + public string Payload + { + get + { + var queryArgs = new List(); + queryArgs.Add("path=/2010-04-01/Events"); + + if (_filters != null) + { + queryArgs.Add(BuildParameter("appParams", GetFilterParams())); + } + + var queryString = String.Join("&", queryArgs.ToArray()); + return Scope + "?" + queryString; + } + } + + private string GetFilterParams() + { + var queryParams = new List(); + foreach (var entry in _filters) + { + queryParams.Add(BuildParameter(entry.Key, entry.Value)); + } + + return String.Join("&", queryParams.ToArray()); + } + + private string BuildParameter(string k, string v) + { #if !NET35 - return WebUtility.UrlEncode(k) + "=" + WebUtility.UrlEncode(v); + return WebUtility.UrlEncode(k) + "=" + WebUtility.UrlEncode(v); #else return HttpUtility.UrlEncode(k) + "=" + HttpUtility.UrlEncode(v); #endif - } - } + } + } } diff --git a/src/Twilio/JWT/Client/IScope.cs b/src/Twilio/JWT/Client/IScope.cs index 6c1e4a17b..ffd8471a8 100644 --- a/src/Twilio/JWT/Client/IScope.cs +++ b/src/Twilio/JWT/Client/IScope.cs @@ -1,15 +1,15 @@ using System; namespace Twilio.Jwt -{ +{ + /// + /// Scope interface of client capabilities + /// + public interface IScope + { /// - /// Scope interface of client capabilities + /// Generate the scope payload /// - public interface IScope - { - /// - /// Generate the scope payload - /// - string Payload { get; } - } + string Payload { get; } + } } diff --git a/src/Twilio/JWT/Client/IncomingClientScope.cs b/src/Twilio/JWT/Client/IncomingClientScope.cs index a30a8f389..2e00ce9f2 100644 --- a/src/Twilio/JWT/Client/IncomingClientScope.cs +++ b/src/Twilio/JWT/Client/IncomingClientScope.cs @@ -1,35 +1,35 @@ using System; namespace Twilio.Jwt.Client -{ +{ + /// + /// Incoming client scope for client capabilities + /// + public class IncomingClientScope : IScope + { + private static readonly string Scope = "scope:client:incoming"; + + private readonly string _clientName; + /// - /// Incoming client scope for client capabilities + /// Create a new IncomingClientScope /// - public class IncomingClientScope : IScope - { - private static readonly string Scope = "scope:client:incoming"; - - private readonly string _clientName; - - /// - /// Create a new IncomingClientScope - /// - /// Client name - public IncomingClientScope(string clientName) - { - this._clientName = clientName; - } - - /// - /// Generate scope payload - /// - public string Payload - { - get - { - var query = "clientName=" + _clientName; - return Scope + "?" + query; - } - } - } + /// Client name + public IncomingClientScope(string clientName) + { + this._clientName = clientName; + } + + /// + /// Generate scope payload + /// + public string Payload + { + get + { + var query = "clientName=" + _clientName; + return Scope + "?" + query; + } + } + } } diff --git a/src/Twilio/JWT/Client/OutgoingClientScope.cs b/src/Twilio/JWT/Client/OutgoingClientScope.cs index 0bac692df..2cd8802d5 100644 --- a/src/Twilio/JWT/Client/OutgoingClientScope.cs +++ b/src/Twilio/JWT/Client/OutgoingClientScope.cs @@ -8,78 +8,78 @@ #endif namespace Twilio.Jwt.Client -{ +{ + /// + /// Scope capability + /// + public class OutgoingClientScope : IScope + { + private static readonly string Scope = "scope:client:outgoing"; + + private readonly string _applicationSid; + private readonly string _clientName; + private readonly Dictionary _parameters; + /// - /// Scope capability + /// Create a new OutgoingClientScope /// - public class OutgoingClientScope : IScope - { - private static readonly string Scope = "scope:client:outgoing"; - - private readonly string _applicationSid; - private readonly string _clientName; - private readonly Dictionary _parameters; - - /// - /// Create a new OutgoingClientScope - /// - /// Twilio Application SID - /// Name of client - /// Parameters to pass - public OutgoingClientScope( - string applicationSid, - string clientName = null, - Dictionary parameters = null - ) - { - this._applicationSid = applicationSid; - this._clientName = clientName; - this._parameters = parameters; - } - - /// - /// Generate scope payload - /// - public string Payload - { - get - { - var queryArgs = new List(); - queryArgs.Add(BuildParameter("appSid", _applicationSid)); - - if (_clientName != null) - { - queryArgs.Add(BuildParameter("clientName", _clientName)); - } - - if (_parameters != null) - { - queryArgs.Add(BuildParameter("appParams", GetAppParams())); - } - - var queryString = String.Join("&", queryArgs.ToArray()); - return Scope + "?" + queryString; - } - } - - private string GetAppParams() - { - var queryParams = new List(); - foreach (var entry in _parameters) - { - queryParams.Add(BuildParameter(entry.Key, entry.Value)); - } - - return String.Join("&", queryParams.ToArray()); - } - - private string BuildParameter(string k, string v) - { + /// Twilio Application SID + /// Name of client + /// Parameters to pass + public OutgoingClientScope( + string applicationSid, + string clientName = null, + Dictionary parameters = null + ) + { + this._applicationSid = applicationSid; + this._clientName = clientName; + this._parameters = parameters; + } + + /// + /// Generate scope payload + /// + public string Payload + { + get + { + var queryArgs = new List(); + queryArgs.Add(BuildParameter("appSid", _applicationSid)); + + if (_clientName != null) + { + queryArgs.Add(BuildParameter("clientName", _clientName)); + } + + if (_parameters != null) + { + queryArgs.Add(BuildParameter("appParams", GetAppParams())); + } + + var queryString = String.Join("&", queryArgs.ToArray()); + return Scope + "?" + queryString; + } + } + + private string GetAppParams() + { + var queryParams = new List(); + foreach (var entry in _parameters) + { + queryParams.Add(BuildParameter(entry.Key, entry.Value)); + } + + return String.Join("&", queryParams.ToArray()); + } + + private string BuildParameter(string k, string v) + { #if !NET35 - return WebUtility.UrlEncode(k) + "=" + WebUtility.UrlEncode(v); + return WebUtility.UrlEncode(k) + "=" + WebUtility.UrlEncode(v); #else return HttpUtility.UrlEncode(k) + "=" + HttpUtility.UrlEncode(v); #endif - } - } + } + } } diff --git a/src/Twilio/JWT/Taskrouter/Policy.cs b/src/Twilio/JWT/Taskrouter/Policy.cs index b018744a5..28b95de71 100755 --- a/src/Twilio/JWT/Taskrouter/Policy.cs +++ b/src/Twilio/JWT/Taskrouter/Policy.cs @@ -2,75 +2,75 @@ using Twilio.Http; namespace Twilio.Jwt.Taskrouter -{ +{ + /// + /// Policy for a TaskRouter token + /// + public class Policy + { /// - /// Policy for a TaskRouter token + /// Filter requirements for a TaskRouter policy /// - public class Policy - { - /// - /// Filter requirements for a TaskRouter policy - /// - public sealed class FilterRequirement : Dictionary - { - private FilterRequirement(bool v) - { - Add("required", v); - } - - /// - /// Parameter is required - /// - public static readonly FilterRequirement Required = new FilterRequirement(true); - - /// - /// Parameter is optional - /// - public static readonly FilterRequirement Optional = new FilterRequirement(false); - } - - private readonly string _url; - private readonly bool _allowed; - private readonly HttpMethod _method; - private readonly Dictionary _queryFilter; - private readonly Dictionary _postFilter; - - /// - /// Create a new Policy - /// - /// TaskRouter URL - /// HTTP method - /// Query param filters - /// POST data filters - /// Allow the JWT to access - public Policy( - string url, - HttpMethod method, - Dictionary queryFilter=null, - Dictionary postFilter=null, - bool allowed=true - ) - { - _url = url; - _allowed = allowed; - _method = method; - _queryFilter = queryFilter ?? new Dictionary(); - _postFilter = postFilter ?? new Dictionary(); - } - - /// - /// Returns dictionary representation of the Policy - /// - /// Dictionary representation of the Policy - public Dictionary ToDict() - { - return new Dictionary { + public sealed class FilterRequirement : Dictionary + { + private FilterRequirement(bool v) + { + Add("required", v); + } + + /// + /// Parameter is required + /// + public static readonly FilterRequirement Required = new FilterRequirement(true); + + /// + /// Parameter is optional + /// + public static readonly FilterRequirement Optional = new FilterRequirement(false); + } + + private readonly string _url; + private readonly bool _allowed; + private readonly HttpMethod _method; + private readonly Dictionary _queryFilter; + private readonly Dictionary _postFilter; + + /// + /// Create a new Policy + /// + /// TaskRouter URL + /// HTTP method + /// Query param filters + /// POST data filters + /// Allow the JWT to access + public Policy( + string url, + HttpMethod method, + Dictionary queryFilter = null, + Dictionary postFilter = null, + bool allowed = true + ) + { + _url = url; + _allowed = allowed; + _method = method; + _queryFilter = queryFilter ?? new Dictionary(); + _postFilter = postFilter ?? new Dictionary(); + } + + /// + /// Returns dictionary representation of the Policy + /// + /// Dictionary representation of the Policy + public Dictionary ToDict() + { + return new Dictionary { { "url", _url }, { "method", _method.ToString() }, { "query_filter", _queryFilter }, { "post_filter", _postFilter }, { "allow", _allowed } - }; - } - } + }; + } + } } diff --git a/src/Twilio/JWT/Taskrouter/PolicyUtils.cs b/src/Twilio/JWT/Taskrouter/PolicyUtils.cs index e607e36b0..42f820fca 100644 --- a/src/Twilio/JWT/Taskrouter/PolicyUtils.cs +++ b/src/Twilio/JWT/Taskrouter/PolicyUtils.cs @@ -3,30 +3,30 @@ using Twilio.Http; namespace Twilio.Jwt.Taskrouter -{ +{ + /// + /// Utility class for generating Policies + /// + public class PolicyUtils + { + private static readonly string TaskRouterEventUrl = "https://event-bridge.twilio.com/v1/wschannels"; + + private PolicyUtils() { } + /// - /// Utility class for generating Policies + /// Generate default event bridge policies /// - public class PolicyUtils - { - private static readonly string TaskRouterEventUrl = "https://event-bridge.twilio.com/v1/wschannels"; - - private PolicyUtils() {} - - /// - /// Generate default event bridge policies - /// - /// Twilio account SID - /// TaskRouter channel ID - /// Default event bridge policies - public static List DefaultEventBridgePolicies(string accountSid, string channelId) - { - var url = TaskRouterEventUrl + "/" + accountSid + "/" + channelId; - return new List + /// Twilio account SID + /// TaskRouter channel ID + /// Default event bridge policies + public static List DefaultEventBridgePolicies(string accountSid, string channelId) + { + var url = TaskRouterEventUrl + "/" + accountSid + "/" + channelId; + return new List { { new Policy(url, HttpMethod.Get) }, { new Policy(url, HttpMethod.Post) } - }; - } - } + }; + } + } } diff --git a/src/Twilio/JWT/Taskrouter/TaskRouterCapability.cs b/src/Twilio/JWT/Taskrouter/TaskRouterCapability.cs index 9e79e92a0..379ad8657 100644 --- a/src/Twilio/JWT/Taskrouter/TaskRouterCapability.cs +++ b/src/Twilio/JWT/Taskrouter/TaskRouterCapability.cs @@ -2,98 +2,98 @@ using System.Collections.Generic; namespace Twilio.Jwt.Taskrouter -{ +{ + /// + /// JWT for TaskRouter use + /// + public class TaskRouterCapability : BaseJwt + { + private readonly string _accountSid; + private readonly string _workspaceSid; + private readonly string _friendlyName; + private readonly string _channelId; + private readonly List _policies; + /// - /// JWT for TaskRouter use + /// Create a new TaskRouter JWT /// - public class TaskRouterCapability : BaseJwt - { - private readonly string _accountSid; - private readonly string _workspaceSid; - private readonly string _friendlyName; - private readonly string _channelId; - private readonly List _policies; - - /// - /// Create a new TaskRouter JWT - /// - /// Twilio account SID - /// Twilio auth token - /// TaskRouter workspace SID - /// TaskRouter channel ID - /// Friendly name for this JWT - /// JWT expiration - /// JWT policies - public TaskRouterCapability( - string accountSid, - string authToken, - string workspaceSid, - string channelId, - string friendlyName = null, - DateTime? expiration = null, - List policies = null - ) : base(authToken, accountSid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) - { - this._accountSid = accountSid; - this._workspaceSid = workspaceSid; - this._channelId = channelId; - this._friendlyName = friendlyName; - this._policies = policies; - } - - /// - /// Get the JWT headers - /// - public override Dictionary Headers - { - get - { - return new Dictionary(); - } - } - - /// - /// Generate JWT payload - /// - public override Dictionary Claims - { - get - { - var payload = new Dictionary + /// Twilio account SID + /// Twilio auth token + /// TaskRouter workspace SID + /// TaskRouter channel ID + /// Friendly name for this JWT + /// JWT expiration + /// JWT policies + public TaskRouterCapability( + string accountSid, + string authToken, + string workspaceSid, + string channelId, + string friendlyName = null, + DateTime? expiration = null, + List policies = null + ) : base(authToken, accountSid, expiration.HasValue ? expiration.Value : DateTime.UtcNow.AddSeconds(3600)) + { + this._accountSid = accountSid; + this._workspaceSid = workspaceSid; + this._channelId = channelId; + this._friendlyName = friendlyName; + this._policies = policies; + } + + /// + /// Get the JWT headers + /// + public override Dictionary Headers + { + get + { + return new Dictionary(); + } + } + + /// + /// Generate JWT payload + /// + public override Dictionary Claims + { + get + { + var payload = new Dictionary { { "version", "v1" }, { "account_sid", _accountSid }, { "friendly_name", _friendlyName }, { "workspace_sid", _workspaceSid }, { "channel", _channelId } - }; - - if (_channelId.StartsWith("WK")) - { - payload.Add("worker_sid", _channelId); - } - else if (_channelId.StartsWith("WQ")) - { - payload.Add("taskqueue_sid", _channelId); - } - - var payloadPolicies = new List(); - foreach (var policy in PolicyUtils.DefaultEventBridgePolicies(_accountSid, _channelId)) - { - payloadPolicies.Add(policy.ToDict()); - } - - if (_policies != null) - { - foreach (var policy in _policies) - { - payloadPolicies.Add(policy.ToDict()); - } - } - - payload.Add("policies", payloadPolicies); - return payload; - } - } - } + }; + + if (_channelId.StartsWith("WK")) + { + payload.Add("worker_sid", _channelId); + } + else if (_channelId.StartsWith("WQ")) + { + payload.Add("taskqueue_sid", _channelId); + } + + var payloadPolicies = new List(); + foreach (var policy in PolicyUtils.DefaultEventBridgePolicies(_accountSid, _channelId)) + { + payloadPolicies.Add(policy.ToDict()); + } + + if (_policies != null) + { + foreach (var policy in _policies) + { + payloadPolicies.Add(policy.ToDict()); + } + } + + payload.Add("policies", payloadPolicies); + return payload; + } + } + } } diff --git a/src/Twilio/Properties/AssemblyInfo.cs b/src/Twilio/Properties/AssemblyInfo.cs index 13dbe9010..08ebcc38d 100644 --- a/src/Twilio/Properties/AssemblyInfo.cs +++ b/src/Twilio/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ // and "{Major}.{Minor}.{Build}.*" will update just the revision. internal class AssemblyInfomation -{ - public const string AssemblyInformationalVersion = "5.69.0"; +{ + public const string AssemblyInformationalVersion = "5.69.0"; } diff --git a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionOptions.cs b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionOptions.cs index 08a491cb2..17c1bbc46 100644 --- a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionOptions.cs +++ b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionOptions.cs @@ -9,22 +9,22 @@ using Twilio.Converters; namespace Twilio.Rest.Accounts.V1 -{ - +{ + + /// + /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old + /// primary Auth Token will result in an error. + /// + public class UpdateAuthTokenPromotionOptions : IOptions + { /// - /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old - /// primary Auth Token will result in an error. + /// Generate the necessary parameters /// - public class UpdateAuthTokenPromotionOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs index e72db5869..67b41d9e1 100644 --- a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs +++ b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs @@ -16,127 +16,127 @@ using Twilio.Http; namespace Twilio.Rest.Accounts.V1 -{ - - public class AuthTokenPromotionResource : Resource - { - private static Request BuildUpdateRequest(UpdateAuthTokenPromotionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/AuthTokens/Promote", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old - /// primary Auth Token will result in an error. - /// - /// Update AuthTokenPromotion parameters - /// Client to make requests to Twilio - /// A single instance of AuthTokenPromotion - public static AuthTokenPromotionResource Update(UpdateAuthTokenPromotionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old - /// primary Auth Token will result in an error. - /// - /// Update AuthTokenPromotion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthTokenPromotion - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthTokenPromotionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old - /// primary Auth Token will result in an error. - /// - /// Client to make requests to Twilio - /// A single instance of AuthTokenPromotion - public static AuthTokenPromotionResource Update(ITwilioRestClient client = null) - { - var options = new UpdateAuthTokenPromotionOptions(); - return Update(options, client); - } - - #if !NET35 - /// - /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old - /// primary Auth Token will result in an error. - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthTokenPromotion - public static async System.Threading.Tasks.Task UpdateAsync(ITwilioRestClient client = null) - { - var options = new UpdateAuthTokenPromotionOptions(); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AuthTokenPromotionResource object - /// - /// Raw JSON string - /// AuthTokenPromotionResource object represented by the provided JSON - public static AuthTokenPromotionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that the secondary Auth Token was created for - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The promoted Auth Token - /// - [JsonProperty("auth_token")] - public string AuthToken { get; private set; } - /// - /// The ISO 8601 formatted date and time in UTC when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 formatted date and time in UTC when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI for this resource, relative to `https://accounts.twilio.com` - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private AuthTokenPromotionResource() - { - - } - } +{ + + public class AuthTokenPromotionResource : Resource + { + private static Request BuildUpdateRequest(UpdateAuthTokenPromotionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/AuthTokens/Promote", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old + /// primary Auth Token will result in an error. + /// + /// Update AuthTokenPromotion parameters + /// Client to make requests to Twilio + /// A single instance of AuthTokenPromotion + public static AuthTokenPromotionResource Update(UpdateAuthTokenPromotionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old + /// primary Auth Token will result in an error. + /// + /// Update AuthTokenPromotion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthTokenPromotion + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthTokenPromotionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old + /// primary Auth Token will result in an error. + /// + /// Client to make requests to Twilio + /// A single instance of AuthTokenPromotion + public static AuthTokenPromotionResource Update(ITwilioRestClient client = null) + { + var options = new UpdateAuthTokenPromotionOptions(); + return Update(options, client); + } + +#if !NET35 + /// + /// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old + /// primary Auth Token will result in an error. + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthTokenPromotion + public static async System.Threading.Tasks.Task UpdateAsync(ITwilioRestClient client = null) + { + var options = new UpdateAuthTokenPromotionOptions(); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AuthTokenPromotionResource object + /// + /// Raw JSON string + /// AuthTokenPromotionResource object represented by the provided JSON + public static AuthTokenPromotionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that the secondary Auth Token was created for + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The promoted Auth Token + /// + [JsonProperty("auth_token")] + public string AuthToken { get; private set; } + /// + /// The ISO 8601 formatted date and time in UTC when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 formatted date and time in UTC when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI for this resource, relative to `https://accounts.twilio.com` + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private AuthTokenPromotionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs b/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs index c33a4e591..6455536a1 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs @@ -1,183 +1,186 @@ -/// This code was generated by -/// \ / _ _ _| _ _ -/// | (_)\/(_)(_|\/| |(/_ v1.0.0 -/// / / - -using System; -using System.Collections.Generic; -using Twilio.Base; -using Twilio.Converters; - -namespace Twilio.Rest.Accounts.V1.Credential -{ - - /// - /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - /// - public class ReadAwsOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - - /// - /// Create a new AWS Credential - /// - public class CreateAwsOptions : IOptions - { - /// - /// A string that contains the AWS access credentials in the format : - /// - public string Credentials { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The Subaccount this Credential should be associated with. - /// - public string AccountSid { get; set; } - - /// - /// Construct a new CreateAwsOptions - /// - /// A string that contains the AWS access credentials in the format - /// : - public CreateAwsOptions(string credentials) - { - Credentials = credentials; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Credentials != null) - { - p.Add(new KeyValuePair("Credentials", Credentials.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - return p; - } - } - - /// - /// Fetch the AWS credentials specified by the provided Credential Sid - /// - public class FetchAwsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAwsOptions - /// - /// The unique string that identifies the resource - public FetchAwsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - - /// - /// Modify the properties of a given Account - /// - public class UpdateAwsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateAwsOptions - /// - /// The unique string that identifies the resource - public UpdateAwsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - - /// - /// Delete a Credential from your account - /// - public class DeleteAwsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAwsOptions - /// - /// The unique string that identifies the resource - public DeleteAwsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - +/// This code was generated by +/// \ / _ _ _| _ _ +/// | (_)\/(_)(_|\/| |(/_ v1.0.0 +/// / / + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + +namespace Twilio.Rest.Accounts.V1.Credential +{ + + /// + /// Retrieves a collection of AWS Credentials belonging to the account used to make the request + /// + public class ReadAwsOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new AWS Credential + /// + public class CreateAwsOptions : IOptions + { + +#pragma warning disable CS1570 // XML comment has badly formed XML + /// + /// A string that contains the AWS access credentials in the format : + /// + public string Credentials { get; } +#pragma warning restore CS1570 // XML comment has badly formed XML + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The Subaccount this Credential should be associated with. + /// + public string AccountSid { get; set; } + + /// + /// Construct a new CreateAwsOptions + /// + /// A string that contains the AWS access credentials in the format + /// : + public CreateAwsOptions(string credentials) + { + Credentials = credentials; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Credentials != null) + { + p.Add(new KeyValuePair("Credentials", Credentials.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch the AWS credentials specified by the provided Credential Sid + /// + public class FetchAwsOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAwsOptions + /// + /// The unique string that identifies the resource + public FetchAwsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Modify the properties of a given Account + /// + public class UpdateAwsOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateAwsOptions + /// + /// The unique string that identifies the resource + public UpdateAwsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete a Credential from your account + /// + public class DeleteAwsOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAwsOptions + /// + /// The unique string that identifies the resource + public DeleteAwsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs b/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs index c06d14200..59462ffc9 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs @@ -16,473 +16,473 @@ using Twilio.Http; namespace Twilio.Rest.Accounts.V1.Credential -{ - - public class AwsResource : Resource - { - private static Request BuildReadRequest(ReadAwsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Accounts, - "/v1/Credentials/AWS", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - /// - /// Read Aws parameters - /// Client to make requests to Twilio - /// A single instance of Aws - public static ResourceSet Read(ReadAwsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - /// - /// Read Aws parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Aws - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAwsOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAwsOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Accounts) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Accounts) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateAwsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/Credentials/AWS", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new AWS Credential - /// - /// Create Aws parameters - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new AWS Credential - /// - /// Create Aws parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task CreateAsync(CreateAwsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new AWS Credential - /// - /// A string that contains the AWS access credentials in the format - /// : - /// A string to describe the resource - /// The Subaccount this Credential should be associated with. - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Create(string credentials, - string friendlyName = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAwsOptions(credentials){FriendlyName = friendlyName, AccountSid = accountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new AWS Credential - /// - /// A string that contains the AWS access credentials in the format - /// : - /// A string to describe the resource - /// The Subaccount this Credential should be associated with. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task CreateAsync(string credentials, - string friendlyName = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAwsOptions(credentials){FriendlyName = friendlyName, AccountSid = accountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchAwsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Accounts, - "/v1/Credentials/AWS/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the AWS credentials specified by the provided Credential Sid - /// - /// Fetch Aws parameters - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the AWS credentials specified by the provided Credential Sid - /// - /// Fetch Aws parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the AWS credentials specified by the provided Credential Sid - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAwsOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the AWS credentials specified by the provided Credential Sid - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAwsOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAwsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/Credentials/AWS/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Modify the properties of a given Account - /// - /// Update Aws parameters - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// Update Aws parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Modify the properties of a given Account - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of Aws - public static AwsResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) - { - var options = new UpdateAwsOptions(pathSid){FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateAwsOptions(pathSid){FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAwsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Accounts, - "/v1/Credentials/AWS/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Credential from your account - /// - /// Delete Aws parameters - /// Client to make requests to Twilio - /// A single instance of Aws - public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Credential from your account - /// - /// Delete Aws parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAwsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Credential from your account - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Aws - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAwsOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Credential from your account - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAwsOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AwsResource object - /// - /// Raw JSON string - /// AwsResource object represented by the provided JSON - public static AwsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI for this resource, relative to `https://accounts.twilio.com` - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private AwsResource() - { - - } - } +{ + + public class AwsResource : Resource + { + private static Request BuildReadRequest(ReadAwsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Accounts, + "/v1/Credentials/AWS", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieves a collection of AWS Credentials belonging to the account used to make the request + /// + /// Read Aws parameters + /// Client to make requests to Twilio + /// A single instance of Aws + public static ResourceSet Read(ReadAwsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of AWS Credentials belonging to the account used to make the request + /// + /// Read Aws parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieves a collection of AWS Credentials belonging to the account used to make the request + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Aws + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAwsOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of AWS Credentials belonging to the account used to make the request + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAwsOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Accounts) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Accounts) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateAwsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/Credentials/AWS", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new AWS Credential + /// + /// Create Aws parameters + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new AWS Credential + /// + /// Create Aws parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task CreateAsync(CreateAwsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new AWS Credential + /// + /// A string that contains the AWS access credentials in the format + /// : + /// A string to describe the resource + /// The Subaccount this Credential should be associated with. + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Create(string credentials, + string friendlyName = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAwsOptions(credentials) { FriendlyName = friendlyName, AccountSid = accountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new AWS Credential + /// + /// A string that contains the AWS access credentials in the format + /// : + /// A string to describe the resource + /// The Subaccount this Credential should be associated with. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task CreateAsync(string credentials, + string friendlyName = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAwsOptions(credentials) { FriendlyName = friendlyName, AccountSid = accountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchAwsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Accounts, + "/v1/Credentials/AWS/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the AWS credentials specified by the provided Credential Sid + /// + /// Fetch Aws parameters + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the AWS credentials specified by the provided Credential Sid + /// + /// Fetch Aws parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the AWS credentials specified by the provided Credential Sid + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAwsOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the AWS credentials specified by the provided Credential Sid + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAwsOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAwsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/Credentials/AWS/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Modify the properties of a given Account + /// + /// Update Aws parameters + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// Update Aws parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Modify the properties of a given Account + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of Aws + public static AwsResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) + { + var options = new UpdateAwsOptions(pathSid) { FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateAwsOptions(pathSid) { FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAwsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Accounts, + "/v1/Credentials/AWS/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Credential from your account + /// + /// Delete Aws parameters + /// Client to make requests to Twilio + /// A single instance of Aws + public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Credential from your account + /// + /// Delete Aws parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAwsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Credential from your account + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Aws + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAwsOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Credential from your account + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Aws + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAwsOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AwsResource object + /// + /// Raw JSON string + /// AwsResource object represented by the provided JSON + public static AwsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI for this resource, relative to `https://accounts.twilio.com` + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private AwsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyOptions.cs b/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyOptions.cs index d60e62d4e..fc4303b2e 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyOptions.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyOptions.cs @@ -1,182 +1,182 @@ -/// This code was generated by -/// \ / _ _ _| _ _ -/// | (_)\/(_)(_|\/| |(/_ v1.0.0 -/// / / - -using System; -using System.Collections.Generic; -using Twilio.Base; -using Twilio.Converters; - -namespace Twilio.Rest.Accounts.V1.Credential -{ - - /// - /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request - /// - public class ReadPublicKeyOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - - /// - /// Create a new Public Key Credential - /// - public class CreatePublicKeyOptions : IOptions - { - /// - /// A URL encoded representation of the public key - /// - public string PublicKey { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The Subaccount this Credential should be associated with. - /// - public string AccountSid { get; set; } - - /// - /// Construct a new CreatePublicKeyOptions - /// - /// A URL encoded representation of the public key - public CreatePublicKeyOptions(string publicKey) - { - PublicKey = publicKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PublicKey != null) - { - p.Add(new KeyValuePair("PublicKey", PublicKey.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - return p; - } - } - - /// - /// Fetch the public key specified by the provided Credential Sid - /// - public class FetchPublicKeyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPublicKeyOptions - /// - /// The unique string that identifies the resource - public FetchPublicKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - - /// - /// Modify the properties of a given Account - /// - public class UpdatePublicKeyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdatePublicKeyOptions - /// - /// The unique string that identifies the resource - public UpdatePublicKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - - /// - /// Delete a Credential from your account - /// - public class DeletePublicKeyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeletePublicKeyOptions - /// - /// The unique string that identifies the resource - public DeletePublicKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - +/// This code was generated by +/// \ / _ _ _| _ _ +/// | (_)\/(_)(_|\/| |(/_ v1.0.0 +/// / / + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + +namespace Twilio.Rest.Accounts.V1.Credential +{ + + /// + /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request + /// + public class ReadPublicKeyOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new Public Key Credential + /// + public class CreatePublicKeyOptions : IOptions + { + /// + /// A URL encoded representation of the public key + /// + public string PublicKey { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The Subaccount this Credential should be associated with. + /// + public string AccountSid { get; set; } + + /// + /// Construct a new CreatePublicKeyOptions + /// + /// A URL encoded representation of the public key + public CreatePublicKeyOptions(string publicKey) + { + PublicKey = publicKey; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PublicKey != null) + { + p.Add(new KeyValuePair("PublicKey", PublicKey.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch the public key specified by the provided Credential Sid + /// + public class FetchPublicKeyOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPublicKeyOptions + /// + /// The unique string that identifies the resource + public FetchPublicKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Modify the properties of a given Account + /// + public class UpdatePublicKeyOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdatePublicKeyOptions + /// + /// The unique string that identifies the resource + public UpdatePublicKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete a Credential from your account + /// + public class DeletePublicKeyOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeletePublicKeyOptions + /// + /// The unique string that identifies the resource + public DeletePublicKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyResource.cs b/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyResource.cs index a760d132f..254448f8e 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyResource.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/PublicKeyResource.cs @@ -16,471 +16,471 @@ using Twilio.Http; namespace Twilio.Rest.Accounts.V1.Credential -{ - - public class PublicKeyResource : Resource - { - private static Request BuildReadRequest(ReadPublicKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Accounts, - "/v1/Credentials/PublicKeys", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request - /// - /// Read PublicKey parameters - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static ResourceSet Read(ReadPublicKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request - /// - /// Read PublicKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task> ReadAsync(ReadPublicKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPublicKeyOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPublicKeyOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Accounts) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Accounts) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreatePublicKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/Credentials/PublicKeys", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Public Key Credential - /// - /// Create PublicKey parameters - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Create(CreatePublicKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Public Key Credential - /// - /// Create PublicKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task CreateAsync(CreatePublicKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Public Key Credential - /// - /// A URL encoded representation of the public key - /// A string to describe the resource - /// The Subaccount this Credential should be associated with. - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Create(string publicKey, - string friendlyName = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new CreatePublicKeyOptions(publicKey){FriendlyName = friendlyName, AccountSid = accountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Public Key Credential - /// - /// A URL encoded representation of the public key - /// A string to describe the resource - /// The Subaccount this Credential should be associated with. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task CreateAsync(string publicKey, - string friendlyName = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new CreatePublicKeyOptions(publicKey){FriendlyName = friendlyName, AccountSid = accountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchPublicKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Accounts, - "/v1/Credentials/PublicKeys/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the public key specified by the provided Credential Sid - /// - /// Fetch PublicKey parameters - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Fetch(FetchPublicKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the public key specified by the provided Credential Sid - /// - /// Fetch PublicKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task FetchAsync(FetchPublicKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the public key specified by the provided Credential Sid - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPublicKeyOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the public key specified by the provided Credential Sid - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPublicKeyOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdatePublicKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/Credentials/PublicKeys/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Modify the properties of a given Account - /// - /// Update PublicKey parameters - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Update(UpdatePublicKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// Update PublicKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task UpdateAsync(UpdatePublicKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Modify the properties of a given Account - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static PublicKeyResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) - { - var options = new UpdatePublicKeyOptions(pathSid){FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdatePublicKeyOptions(pathSid){FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeletePublicKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Accounts, - "/v1/Credentials/PublicKeys/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Credential from your account - /// - /// Delete PublicKey parameters - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static bool Delete(DeletePublicKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Credential from your account - /// - /// Delete PublicKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task DeleteAsync(DeletePublicKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Credential from your account - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PublicKey - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeletePublicKeyOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Credential from your account - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublicKey - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeletePublicKeyOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PublicKeyResource object - /// - /// Raw JSON string - /// PublicKeyResource object represented by the provided JSON - public static PublicKeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Credential that the PublicKey resource belongs to - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI for this resource, relative to `https://accounts.twilio.com` - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private PublicKeyResource() - { - - } - } +{ + + public class PublicKeyResource : Resource + { + private static Request BuildReadRequest(ReadPublicKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Accounts, + "/v1/Credentials/PublicKeys", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request + /// + /// Read PublicKey parameters + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static ResourceSet Read(ReadPublicKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request + /// + /// Read PublicKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task> ReadAsync(ReadPublicKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPublicKeyOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of Public Key Credentials belonging to the account used to make the request + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPublicKeyOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Accounts) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Accounts) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreatePublicKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/Credentials/PublicKeys", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Public Key Credential + /// + /// Create PublicKey parameters + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Create(CreatePublicKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Public Key Credential + /// + /// Create PublicKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task CreateAsync(CreatePublicKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Public Key Credential + /// + /// A URL encoded representation of the public key + /// A string to describe the resource + /// The Subaccount this Credential should be associated with. + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Create(string publicKey, + string friendlyName = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new CreatePublicKeyOptions(publicKey) { FriendlyName = friendlyName, AccountSid = accountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Public Key Credential + /// + /// A URL encoded representation of the public key + /// A string to describe the resource + /// The Subaccount this Credential should be associated with. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task CreateAsync(string publicKey, + string friendlyName = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new CreatePublicKeyOptions(publicKey) { FriendlyName = friendlyName, AccountSid = accountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchPublicKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Accounts, + "/v1/Credentials/PublicKeys/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the public key specified by the provided Credential Sid + /// + /// Fetch PublicKey parameters + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Fetch(FetchPublicKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the public key specified by the provided Credential Sid + /// + /// Fetch PublicKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task FetchAsync(FetchPublicKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the public key specified by the provided Credential Sid + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPublicKeyOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the public key specified by the provided Credential Sid + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPublicKeyOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdatePublicKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/Credentials/PublicKeys/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Modify the properties of a given Account + /// + /// Update PublicKey parameters + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Update(UpdatePublicKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// Update PublicKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task UpdateAsync(UpdatePublicKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Modify the properties of a given Account + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static PublicKeyResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) + { + var options = new UpdatePublicKeyOptions(pathSid) { FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdatePublicKeyOptions(pathSid) { FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeletePublicKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Accounts, + "/v1/Credentials/PublicKeys/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Credential from your account + /// + /// Delete PublicKey parameters + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static bool Delete(DeletePublicKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Credential from your account + /// + /// Delete PublicKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task DeleteAsync(DeletePublicKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Credential from your account + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PublicKey + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeletePublicKeyOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Credential from your account + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublicKey + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeletePublicKeyOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PublicKeyResource object + /// + /// Raw JSON string + /// PublicKeyResource object represented by the provided JSON + public static PublicKeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Credential that the PublicKey resource belongs to + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI for this resource, relative to `https://accounts.twilio.com` + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private PublicKeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenOptions.cs b/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenOptions.cs index b2f9ed577..537427506 100644 --- a/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenOptions.cs +++ b/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenOptions.cs @@ -9,36 +9,36 @@ using Twilio.Converters; namespace Twilio.Rest.Accounts.V1 -{ - +{ + + /// + /// Create a new secondary Auth Token + /// + public class CreateSecondaryAuthTokenOptions : IOptions + { /// - /// Create a new secondary Auth Token + /// Generate the necessary parameters /// - public class CreateSecondaryAuthTokenOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete the secondary Auth Token from your account + /// + public class DeleteSecondaryAuthTokenOptions : IOptions + { /// - /// Delete the secondary Auth Token from your account + /// Generate the necessary parameters /// - public class DeleteSecondaryAuthTokenOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenResource.cs b/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenResource.cs index 01502b182..0be8c460e 100644 --- a/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenResource.cs +++ b/src/Twilio/Rest/Accounts/V1/SecondaryAuthTokenResource.cs @@ -16,187 +16,187 @@ using Twilio.Http; namespace Twilio.Rest.Accounts.V1 -{ - - public class SecondaryAuthTokenResource : Resource - { - private static Request BuildCreateRequest(CreateSecondaryAuthTokenOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Accounts, - "/v1/AuthTokens/Secondary", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new secondary Auth Token - /// - /// Create SecondaryAuthToken parameters - /// Client to make requests to Twilio - /// A single instance of SecondaryAuthToken - public static SecondaryAuthTokenResource Create(CreateSecondaryAuthTokenOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new secondary Auth Token - /// - /// Create SecondaryAuthToken parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SecondaryAuthToken - public static async System.Threading.Tasks.Task CreateAsync(CreateSecondaryAuthTokenOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new secondary Auth Token - /// - /// Client to make requests to Twilio - /// A single instance of SecondaryAuthToken - public static SecondaryAuthTokenResource Create(ITwilioRestClient client = null) - { - var options = new CreateSecondaryAuthTokenOptions(); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new secondary Auth Token - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SecondaryAuthToken - public static async System.Threading.Tasks.Task CreateAsync(ITwilioRestClient client = null) - { - var options = new CreateSecondaryAuthTokenOptions(); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSecondaryAuthTokenOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Accounts, - "/v1/AuthTokens/Secondary", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete the secondary Auth Token from your account - /// - /// Delete SecondaryAuthToken parameters - /// Client to make requests to Twilio - /// A single instance of SecondaryAuthToken - public static bool Delete(DeleteSecondaryAuthTokenOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete the secondary Auth Token from your account - /// - /// Delete SecondaryAuthToken parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SecondaryAuthToken - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSecondaryAuthTokenOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete the secondary Auth Token from your account - /// - /// Client to make requests to Twilio - /// A single instance of SecondaryAuthToken - public static bool Delete(ITwilioRestClient client = null) - { - var options = new DeleteSecondaryAuthTokenOptions(); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete the secondary Auth Token from your account - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SecondaryAuthToken - public static async System.Threading.Tasks.Task DeleteAsync(ITwilioRestClient client = null) - { - var options = new DeleteSecondaryAuthTokenOptions(); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SecondaryAuthTokenResource object - /// - /// Raw JSON string - /// SecondaryAuthTokenResource object represented by the provided JSON - public static SecondaryAuthTokenResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that the secondary Auth Token was created for - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 formatted date and time in UTC when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 formatted date and time in UTC when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The generated secondary Auth Token - /// - [JsonProperty("secondary_auth_token")] - public string SecondaryAuthToken { get; private set; } - /// - /// The URI for this resource, relative to `https://accounts.twilio.com` - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SecondaryAuthTokenResource() - { - - } - } +{ + + public class SecondaryAuthTokenResource : Resource + { + private static Request BuildCreateRequest(CreateSecondaryAuthTokenOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Accounts, + "/v1/AuthTokens/Secondary", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new secondary Auth Token + /// + /// Create SecondaryAuthToken parameters + /// Client to make requests to Twilio + /// A single instance of SecondaryAuthToken + public static SecondaryAuthTokenResource Create(CreateSecondaryAuthTokenOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new secondary Auth Token + /// + /// Create SecondaryAuthToken parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SecondaryAuthToken + public static async System.Threading.Tasks.Task CreateAsync(CreateSecondaryAuthTokenOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new secondary Auth Token + /// + /// Client to make requests to Twilio + /// A single instance of SecondaryAuthToken + public static SecondaryAuthTokenResource Create(ITwilioRestClient client = null) + { + var options = new CreateSecondaryAuthTokenOptions(); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new secondary Auth Token + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SecondaryAuthToken + public static async System.Threading.Tasks.Task CreateAsync(ITwilioRestClient client = null) + { + var options = new CreateSecondaryAuthTokenOptions(); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSecondaryAuthTokenOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Accounts, + "/v1/AuthTokens/Secondary", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete the secondary Auth Token from your account + /// + /// Delete SecondaryAuthToken parameters + /// Client to make requests to Twilio + /// A single instance of SecondaryAuthToken + public static bool Delete(DeleteSecondaryAuthTokenOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete the secondary Auth Token from your account + /// + /// Delete SecondaryAuthToken parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SecondaryAuthToken + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSecondaryAuthTokenOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete the secondary Auth Token from your account + /// + /// Client to make requests to Twilio + /// A single instance of SecondaryAuthToken + public static bool Delete(ITwilioRestClient client = null) + { + var options = new DeleteSecondaryAuthTokenOptions(); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete the secondary Auth Token from your account + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SecondaryAuthToken + public static async System.Threading.Tasks.Task DeleteAsync(ITwilioRestClient client = null) + { + var options = new DeleteSecondaryAuthTokenOptions(); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SecondaryAuthTokenResource object + /// + /// Raw JSON string + /// SecondaryAuthTokenResource object represented by the provided JSON + public static SecondaryAuthTokenResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that the secondary Auth Token was created for + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 formatted date and time in UTC when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 formatted date and time in UTC when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The generated secondary Auth Token + /// + [JsonProperty("secondary_auth_token")] + public string SecondaryAuthToken { get; private set; } + /// + /// The URI for this resource, relative to `https://accounts.twilio.com` + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SecondaryAuthTokenResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberOptions.cs index 4edf5673f..c312dc205 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Address -{ - +{ + + /// + /// ReadDependentPhoneNumberOptions + /// + public class ReadDependentPhoneNumberOptions : ReadOptions + { /// - /// ReadDependentPhoneNumberOptions + /// The SID of the Account that created the resources to read /// - public class ReadDependentPhoneNumberOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string PathAddressSid { get; } - - /// - /// Construct a new ReadDependentPhoneNumberOptions - /// - /// The SID of the Address resource associated with the phone number - public ReadDependentPhoneNumberOptions(string pathAddressSid) - { - PathAddressSid = pathAddressSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string PathAddressSid { get; } + + /// + /// Construct a new ReadDependentPhoneNumberOptions + /// + /// The SID of the Address resource associated with the phone number + public ReadDependentPhoneNumberOptions(string pathAddressSid) + { + PathAddressSid = pathAddressSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberResource.cs b/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberResource.cs index d399092fb..7f9737bd8 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Address/DependentPhoneNumberResource.cs @@ -17,340 +17,340 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Address -{ - - public class DependentPhoneNumberResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - public sealed class EmergencyStatusEnum : StringEnum - { - private EmergencyStatusEnum(string value) : base(value) {} - public EmergencyStatusEnum() {} - public static implicit operator EmergencyStatusEnum(string value) - { - return new EmergencyStatusEnum(value); - } - - public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); - public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); - } - - private static Request BuildReadRequest(ReadDependentPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathAddressSid + "/DependentPhoneNumbers.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read DependentPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of DependentPhoneNumber - public static ResourceSet Read(ReadDependentPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("dependent_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read DependentPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DependentPhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(ReadDependentPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("dependent_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Address resource associated with the phone number - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DependentPhoneNumber - public static ResourceSet Read(string pathAddressSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDependentPhoneNumberOptions(pathAddressSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Address resource associated with the phone number - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DependentPhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(string pathAddressSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDependentPhoneNumberOptions(pathAddressSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("dependent_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("dependent_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("dependent_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a DependentPhoneNumberResource object - /// - /// Raw JSON string - /// DependentPhoneNumberResource object represented by the provided JSON - public static DependentPhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public DependentPhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public object Capabilities { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the application that handles SMS messages sent to the phone number - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// Whether the phone number is enabled for emergency calling - /// - [JsonProperty("emergency_status")] - [JsonConverter(typeof(StringEnumConverter))] - public DependentPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; private set; } - /// - /// The emergency address configuration to use for emergency calling - /// - [JsonProperty("emergency_address_sid")] - public string EmergencyAddressSid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private DependentPhoneNumberResource() - { - - } - } +{ + + public class DependentPhoneNumberResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + public sealed class EmergencyStatusEnum : StringEnum + { + private EmergencyStatusEnum(string value) : base(value) { } + public EmergencyStatusEnum() { } + public static implicit operator EmergencyStatusEnum(string value) + { + return new EmergencyStatusEnum(value); + } + + public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); + public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); + } + + private static Request BuildReadRequest(ReadDependentPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathAddressSid + "/DependentPhoneNumbers.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read DependentPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of DependentPhoneNumber + public static ResourceSet Read(ReadDependentPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("dependent_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read DependentPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DependentPhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(ReadDependentPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("dependent_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Address resource associated with the phone number + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DependentPhoneNumber + public static ResourceSet Read(string pathAddressSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDependentPhoneNumberOptions(pathAddressSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Address resource associated with the phone number + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DependentPhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(string pathAddressSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDependentPhoneNumberOptions(pathAddressSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("dependent_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("dependent_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("dependent_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a DependentPhoneNumberResource object + /// + /// Raw JSON string + /// DependentPhoneNumberResource object represented by the provided JSON + public static DependentPhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public DependentPhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public object Capabilities { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the application that handles SMS messages sent to the phone number + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// Whether the phone number is enabled for emergency calling + /// + [JsonProperty("emergency_status")] + [JsonConverter(typeof(StringEnumConverter))] + public DependentPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; private set; } + /// + /// The emergency address configuration to use for emergency calling + /// + [JsonProperty("emergency_address_sid")] + public string EmergencyAddressSid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private DependentPhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AddressOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AddressOptions.cs index 3485e9a95..0adb11e2d 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AddressOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AddressOptions.cs @@ -9,354 +9,354 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// CreateAddressOptions + /// + public class CreateAddressOptions : IOptions + { /// - /// CreateAddressOptions - /// - public class CreateAddressOptions : IOptions - { - /// - /// The SID of the Account that will be responsible for the new Address resource - /// - public string PathAccountSid { get; set; } - /// - /// The name to associate with the new address - /// - public string CustomerName { get; } - /// - /// The number and street address of the new address - /// - public string Street { get; } - /// - /// The city of the new address - /// - public string City { get; } - /// - /// The state or region of the new address - /// - public string Region { get; } - /// - /// The postal code of the new address - /// - public string PostalCode { get; } - /// - /// The ISO country code of the new address - /// - public string IsoCountry { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// Whether to enable emergency calling on the new address - /// - public bool? EmergencyEnabled { get; set; } - /// - /// Whether we should automatically correct the address - /// - public bool? AutoCorrectAddress { get; set; } - - /// - /// Construct a new CreateAddressOptions - /// - /// The name to associate with the new address - /// The number and street address of the new address - /// The city of the new address - /// The state or region of the new address - /// The postal code of the new address - /// The ISO country code of the new address - public CreateAddressOptions(string customerName, - string street, - string city, - string region, - string postalCode, - string isoCountry) - { - CustomerName = customerName; - Street = street; - City = city; - Region = region; - PostalCode = postalCode; - IsoCountry = isoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CustomerName != null) - { - p.Add(new KeyValuePair("CustomerName", CustomerName)); - } - - if (Street != null) - { - p.Add(new KeyValuePair("Street", Street)); - } - - if (City != null) - { - p.Add(new KeyValuePair("City", City)); - } - - if (Region != null) - { - p.Add(new KeyValuePair("Region", Region)); - } - - if (PostalCode != null) - { - p.Add(new KeyValuePair("PostalCode", PostalCode)); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (EmergencyEnabled != null) - { - p.Add(new KeyValuePair("EmergencyEnabled", EmergencyEnabled.Value.ToString().ToLower())); - } - - if (AutoCorrectAddress != null) - { - p.Add(new KeyValuePair("AutoCorrectAddress", AutoCorrectAddress.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The SID of the Account that will be responsible for the new Address resource + /// + public string PathAccountSid { get; set; } /// - /// DeleteAddressOptions - /// - public class DeleteAddressOptions : IOptions - { - /// - /// The SID of the Account that is responsible for the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAddressOptions - /// - /// The unique string that identifies the resource - public DeleteAddressOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The name to associate with the new address + /// + public string CustomerName { get; } /// - /// FetchAddressOptions - /// - public class FetchAddressOptions : IOptions - { - /// - /// The SID of the Account that is responsible for this address - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAddressOptions - /// - /// The unique string that identifies the resource - public FetchAddressOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The number and street address of the new address + /// + public string Street { get; } /// - /// UpdateAddressOptions - /// - public class UpdateAddressOptions : IOptions - { - /// - /// The SID of the Account that is responsible for the resource to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The name to associate with the address - /// - public string CustomerName { get; set; } - /// - /// The number and street address of the address - /// - public string Street { get; set; } - /// - /// The city of the address - /// - public string City { get; set; } - /// - /// The state or region of the address - /// - public string Region { get; set; } - /// - /// The postal code of the address - /// - public string PostalCode { get; set; } - /// - /// Whether to enable emergency calling on the address - /// - public bool? EmergencyEnabled { get; set; } - /// - /// Whether we should automatically correct the address - /// - public bool? AutoCorrectAddress { get; set; } - - /// - /// Construct a new UpdateAddressOptions - /// - /// The unique string that identifies the resource - public UpdateAddressOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CustomerName != null) - { - p.Add(new KeyValuePair("CustomerName", CustomerName)); - } - - if (Street != null) - { - p.Add(new KeyValuePair("Street", Street)); - } - - if (City != null) - { - p.Add(new KeyValuePair("City", City)); - } - - if (Region != null) - { - p.Add(new KeyValuePair("Region", Region)); - } - - if (PostalCode != null) - { - p.Add(new KeyValuePair("PostalCode", PostalCode)); - } - - if (EmergencyEnabled != null) - { - p.Add(new KeyValuePair("EmergencyEnabled", EmergencyEnabled.Value.ToString().ToLower())); - } - - if (AutoCorrectAddress != null) - { - p.Add(new KeyValuePair("AutoCorrectAddress", AutoCorrectAddress.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The city of the new address + /// + public string City { get; } /// - /// ReadAddressOptions - /// - public class ReadAddressOptions : ReadOptions - { - /// - /// The SID of the Account that is responsible for this address - /// - public string PathAccountSid { get; set; } - /// - /// The `customer_name` of the Address resources to read - /// - public string CustomerName { get; set; } - /// - /// The string that identifies the Address resources to read - /// - public string FriendlyName { get; set; } - /// - /// The ISO country code of the Address resources to read - /// - public string IsoCountry { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (CustomerName != null) - { - p.Add(new KeyValuePair("CustomerName", CustomerName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The state or region of the new address + /// + public string Region { get; } + /// + /// The postal code of the new address + /// + public string PostalCode { get; } + /// + /// The ISO country code of the new address + /// + public string IsoCountry { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + /// + /// Whether to enable emergency calling on the new address + /// + public bool? EmergencyEnabled { get; set; } + /// + /// Whether we should automatically correct the address + /// + public bool? AutoCorrectAddress { get; set; } + + /// + /// Construct a new CreateAddressOptions + /// + /// The name to associate with the new address + /// The number and street address of the new address + /// The city of the new address + /// The state or region of the new address + /// The postal code of the new address + /// The ISO country code of the new address + public CreateAddressOptions(string customerName, + string street, + string city, + string region, + string postalCode, + string isoCountry) + { + CustomerName = customerName; + Street = street; + City = city; + Region = region; + PostalCode = postalCode; + IsoCountry = isoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CustomerName != null) + { + p.Add(new KeyValuePair("CustomerName", CustomerName)); + } + + if (Street != null) + { + p.Add(new KeyValuePair("Street", Street)); + } + + if (City != null) + { + p.Add(new KeyValuePair("City", City)); + } + + if (Region != null) + { + p.Add(new KeyValuePair("Region", Region)); + } + + if (PostalCode != null) + { + p.Add(new KeyValuePair("PostalCode", PostalCode)); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (EmergencyEnabled != null) + { + p.Add(new KeyValuePair("EmergencyEnabled", EmergencyEnabled.Value.ToString().ToLower())); + } + + if (AutoCorrectAddress != null) + { + p.Add(new KeyValuePair("AutoCorrectAddress", AutoCorrectAddress.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// DeleteAddressOptions + /// + public class DeleteAddressOptions : IOptions + { + /// + /// The SID of the Account that is responsible for the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAddressOptions + /// + /// The unique string that identifies the resource + public DeleteAddressOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// FetchAddressOptions + /// + public class FetchAddressOptions : IOptions + { + /// + /// The SID of the Account that is responsible for this address + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAddressOptions + /// + /// The unique string that identifies the resource + public FetchAddressOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateAddressOptions + /// + public class UpdateAddressOptions : IOptions + { + /// + /// The SID of the Account that is responsible for the resource to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The name to associate with the address + /// + public string CustomerName { get; set; } + /// + /// The number and street address of the address + /// + public string Street { get; set; } + /// + /// The city of the address + /// + public string City { get; set; } + /// + /// The state or region of the address + /// + public string Region { get; set; } + /// + /// The postal code of the address + /// + public string PostalCode { get; set; } + /// + /// Whether to enable emergency calling on the address + /// + public bool? EmergencyEnabled { get; set; } + /// + /// Whether we should automatically correct the address + /// + public bool? AutoCorrectAddress { get; set; } + + /// + /// Construct a new UpdateAddressOptions + /// + /// The unique string that identifies the resource + public UpdateAddressOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CustomerName != null) + { + p.Add(new KeyValuePair("CustomerName", CustomerName)); + } + + if (Street != null) + { + p.Add(new KeyValuePair("Street", Street)); + } + + if (City != null) + { + p.Add(new KeyValuePair("City", City)); + } + + if (Region != null) + { + p.Add(new KeyValuePair("Region", Region)); + } + + if (PostalCode != null) + { + p.Add(new KeyValuePair("PostalCode", PostalCode)); + } + + if (EmergencyEnabled != null) + { + p.Add(new KeyValuePair("EmergencyEnabled", EmergencyEnabled.Value.ToString().ToLower())); + } + + if (AutoCorrectAddress != null) + { + p.Add(new KeyValuePair("AutoCorrectAddress", AutoCorrectAddress.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// ReadAddressOptions + /// + public class ReadAddressOptions : ReadOptions + { + /// + /// The SID of the Account that is responsible for this address + /// + public string PathAccountSid { get; set; } + /// + /// The `customer_name` of the Address resources to read + /// + public string CustomerName { get; set; } + /// + /// The string that identifies the Address resources to read + /// + public string FriendlyName { get; set; } + /// + /// The ISO country code of the Address resources to read + /// + public string IsoCountry { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (CustomerName != null) + { + p.Add(new KeyValuePair("CustomerName", CustomerName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AddressResource.cs b/src/Twilio/Rest/Api/V2010/Account/AddressResource.cs index 9ba56dbc6..c18b9525b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AddressResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AddressResource.cs @@ -16,601 +16,601 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class AddressResource : Resource - { - private static Request BuildCreateRequest(CreateAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Address parameters - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Create(CreateAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Address parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task CreateAsync(CreateAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The name to associate with the new address - /// The number and street address of the new address - /// The city of the new address - /// The state or region of the new address - /// The postal code of the new address - /// The ISO country code of the new address - /// The SID of the Account that will be responsible for the new Address resource - /// A string to describe the new resource - /// Whether to enable emergency calling on the new address - /// Whether we should automatically correct the address - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Create(string customerName, - string street, - string city, - string region, - string postalCode, - string isoCountry, - string pathAccountSid = null, - string friendlyName = null, - bool? emergencyEnabled = null, - bool? autoCorrectAddress = null, - ITwilioRestClient client = null) - { - var options = new CreateAddressOptions(customerName, street, city, region, postalCode, isoCountry){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The name to associate with the new address - /// The number and street address of the new address - /// The city of the new address - /// The state or region of the new address - /// The postal code of the new address - /// The ISO country code of the new address - /// The SID of the Account that will be responsible for the new Address resource - /// A string to describe the new resource - /// Whether to enable emergency calling on the new address - /// Whether we should automatically correct the address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task CreateAsync(string customerName, - string street, - string city, - string region, - string postalCode, - string isoCountry, - string pathAccountSid = null, - string friendlyName = null, - bool? emergencyEnabled = null, - bool? autoCorrectAddress = null, - ITwilioRestClient client = null) - { - var options = new CreateAddressOptions(customerName, street, city, region, postalCode, isoCountry){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Address parameters - /// Client to make requests to Twilio - /// A single instance of Address - public static bool Delete(DeleteAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Address parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for the resources to delete - /// Client to make requests to Twilio - /// A single instance of Address - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteAddressOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAddressOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Address parameters - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Fetch(FetchAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Address parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task FetchAsync(FetchAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for this address - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchAddressOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for this address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAddressOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Address parameters - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Update(UpdateAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Address parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for the resource to update - /// A string to describe the resource - /// The name to associate with the address - /// The number and street address of the address - /// The city of the address - /// The state or region of the address - /// The postal code of the address - /// Whether to enable emergency calling on the address - /// Whether we should automatically correct the address - /// Client to make requests to Twilio - /// A single instance of Address - public static AddressResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string customerName = null, - string street = null, - string city = null, - string region = null, - string postalCode = null, - bool? emergencyEnabled = null, - bool? autoCorrectAddress = null, - ITwilioRestClient client = null) - { - var options = new UpdateAddressOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CustomerName = customerName, Street = street, City = city, Region = region, PostalCode = postalCode, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// The SID of the Account that is responsible for the resource to update - /// A string to describe the resource - /// The name to associate with the address - /// The number and street address of the address - /// The city of the address - /// The state or region of the address - /// The postal code of the address - /// Whether to enable emergency calling on the address - /// Whether we should automatically correct the address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string customerName = null, - string street = null, - string city = null, - string region = null, - string postalCode = null, - bool? emergencyEnabled = null, - bool? autoCorrectAddress = null, - ITwilioRestClient client = null) - { - var options = new UpdateAddressOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CustomerName = customerName, Street = street, City = city, Region = region, PostalCode = postalCode, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Address parameters - /// Client to make requests to Twilio - /// A single instance of Address - public static ResourceSet Read(ReadAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("addresses", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Address parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task> ReadAsync(ReadAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("addresses", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that is responsible for this address - /// The `customer_name` of the Address resources to read - /// The string that identifies the Address resources to read - /// The ISO country code of the Address resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Address - public static ResourceSet Read(string pathAccountSid = null, - string customerName = null, - string friendlyName = null, - string isoCountry = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAddressOptions(){PathAccountSid = pathAccountSid, CustomerName = customerName, FriendlyName = friendlyName, IsoCountry = isoCountry, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that is responsible for this address - /// The `customer_name` of the Address resources to read - /// The string that identifies the Address resources to read - /// The ISO country code of the Address resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Address - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - string customerName = null, - string friendlyName = null, - string isoCountry = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAddressOptions(){PathAccountSid = pathAccountSid, CustomerName = customerName, FriendlyName = friendlyName, IsoCountry = isoCountry, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("addresses", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("addresses", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("addresses", response.Content); - } - - /// - /// Converts a JSON string into a AddressResource object - /// - /// Raw JSON string - /// AddressResource object represented by the provided JSON - public static AddressResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that is responsible for the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The city in which the address is located - /// - [JsonProperty("city")] - public string City { get; private set; } - /// - /// The name associated with the address - /// - [JsonProperty("customer_name")] - public string CustomerName { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO country code of the address - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The postal code of the address - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The state or region of the address - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The number and street address of the address - /// - [JsonProperty("street")] - public string Street { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// Whether emergency calling has been enabled on this number - /// - [JsonProperty("emergency_enabled")] - public bool? EmergencyEnabled { get; private set; } - /// - /// Whether the address has been validated to comply with local regulation - /// - [JsonProperty("validated")] - public bool? Validated { get; private set; } - /// - /// Whether the address has been verified to comply with regulation - /// - [JsonProperty("verified")] - public bool? Verified { get; private set; } - - private AddressResource() - { - - } - } +{ + + public class AddressResource : Resource + { + private static Request BuildCreateRequest(CreateAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Address parameters + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Create(CreateAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Address parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task CreateAsync(CreateAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The name to associate with the new address + /// The number and street address of the new address + /// The city of the new address + /// The state or region of the new address + /// The postal code of the new address + /// The ISO country code of the new address + /// The SID of the Account that will be responsible for the new Address resource + /// A string to describe the new resource + /// Whether to enable emergency calling on the new address + /// Whether we should automatically correct the address + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Create(string customerName, + string street, + string city, + string region, + string postalCode, + string isoCountry, + string pathAccountSid = null, + string friendlyName = null, + bool? emergencyEnabled = null, + bool? autoCorrectAddress = null, + ITwilioRestClient client = null) + { + var options = new CreateAddressOptions(customerName, street, city, region, postalCode, isoCountry) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The name to associate with the new address + /// The number and street address of the new address + /// The city of the new address + /// The state or region of the new address + /// The postal code of the new address + /// The ISO country code of the new address + /// The SID of the Account that will be responsible for the new Address resource + /// A string to describe the new resource + /// Whether to enable emergency calling on the new address + /// Whether we should automatically correct the address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task CreateAsync(string customerName, + string street, + string city, + string region, + string postalCode, + string isoCountry, + string pathAccountSid = null, + string friendlyName = null, + bool? emergencyEnabled = null, + bool? autoCorrectAddress = null, + ITwilioRestClient client = null) + { + var options = new CreateAddressOptions(customerName, street, city, region, postalCode, isoCountry) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Address parameters + /// Client to make requests to Twilio + /// A single instance of Address + public static bool Delete(DeleteAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Address parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for the resources to delete + /// Client to make requests to Twilio + /// A single instance of Address + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteAddressOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAddressOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Address parameters + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Fetch(FetchAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Address parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task FetchAsync(FetchAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for this address + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchAddressOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for this address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAddressOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Address parameters + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Update(UpdateAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Address parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for the resource to update + /// A string to describe the resource + /// The name to associate with the address + /// The number and street address of the address + /// The city of the address + /// The state or region of the address + /// The postal code of the address + /// Whether to enable emergency calling on the address + /// Whether we should automatically correct the address + /// Client to make requests to Twilio + /// A single instance of Address + public static AddressResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string customerName = null, + string street = null, + string city = null, + string region = null, + string postalCode = null, + bool? emergencyEnabled = null, + bool? autoCorrectAddress = null, + ITwilioRestClient client = null) + { + var options = new UpdateAddressOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CustomerName = customerName, Street = street, City = city, Region = region, PostalCode = postalCode, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// The SID of the Account that is responsible for the resource to update + /// A string to describe the resource + /// The name to associate with the address + /// The number and street address of the address + /// The city of the address + /// The state or region of the address + /// The postal code of the address + /// Whether to enable emergency calling on the address + /// Whether we should automatically correct the address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string customerName = null, + string street = null, + string city = null, + string region = null, + string postalCode = null, + bool? emergencyEnabled = null, + bool? autoCorrectAddress = null, + ITwilioRestClient client = null) + { + var options = new UpdateAddressOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CustomerName = customerName, Street = street, City = city, Region = region, PostalCode = postalCode, EmergencyEnabled = emergencyEnabled, AutoCorrectAddress = autoCorrectAddress }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Addresses.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Address parameters + /// Client to make requests to Twilio + /// A single instance of Address + public static ResourceSet Read(ReadAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("addresses", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Address parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task> ReadAsync(ReadAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("addresses", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that is responsible for this address + /// The `customer_name` of the Address resources to read + /// The string that identifies the Address resources to read + /// The ISO country code of the Address resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Address + public static ResourceSet Read(string pathAccountSid = null, + string customerName = null, + string friendlyName = null, + string isoCountry = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAddressOptions() { PathAccountSid = pathAccountSid, CustomerName = customerName, FriendlyName = friendlyName, IsoCountry = isoCountry, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that is responsible for this address + /// The `customer_name` of the Address resources to read + /// The string that identifies the Address resources to read + /// The ISO country code of the Address resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Address + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + string customerName = null, + string friendlyName = null, + string isoCountry = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAddressOptions() { PathAccountSid = pathAccountSid, CustomerName = customerName, FriendlyName = friendlyName, IsoCountry = isoCountry, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("addresses", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("addresses", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("addresses", response.Content); + } + + /// + /// Converts a JSON string into a AddressResource object + /// + /// Raw JSON string + /// AddressResource object represented by the provided JSON + public static AddressResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that is responsible for the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The city in which the address is located + /// + [JsonProperty("city")] + public string City { get; private set; } + /// + /// The name associated with the address + /// + [JsonProperty("customer_name")] + public string CustomerName { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO country code of the address + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The postal code of the address + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The state or region of the address + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The number and street address of the address + /// + [JsonProperty("street")] + public string Street { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// Whether emergency calling has been enabled on this number + /// + [JsonProperty("emergency_enabled")] + public bool? EmergencyEnabled { get; private set; } + /// + /// Whether the address has been validated to comply with local regulation + /// + [JsonProperty("validated")] + public bool? Validated { get; private set; } + /// + /// Whether the address has been verified to comply with regulation + /// + [JsonProperty("verified")] + public bool? Verified { get; private set; } + + private AddressResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ApplicationOptions.cs b/src/Twilio/Rest/Api/V2010/Account/ApplicationOptions.cs index 4197a59ed..2e25f8a83 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ApplicationOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ApplicationOptions.cs @@ -9,429 +9,429 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Create a new application within your account + /// + public class CreateApplicationOptions : IOptions + { /// - /// Create a new application within your account - /// - public class CreateApplicationOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The API version to use to start a new TwiML session - /// - public string ApiVersion { get; set; } - /// - /// The URL to call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The HTTP method to use with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL to call when a TwiML error occurs - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method to use with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method to use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The URL to call when the phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The HTTP method to use with sms_url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL to send status information to your application - /// - public Uri SmsStatusCallback { get; set; } - /// - /// The URL to send message status information to your application - /// - public Uri MessageStatusCallback { get; set; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsStatusCallback != null) - { - p.Add(new KeyValuePair("SmsStatusCallback", Serializers.Url(SmsStatusCallback))); - } - - if (MessageStatusCallback != null) - { - p.Add(new KeyValuePair("MessageStatusCallback", Serializers.Url(MessageStatusCallback))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Delete the application by the specified application sid - /// - public class DeleteApplicationOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteApplicationOptions - /// - /// The unique string that identifies the resource - public DeleteApplicationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The API version to use to start a new TwiML session + /// + public string ApiVersion { get; set; } /// - /// Fetch the application specified by the provided sid - /// - public class FetchApplicationOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchApplicationOptions - /// - /// The unique string that identifies the resource - public FetchApplicationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The URL to call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } /// - /// Retrieve a list of applications representing an application within the requesting account - /// - public class ReadApplicationOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The string that identifies the Application resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The HTTP method to use with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } /// - /// Updates the application's properties - /// - public class UpdateApplicationOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The API version to use to start a new TwiML session - /// - public string ApiVersion { get; set; } - /// - /// The URL to call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The HTTP method to use with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL to call when a TwiML error occurs - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method to use with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method to use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The URL to call when the phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The HTTP method to use with sms_url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// Same as message_status_callback. Deprecated, included for backwards compatibility. - /// - public Uri SmsStatusCallback { get; set; } - /// - /// The URL to send message status information to your application - /// - public Uri MessageStatusCallback { get; set; } - - /// - /// Construct a new UpdateApplicationOptions - /// - /// The unique string that identifies the resource - public UpdateApplicationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsStatusCallback != null) - { - p.Add(new KeyValuePair("SmsStatusCallback", Serializers.Url(SmsStatusCallback))); - } - - if (MessageStatusCallback != null) - { - p.Add(new KeyValuePair("MessageStatusCallback", Serializers.Url(MessageStatusCallback))); - } - - return p; - } - } + /// The URL to call when a TwiML error occurs + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method to use with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method to use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The URL to call when the phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The HTTP method to use with sms_url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL to send status information to your application + /// + public Uri SmsStatusCallback { get; set; } + /// + /// The URL to send message status information to your application + /// + public Uri MessageStatusCallback { get; set; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsStatusCallback != null) + { + p.Add(new KeyValuePair("SmsStatusCallback", Serializers.Url(SmsStatusCallback))); + } + + if (MessageStatusCallback != null) + { + p.Add(new KeyValuePair("MessageStatusCallback", Serializers.Url(MessageStatusCallback))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete the application by the specified application sid + /// + public class DeleteApplicationOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteApplicationOptions + /// + /// The unique string that identifies the resource + public DeleteApplicationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch the application specified by the provided sid + /// + public class FetchApplicationOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchApplicationOptions + /// + /// The unique string that identifies the resource + public FetchApplicationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of applications representing an application within the requesting account + /// + public class ReadApplicationOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The string that identifies the Application resources to read + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Updates the application's properties + /// + public class UpdateApplicationOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The API version to use to start a new TwiML session + /// + public string ApiVersion { get; set; } + /// + /// The URL to call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The HTTP method to use with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL to call when a TwiML error occurs + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method to use with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method to use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The URL to call when the phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The HTTP method to use with sms_url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// Same as message_status_callback. Deprecated, included for backwards compatibility. + /// + public Uri SmsStatusCallback { get; set; } + /// + /// The URL to send message status information to your application + /// + public Uri MessageStatusCallback { get; set; } + + /// + /// Construct a new UpdateApplicationOptions + /// + /// The unique string that identifies the resource + public UpdateApplicationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsStatusCallback != null) + { + p.Add(new KeyValuePair("SmsStatusCallback", Serializers.Url(SmsStatusCallback))); + } + + if (MessageStatusCallback != null) + { + p.Add(new KeyValuePair("MessageStatusCallback", Serializers.Url(MessageStatusCallback))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ApplicationResource.cs b/src/Twilio/Rest/Api/V2010/Account/ApplicationResource.cs index bdea8bebe..7c28554f1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ApplicationResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ApplicationResource.cs @@ -16,679 +16,679 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class ApplicationResource : Resource - { - private static Request BuildCreateRequest(CreateApplicationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new application within your account - /// - /// Create Application parameters - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Create(CreateApplicationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new application within your account - /// - /// Create Application parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task CreateAsync(CreateApplicationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new application within your account - /// - /// The SID of the Account that will create the resource - /// The API version to use to start a new TwiML session - /// The URL to call when the phone number receives a call - /// The HTTP method to use with the voice_url - /// The URL to call when a TwiML error occurs - /// The HTTP method to use with voice_fallback_url - /// The URL to send status information to your application - /// The HTTP method to use to call status_callback - /// Whether to lookup the caller's name - /// The URL to call when the phone number receives an incoming SMS message - /// The HTTP method to use with sms_url - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// The HTTP method to use with sms_fallback_url - /// The URL to send status information to your application - /// The URL to send message status information to your application - /// A string to describe the new resource - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Create(string pathAccountSid = null, - string apiVersion = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? voiceCallerIdLookup = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsStatusCallback = null, - Uri messageStatusCallback = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateApplicationOptions(){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback, FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new application within your account - /// - /// The SID of the Account that will create the resource - /// The API version to use to start a new TwiML session - /// The URL to call when the phone number receives a call - /// The HTTP method to use with the voice_url - /// The URL to call when a TwiML error occurs - /// The HTTP method to use with voice_fallback_url - /// The URL to send status information to your application - /// The HTTP method to use to call status_callback - /// Whether to lookup the caller's name - /// The URL to call when the phone number receives an incoming SMS message - /// The HTTP method to use with sms_url - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// The HTTP method to use with sms_fallback_url - /// The URL to send status information to your application - /// The URL to send message status information to your application - /// A string to describe the new resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, - string apiVersion = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? voiceCallerIdLookup = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsStatusCallback = null, - Uri messageStatusCallback = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateApplicationOptions(){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback, FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteApplicationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete the application by the specified application sid - /// - /// Delete Application parameters - /// Client to make requests to Twilio - /// A single instance of Application - public static bool Delete(DeleteApplicationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete the application by the specified application sid - /// - /// Delete Application parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task DeleteAsync(DeleteApplicationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete the application by the specified application sid - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Application - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteApplicationOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete the application by the specified application sid - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteApplicationOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchApplicationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the application specified by the provided sid - /// - /// Fetch Application parameters - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Fetch(FetchApplicationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the application specified by the provided sid - /// - /// Fetch Application parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task FetchAsync(FetchApplicationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the application specified by the provided sid - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchApplicationOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the application specified by the provided sid - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchApplicationOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadApplicationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of applications representing an application within the requesting account - /// - /// Read Application parameters - /// Client to make requests to Twilio - /// A single instance of Application - public static ResourceSet Read(ReadApplicationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("applications", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of applications representing an application within the requesting account - /// - /// Read Application parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task> ReadAsync(ReadApplicationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("applications", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of applications representing an application within the requesting account - /// - /// The SID of the Account that created the resources to read - /// The string that identifies the Application resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Application - public static ResourceSet Read(string pathAccountSid = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadApplicationOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of applications representing an application within the requesting account - /// - /// The SID of the Account that created the resources to read - /// The string that identifies the Application resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadApplicationOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("applications", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("applications", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("applications", response.Content); - } - - private static Request BuildUpdateRequest(UpdateApplicationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the application's properties - /// - /// Update Application parameters - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Update(UpdateApplicationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the application's properties - /// - /// Update Application parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task UpdateAsync(UpdateApplicationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the application's properties - /// - /// The unique string that identifies the resource - /// The SID of the Account that will create the resource - /// A string to describe the resource - /// The API version to use to start a new TwiML session - /// The URL to call when the phone number receives a call - /// The HTTP method to use with the voice_url - /// The URL to call when a TwiML error occurs - /// The HTTP method to use with voice_fallback_url - /// The URL to send status information to your application - /// The HTTP method to use to call status_callback - /// Whether to lookup the caller's name - /// The URL to call when the phone number receives an incoming SMS message - /// The HTTP method to use with sms_url - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// The HTTP method to use with sms_fallback_url - /// Same as message_status_callback. Deprecated, included for backwards compatibility. - /// - /// The URL to send message status information to your application - /// Client to make requests to Twilio - /// A single instance of Application - public static ApplicationResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string apiVersion = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? voiceCallerIdLookup = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsStatusCallback = null, - Uri messageStatusCallback = null, - ITwilioRestClient client = null) - { - var options = new UpdateApplicationOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the application's properties - /// - /// The unique string that identifies the resource - /// The SID of the Account that will create the resource - /// A string to describe the resource - /// The API version to use to start a new TwiML session - /// The URL to call when the phone number receives a call - /// The HTTP method to use with the voice_url - /// The URL to call when a TwiML error occurs - /// The HTTP method to use with voice_fallback_url - /// The URL to send status information to your application - /// The HTTP method to use to call status_callback - /// Whether to lookup the caller's name - /// The URL to call when the phone number receives an incoming SMS message - /// The HTTP method to use with sms_url - /// The URL to call when an error occurs while retrieving or executing the TwiML - /// The HTTP method to use with sms_fallback_url - /// Same as message_status_callback. Deprecated, included for backwards compatibility. - /// - /// The URL to send message status information to your application - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Application - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string apiVersion = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? voiceCallerIdLookup = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsStatusCallback = null, - Uri messageStatusCallback = null, - ITwilioRestClient client = null) - { - var options = new UpdateApplicationOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ApplicationResource object - /// - /// Raw JSON string - /// ApplicationResource object represented by the provided JSON - public static ApplicationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The URL to send message status information to your application - /// - [JsonProperty("message_status_callback")] - public Uri MessageStatusCallback { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("sms_status_callback")] - public Uri SmsStatusCallback { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when a TwiML error occurs - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - - private ApplicationResource() - { - - } - } +{ + + public class ApplicationResource : Resource + { + private static Request BuildCreateRequest(CreateApplicationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new application within your account + /// + /// Create Application parameters + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Create(CreateApplicationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new application within your account + /// + /// Create Application parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task CreateAsync(CreateApplicationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new application within your account + /// + /// The SID of the Account that will create the resource + /// The API version to use to start a new TwiML session + /// The URL to call when the phone number receives a call + /// The HTTP method to use with the voice_url + /// The URL to call when a TwiML error occurs + /// The HTTP method to use with voice_fallback_url + /// The URL to send status information to your application + /// The HTTP method to use to call status_callback + /// Whether to lookup the caller's name + /// The URL to call when the phone number receives an incoming SMS message + /// The HTTP method to use with sms_url + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// The HTTP method to use with sms_fallback_url + /// The URL to send status information to your application + /// The URL to send message status information to your application + /// A string to describe the new resource + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Create(string pathAccountSid = null, + string apiVersion = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? voiceCallerIdLookup = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsStatusCallback = null, + Uri messageStatusCallback = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateApplicationOptions() { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback, FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new application within your account + /// + /// The SID of the Account that will create the resource + /// The API version to use to start a new TwiML session + /// The URL to call when the phone number receives a call + /// The HTTP method to use with the voice_url + /// The URL to call when a TwiML error occurs + /// The HTTP method to use with voice_fallback_url + /// The URL to send status information to your application + /// The HTTP method to use to call status_callback + /// Whether to lookup the caller's name + /// The URL to call when the phone number receives an incoming SMS message + /// The HTTP method to use with sms_url + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// The HTTP method to use with sms_fallback_url + /// The URL to send status information to your application + /// The URL to send message status information to your application + /// A string to describe the new resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, + string apiVersion = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? voiceCallerIdLookup = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsStatusCallback = null, + Uri messageStatusCallback = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateApplicationOptions() { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback, FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteApplicationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete the application by the specified application sid + /// + /// Delete Application parameters + /// Client to make requests to Twilio + /// A single instance of Application + public static bool Delete(DeleteApplicationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete the application by the specified application sid + /// + /// Delete Application parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task DeleteAsync(DeleteApplicationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete the application by the specified application sid + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Application + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteApplicationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete the application by the specified application sid + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteApplicationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchApplicationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the application specified by the provided sid + /// + /// Fetch Application parameters + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Fetch(FetchApplicationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the application specified by the provided sid + /// + /// Fetch Application parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task FetchAsync(FetchApplicationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the application specified by the provided sid + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchApplicationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the application specified by the provided sid + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchApplicationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadApplicationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of applications representing an application within the requesting account + /// + /// Read Application parameters + /// Client to make requests to Twilio + /// A single instance of Application + public static ResourceSet Read(ReadApplicationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("applications", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of applications representing an application within the requesting account + /// + /// Read Application parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task> ReadAsync(ReadApplicationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("applications", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of applications representing an application within the requesting account + /// + /// The SID of the Account that created the resources to read + /// The string that identifies the Application resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Application + public static ResourceSet Read(string pathAccountSid = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadApplicationOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of applications representing an application within the requesting account + /// + /// The SID of the Account that created the resources to read + /// The string that identifies the Application resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadApplicationOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("applications", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("applications", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("applications", response.Content); + } + + private static Request BuildUpdateRequest(UpdateApplicationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Applications/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the application's properties + /// + /// Update Application parameters + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Update(UpdateApplicationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the application's properties + /// + /// Update Application parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task UpdateAsync(UpdateApplicationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the application's properties + /// + /// The unique string that identifies the resource + /// The SID of the Account that will create the resource + /// A string to describe the resource + /// The API version to use to start a new TwiML session + /// The URL to call when the phone number receives a call + /// The HTTP method to use with the voice_url + /// The URL to call when a TwiML error occurs + /// The HTTP method to use with voice_fallback_url + /// The URL to send status information to your application + /// The HTTP method to use to call status_callback + /// Whether to lookup the caller's name + /// The URL to call when the phone number receives an incoming SMS message + /// The HTTP method to use with sms_url + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// The HTTP method to use with sms_fallback_url + /// Same as message_status_callback. Deprecated, included for backwards compatibility. + /// + /// The URL to send message status information to your application + /// Client to make requests to Twilio + /// A single instance of Application + public static ApplicationResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string apiVersion = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? voiceCallerIdLookup = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsStatusCallback = null, + Uri messageStatusCallback = null, + ITwilioRestClient client = null) + { + var options = new UpdateApplicationOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the application's properties + /// + /// The unique string that identifies the resource + /// The SID of the Account that will create the resource + /// A string to describe the resource + /// The API version to use to start a new TwiML session + /// The URL to call when the phone number receives a call + /// The HTTP method to use with the voice_url + /// The URL to call when a TwiML error occurs + /// The HTTP method to use with voice_fallback_url + /// The URL to send status information to your application + /// The HTTP method to use to call status_callback + /// Whether to lookup the caller's name + /// The URL to call when the phone number receives an incoming SMS message + /// The HTTP method to use with sms_url + /// The URL to call when an error occurs while retrieving or executing the TwiML + /// The HTTP method to use with sms_fallback_url + /// Same as message_status_callback. Deprecated, included for backwards compatibility. + /// + /// The URL to send message status information to your application + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Application + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string apiVersion = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? voiceCallerIdLookup = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsStatusCallback = null, + Uri messageStatusCallback = null, + ITwilioRestClient client = null) + { + var options = new UpdateApplicationOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceCallerIdLookup = voiceCallerIdLookup, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsStatusCallback = smsStatusCallback, MessageStatusCallback = messageStatusCallback }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ApplicationResource object + /// + /// Raw JSON string + /// ApplicationResource object represented by the provided JSON + public static ApplicationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The URL to send message status information to your application + /// + [JsonProperty("message_status_callback")] + public Uri MessageStatusCallback { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("sms_status_callback")] + public Uri SmsStatusCallback { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when a TwiML error occurs + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + + private ApplicationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppOptions.cs index c8d7b53cb..0d742aa3f 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppOptions.cs @@ -9,64 +9,64 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of an authorized-connect-app + /// + public class FetchAuthorizedConnectAppOptions : IOptions + { /// - /// Fetch an instance of an authorized-connect-app + /// The SID of the Account that created the resource to fetch /// - public class FetchAuthorizedConnectAppOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Connect App to fetch - /// - public string PathConnectAppSid { get; } - - /// - /// Construct a new FetchAuthorizedConnectAppOptions - /// - /// The SID of the Connect App to fetch - public FetchAuthorizedConnectAppOptions(string pathConnectAppSid) - { - PathConnectAppSid = pathConnectAppSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// The SID of the Connect App to fetch /// - public class ReadAuthorizedConnectAppOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathConnectAppSid { get; } + + /// + /// Construct a new FetchAuthorizedConnectAppOptions + /// + /// The SID of the Connect App to fetch + public FetchAuthorizedConnectAppOptions(string pathConnectAppSid) + { + PathConnectAppSid = pathConnectAppSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// + public class ReadAuthorizedConnectAppOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppResource.cs b/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppResource.cs index 082c60cb4..5c17a25ff 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AuthorizedConnectAppResource.cs @@ -17,306 +17,306 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class AuthorizedConnectAppResource : Resource - { - public sealed class PermissionEnum : StringEnum - { - private PermissionEnum(string value) : base(value) {} - public PermissionEnum() {} - public static implicit operator PermissionEnum(string value) - { - return new PermissionEnum(value); - } - - public static readonly PermissionEnum GetAll = new PermissionEnum("get-all"); - public static readonly PermissionEnum PostAll = new PermissionEnum("post-all"); - } - - private static Request BuildFetchRequest(FetchAuthorizedConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AuthorizedConnectApps/" + options.PathConnectAppSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an authorized-connect-app - /// - /// Fetch AuthorizedConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizedConnectApp - public static AuthorizedConnectAppResource Fetch(FetchAuthorizedConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an authorized-connect-app - /// - /// Fetch AuthorizedConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizedConnectApp - public static async System.Threading.Tasks.Task FetchAsync(FetchAuthorizedConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an authorized-connect-app - /// - /// The SID of the Connect App to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AuthorizedConnectApp - public static AuthorizedConnectAppResource Fetch(string pathConnectAppSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthorizedConnectAppOptions(pathConnectAppSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an authorized-connect-app - /// - /// The SID of the Connect App to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizedConnectApp - public static async System.Threading.Tasks.Task FetchAsync(string pathConnectAppSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthorizedConnectAppOptions(pathConnectAppSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAuthorizedConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AuthorizedConnectApps.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request - /// - /// Read AuthorizedConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizedConnectApp - public static ResourceSet Read(ReadAuthorizedConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("authorized_connect_apps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request - /// - /// Read AuthorizedConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizedConnectApp - public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthorizedConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("authorized_connect_apps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AuthorizedConnectApp - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthorizedConnectAppOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizedConnectApp - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthorizedConnectAppOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("authorized_connect_apps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("authorized_connect_apps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("authorized_connect_apps", response.Content); - } - - /// - /// Converts a JSON string into a AuthorizedConnectAppResource object - /// - /// Raw JSON string - /// AuthorizedConnectAppResource object represented by the provided JSON - public static AuthorizedConnectAppResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The company name set for the Connect App - /// - [JsonProperty("connect_app_company_name")] - public string ConnectAppCompanyName { get; private set; } - /// - /// A detailed description of the app - /// - [JsonProperty("connect_app_description")] - public string ConnectAppDescription { get; private set; } - /// - /// The name of the Connect App - /// - [JsonProperty("connect_app_friendly_name")] - public string ConnectAppFriendlyName { get; private set; } - /// - /// The public URL for the Connect App - /// - [JsonProperty("connect_app_homepage_url")] - public Uri ConnectAppHomepageUrl { get; private set; } - /// - /// The SID that we assigned to the Connect App - /// - [JsonProperty("connect_app_sid")] - public string ConnectAppSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Permissions authorized to the app - /// - [JsonProperty("permissions")] - [JsonConverter(typeof(StringEnumConverter))] - public List Permissions { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private AuthorizedConnectAppResource() - { - - } - } +{ + + public class AuthorizedConnectAppResource : Resource + { + public sealed class PermissionEnum : StringEnum + { + private PermissionEnum(string value) : base(value) { } + public PermissionEnum() { } + public static implicit operator PermissionEnum(string value) + { + return new PermissionEnum(value); + } + + public static readonly PermissionEnum GetAll = new PermissionEnum("get-all"); + public static readonly PermissionEnum PostAll = new PermissionEnum("post-all"); + } + + private static Request BuildFetchRequest(FetchAuthorizedConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AuthorizedConnectApps/" + options.PathConnectAppSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an authorized-connect-app + /// + /// Fetch AuthorizedConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizedConnectApp + public static AuthorizedConnectAppResource Fetch(FetchAuthorizedConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an authorized-connect-app + /// + /// Fetch AuthorizedConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizedConnectApp + public static async System.Threading.Tasks.Task FetchAsync(FetchAuthorizedConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an authorized-connect-app + /// + /// The SID of the Connect App to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AuthorizedConnectApp + public static AuthorizedConnectAppResource Fetch(string pathConnectAppSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthorizedConnectAppOptions(pathConnectAppSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an authorized-connect-app + /// + /// The SID of the Connect App to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizedConnectApp + public static async System.Threading.Tasks.Task FetchAsync(string pathConnectAppSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthorizedConnectAppOptions(pathConnectAppSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAuthorizedConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AuthorizedConnectApps.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// + /// Read AuthorizedConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizedConnectApp + public static ResourceSet Read(ReadAuthorizedConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("authorized_connect_apps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// + /// Read AuthorizedConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizedConnectApp + public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthorizedConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("authorized_connect_apps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AuthorizedConnectApp + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthorizedConnectAppOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of authorized-connect-apps belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizedConnectApp + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthorizedConnectAppOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("authorized_connect_apps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("authorized_connect_apps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("authorized_connect_apps", response.Content); + } + + /// + /// Converts a JSON string into a AuthorizedConnectAppResource object + /// + /// Raw JSON string + /// AuthorizedConnectAppResource object represented by the provided JSON + public static AuthorizedConnectAppResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The company name set for the Connect App + /// + [JsonProperty("connect_app_company_name")] + public string ConnectAppCompanyName { get; private set; } + /// + /// A detailed description of the app + /// + [JsonProperty("connect_app_description")] + public string ConnectAppDescription { get; private set; } + /// + /// The name of the Connect App + /// + [JsonProperty("connect_app_friendly_name")] + public string ConnectAppFriendlyName { get; private set; } + /// + /// The public URL for the Connect App + /// + [JsonProperty("connect_app_homepage_url")] + public Uri ConnectAppHomepageUrl { get; private set; } + /// + /// The SID that we assigned to the Connect App + /// + [JsonProperty("connect_app_sid")] + public string ConnectAppSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Permissions authorized to the app + /// + [JsonProperty("permissions")] + [JsonConverter(typeof(StringEnumConverter))] + public List Permissions { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private AuthorizedConnectAppResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalOptions.cs index 96f50fca8..96dba122a 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadLocalOptions + /// + public class ReadLocalOptions : ReadOptions + { /// - /// ReadLocalOptions - /// - public class ReadLocalOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadLocalOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadLocalOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadLocalOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadLocalOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalResource.cs index 925312b4f..f03fd00b5 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/LocalResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class LocalResource : Resource - { - private static Request BuildReadRequest(ReadLocalOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Local.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Local parameters - /// Client to make requests to Twilio - /// A single instance of Local - public static ResourceSet Read(ReadLocalOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Local parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task> ReadAsync(ReadLocalOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Local - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLocalOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLocalOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a LocalResource object - /// - /// Raw JSON string - /// LocalResource object represented by the provided JSON - public static LocalResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private LocalResource() - { - - } - } +{ + + public class LocalResource : Resource + { + private static Request BuildReadRequest(ReadLocalOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Local.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Local parameters + /// Client to make requests to Twilio + /// A single instance of Local + public static ResourceSet Read(ReadLocalOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Local parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task> ReadAsync(ReadLocalOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Local + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLocalOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLocalOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a LocalResource object + /// + /// Raw JSON string + /// LocalResource object represented by the provided JSON + public static LocalResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private LocalResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineOptions.cs index ae4e688cf..3970ab072 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadMachineToMachineOptions + /// + public class ReadMachineToMachineOptions : ReadOptions + { /// - /// ReadMachineToMachineOptions - /// - public class ReadMachineToMachineOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadMachineToMachineOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadMachineToMachineOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadMachineToMachineOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadMachineToMachineOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineResource.cs index 47b551719..d69a61f8c 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MachineToMachineResource.cs @@ -17,319 +17,319 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class MachineToMachineResource : Resource - { - private static Request BuildReadRequest(ReadMachineToMachineOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/MachineToMachine.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read MachineToMachine parameters - /// Client to make requests to Twilio - /// A single instance of MachineToMachine - public static ResourceSet Read(ReadMachineToMachineOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read MachineToMachine parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MachineToMachine - public static async System.Threading.Tasks.Task> ReadAsync(ReadMachineToMachineOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of MachineToMachine - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMachineToMachineOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MachineToMachine - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMachineToMachineOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a MachineToMachineResource object - /// - /// Raw JSON string - /// MachineToMachineResource object represented by the provided JSON - public static MachineToMachineResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private MachineToMachineResource() - { - - } - } +{ + + public class MachineToMachineResource : Resource + { + private static Request BuildReadRequest(ReadMachineToMachineOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/MachineToMachine.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read MachineToMachine parameters + /// Client to make requests to Twilio + /// A single instance of MachineToMachine + public static ResourceSet Read(ReadMachineToMachineOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read MachineToMachine parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MachineToMachine + public static async System.Threading.Tasks.Task> ReadAsync(ReadMachineToMachineOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of MachineToMachine + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMachineToMachineOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MachineToMachine + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMachineToMachineOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a MachineToMachineResource object + /// + /// Raw JSON string + /// MachineToMachineResource object represented by the provided JSON + public static MachineToMachineResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private MachineToMachineResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileOptions.cs index c804b56f8..3f3f70bdd 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadMobileOptions + /// + public class ReadMobileOptions : ReadOptions + { /// - /// ReadMobileOptions - /// - public class ReadMobileOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadMobileOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadMobileOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadMobileOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadMobileOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileResource.cs index 3a4727137..e9f441870 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/MobileResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class MobileResource : Resource - { - private static Request BuildReadRequest(ReadMobileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Mobile.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Mobile parameters - /// Client to make requests to Twilio - /// A single instance of Mobile - public static ResourceSet Read(ReadMobileOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Mobile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task> ReadAsync(ReadMobileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Mobile - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMobileOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMobileOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a MobileResource object - /// - /// Raw JSON string - /// MobileResource object represented by the provided JSON - public static MobileResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private MobileResource() - { - - } - } +{ + + public class MobileResource : Resource + { + private static Request BuildReadRequest(ReadMobileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Mobile.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Mobile parameters + /// Client to make requests to Twilio + /// A single instance of Mobile + public static ResourceSet Read(ReadMobileOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Mobile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task> ReadAsync(ReadMobileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Mobile + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMobileOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMobileOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a MobileResource object + /// + /// Raw JSON string + /// MobileResource object represented by the provided JSON + public static MobileResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private MobileResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalOptions.cs index 0541a863e..a35947772 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadNationalOptions + /// + public class ReadNationalOptions : ReadOptions + { /// - /// ReadNationalOptions - /// - public class ReadNationalOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadNationalOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadNationalOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadNationalOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadNationalOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalResource.cs index a75d84be4..b835120d9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/NationalResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class NationalResource : Resource - { - private static Request BuildReadRequest(ReadNationalOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/National.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read National parameters - /// Client to make requests to Twilio - /// A single instance of National - public static ResourceSet Read(ReadNationalOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read National parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of National - public static async System.Threading.Tasks.Task> ReadAsync(ReadNationalOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of National - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNationalOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of National - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNationalOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a NationalResource object - /// - /// Raw JSON string - /// NationalResource object represented by the provided JSON - public static NationalResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private NationalResource() - { - - } - } +{ + + public class NationalResource : Resource + { + private static Request BuildReadRequest(ReadNationalOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/National.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read National parameters + /// Client to make requests to Twilio + /// A single instance of National + public static ResourceSet Read(ReadNationalOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read National parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of National + public static async System.Threading.Tasks.Task> ReadAsync(ReadNationalOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of National + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNationalOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of National + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNationalOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a NationalResource object + /// + /// Raw JSON string + /// NationalResource object represented by the provided JSON + public static NationalResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private NationalResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostOptions.cs index 8295b0e66..139ba0436 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadSharedCostOptions + /// + public class ReadSharedCostOptions : ReadOptions + { /// - /// ReadSharedCostOptions - /// - public class ReadSharedCostOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadSharedCostOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadSharedCostOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadSharedCostOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadSharedCostOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostResource.cs index 95f9454e5..2a97fe984 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class SharedCostResource : Resource - { - private static Request BuildReadRequest(ReadSharedCostOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/SharedCost.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SharedCost parameters - /// Client to make requests to Twilio - /// A single instance of SharedCost - public static ResourceSet Read(ReadSharedCostOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SharedCost parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SharedCost - public static async System.Threading.Tasks.Task> ReadAsync(ReadSharedCostOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SharedCost - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSharedCostOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SharedCost - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSharedCostOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a SharedCostResource object - /// - /// Raw JSON string - /// SharedCostResource object represented by the provided JSON - public static SharedCostResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private SharedCostResource() - { - - } - } +{ + + public class SharedCostResource : Resource + { + private static Request BuildReadRequest(ReadSharedCostOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/SharedCost.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SharedCost parameters + /// Client to make requests to Twilio + /// A single instance of SharedCost + public static ResourceSet Read(ReadSharedCostOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SharedCost parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SharedCost + public static async System.Threading.Tasks.Task> ReadAsync(ReadSharedCostOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SharedCost + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSharedCostOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SharedCost + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSharedCostOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a SharedCostResource object + /// + /// Raw JSON string + /// SharedCostResource object represented by the provided JSON + public static SharedCostResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private SharedCostResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeOptions.cs index 9690409e6..5c252060b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadTollFreeOptions + /// + public class ReadTollFreeOptions : ReadOptions + { /// - /// ReadTollFreeOptions - /// - public class ReadTollFreeOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadTollFreeOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadTollFreeOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadTollFreeOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadTollFreeOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeResource.cs index 8923464bf..aaa0634ad 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/TollFreeResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class TollFreeResource : Resource - { - private static Request BuildReadRequest(ReadTollFreeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/TollFree.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read TollFree parameters - /// Client to make requests to Twilio - /// A single instance of TollFree - public static ResourceSet Read(ReadTollFreeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read TollFree parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task> ReadAsync(ReadTollFreeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TollFree - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTollFreeOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTollFreeOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a TollFreeResource object - /// - /// Raw JSON string - /// TollFreeResource object represented by the provided JSON - public static TollFreeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private TollFreeResource() - { - - } - } +{ + + public class TollFreeResource : Resource + { + private static Request BuildReadRequest(ReadTollFreeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/TollFree.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read TollFree parameters + /// Client to make requests to Twilio + /// A single instance of TollFree + public static ResourceSet Read(ReadTollFreeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read TollFree parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task> ReadAsync(ReadTollFreeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TollFree + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTollFreeOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTollFreeOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a TollFreeResource object + /// + /// Raw JSON string + /// TollFreeResource object represented by the provided JSON + public static TollFreeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private TollFreeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipOptions.cs index 75ce5c49a..ac660584a 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - +{ + + /// + /// ReadVoipOptions + /// + public class ReadVoipOptions : ReadOptions + { /// - /// ReadVoipOptions - /// - public class ReadVoipOptions : ReadOptions - { - /// - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// - public string PathAccountSid { get; set; } - /// - /// The ISO Country code of the country from which to read phone numbers - /// - public string PathCountryCode { get; } - /// - /// The area code of the phone numbers to read - /// - public int? AreaCode { get; set; } - /// - /// The pattern on which to match phone numbers - /// - public string Contains { get; set; } - /// - /// Whether the phone numbers can receive text messages - /// - public bool? SmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive MMS messages - /// - public bool? MmsEnabled { get; set; } - /// - /// Whether the phone numbers can receive calls. - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether to exclude phone numbers that require an Address - /// - public bool? ExcludeAllAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a local address - /// - public bool? ExcludeLocalAddressRequired { get; set; } - /// - /// Whether to exclude phone numbers that require a foreign address - /// - public bool? ExcludeForeignAddressRequired { get; set; } - /// - /// Whether to read phone numbers new to the Twilio platform - /// - public bool? Beta { get; set; } - /// - /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) - /// - public Types.PhoneNumber NearNumber { get; set; } - /// - /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) - /// - public string NearLatLong { get; set; } - /// - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// - public int? Distance { get; set; } - /// - /// Limit results to a particular postal code. (US/Canada only) - /// - public string InPostalCode { get; set; } - /// - /// Limit results to a particular region. (US/Canada only) - /// - public string InRegion { get; set; } - /// - /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) - /// - public string InRateCenter { get; set; } - /// - /// Limit results to a specific local access and transport area. (US/Canada only) - /// - public string InLata { get; set; } - /// - /// Limit results to a particular locality - /// - public string InLocality { get; set; } - /// - /// Whether the phone numbers can receive faxes - /// - public bool? FaxEnabled { get; set; } - - /// - /// Construct a new ReadVoipOptions - /// - /// The ISO Country code of the country from which to read phone numbers - public ReadVoipOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); - } - - if (Contains != null) - { - p.Add(new KeyValuePair("Contains", Contains)); - } - - if (SmsEnabled != null) - { - p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); - } - - if (MmsEnabled != null) - { - p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (ExcludeAllAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeLocalAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); - } - - if (ExcludeForeignAddressRequired != null) - { - p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); - } - - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (NearNumber != null) - { - p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); - } - - if (NearLatLong != null) - { - p.Add(new KeyValuePair("NearLatLong", NearLatLong)); - } - - if (Distance != null) - { - p.Add(new KeyValuePair("Distance", Distance.ToString())); - } - - if (InPostalCode != null) - { - p.Add(new KeyValuePair("InPostalCode", InPostalCode)); - } - - if (InRegion != null) - { - p.Add(new KeyValuePair("InRegion", InRegion)); - } - - if (InRateCenter != null) - { - p.Add(new KeyValuePair("InRateCenter", InRateCenter)); - } - - if (InLata != null) - { - p.Add(new KeyValuePair("InLata", InLata)); - } - - if (InLocality != null) - { - p.Add(new KeyValuePair("InLocality", InLocality)); - } - - if (FaxEnabled != null) - { - p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// + public string PathAccountSid { get; set; } + /// + /// The ISO Country code of the country from which to read phone numbers + /// + public string PathCountryCode { get; } + /// + /// The area code of the phone numbers to read + /// + public int? AreaCode { get; set; } + /// + /// The pattern on which to match phone numbers + /// + public string Contains { get; set; } + /// + /// Whether the phone numbers can receive text messages + /// + public bool? SmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive MMS messages + /// + public bool? MmsEnabled { get; set; } + /// + /// Whether the phone numbers can receive calls. + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether to exclude phone numbers that require an Address + /// + public bool? ExcludeAllAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a local address + /// + public bool? ExcludeLocalAddressRequired { get; set; } + /// + /// Whether to exclude phone numbers that require a foreign address + /// + public bool? ExcludeForeignAddressRequired { get; set; } + /// + /// Whether to read phone numbers new to the Twilio platform + /// + public bool? Beta { get; set; } + /// + /// Given a phone number, find a geographically close number within distance miles. (US/Canada only) + /// + public Types.PhoneNumber NearNumber { get; set; } + /// + /// Given a latitude/longitude pair lat,long find geographically close numbers within distance miles. (US/Canada only) + /// + public string NearLatLong { get; set; } + /// + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// + public int? Distance { get; set; } + /// + /// Limit results to a particular postal code. (US/Canada only) + /// + public string InPostalCode { get; set; } + /// + /// Limit results to a particular region. (US/Canada only) + /// + public string InRegion { get; set; } + /// + /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. (US/Canada only) + /// + public string InRateCenter { get; set; } + /// + /// Limit results to a specific local access and transport area. (US/Canada only) + /// + public string InLata { get; set; } + /// + /// Limit results to a particular locality + /// + public string InLocality { get; set; } + /// + /// Whether the phone numbers can receive faxes + /// + public bool? FaxEnabled { get; set; } + + /// + /// Construct a new ReadVoipOptions + /// + /// The ISO Country code of the country from which to read phone numbers + public ReadVoipOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode.ToString())); + } + + if (Contains != null) + { + p.Add(new KeyValuePair("Contains", Contains)); + } + + if (SmsEnabled != null) + { + p.Add(new KeyValuePair("SmsEnabled", SmsEnabled.Value.ToString().ToLower())); + } + + if (MmsEnabled != null) + { + p.Add(new KeyValuePair("MmsEnabled", MmsEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (ExcludeAllAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeLocalAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower())); + } + + if (ExcludeForeignAddressRequired != null) + { + p.Add(new KeyValuePair("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower())); + } + + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (NearNumber != null) + { + p.Add(new KeyValuePair("NearNumber", NearNumber.ToString())); + } + + if (NearLatLong != null) + { + p.Add(new KeyValuePair("NearLatLong", NearLatLong)); + } + + if (Distance != null) + { + p.Add(new KeyValuePair("Distance", Distance.ToString())); + } + + if (InPostalCode != null) + { + p.Add(new KeyValuePair("InPostalCode", InPostalCode)); + } + + if (InRegion != null) + { + p.Add(new KeyValuePair("InRegion", InRegion)); + } + + if (InRateCenter != null) + { + p.Add(new KeyValuePair("InRateCenter", InRateCenter)); + } + + if (InLata != null) + { + p.Add(new KeyValuePair("InLata", InLata)); + } + + if (InLocality != null) + { + p.Add(new KeyValuePair("InLocality", InLocality)); + } + + if (FaxEnabled != null) + { + p.Add(new KeyValuePair("FaxEnabled", FaxEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipResource.cs index f246dbf04..49a017d0e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/VoipResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry -{ - - public class VoipResource : Resource - { - private static Request BuildReadRequest(ReadVoipOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Voip.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Voip parameters - /// Client to make requests to Twilio - /// A single instance of Voip - public static ResourceSet Read(ReadVoipOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Voip parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Voip - public static async System.Threading.Tasks.Task> ReadAsync(ReadVoipOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Voip - public static ResourceSet Read(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVoipOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The ISO Country code of the country from which to read phone numbers - /// The SID of the Account requesting the AvailablePhoneNumber resources - /// The area code of the phone numbers to read - /// The pattern on which to match phone numbers - /// Whether the phone numbers can receive text messages - /// Whether the phone numbers can receive MMS messages - /// Whether the phone numbers can receive calls. - /// Whether to exclude phone numbers that require an Address - /// Whether to exclude phone numbers that require a local address - /// Whether to exclude phone numbers that require a foreign address - /// - /// Whether to read phone numbers new to the Twilio platform - /// Given a phone number, find a geographically close number within distance miles. - /// (US/Canada only) - /// Given a latitude/longitude pair lat,long find geographically close numbers within - /// distance miles. (US/Canada only) - /// The search radius, in miles, for a near_ query. (US/Canada only) - /// Limit results to a particular postal code. (US/Canada only) - /// Limit results to a particular region. (US/Canada only) - /// Limit results to a specific rate center, or given a phone number search within the same - /// rate center as that number. (US/Canada only) - /// Limit results to a specific local access and transport area. (US/Canada only) - /// Limit results to a particular locality - /// Whether the phone numbers can receive faxes - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Voip - public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, - string pathAccountSid = null, - int? areaCode = null, - string contains = null, - bool? smsEnabled = null, - bool? mmsEnabled = null, - bool? voiceEnabled = null, - bool? excludeAllAddressRequired = null, - bool? excludeLocalAddressRequired = null, - bool? excludeForeignAddressRequired = null, - bool? beta = null, - Types.PhoneNumber nearNumber = null, - string nearLatLong = null, - int? distance = null, - string inPostalCode = null, - string inRegion = null, - string inRateCenter = null, - string inLata = null, - string inLocality = null, - bool? faxEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVoipOptions(pathCountryCode){PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("available_phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a VoipResource object - /// - /// Raw JSON string - /// VoipResource object represented by the provided JSON - public static VoipResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A formatted version of the phone number - /// - [JsonProperty("friendly_name")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber FriendlyName { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The LATA of this phone number - /// - [JsonProperty("lata")] - public string Lata { get; private set; } - /// - /// The locality or city of this phone number's location - /// - [JsonProperty("locality")] - public string Locality { get; private set; } - /// - /// The rate center of this phone number - /// - [JsonProperty("rate_center")] - public string RateCenter { get; private set; } - /// - /// The latitude of this phone number's location - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; private set; } - /// - /// The longitude of this phone number's location - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; private set; } - /// - /// The two-letter state or province abbreviation of this phone number's location - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The postal or ZIP code of this phone number's location - /// - [JsonProperty("postal_code")] - public string PostalCode { get; private set; } - /// - /// The ISO country code of this phone number - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of Address resource the phone number requires - /// - [JsonProperty("address_requirements")] - public string AddressRequirements { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Whether a phone number can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - - private VoipResource() - { - - } - } +{ + + public class VoipResource : Resource + { + private static Request BuildReadRequest(ReadVoipOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + "/Voip.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Voip parameters + /// Client to make requests to Twilio + /// A single instance of Voip + public static ResourceSet Read(ReadVoipOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Voip parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Voip + public static async System.Threading.Tasks.Task> ReadAsync(ReadVoipOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Voip + public static ResourceSet Read(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVoipOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The ISO Country code of the country from which to read phone numbers + /// The SID of the Account requesting the AvailablePhoneNumber resources + /// The area code of the phone numbers to read + /// The pattern on which to match phone numbers + /// Whether the phone numbers can receive text messages + /// Whether the phone numbers can receive MMS messages + /// Whether the phone numbers can receive calls. + /// Whether to exclude phone numbers that require an Address + /// Whether to exclude phone numbers that require a local address + /// Whether to exclude phone numbers that require a foreign address + /// + /// Whether to read phone numbers new to the Twilio platform + /// Given a phone number, find a geographically close number within distance miles. + /// (US/Canada only) + /// Given a latitude/longitude pair lat,long find geographically close numbers within + /// distance miles. (US/Canada only) + /// The search radius, in miles, for a near_ query. (US/Canada only) + /// Limit results to a particular postal code. (US/Canada only) + /// Limit results to a particular region. (US/Canada only) + /// Limit results to a specific rate center, or given a phone number search within the same + /// rate center as that number. (US/Canada only) + /// Limit results to a specific local access and transport area. (US/Canada only) + /// Limit results to a particular locality + /// Whether the phone numbers can receive faxes + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Voip + public static async System.Threading.Tasks.Task> ReadAsync(string pathCountryCode, + string pathAccountSid = null, + int? areaCode = null, + string contains = null, + bool? smsEnabled = null, + bool? mmsEnabled = null, + bool? voiceEnabled = null, + bool? excludeAllAddressRequired = null, + bool? excludeLocalAddressRequired = null, + bool? excludeForeignAddressRequired = null, + bool? beta = null, + Types.PhoneNumber nearNumber = null, + string nearLatLong = null, + int? distance = null, + string inPostalCode = null, + string inRegion = null, + string inRateCenter = null, + string inLata = null, + string inLocality = null, + bool? faxEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVoipOptions(pathCountryCode) { PathAccountSid = pathAccountSid, AreaCode = areaCode, Contains = contains, SmsEnabled = smsEnabled, MmsEnabled = mmsEnabled, VoiceEnabled = voiceEnabled, ExcludeAllAddressRequired = excludeAllAddressRequired, ExcludeLocalAddressRequired = excludeLocalAddressRequired, ExcludeForeignAddressRequired = excludeForeignAddressRequired, Beta = beta, NearNumber = nearNumber, NearLatLong = nearLatLong, Distance = distance, InPostalCode = inPostalCode, InRegion = inRegion, InRateCenter = inRateCenter, InLata = inLata, InLocality = inLocality, FaxEnabled = faxEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("available_phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a VoipResource object + /// + /// Raw JSON string + /// VoipResource object represented by the provided JSON + public static VoipResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A formatted version of the phone number + /// + [JsonProperty("friendly_name")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber FriendlyName { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The LATA of this phone number + /// + [JsonProperty("lata")] + public string Lata { get; private set; } + /// + /// The locality or city of this phone number's location + /// + [JsonProperty("locality")] + public string Locality { get; private set; } + /// + /// The rate center of this phone number + /// + [JsonProperty("rate_center")] + public string RateCenter { get; private set; } + /// + /// The latitude of this phone number's location + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; private set; } + /// + /// The longitude of this phone number's location + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; private set; } + /// + /// The two-letter state or province abbreviation of this phone number's location + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The postal or ZIP code of this phone number's location + /// + [JsonProperty("postal_code")] + public string PostalCode { get; private set; } + /// + /// The ISO country code of this phone number + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of Address resource the phone number requires + /// + [JsonProperty("address_requirements")] + public string AddressRequirements { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Whether a phone number can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + + private VoipResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryOptions.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryOptions.cs index 18bc82d2c..4d8ed2fdf 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryOptions.cs @@ -9,65 +9,65 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// ReadAvailablePhoneNumberCountryOptions + /// + public class ReadAvailablePhoneNumberCountryOptions : ReadOptions + { /// - /// ReadAvailablePhoneNumberCountryOptions + /// The SID of the Account requesting the available phone number Country resources /// - public class ReadAvailablePhoneNumberCountryOptions : ReadOptions - { - /// - /// The SID of the Account requesting the available phone number Country resources - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathAccountSid { get; set; } + /// - /// FetchAvailablePhoneNumberCountryOptions + /// Generate the necessary parameters /// - public class FetchAvailablePhoneNumberCountryOptions : IOptions - { - /// - /// The SID of the Account requesting the available phone number Country resource - /// - public string PathAccountSid { get; set; } - /// - /// The ISO country code of the country to fetch available phone number information about - /// - public string PathCountryCode { get; } - - /// - /// Construct a new FetchAvailablePhoneNumberCountryOptions - /// - /// The ISO country code of the country to fetch available phone number information - /// about - public FetchAvailablePhoneNumberCountryOptions(string pathCountryCode) - { - PathCountryCode = pathCountryCode; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchAvailablePhoneNumberCountryOptions + /// + public class FetchAvailablePhoneNumberCountryOptions : IOptions + { + /// + /// The SID of the Account requesting the available phone number Country resource + /// + public string PathAccountSid { get; set; } + /// + /// The ISO country code of the country to fetch available phone number information about + /// + public string PathCountryCode { get; } + + /// + /// Construct a new FetchAvailablePhoneNumberCountryOptions + /// + /// The ISO country code of the country to fetch available phone number information + /// about + public FetchAvailablePhoneNumberCountryOptions(string pathCountryCode) + { + PathCountryCode = pathCountryCode; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryResource.cs b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryResource.cs index 933e6f7a1..e3c80936b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryResource.cs @@ -16,271 +16,271 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class AvailablePhoneNumberCountryResource : Resource - { - private static Request BuildReadRequest(ReadAvailablePhoneNumberCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read AvailablePhoneNumberCountry parameters - /// Client to make requests to Twilio - /// A single instance of AvailablePhoneNumberCountry - public static ResourceSet Read(ReadAvailablePhoneNumberCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read AvailablePhoneNumberCountry parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailablePhoneNumberCountry - public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailablePhoneNumberCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account requesting the available phone number Country resources - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AvailablePhoneNumberCountry - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailablePhoneNumberCountryOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account requesting the available phone number Country resources - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailablePhoneNumberCountry - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailablePhoneNumberCountryOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchAvailablePhoneNumberCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch AvailablePhoneNumberCountry parameters - /// Client to make requests to Twilio - /// A single instance of AvailablePhoneNumberCountry - public static AvailablePhoneNumberCountryResource Fetch(FetchAvailablePhoneNumberCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch AvailablePhoneNumberCountry parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailablePhoneNumberCountry - public static async System.Threading.Tasks.Task FetchAsync(FetchAvailablePhoneNumberCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The ISO country code of the country to fetch available phone number information - /// about - /// The SID of the Account requesting the available phone number Country resource - /// Client to make requests to Twilio - /// A single instance of AvailablePhoneNumberCountry - public static AvailablePhoneNumberCountryResource Fetch(string pathCountryCode, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAvailablePhoneNumberCountryOptions(pathCountryCode){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The ISO country code of the country to fetch available phone number information - /// about - /// The SID of the Account requesting the available phone number Country resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailablePhoneNumberCountry - public static async System.Threading.Tasks.Task FetchAsync(string pathCountryCode, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAvailablePhoneNumberCountryOptions(pathCountryCode){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AvailablePhoneNumberCountryResource object - /// - /// Raw JSON string - /// AvailablePhoneNumberCountryResource object represented by the provided JSON - public static AvailablePhoneNumberCountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The ISO-3166-1 country code of the country. - /// - [JsonProperty("country_code")] - public string CountryCode { get; private set; } - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The URI of the Country resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public Uri Uri { get; private set; } - /// - /// Whether all phone numbers available in the country are new to the Twilio platform. - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private AvailablePhoneNumberCountryResource() - { - - } - } +{ + + public class AvailablePhoneNumberCountryResource : Resource + { + private static Request BuildReadRequest(ReadAvailablePhoneNumberCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read AvailablePhoneNumberCountry parameters + /// Client to make requests to Twilio + /// A single instance of AvailablePhoneNumberCountry + public static ResourceSet Read(ReadAvailablePhoneNumberCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read AvailablePhoneNumberCountry parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailablePhoneNumberCountry + public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailablePhoneNumberCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account requesting the available phone number Country resources + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AvailablePhoneNumberCountry + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailablePhoneNumberCountryOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account requesting the available phone number Country resources + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailablePhoneNumberCountry + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailablePhoneNumberCountryOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchAvailablePhoneNumberCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/AvailablePhoneNumbers/" + options.PathCountryCode + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch AvailablePhoneNumberCountry parameters + /// Client to make requests to Twilio + /// A single instance of AvailablePhoneNumberCountry + public static AvailablePhoneNumberCountryResource Fetch(FetchAvailablePhoneNumberCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch AvailablePhoneNumberCountry parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailablePhoneNumberCountry + public static async System.Threading.Tasks.Task FetchAsync(FetchAvailablePhoneNumberCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The ISO country code of the country to fetch available phone number information + /// about + /// The SID of the Account requesting the available phone number Country resource + /// Client to make requests to Twilio + /// A single instance of AvailablePhoneNumberCountry + public static AvailablePhoneNumberCountryResource Fetch(string pathCountryCode, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAvailablePhoneNumberCountryOptions(pathCountryCode) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The ISO country code of the country to fetch available phone number information + /// about + /// The SID of the Account requesting the available phone number Country resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailablePhoneNumberCountry + public static async System.Threading.Tasks.Task FetchAsync(string pathCountryCode, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAvailablePhoneNumberCountryOptions(pathCountryCode) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AvailablePhoneNumberCountryResource object + /// + /// Raw JSON string + /// AvailablePhoneNumberCountryResource object represented by the provided JSON + public static AvailablePhoneNumberCountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The ISO-3166-1 country code of the country. + /// + [JsonProperty("country_code")] + public string CountryCode { get; private set; } + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The URI of the Country resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public Uri Uri { get; private set; } + /// + /// Whether all phone numbers available in the country are new to the Twilio platform. + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private AvailablePhoneNumberCountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/BalanceOptions.cs b/src/Twilio/Rest/Api/V2010/Account/BalanceOptions.cs index 763e8fd12..77b7d0356 100644 --- a/src/Twilio/Rest/Api/V2010/Account/BalanceOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/BalanceOptions.cs @@ -9,27 +9,27 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child + /// accounts do not contain balance information + /// + public class FetchBalanceOptions : IOptions + { /// - /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child - /// accounts do not contain balance information + /// Account Sid. /// - public class FetchBalanceOptions : IOptions - { - /// - /// Account Sid. - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/BalanceResource.cs b/src/Twilio/Rest/Api/V2010/Account/BalanceResource.cs index 62eafbb6a..263cc3db1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/BalanceResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/BalanceResource.cs @@ -16,119 +16,119 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class BalanceResource : Resource - { - private static Request BuildFetchRequest(FetchBalanceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Balance.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child - /// accounts do not contain balance information - /// - /// Fetch Balance parameters - /// Client to make requests to Twilio - /// A single instance of Balance - public static BalanceResource Fetch(FetchBalanceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child - /// accounts do not contain balance information - /// - /// Fetch Balance parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Balance - public static async System.Threading.Tasks.Task FetchAsync(FetchBalanceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child - /// accounts do not contain balance information - /// - /// Account Sid. - /// Client to make requests to Twilio - /// A single instance of Balance - public static BalanceResource Fetch(string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchBalanceOptions(){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child - /// accounts do not contain balance information - /// - /// Account Sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Balance - public static async System.Threading.Tasks.Task FetchAsync(string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchBalanceOptions(){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BalanceResource object - /// - /// Raw JSON string - /// BalanceResource object represented by the provided JSON - public static BalanceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Account balance - /// - [JsonProperty("balance")] - public string Balance { get; private set; } - /// - /// Currency units - /// - [JsonProperty("currency")] - public string Currency { get; private set; } - - private BalanceResource() - { - - } - } +{ + + public class BalanceResource : Resource + { + private static Request BuildFetchRequest(FetchBalanceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Balance.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child + /// accounts do not contain balance information + /// + /// Fetch Balance parameters + /// Client to make requests to Twilio + /// A single instance of Balance + public static BalanceResource Fetch(FetchBalanceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child + /// accounts do not contain balance information + /// + /// Fetch Balance parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Balance + public static async System.Threading.Tasks.Task FetchAsync(FetchBalanceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child + /// accounts do not contain balance information + /// + /// Account Sid. + /// Client to make requests to Twilio + /// A single instance of Balance + public static BalanceResource Fetch(string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchBalanceOptions() { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the balance for an Account based on Account Sid. Balance changes may not be reflected immediately. Child + /// accounts do not contain balance information + /// + /// Account Sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Balance + public static async System.Threading.Tasks.Task FetchAsync(string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchBalanceOptions() { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BalanceResource object + /// + /// Raw JSON string + /// BalanceResource object represented by the provided JSON + public static BalanceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Account balance + /// + [JsonProperty("balance")] + public string Balance { get; private set; } + /// + /// Currency units + /// + [JsonProperty("currency")] + public string Currency { get; private set; } + + private BalanceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/EventOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/EventOptions.cs index 3ad784c53..d2b254eea 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/EventOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/EventOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// Retrieve a list of all events for a call. + /// + public class ReadEventOptions : ReadOptions + { /// - /// Retrieve a list of all events for a call. + /// Account Sid. /// - public class ReadEventOptions : ReadOptions - { - /// - /// Account Sid. - /// - public string PathAccountSid { get; set; } - /// - /// Call Sid. - /// - public string PathCallSid { get; } - - /// - /// Construct a new ReadEventOptions - /// - /// Call Sid. - public ReadEventOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// Call Sid. + /// + public string PathCallSid { get; } + + /// + /// Construct a new ReadEventOptions + /// + /// Call Sid. + public ReadEventOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/EventResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/EventResource.cs index c818c92f9..844467d38 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/EventResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/EventResource.cs @@ -16,180 +16,180 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class EventResource : Resource - { - private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Events.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all events for a call. - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all events for a call. - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all events for a call. - /// - /// Call Sid. - /// Account Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(string pathCallSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathCallSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all events for a call. - /// - /// Call Sid. - /// Account Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathCallSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Converts a JSON string into a EventResource object - /// - /// Raw JSON string - /// EventResource object represented by the provided JSON - public static EventResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Call Request. - /// - [JsonProperty("request")] - public object Request { get; private set; } - /// - /// Call Response with Events. - /// - [JsonProperty("response")] - public object Response { get; private set; } - - private EventResource() - { - - } - } +{ + + public class EventResource : Resource + { + private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Events.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all events for a call. + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all events for a call. + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all events for a call. + /// + /// Call Sid. + /// Account Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(string pathCallSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathCallSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all events for a call. + /// + /// Call Sid. + /// Account Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathCallSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Converts a JSON string into a EventResource object + /// + /// Raw JSON string + /// EventResource object represented by the provided JSON + public static EventResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Call Request. + /// + [JsonProperty("request")] + public object Request { get; private set; } + /// + /// Call Response with Events. + /// + [JsonProperty("response")] + public object Response { get; private set; } + + private EventResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackOptions.cs index 623c90928..4f5332d06 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackOptions.cs @@ -10,145 +10,145 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// Fetch a Feedback resource from a call + /// + public class FetchFeedbackOptions : IOptions + { /// - /// Fetch a Feedback resource from a call - /// - public class FetchFeedbackOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The call sid that uniquely identifies the call - /// - public string PathCallSid { get; } - - /// - /// Construct a new FetchFeedbackOptions - /// - /// The call sid that uniquely identifies the call - public FetchFeedbackOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } /// - /// Create a Feedback resource for a call - /// - public class CreateFeedbackOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The call sid that uniquely identifies the call - /// - public string PathCallSid { get; } - /// - /// The call quality expressed as an integer from 1 to 5 - /// - public int? QualityScore { get; } - /// - /// Issues experienced during the call - /// - public List Issue { get; set; } - - /// - /// Construct a new CreateFeedbackOptions - /// - /// The call sid that uniquely identifies the call - /// The call quality expressed as an integer from 1 to 5 - public CreateFeedbackOptions(string pathCallSid, int? qualityScore) - { - PathCallSid = pathCallSid; - QualityScore = qualityScore; - Issue = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (QualityScore != null) - { - p.Add(new KeyValuePair("QualityScore", QualityScore.ToString())); - } - - if (Issue != null) - { - p.AddRange(Issue.Select(prop => new KeyValuePair("Issue", prop.ToString()))); - } - - return p; - } - } - + /// The call sid that uniquely identifies the call + /// + public string PathCallSid { get; } + /// - /// Update a Feedback resource for a call - /// - public class UpdateFeedbackOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The call sid that uniquely identifies the call - /// - public string PathCallSid { get; } - /// - /// The call quality expressed as an integer from 1 to 5 - /// - public int? QualityScore { get; set; } - /// - /// Issues experienced during the call - /// - public List Issue { get; set; } - - /// - /// Construct a new UpdateFeedbackOptions - /// - /// The call sid that uniquely identifies the call - public UpdateFeedbackOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - Issue = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (QualityScore != null) - { - p.Add(new KeyValuePair("QualityScore", QualityScore.ToString())); - } - - if (Issue != null) - { - p.AddRange(Issue.Select(prop => new KeyValuePair("Issue", prop.ToString()))); - } - - return p; - } - } + /// Construct a new FetchFeedbackOptions + /// + /// The call sid that uniquely identifies the call + public FetchFeedbackOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Create a Feedback resource for a call + /// + public class CreateFeedbackOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// The call sid that uniquely identifies the call + /// + public string PathCallSid { get; } + /// + /// The call quality expressed as an integer from 1 to 5 + /// + public int? QualityScore { get; } + /// + /// Issues experienced during the call + /// + public List Issue { get; set; } + + /// + /// Construct a new CreateFeedbackOptions + /// + /// The call sid that uniquely identifies the call + /// The call quality expressed as an integer from 1 to 5 + public CreateFeedbackOptions(string pathCallSid, int? qualityScore) + { + PathCallSid = pathCallSid; + QualityScore = qualityScore; + Issue = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (QualityScore != null) + { + p.Add(new KeyValuePair("QualityScore", QualityScore.ToString())); + } + + if (Issue != null) + { + p.AddRange(Issue.Select(prop => new KeyValuePair("Issue", prop.ToString()))); + } + + return p; + } + } + + /// + /// Update a Feedback resource for a call + /// + public class UpdateFeedbackOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// The call sid that uniquely identifies the call + /// + public string PathCallSid { get; } + /// + /// The call quality expressed as an integer from 1 to 5 + /// + public int? QualityScore { get; set; } + /// + /// Issues experienced during the call + /// + public List Issue { get; set; } + + /// + /// Construct a new UpdateFeedbackOptions + /// + /// The call sid that uniquely identifies the call + public UpdateFeedbackOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + Issue = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (QualityScore != null) + { + p.Add(new KeyValuePair("QualityScore", QualityScore.ToString())); + } + + if (Issue != null) + { + p.AddRange(Issue.Select(prop => new KeyValuePair("Issue", prop.ToString()))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackResource.cs index ef00880fc..91f6e0b94 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackResource.cs @@ -17,315 +17,315 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class FeedbackResource : Resource - { - public sealed class IssuesEnum : StringEnum - { - private IssuesEnum(string value) : base(value) {} - public IssuesEnum() {} - public static implicit operator IssuesEnum(string value) - { - return new IssuesEnum(value); - } - - public static readonly IssuesEnum AudioLatency = new IssuesEnum("audio-latency"); - public static readonly IssuesEnum DigitsNotCaptured = new IssuesEnum("digits-not-captured"); - public static readonly IssuesEnum DroppedCall = new IssuesEnum("dropped-call"); - public static readonly IssuesEnum ImperfectAudio = new IssuesEnum("imperfect-audio"); - public static readonly IssuesEnum IncorrectCallerId = new IssuesEnum("incorrect-caller-id"); - public static readonly IssuesEnum OneWayAudio = new IssuesEnum("one-way-audio"); - public static readonly IssuesEnum PostDialDelay = new IssuesEnum("post-dial-delay"); - public static readonly IssuesEnum UnsolicitedCall = new IssuesEnum("unsolicited-call"); - } - - private static Request BuildFetchRequest(FetchFeedbackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Feedback resource from a call - /// - /// Fetch Feedback parameters - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Fetch(FetchFeedbackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Feedback resource from a call - /// - /// Fetch Feedback parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task FetchAsync(FetchFeedbackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Feedback resource from a call - /// - /// The call sid that uniquely identifies the call - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Fetch(string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchFeedbackOptions(pathCallSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Feedback resource from a call - /// - /// The call sid that uniquely identifies the call - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchFeedbackOptions(pathCallSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateFeedbackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a Feedback resource for a call - /// - /// Create Feedback parameters - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Create(CreateFeedbackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a Feedback resource for a call - /// - /// Create Feedback parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a Feedback resource for a call - /// - /// The call sid that uniquely identifies the call - /// The call quality expressed as an integer from 1 to 5 - /// The unique sid that identifies this account - /// Issues experienced during the call - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Create(string pathCallSid, - int? qualityScore, - string pathAccountSid = null, - List issue = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackOptions(pathCallSid, qualityScore){PathAccountSid = pathAccountSid, Issue = issue}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a Feedback resource for a call - /// - /// The call sid that uniquely identifies the call - /// The call quality expressed as an integer from 1 to 5 - /// The unique sid that identifies this account - /// Issues experienced during the call - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, - int? qualityScore, - string pathAccountSid = null, - List issue = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackOptions(pathCallSid, qualityScore){PathAccountSid = pathAccountSid, Issue = issue}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFeedbackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a Feedback resource for a call - /// - /// Update Feedback parameters - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Update(UpdateFeedbackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a Feedback resource for a call - /// - /// Update Feedback parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFeedbackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a Feedback resource for a call - /// - /// The call sid that uniquely identifies the call - /// The unique sid that identifies this account - /// The call quality expressed as an integer from 1 to 5 - /// Issues experienced during the call - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Update(string pathCallSid, - string pathAccountSid = null, - int? qualityScore = null, - List issue = null, - ITwilioRestClient client = null) - { - var options = new UpdateFeedbackOptions(pathCallSid){PathAccountSid = pathAccountSid, QualityScore = qualityScore, Issue = issue}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a Feedback resource for a call - /// - /// The call sid that uniquely identifies the call - /// The unique sid that identifies this account - /// The call quality expressed as an integer from 1 to 5 - /// Issues experienced during the call - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, - string pathAccountSid = null, - int? qualityScore = null, - List issue = null, - ITwilioRestClient client = null) - { - var options = new UpdateFeedbackOptions(pathCallSid){PathAccountSid = pathAccountSid, QualityScore = qualityScore, Issue = issue}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FeedbackResource object - /// - /// Raw JSON string - /// FeedbackResource object represented by the provided JSON - public static FeedbackResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique sid that identifies this account - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Issues experienced during the call - /// - [JsonProperty("issues")] - [JsonConverter(typeof(StringEnumConverter))] - public List Issues { get; private set; } - /// - /// 1 to 5 quality score - /// - [JsonProperty("quality_score")] - public int? QualityScore { get; private set; } - /// - /// A string that uniquely identifies this feedback resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - - private FeedbackResource() - { - - } - } +{ + + public class FeedbackResource : Resource + { + public sealed class IssuesEnum : StringEnum + { + private IssuesEnum(string value) : base(value) { } + public IssuesEnum() { } + public static implicit operator IssuesEnum(string value) + { + return new IssuesEnum(value); + } + + public static readonly IssuesEnum AudioLatency = new IssuesEnum("audio-latency"); + public static readonly IssuesEnum DigitsNotCaptured = new IssuesEnum("digits-not-captured"); + public static readonly IssuesEnum DroppedCall = new IssuesEnum("dropped-call"); + public static readonly IssuesEnum ImperfectAudio = new IssuesEnum("imperfect-audio"); + public static readonly IssuesEnum IncorrectCallerId = new IssuesEnum("incorrect-caller-id"); + public static readonly IssuesEnum OneWayAudio = new IssuesEnum("one-way-audio"); + public static readonly IssuesEnum PostDialDelay = new IssuesEnum("post-dial-delay"); + public static readonly IssuesEnum UnsolicitedCall = new IssuesEnum("unsolicited-call"); + } + + private static Request BuildFetchRequest(FetchFeedbackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Feedback resource from a call + /// + /// Fetch Feedback parameters + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Fetch(FetchFeedbackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Feedback resource from a call + /// + /// Fetch Feedback parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task FetchAsync(FetchFeedbackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Feedback resource from a call + /// + /// The call sid that uniquely identifies the call + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Fetch(string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchFeedbackOptions(pathCallSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Feedback resource from a call + /// + /// The call sid that uniquely identifies the call + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchFeedbackOptions(pathCallSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateFeedbackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a Feedback resource for a call + /// + /// Create Feedback parameters + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Create(CreateFeedbackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a Feedback resource for a call + /// + /// Create Feedback parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a Feedback resource for a call + /// + /// The call sid that uniquely identifies the call + /// The call quality expressed as an integer from 1 to 5 + /// The unique sid that identifies this account + /// Issues experienced during the call + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Create(string pathCallSid, + int? qualityScore, + string pathAccountSid = null, + List issue = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackOptions(pathCallSid, qualityScore) { PathAccountSid = pathAccountSid, Issue = issue }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a Feedback resource for a call + /// + /// The call sid that uniquely identifies the call + /// The call quality expressed as an integer from 1 to 5 + /// The unique sid that identifies this account + /// Issues experienced during the call + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, + int? qualityScore, + string pathAccountSid = null, + List issue = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackOptions(pathCallSid, qualityScore) { PathAccountSid = pathAccountSid, Issue = issue }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFeedbackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Feedback.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a Feedback resource for a call + /// + /// Update Feedback parameters + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Update(UpdateFeedbackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a Feedback resource for a call + /// + /// Update Feedback parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFeedbackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a Feedback resource for a call + /// + /// The call sid that uniquely identifies the call + /// The unique sid that identifies this account + /// The call quality expressed as an integer from 1 to 5 + /// Issues experienced during the call + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Update(string pathCallSid, + string pathAccountSid = null, + int? qualityScore = null, + List issue = null, + ITwilioRestClient client = null) + { + var options = new UpdateFeedbackOptions(pathCallSid) { PathAccountSid = pathAccountSid, QualityScore = qualityScore, Issue = issue }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a Feedback resource for a call + /// + /// The call sid that uniquely identifies the call + /// The unique sid that identifies this account + /// The call quality expressed as an integer from 1 to 5 + /// Issues experienced during the call + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, + string pathAccountSid = null, + int? qualityScore = null, + List issue = null, + ITwilioRestClient client = null) + { + var options = new UpdateFeedbackOptions(pathCallSid) { PathAccountSid = pathAccountSid, QualityScore = qualityScore, Issue = issue }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FeedbackResource object + /// + /// Raw JSON string + /// FeedbackResource object represented by the provided JSON + public static FeedbackResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique sid that identifies this account + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Issues experienced during the call + /// + [JsonProperty("issues")] + [JsonConverter(typeof(StringEnumConverter))] + public List Issues { get; private set; } + /// + /// 1 to 5 quality score + /// + [JsonProperty("quality_score")] + public int? QualityScore { get; private set; } + /// + /// A string that uniquely identifies this feedback resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + + private FeedbackResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryOptions.cs index f704a826f..b4d6e804b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryOptions.cs @@ -9,148 +9,148 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// Create a FeedbackSummary resource for a call + /// + public class CreateFeedbackSummaryOptions : IOptions + { /// - /// Create a FeedbackSummary resource for a call - /// - public class CreateFeedbackSummaryOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// Only include feedback given on or after this date - /// - public DateTime? StartDate { get; } - /// - /// Only include feedback given on or before this date - /// - public DateTime? EndDate { get; } - /// - /// `true` includes feedback from the specified account and its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - /// - /// The URL that we will request when the feedback summary is complete - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we use to make requests to the StatusCallback URL - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Construct a new CreateFeedbackSummaryOptions - /// - /// Only include feedback given on or after this date - /// Only include feedback given on or before this date - public CreateFeedbackSummaryOptions(DateTime? startDate, DateTime? endDate) - { - StartDate = startDate; - EndDate = endDate; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - return p; - } - } - + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } /// - /// Fetch a FeedbackSummary resource from a call - /// - public class FetchFeedbackSummaryOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies this feedback summary resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFeedbackSummaryOptions - /// - /// A string that uniquely identifies this feedback summary resource - public FetchFeedbackSummaryOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Only include feedback given on or after this date + /// + public DateTime? StartDate { get; } /// - /// Delete a FeedbackSummary resource from a call - /// - public class DeleteFeedbackSummaryOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies this feedback summary resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFeedbackSummaryOptions - /// - /// A string that uniquely identifies this feedback summary resource - public DeleteFeedbackSummaryOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Only include feedback given on or before this date + /// + public DateTime? EndDate { get; } + /// + /// `true` includes feedback from the specified account and its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + /// + /// The URL that we will request when the feedback summary is complete + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we use to make requests to the StatusCallback URL + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Construct a new CreateFeedbackSummaryOptions + /// + /// Only include feedback given on or after this date + /// Only include feedback given on or before this date + public CreateFeedbackSummaryOptions(DateTime? startDate, DateTime? endDate) + { + StartDate = startDate; + EndDate = endDate; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + return p; + } + } + + /// + /// Fetch a FeedbackSummary resource from a call + /// + public class FetchFeedbackSummaryOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that uniquely identifies this feedback summary resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFeedbackSummaryOptions + /// + /// A string that uniquely identifies this feedback summary resource + public FetchFeedbackSummaryOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a FeedbackSummary resource from a call + /// + public class DeleteFeedbackSummaryOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that uniquely identifies this feedback summary resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFeedbackSummaryOptions + /// + /// A string that uniquely identifies this feedback summary resource + public DeleteFeedbackSummaryOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryResource.cs index 38359522e..b2dcf23da 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackSummaryResource.cs @@ -17,349 +17,349 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class FeedbackSummaryResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - private static Request BuildCreateRequest(CreateFeedbackSummaryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a FeedbackSummary resource for a call - /// - /// Create FeedbackSummary parameters - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static FeedbackSummaryResource Create(CreateFeedbackSummaryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a FeedbackSummary resource for a call - /// - /// Create FeedbackSummary parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackSummaryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a FeedbackSummary resource for a call - /// - /// Only include feedback given on or after this date - /// Only include feedback given on or before this date - /// The unique sid that identifies this account - /// `true` includes feedback from the specified account and its subaccounts - /// The URL that we will request when the feedback summary is complete - /// The HTTP method we use to make requests to the StatusCallback URL - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static FeedbackSummaryResource Create(DateTime? startDate, - DateTime? endDate, - string pathAccountSid = null, - bool? includeSubaccounts = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackSummaryOptions(startDate, endDate){PathAccountSid = pathAccountSid, IncludeSubaccounts = includeSubaccounts, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a FeedbackSummary resource for a call - /// - /// Only include feedback given on or after this date - /// Only include feedback given on or before this date - /// The unique sid that identifies this account - /// `true` includes feedback from the specified account and its subaccounts - /// The URL that we will request when the feedback summary is complete - /// The HTTP method we use to make requests to the StatusCallback URL - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task CreateAsync(DateTime? startDate, - DateTime? endDate, - string pathAccountSid = null, - bool? includeSubaccounts = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackSummaryOptions(startDate, endDate){PathAccountSid = pathAccountSid, IncludeSubaccounts = includeSubaccounts, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchFeedbackSummaryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a FeedbackSummary resource from a call - /// - /// Fetch FeedbackSummary parameters - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static FeedbackSummaryResource Fetch(FetchFeedbackSummaryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a FeedbackSummary resource from a call - /// - /// Fetch FeedbackSummary parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task FetchAsync(FetchFeedbackSummaryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a FeedbackSummary resource from a call - /// - /// A string that uniquely identifies this feedback summary resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static FeedbackSummaryResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchFeedbackSummaryOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a FeedbackSummary resource from a call - /// - /// A string that uniquely identifies this feedback summary resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchFeedbackSummaryOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFeedbackSummaryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a FeedbackSummary resource from a call - /// - /// Delete FeedbackSummary parameters - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static bool Delete(DeleteFeedbackSummaryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a FeedbackSummary resource from a call - /// - /// Delete FeedbackSummary parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFeedbackSummaryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a FeedbackSummary resource from a call - /// - /// A string that uniquely identifies this feedback summary resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of FeedbackSummary - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteFeedbackSummaryOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a FeedbackSummary resource from a call - /// - /// A string that uniquely identifies this feedback summary resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FeedbackSummary - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteFeedbackSummaryOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FeedbackSummaryResource object - /// - /// Raw JSON string - /// FeedbackSummaryResource object represented by the provided JSON - public static FeedbackSummaryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique sid that identifies this account - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The total number of calls - /// - [JsonProperty("call_count")] - public int? CallCount { get; private set; } - /// - /// The total number of calls with a feedback entry - /// - [JsonProperty("call_feedback_count")] - public int? CallFeedbackCount { get; private set; } - /// - /// The date this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The latest feedback entry date in the summary - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// Whether the feedback summary includes subaccounts - /// - [JsonProperty("include_subaccounts")] - public bool? IncludeSubaccounts { get; private set; } - /// - /// Issues experienced during the call - /// - [JsonProperty("issues")] - public List Issues { get; private set; } - /// - /// The average QualityScore of the feedback entries - /// - [JsonProperty("quality_score_average")] - public decimal? QualityScoreAverage { get; private set; } - /// - /// The median QualityScore of the feedback entries - /// - [JsonProperty("quality_score_median")] - public decimal? QualityScoreMedian { get; private set; } - /// - /// The standard deviation of the quality scores - /// - [JsonProperty("quality_score_standard_deviation")] - public decimal? QualityScoreStandardDeviation { get; private set; } - /// - /// A string that uniquely identifies this feedback entry - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The earliest feedback entry date in the summary - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// The status of the feedback summary - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FeedbackSummaryResource.StatusEnum Status { get; private set; } - - private FeedbackSummaryResource() - { - - } - } +{ + + public class FeedbackSummaryResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + private static Request BuildCreateRequest(CreateFeedbackSummaryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a FeedbackSummary resource for a call + /// + /// Create FeedbackSummary parameters + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static FeedbackSummaryResource Create(CreateFeedbackSummaryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a FeedbackSummary resource for a call + /// + /// Create FeedbackSummary parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackSummaryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a FeedbackSummary resource for a call + /// + /// Only include feedback given on or after this date + /// Only include feedback given on or before this date + /// The unique sid that identifies this account + /// `true` includes feedback from the specified account and its subaccounts + /// The URL that we will request when the feedback summary is complete + /// The HTTP method we use to make requests to the StatusCallback URL + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static FeedbackSummaryResource Create(DateTime? startDate, + DateTime? endDate, + string pathAccountSid = null, + bool? includeSubaccounts = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackSummaryOptions(startDate, endDate) { PathAccountSid = pathAccountSid, IncludeSubaccounts = includeSubaccounts, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a FeedbackSummary resource for a call + /// + /// Only include feedback given on or after this date + /// Only include feedback given on or before this date + /// The unique sid that identifies this account + /// `true` includes feedback from the specified account and its subaccounts + /// The URL that we will request when the feedback summary is complete + /// The HTTP method we use to make requests to the StatusCallback URL + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task CreateAsync(DateTime? startDate, + DateTime? endDate, + string pathAccountSid = null, + bool? includeSubaccounts = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackSummaryOptions(startDate, endDate) { PathAccountSid = pathAccountSid, IncludeSubaccounts = includeSubaccounts, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchFeedbackSummaryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a FeedbackSummary resource from a call + /// + /// Fetch FeedbackSummary parameters + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static FeedbackSummaryResource Fetch(FetchFeedbackSummaryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a FeedbackSummary resource from a call + /// + /// Fetch FeedbackSummary parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task FetchAsync(FetchFeedbackSummaryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a FeedbackSummary resource from a call + /// + /// A string that uniquely identifies this feedback summary resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static FeedbackSummaryResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchFeedbackSummaryOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a FeedbackSummary resource from a call + /// + /// A string that uniquely identifies this feedback summary resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchFeedbackSummaryOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFeedbackSummaryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/FeedbackSummary/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a FeedbackSummary resource from a call + /// + /// Delete FeedbackSummary parameters + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static bool Delete(DeleteFeedbackSummaryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a FeedbackSummary resource from a call + /// + /// Delete FeedbackSummary parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFeedbackSummaryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a FeedbackSummary resource from a call + /// + /// A string that uniquely identifies this feedback summary resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of FeedbackSummary + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteFeedbackSummaryOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a FeedbackSummary resource from a call + /// + /// A string that uniquely identifies this feedback summary resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FeedbackSummary + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteFeedbackSummaryOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FeedbackSummaryResource object + /// + /// Raw JSON string + /// FeedbackSummaryResource object represented by the provided JSON + public static FeedbackSummaryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique sid that identifies this account + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The total number of calls + /// + [JsonProperty("call_count")] + public int? CallCount { get; private set; } + /// + /// The total number of calls with a feedback entry + /// + [JsonProperty("call_feedback_count")] + public int? CallFeedbackCount { get; private set; } + /// + /// The date this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The latest feedback entry date in the summary + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// Whether the feedback summary includes subaccounts + /// + [JsonProperty("include_subaccounts")] + public bool? IncludeSubaccounts { get; private set; } + /// + /// Issues experienced during the call + /// + [JsonProperty("issues")] + public List Issues { get; private set; } + /// + /// The average QualityScore of the feedback entries + /// + [JsonProperty("quality_score_average")] + public decimal? QualityScoreAverage { get; private set; } + /// + /// The median QualityScore of the feedback entries + /// + [JsonProperty("quality_score_median")] + public decimal? QualityScoreMedian { get; private set; } + /// + /// The standard deviation of the quality scores + /// + [JsonProperty("quality_score_standard_deviation")] + public decimal? QualityScoreStandardDeviation { get; private set; } + /// + /// A string that uniquely identifies this feedback entry + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The earliest feedback entry date in the summary + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// The status of the feedback summary + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FeedbackSummaryResource.StatusEnum Status { get; private set; } + + private FeedbackSummaryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/NotificationOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/NotificationOptions.cs index 54a69c7b1..906b290b7 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/NotificationOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/NotificationOptions.cs @@ -9,121 +9,121 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// FetchNotificationOptions + /// + public class FetchNotificationOptions : IOptions + { /// - /// FetchNotificationOptions + /// The SID of the Account that created the resource to fetch /// - public class FetchNotificationOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resource to fetch - /// - public string PathCallSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchNotificationOptions - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - public FetchNotificationOptions(string pathCallSid, string pathSid) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// ReadNotificationOptions + /// The Call SID of the resource to fetch /// - public class ReadNotificationOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resources to read - /// - public string PathCallSid { get; } - /// - /// Filter by log level - /// - public int? Log { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDateBefore { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDate { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDateAfter { get; set; } - - /// - /// Construct a new ReadNotificationOptions - /// - /// The Call SID of the resources to read - public ReadNotificationOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Log != null) - { - p.Add(new KeyValuePair("Log", Log.ToString())); - } - - if (MessageDate != null) - { - p.Add(new KeyValuePair("MessageDate", MessageDate.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (MessageDateBefore != null) - { - p.Add(new KeyValuePair("MessageDate<", MessageDateBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (MessageDateAfter != null) - { - p.Add(new KeyValuePair("MessageDate>", MessageDateAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathCallSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchNotificationOptions + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + public FetchNotificationOptions(string pathCallSid, string pathSid) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadNotificationOptions + /// + public class ReadNotificationOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The Call SID of the resources to read + /// + public string PathCallSid { get; } + /// + /// Filter by log level + /// + public int? Log { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDateBefore { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDate { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDateAfter { get; set; } + + /// + /// Construct a new ReadNotificationOptions + /// + /// The Call SID of the resources to read + public ReadNotificationOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Log != null) + { + p.Add(new KeyValuePair("Log", Log.ToString())); + } + + if (MessageDate != null) + { + p.Add(new KeyValuePair("MessageDate", MessageDate.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (MessageDateBefore != null) + { + p.Add(new KeyValuePair("MessageDate<", MessageDateBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (MessageDateAfter != null) + { + p.Add(new KeyValuePair("MessageDate>", MessageDateAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/NotificationResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/NotificationResource.cs index 3e81cd26c..2dde89e6d 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/NotificationResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/NotificationResource.cs @@ -16,349 +16,349 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class NotificationResource : Resource - { - private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Notifications/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Notifications.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static ResourceSet Read(ReadNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("notifications", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task> ReadAsync(ReadNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("notifications", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The Call SID of the resources to read - /// The SID of the Account that created the resources to read - /// Filter by log level - /// Filter by date - /// Filter by date - /// Filter by date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Notification - public static ResourceSet Read(string pathCallSid, - string pathAccountSid = null, - int? log = null, - DateTime? messageDateBefore = null, - DateTime? messageDate = null, - DateTime? messageDateAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNotificationOptions(pathCallSid){PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The Call SID of the resources to read - /// The SID of the Account that created the resources to read - /// Filter by log level - /// Filter by date - /// Filter by date - /// Filter by date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, - string pathAccountSid = null, - int? log = null, - DateTime? messageDateBefore = null, - DateTime? messageDate = null, - DateTime? messageDateAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNotificationOptions(pathCallSid){PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Converts a JSON string into a NotificationResource object - /// - /// Raw JSON string - /// NotificationResource object represented by the provided JSON - public static NotificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the Call Notification resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A unique error code corresponding to the notification - /// - [JsonProperty("error_code")] - public string ErrorCode { get; private set; } - /// - /// An integer log level - /// - [JsonProperty("log")] - public string Log { get; private set; } - /// - /// The date the notification was generated - /// - [JsonProperty("message_date")] - public DateTime? MessageDate { get; private set; } - /// - /// The text of the notification - /// - [JsonProperty("message_text")] - public string MessageText { get; private set; } - /// - /// A URL for more information about the error code - /// - [JsonProperty("more_info")] - public Uri MoreInfo { get; private set; } - /// - /// HTTP method used with the request url - /// - [JsonProperty("request_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod RequestMethod { get; private set; } - /// - /// URL of the resource that generated the notification - /// - [JsonProperty("request_url")] - public Uri RequestUrl { get; private set; } - /// - /// Twilio-generated HTTP variables sent to the server - /// - [JsonProperty("request_variables")] - public string RequestVariables { get; private set; } - /// - /// The HTTP body returned by your server - /// - [JsonProperty("response_body")] - public string ResponseBody { get; private set; } - /// - /// The HTTP headers returned by your server - /// - [JsonProperty("response_headers")] - public string ResponseHeaders { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private NotificationResource() - { - - } - } +{ + + public class NotificationResource : Resource + { + private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Notifications/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Notifications.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static ResourceSet Read(ReadNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("notifications", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task> ReadAsync(ReadNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("notifications", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The Call SID of the resources to read + /// The SID of the Account that created the resources to read + /// Filter by log level + /// Filter by date + /// Filter by date + /// Filter by date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Notification + public static ResourceSet Read(string pathCallSid, + string pathAccountSid = null, + int? log = null, + DateTime? messageDateBefore = null, + DateTime? messageDate = null, + DateTime? messageDateAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNotificationOptions(pathCallSid) { PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The Call SID of the resources to read + /// The SID of the Account that created the resources to read + /// Filter by log level + /// Filter by date + /// Filter by date + /// Filter by date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, + string pathAccountSid = null, + int? log = null, + DateTime? messageDateBefore = null, + DateTime? messageDate = null, + DateTime? messageDateAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNotificationOptions(pathCallSid) { PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Converts a JSON string into a NotificationResource object + /// + /// Raw JSON string + /// NotificationResource object represented by the provided JSON + public static NotificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the Call Notification resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A unique error code corresponding to the notification + /// + [JsonProperty("error_code")] + public string ErrorCode { get; private set; } + /// + /// An integer log level + /// + [JsonProperty("log")] + public string Log { get; private set; } + /// + /// The date the notification was generated + /// + [JsonProperty("message_date")] + public DateTime? MessageDate { get; private set; } + /// + /// The text of the notification + /// + [JsonProperty("message_text")] + public string MessageText { get; private set; } + /// + /// A URL for more information about the error code + /// + [JsonProperty("more_info")] + public Uri MoreInfo { get; private set; } + /// + /// HTTP method used with the request url + /// + [JsonProperty("request_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod RequestMethod { get; private set; } + /// + /// URL of the resource that generated the notification + /// + [JsonProperty("request_url")] + public Uri RequestUrl { get; private set; } + /// + /// Twilio-generated HTTP variables sent to the server + /// + [JsonProperty("request_variables")] + public string RequestVariables { get; private set; } + /// + /// The HTTP body returned by your server + /// + [JsonProperty("response_body")] + public string ResponseBody { get; private set; } + /// + /// The HTTP headers returned by your server + /// + [JsonProperty("response_headers")] + public string ResponseHeaders { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private NotificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/PaymentOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/PaymentOptions.cs index 034cec96a..b2613c394 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/PaymentOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/PaymentOptions.cs @@ -9,276 +9,276 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// create an instance of payments. This will start a new payments session + /// + public class CreatePaymentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// create an instance of payments. This will start a new payments session + /// The SID of the Account that will create the resource /// - public class CreatePaymentOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the call that will create the resource. - /// - public string PathCallSid { get; } - /// - /// A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. - /// - public string IdempotencyKey { get; } - /// - /// Provide an absolute or relative URL to receive status updates regarding your Pay session.. - /// - public Uri StatusCallback { get; } - /// - /// Type of bank account if payment source is ACH. - /// - public PaymentResource.BankAccountTypeEnum BankAccountType { get; set; } - /// - /// A positive decimal value less than 1,000,000 to charge against the credit card or bank account. - /// - public decimal? ChargeAmount { get; set; } - /// - /// The currency of the `charge_amount`. - /// - public string Currency { get; set; } - /// - /// The description can be used to provide more details regarding the transaction. - /// - public string Description { get; set; } - /// - /// A list of inputs that should be accepted. Currently only `dtmf` is supported. - /// - public string Input { get; set; } - /// - /// A positive integer that is used to validate the length of the `PostalCode` inputted by the user. - /// - public int? MinPostalCodeLength { get; set; } - /// - /// A single level JSON string that is required when accepting certain information specific only to ACH payments. - /// - public object Parameter { get; set; } - /// - /// This is the unique name corresponding to the Payment Gateway Connector installed in the Twilio Add-ons. - /// - public string PaymentConnector { get; set; } - /// - /// Type of payment being captured. - /// - public PaymentResource.PaymentMethodEnum PaymentMethod { get; set; } - /// - /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment information that must be provided by the caller. - /// - public bool? PostalCode { get; set; } - /// - /// Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. - /// - public bool? SecurityCode { get; set; } - /// - /// The number of seconds that should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. - /// - public int? Timeout { get; set; } - /// - /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` token. - /// - public PaymentResource.TokenTypeEnum TokenType { get; set; } - /// - /// Credit card types separated by space that Pay should accept. - /// - public string ValidCardTypes { get; set; } - - /// - /// Construct a new CreatePaymentOptions - /// - /// The SID of the call that will create the resource. - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session.. - public CreatePaymentOptions(string pathCallSid, string idempotencyKey, Uri statusCallback) - { - PathCallSid = pathCallSid; - IdempotencyKey = idempotencyKey; - StatusCallback = statusCallback; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IdempotencyKey != null) - { - p.Add(new KeyValuePair("IdempotencyKey", IdempotencyKey)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (BankAccountType != null) - { - p.Add(new KeyValuePair("BankAccountType", BankAccountType.ToString())); - } - - if (ChargeAmount != null) - { - p.Add(new KeyValuePair("ChargeAmount", ChargeAmount.Value.ToString())); - } - - if (Currency != null) - { - p.Add(new KeyValuePair("Currency", Currency)); - } - - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (Input != null) - { - p.Add(new KeyValuePair("Input", Input)); - } - - if (MinPostalCodeLength != null) - { - p.Add(new KeyValuePair("MinPostalCodeLength", MinPostalCodeLength.ToString())); - } - - if (Parameter != null) - { - p.Add(new KeyValuePair("Parameter", Serializers.JsonObject(Parameter))); - } - - if (PaymentConnector != null) - { - p.Add(new KeyValuePair("PaymentConnector", PaymentConnector)); - } - - if (PaymentMethod != null) - { - p.Add(new KeyValuePair("PaymentMethod", PaymentMethod.ToString())); - } - - if (PostalCode != null) - { - p.Add(new KeyValuePair("PostalCode", PostalCode.Value.ToString().ToLower())); - } - - if (SecurityCode != null) - { - p.Add(new KeyValuePair("SecurityCode", SecurityCode.Value.ToString().ToLower())); - } - - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (TokenType != null) - { - p.Add(new KeyValuePair("TokenType", TokenType.ToString())); - } - - if (ValidCardTypes != null) - { - p.Add(new KeyValuePair("ValidCardTypes", ValidCardTypes)); - } - - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// update an instance of payments with different phases of payment flows. + /// The SID of the call that will create the resource. /// - public class UpdatePaymentOptions : IOptions - { - /// - /// The SID of the Account that will update the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the call that will create the resource. - /// - public string PathCallSid { get; } - /// - /// The SID of Payments session - /// - public string PathSid { get; } - /// - /// A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. - /// - public string IdempotencyKey { get; } - /// - /// Provide an absolute or relative URL to receive status updates regarding your Pay session. - /// - public Uri StatusCallback { get; } - /// - /// The piece of payment information that you wish the caller to enter. - /// - public PaymentResource.CaptureEnum Capture { get; set; } - /// - /// Indicates whether the current payment session should be cancelled or completed. - /// - public PaymentResource.StatusEnum Status { get; set; } - - /// - /// Construct a new UpdatePaymentOptions - /// - /// The SID of the call that will create the resource. - /// The SID of Payments session - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session. - public UpdatePaymentOptions(string pathCallSid, string pathSid, string idempotencyKey, Uri statusCallback) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - IdempotencyKey = idempotencyKey; - StatusCallback = statusCallback; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IdempotencyKey != null) - { - p.Add(new KeyValuePair("IdempotencyKey", IdempotencyKey)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (Capture != null) - { - p.Add(new KeyValuePair("Capture", Capture.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + public string PathCallSid { get; } + /// + /// A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. + /// + public string IdempotencyKey { get; } + /// + /// Provide an absolute or relative URL to receive status updates regarding your Pay session.. + /// + public Uri StatusCallback { get; } + /// + /// Type of bank account if payment source is ACH. + /// + public PaymentResource.BankAccountTypeEnum BankAccountType { get; set; } + /// + /// A positive decimal value less than 1,000,000 to charge against the credit card or bank account. + /// + public decimal? ChargeAmount { get; set; } + /// + /// The currency of the `charge_amount`. + /// + public string Currency { get; set; } + /// + /// The description can be used to provide more details regarding the transaction. + /// + public string Description { get; set; } + /// + /// A list of inputs that should be accepted. Currently only `dtmf` is supported. + /// + public string Input { get; set; } + /// + /// A positive integer that is used to validate the length of the `PostalCode` inputted by the user. + /// + public int? MinPostalCodeLength { get; set; } + /// + /// A single level JSON string that is required when accepting certain information specific only to ACH payments. + /// + public object Parameter { get; set; } + /// + /// This is the unique name corresponding to the Payment Gateway Connector installed in the Twilio Add-ons. + /// + public string PaymentConnector { get; set; } + /// + /// Type of payment being captured. + /// + public PaymentResource.PaymentMethodEnum PaymentMethod { get; set; } + /// + /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment information that must be provided by the caller. + /// + public bool? PostalCode { get; set; } + /// + /// Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. + /// + public bool? SecurityCode { get; set; } + /// + /// The number of seconds that should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. + /// + public int? Timeout { get; set; } + /// + /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` token. + /// + public PaymentResource.TokenTypeEnum TokenType { get; set; } + /// + /// Credit card types separated by space that Pay should accept. + /// + public string ValidCardTypes { get; set; } + + /// + /// Construct a new CreatePaymentOptions + /// + /// The SID of the call that will create the resource. + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session.. + public CreatePaymentOptions(string pathCallSid, string idempotencyKey, Uri statusCallback) + { + PathCallSid = pathCallSid; + IdempotencyKey = idempotencyKey; + StatusCallback = statusCallback; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IdempotencyKey != null) + { + p.Add(new KeyValuePair("IdempotencyKey", IdempotencyKey)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (BankAccountType != null) + { + p.Add(new KeyValuePair("BankAccountType", BankAccountType.ToString())); + } + + if (ChargeAmount != null) + { + p.Add(new KeyValuePair("ChargeAmount", ChargeAmount.Value.ToString())); + } + + if (Currency != null) + { + p.Add(new KeyValuePair("Currency", Currency)); + } + + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (Input != null) + { + p.Add(new KeyValuePair("Input", Input)); + } + + if (MinPostalCodeLength != null) + { + p.Add(new KeyValuePair("MinPostalCodeLength", MinPostalCodeLength.ToString())); + } + + if (Parameter != null) + { + p.Add(new KeyValuePair("Parameter", Serializers.JsonObject(Parameter))); + } + + if (PaymentConnector != null) + { + p.Add(new KeyValuePair("PaymentConnector", PaymentConnector)); + } + + if (PaymentMethod != null) + { + p.Add(new KeyValuePair("PaymentMethod", PaymentMethod.ToString())); + } + + if (PostalCode != null) + { + p.Add(new KeyValuePair("PostalCode", PostalCode.Value.ToString().ToLower())); + } + + if (SecurityCode != null) + { + p.Add(new KeyValuePair("SecurityCode", SecurityCode.Value.ToString().ToLower())); + } + + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (TokenType != null) + { + p.Add(new KeyValuePair("TokenType", TokenType.ToString())); + } + + if (ValidCardTypes != null) + { + p.Add(new KeyValuePair("ValidCardTypes", ValidCardTypes)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// update an instance of payments with different phases of payment flows. + /// + public class UpdatePaymentOptions : IOptions + { + /// + /// The SID of the Account that will update the resource + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the call that will create the resource. + /// + public string PathCallSid { get; } + /// + /// The SID of Payments session + /// + public string PathSid { get; } + /// + /// A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. + /// + public string IdempotencyKey { get; } + /// + /// Provide an absolute or relative URL to receive status updates regarding your Pay session. + /// + public Uri StatusCallback { get; } + /// + /// The piece of payment information that you wish the caller to enter. + /// + public PaymentResource.CaptureEnum Capture { get; set; } + /// + /// Indicates whether the current payment session should be cancelled or completed. + /// + public PaymentResource.StatusEnum Status { get; set; } + + /// + /// Construct a new UpdatePaymentOptions + /// + /// The SID of the call that will create the resource. + /// The SID of Payments session + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session. + public UpdatePaymentOptions(string pathCallSid, string pathSid, string idempotencyKey, Uri statusCallback) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + IdempotencyKey = idempotencyKey; + StatusCallback = statusCallback; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IdempotencyKey != null) + { + p.Add(new KeyValuePair("IdempotencyKey", IdempotencyKey)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (Capture != null) + { + p.Add(new KeyValuePair("Capture", Capture.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/PaymentResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/PaymentResource.cs index 631fa1557..396cacadf 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/PaymentResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/PaymentResource.cs @@ -20,385 +20,385 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class PaymentResource : Resource - { - public sealed class PaymentMethodEnum : StringEnum - { - private PaymentMethodEnum(string value) : base(value) {} - public PaymentMethodEnum() {} - public static implicit operator PaymentMethodEnum(string value) - { - return new PaymentMethodEnum(value); - } - - public static readonly PaymentMethodEnum CreditCard = new PaymentMethodEnum("credit-card"); - public static readonly PaymentMethodEnum AchDebit = new PaymentMethodEnum("ach-debit"); - } - - public sealed class BankAccountTypeEnum : StringEnum - { - private BankAccountTypeEnum(string value) : base(value) {} - public BankAccountTypeEnum() {} - public static implicit operator BankAccountTypeEnum(string value) - { - return new BankAccountTypeEnum(value); - } - - public static readonly BankAccountTypeEnum ConsumerChecking = new BankAccountTypeEnum("consumer-checking"); - public static readonly BankAccountTypeEnum ConsumerSavings = new BankAccountTypeEnum("consumer-savings"); - public static readonly BankAccountTypeEnum CommercialChecking = new BankAccountTypeEnum("commercial-checking"); - } - - public sealed class TokenTypeEnum : StringEnum - { - private TokenTypeEnum(string value) : base(value) {} - public TokenTypeEnum() {} - public static implicit operator TokenTypeEnum(string value) - { - return new TokenTypeEnum(value); - } - - public static readonly TokenTypeEnum OneTime = new TokenTypeEnum("one-time"); - public static readonly TokenTypeEnum Reusable = new TokenTypeEnum("reusable"); - } - - public sealed class CaptureEnum : StringEnum - { - private CaptureEnum(string value) : base(value) {} - public CaptureEnum() {} - public static implicit operator CaptureEnum(string value) - { - return new CaptureEnum(value); - } - - public static readonly CaptureEnum PaymentCardNumber = new CaptureEnum("payment-card-number"); - public static readonly CaptureEnum ExpirationDate = new CaptureEnum("expiration-date"); - public static readonly CaptureEnum SecurityCode = new CaptureEnum("security-code"); - public static readonly CaptureEnum PostalCode = new CaptureEnum("postal-code"); - public static readonly CaptureEnum BankRoutingNumber = new CaptureEnum("bank-routing-number"); - public static readonly CaptureEnum BankAccountNumber = new CaptureEnum("bank-account-number"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Complete = new StatusEnum("complete"); - public static readonly StatusEnum Cancel = new StatusEnum("cancel"); - } - - private static Request BuildCreateRequest(CreatePaymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Payments.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create an instance of payments. This will start a new payments session - /// - /// Create Payment parameters - /// Client to make requests to Twilio - /// A single instance of Payment - public static PaymentResource Create(CreatePaymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create an instance of payments. This will start a new payments session - /// - /// Create Payment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payment - public static async System.Threading.Tasks.Task CreateAsync(CreatePaymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create an instance of payments. This will start a new payments session - /// - /// The SID of the call that will create the resource. - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session.. - /// The SID of the Account that will create the resource - /// Type of bank account if payment source is ACH. - /// A positive decimal value less than 1,000,000 to charge against the credit card or bank - /// account. - /// The currency of the `charge_amount`. - /// The description can be used to provide more details regarding the transaction. - /// A list of inputs that should be accepted. Currently only `dtmf` is supported. - /// A positive integer that is used to validate the length of the `PostalCode` - /// inputted by the user. - /// A single level JSON string that is required when accepting certain information specific - /// only to ACH payments. - /// This is the unique name corresponding to the Payment Gateway Connector installed in - /// the Twilio Add-ons. - /// Type of payment being captured. - /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment - /// information that must be provided by the caller. - /// Indicates whether the credit card security code is a required piece of payment - /// information that must be provided by the caller. - /// The number of seconds that should wait for the caller to press a digit between each - /// subsequent digit, after the first one, before moving on to validate the digits captured. - /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` - /// token. - /// Credit card types separated by space that Pay should accept. - /// Client to make requests to Twilio - /// A single instance of Payment - public static PaymentResource Create(string pathCallSid, - string idempotencyKey, - Uri statusCallback, - string pathAccountSid = null, - PaymentResource.BankAccountTypeEnum bankAccountType = null, - decimal? chargeAmount = null, - string currency = null, - string description = null, - string input = null, - int? minPostalCodeLength = null, - object parameter = null, - string paymentConnector = null, - PaymentResource.PaymentMethodEnum paymentMethod = null, - bool? postalCode = null, - bool? securityCode = null, - int? timeout = null, - PaymentResource.TokenTypeEnum tokenType = null, - string validCardTypes = null, - ITwilioRestClient client = null) - { - var options = new CreatePaymentOptions(pathCallSid, idempotencyKey, statusCallback){PathAccountSid = pathAccountSid, BankAccountType = bankAccountType, ChargeAmount = chargeAmount, Currency = currency, Description = description, Input = input, MinPostalCodeLength = minPostalCodeLength, Parameter = parameter, PaymentConnector = paymentConnector, PaymentMethod = paymentMethod, PostalCode = postalCode, SecurityCode = securityCode, Timeout = timeout, TokenType = tokenType, ValidCardTypes = validCardTypes}; - return Create(options, client); - } - - #if !NET35 - /// - /// create an instance of payments. This will start a new payments session - /// - /// The SID of the call that will create the resource. - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session.. - /// The SID of the Account that will create the resource - /// Type of bank account if payment source is ACH. - /// A positive decimal value less than 1,000,000 to charge against the credit card or bank - /// account. - /// The currency of the `charge_amount`. - /// The description can be used to provide more details regarding the transaction. - /// A list of inputs that should be accepted. Currently only `dtmf` is supported. - /// A positive integer that is used to validate the length of the `PostalCode` - /// inputted by the user. - /// A single level JSON string that is required when accepting certain information specific - /// only to ACH payments. - /// This is the unique name corresponding to the Payment Gateway Connector installed in - /// the Twilio Add-ons. - /// Type of payment being captured. - /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment - /// information that must be provided by the caller. - /// Indicates whether the credit card security code is a required piece of payment - /// information that must be provided by the caller. - /// The number of seconds that should wait for the caller to press a digit between each - /// subsequent digit, after the first one, before moving on to validate the digits captured. - /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` - /// token. - /// Credit card types separated by space that Pay should accept. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payment - public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, - string idempotencyKey, - Uri statusCallback, - string pathAccountSid = null, - PaymentResource.BankAccountTypeEnum bankAccountType = null, - decimal? chargeAmount = null, - string currency = null, - string description = null, - string input = null, - int? minPostalCodeLength = null, - object parameter = null, - string paymentConnector = null, - PaymentResource.PaymentMethodEnum paymentMethod = null, - bool? postalCode = null, - bool? securityCode = null, - int? timeout = null, - PaymentResource.TokenTypeEnum tokenType = null, - string validCardTypes = null, - ITwilioRestClient client = null) - { - var options = new CreatePaymentOptions(pathCallSid, idempotencyKey, statusCallback){PathAccountSid = pathAccountSid, BankAccountType = bankAccountType, ChargeAmount = chargeAmount, Currency = currency, Description = description, Input = input, MinPostalCodeLength = minPostalCodeLength, Parameter = parameter, PaymentConnector = paymentConnector, PaymentMethod = paymentMethod, PostalCode = postalCode, SecurityCode = securityCode, Timeout = timeout, TokenType = tokenType, ValidCardTypes = validCardTypes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdatePaymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Payments/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update an instance of payments with different phases of payment flows. - /// - /// Update Payment parameters - /// Client to make requests to Twilio - /// A single instance of Payment - public static PaymentResource Update(UpdatePaymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update an instance of payments with different phases of payment flows. - /// - /// Update Payment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payment - public static async System.Threading.Tasks.Task UpdateAsync(UpdatePaymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update an instance of payments with different phases of payment flows. - /// - /// The SID of the call that will create the resource. - /// The SID of Payments session - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session. - /// The SID of the Account that will update the resource - /// The piece of payment information that you wish the caller to enter. - /// Indicates whether the current payment session should be cancelled or completed. - /// Client to make requests to Twilio - /// A single instance of Payment - public static PaymentResource Update(string pathCallSid, - string pathSid, - string idempotencyKey, - Uri statusCallback, - string pathAccountSid = null, - PaymentResource.CaptureEnum capture = null, - PaymentResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdatePaymentOptions(pathCallSid, pathSid, idempotencyKey, statusCallback){PathAccountSid = pathAccountSid, Capture = capture, Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// update an instance of payments with different phases of payment flows. - /// - /// The SID of the call that will create the resource. - /// The SID of Payments session - /// A unique token that will be used to ensure that multiple API calls with the same - /// information do not result in multiple transactions. - /// Provide an absolute or relative URL to receive status updates regarding your Pay - /// session. - /// The SID of the Account that will update the resource - /// The piece of payment information that you wish the caller to enter. - /// Indicates whether the current payment session should be cancelled or completed. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payment - public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, - string pathSid, - string idempotencyKey, - Uri statusCallback, - string pathAccountSid = null, - PaymentResource.CaptureEnum capture = null, - PaymentResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdatePaymentOptions(pathCallSid, pathSid, idempotencyKey, statusCallback){PathAccountSid = pathAccountSid, Capture = capture, Status = status}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PaymentResource object - /// - /// Raw JSON string - /// PaymentResource object represented by the provided JSON - public static PaymentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the Payments resource. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Call the resource is associated with. - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The SID of the Payments resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private PaymentResource() - { - - } - } +{ + + public class PaymentResource : Resource + { + public sealed class PaymentMethodEnum : StringEnum + { + private PaymentMethodEnum(string value) : base(value) { } + public PaymentMethodEnum() { } + public static implicit operator PaymentMethodEnum(string value) + { + return new PaymentMethodEnum(value); + } + + public static readonly PaymentMethodEnum CreditCard = new PaymentMethodEnum("credit-card"); + public static readonly PaymentMethodEnum AchDebit = new PaymentMethodEnum("ach-debit"); + } + + public sealed class BankAccountTypeEnum : StringEnum + { + private BankAccountTypeEnum(string value) : base(value) { } + public BankAccountTypeEnum() { } + public static implicit operator BankAccountTypeEnum(string value) + { + return new BankAccountTypeEnum(value); + } + + public static readonly BankAccountTypeEnum ConsumerChecking = new BankAccountTypeEnum("consumer-checking"); + public static readonly BankAccountTypeEnum ConsumerSavings = new BankAccountTypeEnum("consumer-savings"); + public static readonly BankAccountTypeEnum CommercialChecking = new BankAccountTypeEnum("commercial-checking"); + } + + public sealed class TokenTypeEnum : StringEnum + { + private TokenTypeEnum(string value) : base(value) { } + public TokenTypeEnum() { } + public static implicit operator TokenTypeEnum(string value) + { + return new TokenTypeEnum(value); + } + + public static readonly TokenTypeEnum OneTime = new TokenTypeEnum("one-time"); + public static readonly TokenTypeEnum Reusable = new TokenTypeEnum("reusable"); + } + + public sealed class CaptureEnum : StringEnum + { + private CaptureEnum(string value) : base(value) { } + public CaptureEnum() { } + public static implicit operator CaptureEnum(string value) + { + return new CaptureEnum(value); + } + + public static readonly CaptureEnum PaymentCardNumber = new CaptureEnum("payment-card-number"); + public static readonly CaptureEnum ExpirationDate = new CaptureEnum("expiration-date"); + public static readonly CaptureEnum SecurityCode = new CaptureEnum("security-code"); + public static readonly CaptureEnum PostalCode = new CaptureEnum("postal-code"); + public static readonly CaptureEnum BankRoutingNumber = new CaptureEnum("bank-routing-number"); + public static readonly CaptureEnum BankAccountNumber = new CaptureEnum("bank-account-number"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Complete = new StatusEnum("complete"); + public static readonly StatusEnum Cancel = new StatusEnum("cancel"); + } + + private static Request BuildCreateRequest(CreatePaymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Payments.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create an instance of payments. This will start a new payments session + /// + /// Create Payment parameters + /// Client to make requests to Twilio + /// A single instance of Payment + public static PaymentResource Create(CreatePaymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create an instance of payments. This will start a new payments session + /// + /// Create Payment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payment + public static async System.Threading.Tasks.Task CreateAsync(CreatePaymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create an instance of payments. This will start a new payments session + /// + /// The SID of the call that will create the resource. + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session.. + /// The SID of the Account that will create the resource + /// Type of bank account if payment source is ACH. + /// A positive decimal value less than 1,000,000 to charge against the credit card or bank + /// account. + /// The currency of the `charge_amount`. + /// The description can be used to provide more details regarding the transaction. + /// A list of inputs that should be accepted. Currently only `dtmf` is supported. + /// A positive integer that is used to validate the length of the `PostalCode` + /// inputted by the user. + /// A single level JSON string that is required when accepting certain information specific + /// only to ACH payments. + /// This is the unique name corresponding to the Payment Gateway Connector installed in + /// the Twilio Add-ons. + /// Type of payment being captured. + /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment + /// information that must be provided by the caller. + /// Indicates whether the credit card security code is a required piece of payment + /// information that must be provided by the caller. + /// The number of seconds that should wait for the caller to press a digit between each + /// subsequent digit, after the first one, before moving on to validate the digits captured. + /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` + /// token. + /// Credit card types separated by space that Pay should accept. + /// Client to make requests to Twilio + /// A single instance of Payment + public static PaymentResource Create(string pathCallSid, + string idempotencyKey, + Uri statusCallback, + string pathAccountSid = null, + PaymentResource.BankAccountTypeEnum bankAccountType = null, + decimal? chargeAmount = null, + string currency = null, + string description = null, + string input = null, + int? minPostalCodeLength = null, + object parameter = null, + string paymentConnector = null, + PaymentResource.PaymentMethodEnum paymentMethod = null, + bool? postalCode = null, + bool? securityCode = null, + int? timeout = null, + PaymentResource.TokenTypeEnum tokenType = null, + string validCardTypes = null, + ITwilioRestClient client = null) + { + var options = new CreatePaymentOptions(pathCallSid, idempotencyKey, statusCallback) { PathAccountSid = pathAccountSid, BankAccountType = bankAccountType, ChargeAmount = chargeAmount, Currency = currency, Description = description, Input = input, MinPostalCodeLength = minPostalCodeLength, Parameter = parameter, PaymentConnector = paymentConnector, PaymentMethod = paymentMethod, PostalCode = postalCode, SecurityCode = securityCode, Timeout = timeout, TokenType = tokenType, ValidCardTypes = validCardTypes }; + return Create(options, client); + } + +#if !NET35 + /// + /// create an instance of payments. This will start a new payments session + /// + /// The SID of the call that will create the resource. + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session.. + /// The SID of the Account that will create the resource + /// Type of bank account if payment source is ACH. + /// A positive decimal value less than 1,000,000 to charge against the credit card or bank + /// account. + /// The currency of the `charge_amount`. + /// The description can be used to provide more details regarding the transaction. + /// A list of inputs that should be accepted. Currently only `dtmf` is supported. + /// A positive integer that is used to validate the length of the `PostalCode` + /// inputted by the user. + /// A single level JSON string that is required when accepting certain information specific + /// only to ACH payments. + /// This is the unique name corresponding to the Payment Gateway Connector installed in + /// the Twilio Add-ons. + /// Type of payment being captured. + /// Indicates whether the credit card PostalCode (zip code) is a required piece of payment + /// information that must be provided by the caller. + /// Indicates whether the credit card security code is a required piece of payment + /// information that must be provided by the caller. + /// The number of seconds that should wait for the caller to press a digit between each + /// subsequent digit, after the first one, before moving on to validate the digits captured. + /// Indicates whether the payment method should be tokenized as a `one-time` or `reusable` + /// token. + /// Credit card types separated by space that Pay should accept. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payment + public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, + string idempotencyKey, + Uri statusCallback, + string pathAccountSid = null, + PaymentResource.BankAccountTypeEnum bankAccountType = null, + decimal? chargeAmount = null, + string currency = null, + string description = null, + string input = null, + int? minPostalCodeLength = null, + object parameter = null, + string paymentConnector = null, + PaymentResource.PaymentMethodEnum paymentMethod = null, + bool? postalCode = null, + bool? securityCode = null, + int? timeout = null, + PaymentResource.TokenTypeEnum tokenType = null, + string validCardTypes = null, + ITwilioRestClient client = null) + { + var options = new CreatePaymentOptions(pathCallSid, idempotencyKey, statusCallback) { PathAccountSid = pathAccountSid, BankAccountType = bankAccountType, ChargeAmount = chargeAmount, Currency = currency, Description = description, Input = input, MinPostalCodeLength = minPostalCodeLength, Parameter = parameter, PaymentConnector = paymentConnector, PaymentMethod = paymentMethod, PostalCode = postalCode, SecurityCode = securityCode, Timeout = timeout, TokenType = tokenType, ValidCardTypes = validCardTypes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdatePaymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Payments/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update an instance of payments with different phases of payment flows. + /// + /// Update Payment parameters + /// Client to make requests to Twilio + /// A single instance of Payment + public static PaymentResource Update(UpdatePaymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update an instance of payments with different phases of payment flows. + /// + /// Update Payment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payment + public static async System.Threading.Tasks.Task UpdateAsync(UpdatePaymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update an instance of payments with different phases of payment flows. + /// + /// The SID of the call that will create the resource. + /// The SID of Payments session + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session. + /// The SID of the Account that will update the resource + /// The piece of payment information that you wish the caller to enter. + /// Indicates whether the current payment session should be cancelled or completed. + /// Client to make requests to Twilio + /// A single instance of Payment + public static PaymentResource Update(string pathCallSid, + string pathSid, + string idempotencyKey, + Uri statusCallback, + string pathAccountSid = null, + PaymentResource.CaptureEnum capture = null, + PaymentResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdatePaymentOptions(pathCallSid, pathSid, idempotencyKey, statusCallback) { PathAccountSid = pathAccountSid, Capture = capture, Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// update an instance of payments with different phases of payment flows. + /// + /// The SID of the call that will create the resource. + /// The SID of Payments session + /// A unique token that will be used to ensure that multiple API calls with the same + /// information do not result in multiple transactions. + /// Provide an absolute or relative URL to receive status updates regarding your Pay + /// session. + /// The SID of the Account that will update the resource + /// The piece of payment information that you wish the caller to enter. + /// Indicates whether the current payment session should be cancelled or completed. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payment + public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, + string pathSid, + string idempotencyKey, + Uri statusCallback, + string pathAccountSid = null, + PaymentResource.CaptureEnum capture = null, + PaymentResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdatePaymentOptions(pathCallSid, pathSid, idempotencyKey, statusCallback) { PathAccountSid = pathAccountSid, Capture = capture, Status = status }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PaymentResource object + /// + /// Raw JSON string + /// PaymentResource object represented by the provided JSON + public static PaymentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the Payments resource. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Call the resource is associated with. + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The SID of the Payments resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private PaymentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/RecordingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/RecordingOptions.cs index 14f4d22fe..a910748b1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/RecordingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/RecordingOptions.cs @@ -10,299 +10,299 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// Create a recording for the call + /// + public class CreateRecordingOptions : IOptions + { /// - /// Create a recording for the call - /// - public class CreateRecordingOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Call to associate the resource with - /// - public string PathCallSid { get; } - /// - /// The recording status changes that should generate a callback - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// The callback URL on each selected recording event - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use to call `recording_status_callback` - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// Whether to trim the silence in the recording - /// - public string Trim { get; set; } - /// - /// The number of channels that the output recording will be configured with - /// - public string RecordingChannels { get; set; } - /// - /// Which track(s) to record - /// - public string RecordingTrack { get; set; } - - /// - /// Construct a new CreateRecordingOptions - /// - /// The SID of the Call to associate the resource with - public CreateRecordingOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - RecordingStatusCallbackEvent = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RecordingStatusCallbackEvent != null) - { - p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); - } - - if (RecordingStatusCallback != null) - { - p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); - } - - if (RecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim)); - } - - if (RecordingChannels != null) - { - p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); - } - - if (RecordingTrack != null) - { - p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of - /// recording sid to reference current active recording. - /// - public class UpdateRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to update - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resource to update - /// - public string PathCallSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The new status of the recording - /// - public RecordingResource.StatusEnum Status { get; } - /// - /// Whether to record or not during the pause period. - /// - public string PauseBehavior { get; set; } - - /// - /// Construct a new UpdateRecordingOptions - /// - /// The Call SID of the resource to update - /// The unique string that identifies the resource - /// The new status of the recording - public UpdateRecordingOptions(string pathCallSid, string pathSid, RecordingResource.StatusEnum status) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PauseBehavior != null) - { - p.Add(new KeyValuePair("PauseBehavior", PauseBehavior)); - } - - return p; - } - } - + /// The SID of the Call to associate the resource with + /// + public string PathCallSid { get; } /// - /// Fetch an instance of a recording for a call - /// - public class FetchRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resource to fetch - /// - public string PathCallSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRecordingOptions - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - public FetchRecordingOptions(string pathCallSid, string pathSid) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The recording status changes that should generate a callback + /// + public List RecordingStatusCallbackEvent { get; set; } /// - /// Delete a recording from your account - /// - public class DeleteRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resources to delete - /// - public string PathCallSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRecordingOptions - /// - /// The Call SID of the resources to delete - /// The unique string that identifies the resource - public DeleteRecordingOptions(string pathCallSid, string pathSid) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The callback URL on each selected recording event + /// + public Uri RecordingStatusCallback { get; set; } /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - public class ReadRecordingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The Call SID of the resources to read - /// - public string PathCallSid { get; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreated { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedAfter { get; set; } - - /// - /// Construct a new ReadRecordingOptions - /// - /// The Call SID of the resources to read - public ReadRecordingOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The HTTP method we should use to call `recording_status_callback` + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// Whether to trim the silence in the recording + /// + public string Trim { get; set; } + /// + /// The number of channels that the output recording will be configured with + /// + public string RecordingChannels { get; set; } + /// + /// Which track(s) to record + /// + public string RecordingTrack { get; set; } + + /// + /// Construct a new CreateRecordingOptions + /// + /// The SID of the Call to associate the resource with + public CreateRecordingOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + RecordingStatusCallbackEvent = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RecordingStatusCallbackEvent != null) + { + p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); + } + + if (RecordingStatusCallback != null) + { + p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); + } + + if (RecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim)); + } + + if (RecordingChannels != null) + { + p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); + } + + if (RecordingTrack != null) + { + p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); + } + + return p; + } + } + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of + /// recording sid to reference current active recording. + /// + public class UpdateRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to update + /// + public string PathAccountSid { get; set; } + /// + /// The Call SID of the resource to update + /// + public string PathCallSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The new status of the recording + /// + public RecordingResource.StatusEnum Status { get; } + /// + /// Whether to record or not during the pause period. + /// + public string PauseBehavior { get; set; } + + /// + /// Construct a new UpdateRecordingOptions + /// + /// The Call SID of the resource to update + /// The unique string that identifies the resource + /// The new status of the recording + public UpdateRecordingOptions(string pathCallSid, string pathSid, RecordingResource.StatusEnum status) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PauseBehavior != null) + { + p.Add(new KeyValuePair("PauseBehavior", PauseBehavior)); + } + + return p; + } + } + + /// + /// Fetch an instance of a recording for a call + /// + public class FetchRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The Call SID of the resource to fetch + /// + public string PathCallSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRecordingOptions + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + public FetchRecordingOptions(string pathCallSid, string pathSid) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a recording from your account + /// + public class DeleteRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The Call SID of the resources to delete + /// + public string PathCallSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRecordingOptions + /// + /// The Call SID of the resources to delete + /// The unique string that identifies the resource + public DeleteRecordingOptions(string pathCallSid, string pathSid) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + public class ReadRecordingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The Call SID of the resources to read + /// + public string PathCallSid { get; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreated { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedAfter { get; set; } + + /// + /// Construct a new ReadRecordingOptions + /// + /// The Call SID of the resources to read + public ReadRecordingOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/RecordingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/RecordingResource.cs index 4663e1e91..203a0daf4 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/RecordingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/RecordingResource.cs @@ -17,647 +17,647 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class RecordingResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Paused = new StatusEnum("paused"); - public static readonly StatusEnum Stopped = new StatusEnum("stopped"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Absent = new StatusEnum("absent"); - } - - public sealed class SourceEnum : StringEnum - { - private SourceEnum(string value) : base(value) {} - public SourceEnum() {} - public static implicit operator SourceEnum(string value) - { - return new SourceEnum(value); - } - - public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); - public static readonly SourceEnum Conference = new SourceEnum("Conference"); - public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); - public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); - public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); - public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); - public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); - } - - private static Request BuildCreateRequest(CreateRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a recording for the call - /// - /// Create Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Create(CreateRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a recording for the call - /// - /// Create Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task CreateAsync(CreateRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a recording for the call - /// - /// The SID of the Call to associate the resource with - /// The SID of the Account that will create the resource - /// The recording status changes that should generate a callback - /// The callback URL on each selected recording event - /// The HTTP method we should use to call `recording_status_callback` - /// - /// Whether to trim the silence in the recording - /// The number of channels that the output recording will be configured with - /// Which track(s) to record - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Create(string pathCallSid, - string pathAccountSid = null, - List recordingStatusCallbackEvent = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string trim = null, - string recordingChannels = null, - string recordingTrack = null, - ITwilioRestClient client = null) - { - var options = new CreateRecordingOptions(pathCallSid){PathAccountSid = pathAccountSid, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, Trim = trim, RecordingChannels = recordingChannels, RecordingTrack = recordingTrack}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a recording for the call - /// - /// The SID of the Call to associate the resource with - /// The SID of the Account that will create the resource - /// The recording status changes that should generate a callback - /// The callback URL on each selected recording event - /// The HTTP method we should use to call `recording_status_callback` - /// - /// Whether to trim the silence in the recording - /// The number of channels that the output recording will be configured with - /// Which track(s) to record - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, - string pathAccountSid = null, - List recordingStatusCallbackEvent = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string trim = null, - string recordingChannels = null, - string recordingTrack = null, - ITwilioRestClient client = null) - { - var options = new CreateRecordingOptions(pathCallSid){PathAccountSid = pathAccountSid, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, Trim = trim, RecordingChannels = recordingChannels, RecordingTrack = recordingTrack}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of - /// recording sid to reference current active recording. - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of - /// recording sid to reference current active recording. - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of - /// recording sid to reference current active recording. - /// - /// The Call SID of the resource to update - /// The unique string that identifies the resource - /// The new status of the recording - /// The SID of the Account that created the resource to update - /// Whether to record or not during the pause period. - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(string pathCallSid, - string pathSid, - RecordingResource.StatusEnum status, - string pathAccountSid = null, - string pauseBehavior = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathCallSid, pathSid, status){PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior}; - return Update(options, client); - } - - #if !NET35 - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of - /// recording sid to reference current active recording. - /// - /// The Call SID of the resource to update - /// The unique string that identifies the resource - /// The new status of the recording - /// The SID of the Account that created the resource to update - /// Whether to record or not during the pause period. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, - string pathSid, - RecordingResource.StatusEnum status, - string pathAccountSid = null, - string pauseBehavior = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathCallSid, pathSid, status){PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a recording for a call - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a recording for a call - /// - /// The Call SID of the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a recording from your account - /// - /// The Call SID of the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// The Call SID of the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(string pathCallSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathCallSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// The Call SID of the resources to read - /// The SID of the Account that created the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(string pathCallSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(pathCallSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// The Call SID of the resources to read - /// The SID of the Account that created the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(pathCallSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Converts a JSON string into a RecordingResource object - /// - /// Raw JSON string - /// RecordingResource object represented by the provided JSON - public static RecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to make the recording - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The Conference SID that identifies the conference associated with the recording - /// - [JsonProperty("conference_sid")] - public string ConferenceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The start time of the recording, given in RFC 2822 format - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The length of the recording in seconds - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The one-time cost of creating the recording. - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// How to decrypt the recording. - /// - [JsonProperty("encryption_details")] - public object EncryptionDetails { get; private set; } - /// - /// The currency used in the price property. - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The status of the recording - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.StatusEnum Status { get; private set; } - /// - /// The number of channels in the final recording file - /// - [JsonProperty("channels")] - public int? Channels { get; private set; } - /// - /// How the recording was created - /// - [JsonProperty("source")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.SourceEnum Source { get; private set; } - /// - /// More information about why the recording is missing, if status is `absent`. - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// The recorded track. Can be: `inbound`, `outbound`, or `both`. - /// - [JsonProperty("track")] - public string Track { get; private set; } - - private RecordingResource() - { - - } - } +{ + + public class RecordingResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Paused = new StatusEnum("paused"); + public static readonly StatusEnum Stopped = new StatusEnum("stopped"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Absent = new StatusEnum("absent"); + } + + public sealed class SourceEnum : StringEnum + { + private SourceEnum(string value) : base(value) { } + public SourceEnum() { } + public static implicit operator SourceEnum(string value) + { + return new SourceEnum(value); + } + + public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); + public static readonly SourceEnum Conference = new SourceEnum("Conference"); + public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); + public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); + public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); + public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); + public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); + } + + private static Request BuildCreateRequest(CreateRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a recording for the call + /// + /// Create Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Create(CreateRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a recording for the call + /// + /// Create Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task CreateAsync(CreateRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a recording for the call + /// + /// The SID of the Call to associate the resource with + /// The SID of the Account that will create the resource + /// The recording status changes that should generate a callback + /// The callback URL on each selected recording event + /// The HTTP method we should use to call `recording_status_callback` + /// + /// Whether to trim the silence in the recording + /// The number of channels that the output recording will be configured with + /// Which track(s) to record + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Create(string pathCallSid, + string pathAccountSid = null, + List recordingStatusCallbackEvent = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string trim = null, + string recordingChannels = null, + string recordingTrack = null, + ITwilioRestClient client = null) + { + var options = new CreateRecordingOptions(pathCallSid) { PathAccountSid = pathAccountSid, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, Trim = trim, RecordingChannels = recordingChannels, RecordingTrack = recordingTrack }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a recording for the call + /// + /// The SID of the Call to associate the resource with + /// The SID of the Account that will create the resource + /// The recording status changes that should generate a callback + /// The callback URL on each selected recording event + /// The HTTP method we should use to call `recording_status_callback` + /// + /// Whether to trim the silence in the recording + /// The number of channels that the output recording will be configured with + /// Which track(s) to record + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, + string pathAccountSid = null, + List recordingStatusCallbackEvent = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string trim = null, + string recordingChannels = null, + string recordingTrack = null, + ITwilioRestClient client = null) + { + var options = new CreateRecordingOptions(pathCallSid) { PathAccountSid = pathAccountSid, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, Trim = trim, RecordingChannels = recordingChannels, RecordingTrack = recordingTrack }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of + /// recording sid to reference current active recording. + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of + /// recording sid to reference current active recording. + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of + /// recording sid to reference current active recording. + /// + /// The Call SID of the resource to update + /// The unique string that identifies the resource + /// The new status of the recording + /// The SID of the Account that created the resource to update + /// Whether to record or not during the pause period. + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(string pathCallSid, + string pathSid, + RecordingResource.StatusEnum status, + string pathAccountSid = null, + string pauseBehavior = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathCallSid, pathSid, status) { PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior }; + return Update(options, client); + } + +#if !NET35 + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: Pass `Twilio.CURRENT` instead of + /// recording sid to reference current active recording. + /// + /// The Call SID of the resource to update + /// The unique string that identifies the resource + /// The new status of the recording + /// The SID of the Account that created the resource to update + /// Whether to record or not during the pause period. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, + string pathSid, + RecordingResource.StatusEnum status, + string pathAccountSid = null, + string pauseBehavior = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathCallSid, pathSid, status) { PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a recording for a call + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a recording for a call + /// + /// The Call SID of the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a recording from your account + /// + /// The Call SID of the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// The Call SID of the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(string pathCallSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathCallSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Recordings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// The Call SID of the resources to read + /// The SID of the Account that created the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(string pathCallSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions(pathCallSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// The Call SID of the resources to read + /// The SID of the Account that created the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions(pathCallSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Converts a JSON string into a RecordingResource object + /// + /// Raw JSON string + /// RecordingResource object represented by the provided JSON + public static RecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to make the recording + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The Conference SID that identifies the conference associated with the recording + /// + [JsonProperty("conference_sid")] + public string ConferenceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The start time of the recording, given in RFC 2822 format + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The length of the recording in seconds + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The one-time cost of creating the recording. + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// How to decrypt the recording. + /// + [JsonProperty("encryption_details")] + public object EncryptionDetails { get; private set; } + /// + /// The currency used in the price property. + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The status of the recording + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.StatusEnum Status { get; private set; } + /// + /// The number of channels in the final recording file + /// + [JsonProperty("channels")] + public int? Channels { get; private set; } + /// + /// How the recording was created + /// + [JsonProperty("source")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.SourceEnum Source { get; private set; } + /// + /// More information about why the recording is missing, if status is `absent`. + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// The recorded track. Can be: `inbound`, `outbound`, or `both`. + /// + [JsonProperty("track")] + public string Track { get; private set; } + + private RecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/SiprecOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Call/SiprecOptions.cs index 757caeaaa..d4a0115c4 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/SiprecOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/SiprecOptions.cs @@ -9,1916 +9,1916 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Call -{ - +{ + + /// + /// Create a Siprec + /// + public class CreateSiprecOptions : IOptions + { + /// + /// The SID of the Account that created this resource + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Call the resource is associated with + /// + public string PathCallSid { get; } + /// + /// The name of this resource + /// + public string Name { get; set; } + /// + /// Unique name used when configuring the connector via Marketplace Add-on. + /// + public string ConnectorName { get; set; } + /// + /// One of `inbound_track`, `outbound_track`, `both_tracks`. + /// + public SiprecResource.TrackEnum Track { get; set; } + /// + /// Absolute URL of the status callback. + /// + public Uri StatusCallback { get; set; } + /// + /// The http method for the status_callback. + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Parameter name + /// + public string Parameter1Name { get; set; } + /// + /// Parameter value + /// + public string Parameter1Value { get; set; } + /// + /// Parameter name + /// + public string Parameter2Name { get; set; } + /// + /// Parameter value + /// + public string Parameter2Value { get; set; } + /// + /// Parameter name + /// + public string Parameter3Name { get; set; } + /// + /// Parameter value + /// + public string Parameter3Value { get; set; } + /// + /// Parameter name + /// + public string Parameter4Name { get; set; } + /// + /// Parameter value + /// + public string Parameter4Value { get; set; } + /// + /// Parameter name + /// + public string Parameter5Name { get; set; } + /// + /// Parameter value + /// + public string Parameter5Value { get; set; } + /// + /// Parameter name + /// + public string Parameter6Name { get; set; } + /// + /// Parameter value + /// + public string Parameter6Value { get; set; } + /// + /// Parameter name + /// + public string Parameter7Name { get; set; } + /// + /// Parameter value + /// + public string Parameter7Value { get; set; } + /// + /// Parameter name + /// + public string Parameter8Name { get; set; } + /// + /// Parameter value + /// + public string Parameter8Value { get; set; } + /// + /// Parameter name + /// + public string Parameter9Name { get; set; } + /// + /// Parameter value + /// + public string Parameter9Value { get; set; } + /// + /// Parameter name + /// + public string Parameter10Name { get; set; } + /// + /// Parameter value + /// + public string Parameter10Value { get; set; } + /// + /// Parameter name + /// + public string Parameter11Name { get; set; } + /// + /// Parameter value + /// + public string Parameter11Value { get; set; } + /// + /// Parameter name + /// + public string Parameter12Name { get; set; } + /// + /// Parameter value + /// + public string Parameter12Value { get; set; } + /// + /// Parameter name + /// + public string Parameter13Name { get; set; } + /// + /// Parameter value + /// + public string Parameter13Value { get; set; } + /// + /// Parameter name + /// + public string Parameter14Name { get; set; } + /// + /// Parameter value + /// + public string Parameter14Value { get; set; } + /// + /// Parameter name + /// + public string Parameter15Name { get; set; } + /// + /// Parameter value + /// + public string Parameter15Value { get; set; } + /// + /// Parameter name + /// + public string Parameter16Name { get; set; } + /// + /// Parameter value + /// + public string Parameter16Value { get; set; } + /// + /// Parameter name + /// + public string Parameter17Name { get; set; } + /// + /// Parameter value + /// + public string Parameter17Value { get; set; } + /// + /// Parameter name + /// + public string Parameter18Name { get; set; } + /// + /// Parameter value + /// + public string Parameter18Value { get; set; } + /// + /// Parameter name + /// + public string Parameter19Name { get; set; } + /// + /// Parameter value + /// + public string Parameter19Value { get; set; } + /// + /// Parameter name + /// + public string Parameter20Name { get; set; } + /// + /// Parameter value + /// + public string Parameter20Value { get; set; } + /// + /// Parameter name + /// + public string Parameter21Name { get; set; } + /// + /// Parameter value + /// + public string Parameter21Value { get; set; } + /// + /// Parameter name + /// + public string Parameter22Name { get; set; } + /// + /// Parameter value + /// + public string Parameter22Value { get; set; } + /// + /// Parameter name + /// + public string Parameter23Name { get; set; } + /// + /// Parameter value + /// + public string Parameter23Value { get; set; } + /// + /// Parameter name + /// + public string Parameter24Name { get; set; } + /// + /// Parameter value + /// + public string Parameter24Value { get; set; } + /// + /// Parameter name + /// + public string Parameter25Name { get; set; } + /// + /// Parameter value + /// + public string Parameter25Value { get; set; } + /// + /// Parameter name + /// + public string Parameter26Name { get; set; } + /// + /// Parameter value + /// + public string Parameter26Value { get; set; } + /// + /// Parameter name + /// + public string Parameter27Name { get; set; } + /// + /// Parameter value + /// + public string Parameter27Value { get; set; } + /// + /// Parameter name + /// + public string Parameter28Name { get; set; } + /// + /// Parameter value + /// + public string Parameter28Value { get; set; } + /// + /// Parameter name + /// + public string Parameter29Name { get; set; } + /// + /// Parameter value + /// + public string Parameter29Value { get; set; } + /// + /// Parameter name + /// + public string Parameter30Name { get; set; } + /// + /// Parameter value + /// + public string Parameter30Value { get; set; } + /// + /// Parameter name + /// + public string Parameter31Name { get; set; } + /// + /// Parameter value + /// + public string Parameter31Value { get; set; } + /// + /// Parameter name + /// + public string Parameter32Name { get; set; } + /// + /// Parameter value + /// + public string Parameter32Value { get; set; } + /// + /// Parameter name + /// + public string Parameter33Name { get; set; } + /// + /// Parameter value + /// + public string Parameter33Value { get; set; } + /// + /// Parameter name + /// + public string Parameter34Name { get; set; } + /// + /// Parameter value + /// + public string Parameter34Value { get; set; } + /// + /// Parameter name + /// + public string Parameter35Name { get; set; } + /// + /// Parameter value + /// + public string Parameter35Value { get; set; } + /// + /// Parameter name + /// + public string Parameter36Name { get; set; } + /// + /// Parameter value + /// + public string Parameter36Value { get; set; } + /// + /// Parameter name + /// + public string Parameter37Name { get; set; } + /// + /// Parameter value + /// + public string Parameter37Value { get; set; } + /// + /// Parameter name + /// + public string Parameter38Name { get; set; } + /// + /// Parameter value + /// + public string Parameter38Value { get; set; } + /// + /// Parameter name + /// + public string Parameter39Name { get; set; } + /// + /// Parameter value + /// + public string Parameter39Value { get; set; } + /// + /// Parameter name + /// + public string Parameter40Name { get; set; } + /// + /// Parameter value + /// + public string Parameter40Value { get; set; } + /// + /// Parameter name + /// + public string Parameter41Name { get; set; } + /// + /// Parameter value + /// + public string Parameter41Value { get; set; } + /// + /// Parameter name + /// + public string Parameter42Name { get; set; } + /// + /// Parameter value + /// + public string Parameter42Value { get; set; } + /// + /// Parameter name + /// + public string Parameter43Name { get; set; } + /// + /// Parameter value + /// + public string Parameter43Value { get; set; } + /// + /// Parameter name + /// + public string Parameter44Name { get; set; } + /// + /// Parameter value + /// + public string Parameter44Value { get; set; } + /// + /// Parameter name + /// + public string Parameter45Name { get; set; } + /// + /// Parameter value + /// + public string Parameter45Value { get; set; } + /// + /// Parameter name + /// + public string Parameter46Name { get; set; } + /// + /// Parameter value + /// + public string Parameter46Value { get; set; } + /// + /// Parameter name + /// + public string Parameter47Name { get; set; } + /// + /// Parameter value + /// + public string Parameter47Value { get; set; } + /// + /// Parameter name + /// + public string Parameter48Name { get; set; } + /// + /// Parameter value + /// + public string Parameter48Value { get; set; } + /// + /// Parameter name + /// + public string Parameter49Name { get; set; } + /// + /// Parameter value + /// + public string Parameter49Value { get; set; } + /// + /// Parameter name + /// + public string Parameter50Name { get; set; } + /// + /// Parameter value + /// + public string Parameter50Value { get; set; } + /// + /// Parameter name + /// + public string Parameter51Name { get; set; } + /// + /// Parameter value + /// + public string Parameter51Value { get; set; } + /// + /// Parameter name + /// + public string Parameter52Name { get; set; } + /// + /// Parameter value + /// + public string Parameter52Value { get; set; } + /// + /// Parameter name + /// + public string Parameter53Name { get; set; } + /// + /// Parameter value + /// + public string Parameter53Value { get; set; } + /// + /// Parameter name + /// + public string Parameter54Name { get; set; } + /// + /// Parameter value + /// + public string Parameter54Value { get; set; } + /// + /// Parameter name + /// + public string Parameter55Name { get; set; } + /// + /// Parameter value + /// + public string Parameter55Value { get; set; } + /// + /// Parameter name + /// + public string Parameter56Name { get; set; } + /// + /// Parameter value + /// + public string Parameter56Value { get; set; } + /// + /// Parameter name + /// + public string Parameter57Name { get; set; } + /// + /// Parameter value + /// + public string Parameter57Value { get; set; } + /// + /// Parameter name + /// + public string Parameter58Name { get; set; } + /// + /// Parameter value + /// + public string Parameter58Value { get; set; } + /// + /// Parameter name + /// + public string Parameter59Name { get; set; } + /// + /// Parameter value + /// + public string Parameter59Value { get; set; } + /// + /// Parameter name + /// + public string Parameter60Name { get; set; } + /// + /// Parameter value + /// + public string Parameter60Value { get; set; } + /// + /// Parameter name + /// + public string Parameter61Name { get; set; } + /// + /// Parameter value + /// + public string Parameter61Value { get; set; } + /// + /// Parameter name + /// + public string Parameter62Name { get; set; } + /// + /// Parameter value + /// + public string Parameter62Value { get; set; } + /// + /// Parameter name + /// + public string Parameter63Name { get; set; } + /// + /// Parameter value + /// + public string Parameter63Value { get; set; } + /// + /// Parameter name + /// + public string Parameter64Name { get; set; } + /// + /// Parameter value + /// + public string Parameter64Value { get; set; } + /// + /// Parameter name + /// + public string Parameter65Name { get; set; } + /// + /// Parameter value + /// + public string Parameter65Value { get; set; } + /// + /// Parameter name + /// + public string Parameter66Name { get; set; } + /// + /// Parameter value + /// + public string Parameter66Value { get; set; } + /// + /// Parameter name + /// + public string Parameter67Name { get; set; } + /// + /// Parameter value + /// + public string Parameter67Value { get; set; } + /// + /// Parameter name + /// + public string Parameter68Name { get; set; } + /// + /// Parameter value + /// + public string Parameter68Value { get; set; } + /// + /// Parameter name + /// + public string Parameter69Name { get; set; } + /// + /// Parameter value + /// + public string Parameter69Value { get; set; } + /// + /// Parameter name + /// + public string Parameter70Name { get; set; } + /// + /// Parameter value + /// + public string Parameter70Value { get; set; } + /// + /// Parameter name + /// + public string Parameter71Name { get; set; } + /// + /// Parameter value + /// + public string Parameter71Value { get; set; } + /// + /// Parameter name + /// + public string Parameter72Name { get; set; } + /// + /// Parameter value + /// + public string Parameter72Value { get; set; } + /// + /// Parameter name + /// + public string Parameter73Name { get; set; } + /// + /// Parameter value + /// + public string Parameter73Value { get; set; } + /// + /// Parameter name + /// + public string Parameter74Name { get; set; } + /// + /// Parameter value + /// + public string Parameter74Value { get; set; } + /// + /// Parameter name + /// + public string Parameter75Name { get; set; } + /// + /// Parameter value + /// + public string Parameter75Value { get; set; } + /// + /// Parameter name + /// + public string Parameter76Name { get; set; } + /// + /// Parameter value + /// + public string Parameter76Value { get; set; } + /// + /// Parameter name + /// + public string Parameter77Name { get; set; } + /// + /// Parameter value + /// + public string Parameter77Value { get; set; } + /// + /// Parameter name + /// + public string Parameter78Name { get; set; } + /// + /// Parameter value + /// + public string Parameter78Value { get; set; } + /// + /// Parameter name + /// + public string Parameter79Name { get; set; } + /// + /// Parameter value + /// + public string Parameter79Value { get; set; } + /// + /// Parameter name + /// + public string Parameter80Name { get; set; } + /// + /// Parameter value + /// + public string Parameter80Value { get; set; } + /// + /// Parameter name + /// + public string Parameter81Name { get; set; } + /// + /// Parameter value + /// + public string Parameter81Value { get; set; } + /// + /// Parameter name + /// + public string Parameter82Name { get; set; } + /// + /// Parameter value + /// + public string Parameter82Value { get; set; } + /// + /// Parameter name + /// + public string Parameter83Name { get; set; } + /// + /// Parameter value + /// + public string Parameter83Value { get; set; } + /// + /// Parameter name + /// + public string Parameter84Name { get; set; } + /// + /// Parameter value + /// + public string Parameter84Value { get; set; } + /// + /// Parameter name + /// + public string Parameter85Name { get; set; } + /// + /// Parameter value + /// + public string Parameter85Value { get; set; } + /// + /// Parameter name + /// + public string Parameter86Name { get; set; } + /// + /// Parameter value + /// + public string Parameter86Value { get; set; } + /// + /// Parameter name + /// + public string Parameter87Name { get; set; } + /// + /// Parameter value + /// + public string Parameter87Value { get; set; } + /// + /// Parameter name + /// + public string Parameter88Name { get; set; } + /// + /// Parameter value + /// + public string Parameter88Value { get; set; } + /// + /// Parameter name + /// + public string Parameter89Name { get; set; } + /// + /// Parameter value + /// + public string Parameter89Value { get; set; } + /// + /// Parameter name + /// + public string Parameter90Name { get; set; } + /// + /// Parameter value + /// + public string Parameter90Value { get; set; } + /// + /// Parameter name + /// + public string Parameter91Name { get; set; } + /// + /// Parameter value + /// + public string Parameter91Value { get; set; } /// - /// Create a Siprec - /// - public class CreateSiprecOptions : IOptions - { - /// - /// The SID of the Account that created this resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Call the resource is associated with - /// - public string PathCallSid { get; } - /// - /// The name of this resource - /// - public string Name { get; set; } - /// - /// Unique name used when configuring the connector via Marketplace Add-on. - /// - public string ConnectorName { get; set; } - /// - /// One of `inbound_track`, `outbound_track`, `both_tracks`. - /// - public SiprecResource.TrackEnum Track { get; set; } - /// - /// Absolute URL of the status callback. - /// - public Uri StatusCallback { get; set; } - /// - /// The http method for the status_callback. - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Parameter name - /// - public string Parameter1Name { get; set; } - /// - /// Parameter value - /// - public string Parameter1Value { get; set; } - /// - /// Parameter name - /// - public string Parameter2Name { get; set; } - /// - /// Parameter value - /// - public string Parameter2Value { get; set; } - /// - /// Parameter name - /// - public string Parameter3Name { get; set; } - /// - /// Parameter value - /// - public string Parameter3Value { get; set; } - /// - /// Parameter name - /// - public string Parameter4Name { get; set; } - /// - /// Parameter value - /// - public string Parameter4Value { get; set; } - /// - /// Parameter name - /// - public string Parameter5Name { get; set; } - /// - /// Parameter value - /// - public string Parameter5Value { get; set; } - /// - /// Parameter name - /// - public string Parameter6Name { get; set; } - /// - /// Parameter value - /// - public string Parameter6Value { get; set; } - /// - /// Parameter name - /// - public string Parameter7Name { get; set; } - /// - /// Parameter value - /// - public string Parameter7Value { get; set; } - /// - /// Parameter name - /// - public string Parameter8Name { get; set; } - /// - /// Parameter value - /// - public string Parameter8Value { get; set; } - /// - /// Parameter name - /// - public string Parameter9Name { get; set; } - /// - /// Parameter value - /// - public string Parameter9Value { get; set; } - /// - /// Parameter name - /// - public string Parameter10Name { get; set; } - /// - /// Parameter value - /// - public string Parameter10Value { get; set; } - /// - /// Parameter name - /// - public string Parameter11Name { get; set; } - /// - /// Parameter value - /// - public string Parameter11Value { get; set; } - /// - /// Parameter name - /// - public string Parameter12Name { get; set; } - /// - /// Parameter value - /// - public string Parameter12Value { get; set; } - /// - /// Parameter name - /// - public string Parameter13Name { get; set; } - /// - /// Parameter value - /// - public string Parameter13Value { get; set; } - /// - /// Parameter name - /// - public string Parameter14Name { get; set; } - /// - /// Parameter value - /// - public string Parameter14Value { get; set; } - /// - /// Parameter name - /// - public string Parameter15Name { get; set; } - /// - /// Parameter value - /// - public string Parameter15Value { get; set; } - /// - /// Parameter name - /// - public string Parameter16Name { get; set; } - /// - /// Parameter value - /// - public string Parameter16Value { get; set; } - /// - /// Parameter name - /// - public string Parameter17Name { get; set; } - /// - /// Parameter value - /// - public string Parameter17Value { get; set; } - /// - /// Parameter name - /// - public string Parameter18Name { get; set; } - /// - /// Parameter value - /// - public string Parameter18Value { get; set; } - /// - /// Parameter name - /// - public string Parameter19Name { get; set; } - /// - /// Parameter value - /// - public string Parameter19Value { get; set; } - /// - /// Parameter name - /// - public string Parameter20Name { get; set; } - /// - /// Parameter value - /// - public string Parameter20Value { get; set; } - /// - /// Parameter name - /// - public string Parameter21Name { get; set; } - /// - /// Parameter value - /// - public string Parameter21Value { get; set; } - /// - /// Parameter name - /// - public string Parameter22Name { get; set; } - /// - /// Parameter value - /// - public string Parameter22Value { get; set; } - /// - /// Parameter name - /// - public string Parameter23Name { get; set; } - /// - /// Parameter value - /// - public string Parameter23Value { get; set; } - /// - /// Parameter name - /// - public string Parameter24Name { get; set; } - /// - /// Parameter value - /// - public string Parameter24Value { get; set; } - /// - /// Parameter name - /// - public string Parameter25Name { get; set; } - /// - /// Parameter value - /// - public string Parameter25Value { get; set; } - /// - /// Parameter name - /// - public string Parameter26Name { get; set; } - /// - /// Parameter value - /// - public string Parameter26Value { get; set; } - /// - /// Parameter name - /// - public string Parameter27Name { get; set; } - /// - /// Parameter value - /// - public string Parameter27Value { get; set; } - /// - /// Parameter name - /// - public string Parameter28Name { get; set; } - /// - /// Parameter value - /// - public string Parameter28Value { get; set; } - /// - /// Parameter name - /// - public string Parameter29Name { get; set; } - /// - /// Parameter value - /// - public string Parameter29Value { get; set; } - /// - /// Parameter name - /// - public string Parameter30Name { get; set; } - /// - /// Parameter value - /// - public string Parameter30Value { get; set; } - /// - /// Parameter name - /// - public string Parameter31Name { get; set; } - /// - /// Parameter value - /// - public string Parameter31Value { get; set; } - /// - /// Parameter name - /// - public string Parameter32Name { get; set; } - /// - /// Parameter value - /// - public string Parameter32Value { get; set; } - /// - /// Parameter name - /// - public string Parameter33Name { get; set; } - /// - /// Parameter value - /// - public string Parameter33Value { get; set; } - /// - /// Parameter name - /// - public string Parameter34Name { get; set; } - /// - /// Parameter value - /// - public string Parameter34Value { get; set; } - /// - /// Parameter name - /// - public string Parameter35Name { get; set; } - /// - /// Parameter value - /// - public string Parameter35Value { get; set; } - /// - /// Parameter name - /// - public string Parameter36Name { get; set; } - /// - /// Parameter value - /// - public string Parameter36Value { get; set; } - /// - /// Parameter name - /// - public string Parameter37Name { get; set; } - /// - /// Parameter value - /// - public string Parameter37Value { get; set; } - /// - /// Parameter name - /// - public string Parameter38Name { get; set; } - /// - /// Parameter value - /// - public string Parameter38Value { get; set; } - /// - /// Parameter name - /// - public string Parameter39Name { get; set; } - /// - /// Parameter value - /// - public string Parameter39Value { get; set; } - /// - /// Parameter name - /// - public string Parameter40Name { get; set; } - /// - /// Parameter value - /// - public string Parameter40Value { get; set; } - /// - /// Parameter name - /// - public string Parameter41Name { get; set; } - /// - /// Parameter value - /// - public string Parameter41Value { get; set; } - /// - /// Parameter name - /// - public string Parameter42Name { get; set; } - /// - /// Parameter value - /// - public string Parameter42Value { get; set; } - /// - /// Parameter name - /// - public string Parameter43Name { get; set; } - /// - /// Parameter value - /// - public string Parameter43Value { get; set; } - /// - /// Parameter name - /// - public string Parameter44Name { get; set; } - /// - /// Parameter value - /// - public string Parameter44Value { get; set; } - /// - /// Parameter name - /// - public string Parameter45Name { get; set; } - /// - /// Parameter value - /// - public string Parameter45Value { get; set; } - /// - /// Parameter name - /// - public string Parameter46Name { get; set; } - /// - /// Parameter value - /// - public string Parameter46Value { get; set; } - /// - /// Parameter name - /// - public string Parameter47Name { get; set; } - /// - /// Parameter value - /// - public string Parameter47Value { get; set; } - /// - /// Parameter name - /// - public string Parameter48Name { get; set; } - /// - /// Parameter value - /// - public string Parameter48Value { get; set; } - /// - /// Parameter name - /// - public string Parameter49Name { get; set; } - /// - /// Parameter value - /// - public string Parameter49Value { get; set; } - /// - /// Parameter name - /// - public string Parameter50Name { get; set; } - /// - /// Parameter value - /// - public string Parameter50Value { get; set; } - /// - /// Parameter name - /// - public string Parameter51Name { get; set; } - /// - /// Parameter value - /// - public string Parameter51Value { get; set; } - /// - /// Parameter name - /// - public string Parameter52Name { get; set; } - /// - /// Parameter value - /// - public string Parameter52Value { get; set; } - /// - /// Parameter name - /// - public string Parameter53Name { get; set; } - /// - /// Parameter value - /// - public string Parameter53Value { get; set; } - /// - /// Parameter name - /// - public string Parameter54Name { get; set; } - /// - /// Parameter value - /// - public string Parameter54Value { get; set; } - /// - /// Parameter name - /// - public string Parameter55Name { get; set; } - /// - /// Parameter value - /// - public string Parameter55Value { get; set; } - /// - /// Parameter name - /// - public string Parameter56Name { get; set; } - /// - /// Parameter value - /// - public string Parameter56Value { get; set; } - /// - /// Parameter name - /// - public string Parameter57Name { get; set; } - /// - /// Parameter value - /// - public string Parameter57Value { get; set; } - /// - /// Parameter name - /// - public string Parameter58Name { get; set; } - /// - /// Parameter value - /// - public string Parameter58Value { get; set; } - /// - /// Parameter name - /// - public string Parameter59Name { get; set; } - /// - /// Parameter value - /// - public string Parameter59Value { get; set; } - /// - /// Parameter name - /// - public string Parameter60Name { get; set; } - /// - /// Parameter value - /// - public string Parameter60Value { get; set; } - /// - /// Parameter name - /// - public string Parameter61Name { get; set; } - /// - /// Parameter value - /// - public string Parameter61Value { get; set; } - /// - /// Parameter name - /// - public string Parameter62Name { get; set; } - /// - /// Parameter value - /// - public string Parameter62Value { get; set; } - /// - /// Parameter name - /// - public string Parameter63Name { get; set; } - /// - /// Parameter value - /// - public string Parameter63Value { get; set; } - /// - /// Parameter name - /// - public string Parameter64Name { get; set; } - /// - /// Parameter value - /// - public string Parameter64Value { get; set; } - /// - /// Parameter name - /// - public string Parameter65Name { get; set; } - /// - /// Parameter value - /// - public string Parameter65Value { get; set; } - /// - /// Parameter name - /// - public string Parameter66Name { get; set; } - /// - /// Parameter value - /// - public string Parameter66Value { get; set; } - /// - /// Parameter name - /// - public string Parameter67Name { get; set; } - /// - /// Parameter value - /// - public string Parameter67Value { get; set; } - /// - /// Parameter name - /// - public string Parameter68Name { get; set; } - /// - /// Parameter value - /// - public string Parameter68Value { get; set; } - /// - /// Parameter name - /// - public string Parameter69Name { get; set; } - /// - /// Parameter value - /// - public string Parameter69Value { get; set; } - /// - /// Parameter name - /// - public string Parameter70Name { get; set; } - /// - /// Parameter value - /// - public string Parameter70Value { get; set; } - /// - /// Parameter name - /// - public string Parameter71Name { get; set; } - /// - /// Parameter value - /// - public string Parameter71Value { get; set; } - /// - /// Parameter name - /// - public string Parameter72Name { get; set; } - /// - /// Parameter value - /// - public string Parameter72Value { get; set; } - /// - /// Parameter name - /// - public string Parameter73Name { get; set; } - /// - /// Parameter value - /// - public string Parameter73Value { get; set; } - /// - /// Parameter name - /// - public string Parameter74Name { get; set; } - /// - /// Parameter value - /// - public string Parameter74Value { get; set; } - /// - /// Parameter name - /// - public string Parameter75Name { get; set; } - /// - /// Parameter value - /// - public string Parameter75Value { get; set; } - /// - /// Parameter name - /// - public string Parameter76Name { get; set; } - /// - /// Parameter value - /// - public string Parameter76Value { get; set; } - /// - /// Parameter name - /// - public string Parameter77Name { get; set; } - /// - /// Parameter value - /// - public string Parameter77Value { get; set; } - /// - /// Parameter name - /// - public string Parameter78Name { get; set; } - /// - /// Parameter value - /// - public string Parameter78Value { get; set; } - /// - /// Parameter name - /// - public string Parameter79Name { get; set; } - /// - /// Parameter value - /// - public string Parameter79Value { get; set; } - /// - /// Parameter name - /// - public string Parameter80Name { get; set; } - /// - /// Parameter value - /// - public string Parameter80Value { get; set; } - /// - /// Parameter name - /// - public string Parameter81Name { get; set; } - /// - /// Parameter value - /// - public string Parameter81Value { get; set; } - /// - /// Parameter name - /// - public string Parameter82Name { get; set; } - /// - /// Parameter value - /// - public string Parameter82Value { get; set; } - /// - /// Parameter name - /// - public string Parameter83Name { get; set; } - /// - /// Parameter value - /// - public string Parameter83Value { get; set; } - /// - /// Parameter name - /// - public string Parameter84Name { get; set; } - /// - /// Parameter value - /// - public string Parameter84Value { get; set; } - /// - /// Parameter name - /// - public string Parameter85Name { get; set; } - /// - /// Parameter value - /// - public string Parameter85Value { get; set; } - /// - /// Parameter name - /// - public string Parameter86Name { get; set; } - /// - /// Parameter value - /// - public string Parameter86Value { get; set; } - /// - /// Parameter name - /// - public string Parameter87Name { get; set; } - /// - /// Parameter value - /// - public string Parameter87Value { get; set; } - /// - /// Parameter name - /// - public string Parameter88Name { get; set; } - /// - /// Parameter value - /// - public string Parameter88Value { get; set; } - /// - /// Parameter name - /// - public string Parameter89Name { get; set; } - /// - /// Parameter value - /// - public string Parameter89Value { get; set; } - /// - /// Parameter name - /// - public string Parameter90Name { get; set; } - /// - /// Parameter value - /// - public string Parameter90Value { get; set; } - /// - /// Parameter name - /// - public string Parameter91Name { get; set; } - /// - /// Parameter value - /// - public string Parameter91Value { get; set; } - /// - /// Parameter name - /// - public string Parameter92Name { get; set; } - /// - /// Parameter value - /// - public string Parameter92Value { get; set; } - /// - /// Parameter name - /// - public string Parameter93Name { get; set; } - /// - /// Parameter value - /// - public string Parameter93Value { get; set; } - /// - /// Parameter name - /// - public string Parameter94Name { get; set; } - /// - /// Parameter value - /// - public string Parameter94Value { get; set; } - /// - /// Parameter name - /// - public string Parameter95Name { get; set; } - /// - /// Parameter value - /// - public string Parameter95Value { get; set; } - /// - /// Parameter name - /// - public string Parameter96Name { get; set; } - /// - /// Parameter value - /// - public string Parameter96Value { get; set; } - /// - /// Parameter name - /// - public string Parameter97Name { get; set; } - /// - /// Parameter value - /// - public string Parameter97Value { get; set; } - /// - /// Parameter name - /// - public string Parameter98Name { get; set; } - /// - /// Parameter value - /// - public string Parameter98Value { get; set; } - /// - /// Parameter name - /// - public string Parameter99Name { get; set; } - /// - /// Parameter value - /// - public string Parameter99Value { get; set; } - - /// - /// Construct a new CreateSiprecOptions - /// - /// The SID of the Call the resource is associated with - public CreateSiprecOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Name != null) - { - p.Add(new KeyValuePair("Name", Name)); - } - - if (ConnectorName != null) - { - p.Add(new KeyValuePair("ConnectorName", ConnectorName)); - } - - if (Track != null) - { - p.Add(new KeyValuePair("Track", Track.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (Parameter1Name != null) - { - p.Add(new KeyValuePair("Parameter1.Name", Parameter1Name)); - } - - if (Parameter1Value != null) - { - p.Add(new KeyValuePair("Parameter1.Value", Parameter1Value)); - } - - if (Parameter2Name != null) - { - p.Add(new KeyValuePair("Parameter2.Name", Parameter2Name)); - } - - if (Parameter2Value != null) - { - p.Add(new KeyValuePair("Parameter2.Value", Parameter2Value)); - } - - if (Parameter3Name != null) - { - p.Add(new KeyValuePair("Parameter3.Name", Parameter3Name)); - } - - if (Parameter3Value != null) - { - p.Add(new KeyValuePair("Parameter3.Value", Parameter3Value)); - } - - if (Parameter4Name != null) - { - p.Add(new KeyValuePair("Parameter4.Name", Parameter4Name)); - } - - if (Parameter4Value != null) - { - p.Add(new KeyValuePair("Parameter4.Value", Parameter4Value)); - } - - if (Parameter5Name != null) - { - p.Add(new KeyValuePair("Parameter5.Name", Parameter5Name)); - } - - if (Parameter5Value != null) - { - p.Add(new KeyValuePair("Parameter5.Value", Parameter5Value)); - } - - if (Parameter6Name != null) - { - p.Add(new KeyValuePair("Parameter6.Name", Parameter6Name)); - } - - if (Parameter6Value != null) - { - p.Add(new KeyValuePair("Parameter6.Value", Parameter6Value)); - } - - if (Parameter7Name != null) - { - p.Add(new KeyValuePair("Parameter7.Name", Parameter7Name)); - } - - if (Parameter7Value != null) - { - p.Add(new KeyValuePair("Parameter7.Value", Parameter7Value)); - } - - if (Parameter8Name != null) - { - p.Add(new KeyValuePair("Parameter8.Name", Parameter8Name)); - } - - if (Parameter8Value != null) - { - p.Add(new KeyValuePair("Parameter8.Value", Parameter8Value)); - } - - if (Parameter9Name != null) - { - p.Add(new KeyValuePair("Parameter9.Name", Parameter9Name)); - } - - if (Parameter9Value != null) - { - p.Add(new KeyValuePair("Parameter9.Value", Parameter9Value)); - } - - if (Parameter10Name != null) - { - p.Add(new KeyValuePair("Parameter10.Name", Parameter10Name)); - } - - if (Parameter10Value != null) - { - p.Add(new KeyValuePair("Parameter10.Value", Parameter10Value)); - } - - if (Parameter11Name != null) - { - p.Add(new KeyValuePair("Parameter11.Name", Parameter11Name)); - } - - if (Parameter11Value != null) - { - p.Add(new KeyValuePair("Parameter11.Value", Parameter11Value)); - } - - if (Parameter12Name != null) - { - p.Add(new KeyValuePair("Parameter12.Name", Parameter12Name)); - } - - if (Parameter12Value != null) - { - p.Add(new KeyValuePair("Parameter12.Value", Parameter12Value)); - } - - if (Parameter13Name != null) - { - p.Add(new KeyValuePair("Parameter13.Name", Parameter13Name)); - } - - if (Parameter13Value != null) - { - p.Add(new KeyValuePair("Parameter13.Value", Parameter13Value)); - } - - if (Parameter14Name != null) - { - p.Add(new KeyValuePair("Parameter14.Name", Parameter14Name)); - } - - if (Parameter14Value != null) - { - p.Add(new KeyValuePair("Parameter14.Value", Parameter14Value)); - } - - if (Parameter15Name != null) - { - p.Add(new KeyValuePair("Parameter15.Name", Parameter15Name)); - } - - if (Parameter15Value != null) - { - p.Add(new KeyValuePair("Parameter15.Value", Parameter15Value)); - } - - if (Parameter16Name != null) - { - p.Add(new KeyValuePair("Parameter16.Name", Parameter16Name)); - } - - if (Parameter16Value != null) - { - p.Add(new KeyValuePair("Parameter16.Value", Parameter16Value)); - } - - if (Parameter17Name != null) - { - p.Add(new KeyValuePair("Parameter17.Name", Parameter17Name)); - } - - if (Parameter17Value != null) - { - p.Add(new KeyValuePair("Parameter17.Value", Parameter17Value)); - } - - if (Parameter18Name != null) - { - p.Add(new KeyValuePair("Parameter18.Name", Parameter18Name)); - } - - if (Parameter18Value != null) - { - p.Add(new KeyValuePair("Parameter18.Value", Parameter18Value)); - } - - if (Parameter19Name != null) - { - p.Add(new KeyValuePair("Parameter19.Name", Parameter19Name)); - } - - if (Parameter19Value != null) - { - p.Add(new KeyValuePair("Parameter19.Value", Parameter19Value)); - } - - if (Parameter20Name != null) - { - p.Add(new KeyValuePair("Parameter20.Name", Parameter20Name)); - } - - if (Parameter20Value != null) - { - p.Add(new KeyValuePair("Parameter20.Value", Parameter20Value)); - } - - if (Parameter21Name != null) - { - p.Add(new KeyValuePair("Parameter21.Name", Parameter21Name)); - } - - if (Parameter21Value != null) - { - p.Add(new KeyValuePair("Parameter21.Value", Parameter21Value)); - } - - if (Parameter22Name != null) - { - p.Add(new KeyValuePair("Parameter22.Name", Parameter22Name)); - } - - if (Parameter22Value != null) - { - p.Add(new KeyValuePair("Parameter22.Value", Parameter22Value)); - } - - if (Parameter23Name != null) - { - p.Add(new KeyValuePair("Parameter23.Name", Parameter23Name)); - } - - if (Parameter23Value != null) - { - p.Add(new KeyValuePair("Parameter23.Value", Parameter23Value)); - } - - if (Parameter24Name != null) - { - p.Add(new KeyValuePair("Parameter24.Name", Parameter24Name)); - } - - if (Parameter24Value != null) - { - p.Add(new KeyValuePair("Parameter24.Value", Parameter24Value)); - } - - if (Parameter25Name != null) - { - p.Add(new KeyValuePair("Parameter25.Name", Parameter25Name)); - } - - if (Parameter25Value != null) - { - p.Add(new KeyValuePair("Parameter25.Value", Parameter25Value)); - } - - if (Parameter26Name != null) - { - p.Add(new KeyValuePair("Parameter26.Name", Parameter26Name)); - } - - if (Parameter26Value != null) - { - p.Add(new KeyValuePair("Parameter26.Value", Parameter26Value)); - } - - if (Parameter27Name != null) - { - p.Add(new KeyValuePair("Parameter27.Name", Parameter27Name)); - } - - if (Parameter27Value != null) - { - p.Add(new KeyValuePair("Parameter27.Value", Parameter27Value)); - } - - if (Parameter28Name != null) - { - p.Add(new KeyValuePair("Parameter28.Name", Parameter28Name)); - } - - if (Parameter28Value != null) - { - p.Add(new KeyValuePair("Parameter28.Value", Parameter28Value)); - } - - if (Parameter29Name != null) - { - p.Add(new KeyValuePair("Parameter29.Name", Parameter29Name)); - } - - if (Parameter29Value != null) - { - p.Add(new KeyValuePair("Parameter29.Value", Parameter29Value)); - } - - if (Parameter30Name != null) - { - p.Add(new KeyValuePair("Parameter30.Name", Parameter30Name)); - } - - if (Parameter30Value != null) - { - p.Add(new KeyValuePair("Parameter30.Value", Parameter30Value)); - } - - if (Parameter31Name != null) - { - p.Add(new KeyValuePair("Parameter31.Name", Parameter31Name)); - } - - if (Parameter31Value != null) - { - p.Add(new KeyValuePair("Parameter31.Value", Parameter31Value)); - } - - if (Parameter32Name != null) - { - p.Add(new KeyValuePair("Parameter32.Name", Parameter32Name)); - } - - if (Parameter32Value != null) - { - p.Add(new KeyValuePair("Parameter32.Value", Parameter32Value)); - } - - if (Parameter33Name != null) - { - p.Add(new KeyValuePair("Parameter33.Name", Parameter33Name)); - } - - if (Parameter33Value != null) - { - p.Add(new KeyValuePair("Parameter33.Value", Parameter33Value)); - } - - if (Parameter34Name != null) - { - p.Add(new KeyValuePair("Parameter34.Name", Parameter34Name)); - } - - if (Parameter34Value != null) - { - p.Add(new KeyValuePair("Parameter34.Value", Parameter34Value)); - } - - if (Parameter35Name != null) - { - p.Add(new KeyValuePair("Parameter35.Name", Parameter35Name)); - } - - if (Parameter35Value != null) - { - p.Add(new KeyValuePair("Parameter35.Value", Parameter35Value)); - } - - if (Parameter36Name != null) - { - p.Add(new KeyValuePair("Parameter36.Name", Parameter36Name)); - } - - if (Parameter36Value != null) - { - p.Add(new KeyValuePair("Parameter36.Value", Parameter36Value)); - } - - if (Parameter37Name != null) - { - p.Add(new KeyValuePair("Parameter37.Name", Parameter37Name)); - } - - if (Parameter37Value != null) - { - p.Add(new KeyValuePair("Parameter37.Value", Parameter37Value)); - } - - if (Parameter38Name != null) - { - p.Add(new KeyValuePair("Parameter38.Name", Parameter38Name)); - } - - if (Parameter38Value != null) - { - p.Add(new KeyValuePair("Parameter38.Value", Parameter38Value)); - } - - if (Parameter39Name != null) - { - p.Add(new KeyValuePair("Parameter39.Name", Parameter39Name)); - } - - if (Parameter39Value != null) - { - p.Add(new KeyValuePair("Parameter39.Value", Parameter39Value)); - } - - if (Parameter40Name != null) - { - p.Add(new KeyValuePair("Parameter40.Name", Parameter40Name)); - } - - if (Parameter40Value != null) - { - p.Add(new KeyValuePair("Parameter40.Value", Parameter40Value)); - } - - if (Parameter41Name != null) - { - p.Add(new KeyValuePair("Parameter41.Name", Parameter41Name)); - } - - if (Parameter41Value != null) - { - p.Add(new KeyValuePair("Parameter41.Value", Parameter41Value)); - } - - if (Parameter42Name != null) - { - p.Add(new KeyValuePair("Parameter42.Name", Parameter42Name)); - } - - if (Parameter42Value != null) - { - p.Add(new KeyValuePair("Parameter42.Value", Parameter42Value)); - } - - if (Parameter43Name != null) - { - p.Add(new KeyValuePair("Parameter43.Name", Parameter43Name)); - } - - if (Parameter43Value != null) - { - p.Add(new KeyValuePair("Parameter43.Value", Parameter43Value)); - } - - if (Parameter44Name != null) - { - p.Add(new KeyValuePair("Parameter44.Name", Parameter44Name)); - } - - if (Parameter44Value != null) - { - p.Add(new KeyValuePair("Parameter44.Value", Parameter44Value)); - } - - if (Parameter45Name != null) - { - p.Add(new KeyValuePair("Parameter45.Name", Parameter45Name)); - } - - if (Parameter45Value != null) - { - p.Add(new KeyValuePair("Parameter45.Value", Parameter45Value)); - } - - if (Parameter46Name != null) - { - p.Add(new KeyValuePair("Parameter46.Name", Parameter46Name)); - } - - if (Parameter46Value != null) - { - p.Add(new KeyValuePair("Parameter46.Value", Parameter46Value)); - } - - if (Parameter47Name != null) - { - p.Add(new KeyValuePair("Parameter47.Name", Parameter47Name)); - } - - if (Parameter47Value != null) - { - p.Add(new KeyValuePair("Parameter47.Value", Parameter47Value)); - } - - if (Parameter48Name != null) - { - p.Add(new KeyValuePair("Parameter48.Name", Parameter48Name)); - } - - if (Parameter48Value != null) - { - p.Add(new KeyValuePair("Parameter48.Value", Parameter48Value)); - } - - if (Parameter49Name != null) - { - p.Add(new KeyValuePair("Parameter49.Name", Parameter49Name)); - } - - if (Parameter49Value != null) - { - p.Add(new KeyValuePair("Parameter49.Value", Parameter49Value)); - } - - if (Parameter50Name != null) - { - p.Add(new KeyValuePair("Parameter50.Name", Parameter50Name)); - } - - if (Parameter50Value != null) - { - p.Add(new KeyValuePair("Parameter50.Value", Parameter50Value)); - } - - if (Parameter51Name != null) - { - p.Add(new KeyValuePair("Parameter51.Name", Parameter51Name)); - } - - if (Parameter51Value != null) - { - p.Add(new KeyValuePair("Parameter51.Value", Parameter51Value)); - } - - if (Parameter52Name != null) - { - p.Add(new KeyValuePair("Parameter52.Name", Parameter52Name)); - } - - if (Parameter52Value != null) - { - p.Add(new KeyValuePair("Parameter52.Value", Parameter52Value)); - } - - if (Parameter53Name != null) - { - p.Add(new KeyValuePair("Parameter53.Name", Parameter53Name)); - } - - if (Parameter53Value != null) - { - p.Add(new KeyValuePair("Parameter53.Value", Parameter53Value)); - } - - if (Parameter54Name != null) - { - p.Add(new KeyValuePair("Parameter54.Name", Parameter54Name)); - } - - if (Parameter54Value != null) - { - p.Add(new KeyValuePair("Parameter54.Value", Parameter54Value)); - } - - if (Parameter55Name != null) - { - p.Add(new KeyValuePair("Parameter55.Name", Parameter55Name)); - } - - if (Parameter55Value != null) - { - p.Add(new KeyValuePair("Parameter55.Value", Parameter55Value)); - } - - if (Parameter56Name != null) - { - p.Add(new KeyValuePair("Parameter56.Name", Parameter56Name)); - } - - if (Parameter56Value != null) - { - p.Add(new KeyValuePair("Parameter56.Value", Parameter56Value)); - } - - if (Parameter57Name != null) - { - p.Add(new KeyValuePair("Parameter57.Name", Parameter57Name)); - } - - if (Parameter57Value != null) - { - p.Add(new KeyValuePair("Parameter57.Value", Parameter57Value)); - } - - if (Parameter58Name != null) - { - p.Add(new KeyValuePair("Parameter58.Name", Parameter58Name)); - } - - if (Parameter58Value != null) - { - p.Add(new KeyValuePair("Parameter58.Value", Parameter58Value)); - } - - if (Parameter59Name != null) - { - p.Add(new KeyValuePair("Parameter59.Name", Parameter59Name)); - } - - if (Parameter59Value != null) - { - p.Add(new KeyValuePair("Parameter59.Value", Parameter59Value)); - } - - if (Parameter60Name != null) - { - p.Add(new KeyValuePair("Parameter60.Name", Parameter60Name)); - } - - if (Parameter60Value != null) - { - p.Add(new KeyValuePair("Parameter60.Value", Parameter60Value)); - } - - if (Parameter61Name != null) - { - p.Add(new KeyValuePair("Parameter61.Name", Parameter61Name)); - } - - if (Parameter61Value != null) - { - p.Add(new KeyValuePair("Parameter61.Value", Parameter61Value)); - } - - if (Parameter62Name != null) - { - p.Add(new KeyValuePair("Parameter62.Name", Parameter62Name)); - } - - if (Parameter62Value != null) - { - p.Add(new KeyValuePair("Parameter62.Value", Parameter62Value)); - } - - if (Parameter63Name != null) - { - p.Add(new KeyValuePair("Parameter63.Name", Parameter63Name)); - } - - if (Parameter63Value != null) - { - p.Add(new KeyValuePair("Parameter63.Value", Parameter63Value)); - } - - if (Parameter64Name != null) - { - p.Add(new KeyValuePair("Parameter64.Name", Parameter64Name)); - } - - if (Parameter64Value != null) - { - p.Add(new KeyValuePair("Parameter64.Value", Parameter64Value)); - } - - if (Parameter65Name != null) - { - p.Add(new KeyValuePair("Parameter65.Name", Parameter65Name)); - } - - if (Parameter65Value != null) - { - p.Add(new KeyValuePair("Parameter65.Value", Parameter65Value)); - } - - if (Parameter66Name != null) - { - p.Add(new KeyValuePair("Parameter66.Name", Parameter66Name)); - } - - if (Parameter66Value != null) - { - p.Add(new KeyValuePair("Parameter66.Value", Parameter66Value)); - } - - if (Parameter67Name != null) - { - p.Add(new KeyValuePair("Parameter67.Name", Parameter67Name)); - } - - if (Parameter67Value != null) - { - p.Add(new KeyValuePair("Parameter67.Value", Parameter67Value)); - } - - if (Parameter68Name != null) - { - p.Add(new KeyValuePair("Parameter68.Name", Parameter68Name)); - } - - if (Parameter68Value != null) - { - p.Add(new KeyValuePair("Parameter68.Value", Parameter68Value)); - } - - if (Parameter69Name != null) - { - p.Add(new KeyValuePair("Parameter69.Name", Parameter69Name)); - } - - if (Parameter69Value != null) - { - p.Add(new KeyValuePair("Parameter69.Value", Parameter69Value)); - } - - if (Parameter70Name != null) - { - p.Add(new KeyValuePair("Parameter70.Name", Parameter70Name)); - } - - if (Parameter70Value != null) - { - p.Add(new KeyValuePair("Parameter70.Value", Parameter70Value)); - } - - if (Parameter71Name != null) - { - p.Add(new KeyValuePair("Parameter71.Name", Parameter71Name)); - } - - if (Parameter71Value != null) - { - p.Add(new KeyValuePair("Parameter71.Value", Parameter71Value)); - } - - if (Parameter72Name != null) - { - p.Add(new KeyValuePair("Parameter72.Name", Parameter72Name)); - } - - if (Parameter72Value != null) - { - p.Add(new KeyValuePair("Parameter72.Value", Parameter72Value)); - } - - if (Parameter73Name != null) - { - p.Add(new KeyValuePair("Parameter73.Name", Parameter73Name)); - } - - if (Parameter73Value != null) - { - p.Add(new KeyValuePair("Parameter73.Value", Parameter73Value)); - } - - if (Parameter74Name != null) - { - p.Add(new KeyValuePair("Parameter74.Name", Parameter74Name)); - } - - if (Parameter74Value != null) - { - p.Add(new KeyValuePair("Parameter74.Value", Parameter74Value)); - } - - if (Parameter75Name != null) - { - p.Add(new KeyValuePair("Parameter75.Name", Parameter75Name)); - } - - if (Parameter75Value != null) - { - p.Add(new KeyValuePair("Parameter75.Value", Parameter75Value)); - } - - if (Parameter76Name != null) - { - p.Add(new KeyValuePair("Parameter76.Name", Parameter76Name)); - } - - if (Parameter76Value != null) - { - p.Add(new KeyValuePair("Parameter76.Value", Parameter76Value)); - } - - if (Parameter77Name != null) - { - p.Add(new KeyValuePair("Parameter77.Name", Parameter77Name)); - } - - if (Parameter77Value != null) - { - p.Add(new KeyValuePair("Parameter77.Value", Parameter77Value)); - } - - if (Parameter78Name != null) - { - p.Add(new KeyValuePair("Parameter78.Name", Parameter78Name)); - } - - if (Parameter78Value != null) - { - p.Add(new KeyValuePair("Parameter78.Value", Parameter78Value)); - } - - if (Parameter79Name != null) - { - p.Add(new KeyValuePair("Parameter79.Name", Parameter79Name)); - } - - if (Parameter79Value != null) - { - p.Add(new KeyValuePair("Parameter79.Value", Parameter79Value)); - } - - if (Parameter80Name != null) - { - p.Add(new KeyValuePair("Parameter80.Name", Parameter80Name)); - } - - if (Parameter80Value != null) - { - p.Add(new KeyValuePair("Parameter80.Value", Parameter80Value)); - } - - if (Parameter81Name != null) - { - p.Add(new KeyValuePair("Parameter81.Name", Parameter81Name)); - } - - if (Parameter81Value != null) - { - p.Add(new KeyValuePair("Parameter81.Value", Parameter81Value)); - } - - if (Parameter82Name != null) - { - p.Add(new KeyValuePair("Parameter82.Name", Parameter82Name)); - } - - if (Parameter82Value != null) - { - p.Add(new KeyValuePair("Parameter82.Value", Parameter82Value)); - } - - if (Parameter83Name != null) - { - p.Add(new KeyValuePair("Parameter83.Name", Parameter83Name)); - } - - if (Parameter83Value != null) - { - p.Add(new KeyValuePair("Parameter83.Value", Parameter83Value)); - } - - if (Parameter84Name != null) - { - p.Add(new KeyValuePair("Parameter84.Name", Parameter84Name)); - } - - if (Parameter84Value != null) - { - p.Add(new KeyValuePair("Parameter84.Value", Parameter84Value)); - } - - if (Parameter85Name != null) - { - p.Add(new KeyValuePair("Parameter85.Name", Parameter85Name)); - } - - if (Parameter85Value != null) - { - p.Add(new KeyValuePair("Parameter85.Value", Parameter85Value)); - } - - if (Parameter86Name != null) - { - p.Add(new KeyValuePair("Parameter86.Name", Parameter86Name)); - } - - if (Parameter86Value != null) - { - p.Add(new KeyValuePair("Parameter86.Value", Parameter86Value)); - } - - if (Parameter87Name != null) - { - p.Add(new KeyValuePair("Parameter87.Name", Parameter87Name)); - } - - if (Parameter87Value != null) - { - p.Add(new KeyValuePair("Parameter87.Value", Parameter87Value)); - } - - if (Parameter88Name != null) - { - p.Add(new KeyValuePair("Parameter88.Name", Parameter88Name)); - } - - if (Parameter88Value != null) - { - p.Add(new KeyValuePair("Parameter88.Value", Parameter88Value)); - } - - if (Parameter89Name != null) - { - p.Add(new KeyValuePair("Parameter89.Name", Parameter89Name)); - } - - if (Parameter89Value != null) - { - p.Add(new KeyValuePair("Parameter89.Value", Parameter89Value)); - } - - if (Parameter90Name != null) - { - p.Add(new KeyValuePair("Parameter90.Name", Parameter90Name)); - } - - if (Parameter90Value != null) - { - p.Add(new KeyValuePair("Parameter90.Value", Parameter90Value)); - } - - if (Parameter91Name != null) - { - p.Add(new KeyValuePair("Parameter91.Name", Parameter91Name)); - } - - if (Parameter91Value != null) - { - p.Add(new KeyValuePair("Parameter91.Value", Parameter91Value)); - } - - if (Parameter92Name != null) - { - p.Add(new KeyValuePair("Parameter92.Name", Parameter92Name)); - } - - if (Parameter92Value != null) - { - p.Add(new KeyValuePair("Parameter92.Value", Parameter92Value)); - } - - if (Parameter93Name != null) - { - p.Add(new KeyValuePair("Parameter93.Name", Parameter93Name)); - } - - if (Parameter93Value != null) - { - p.Add(new KeyValuePair("Parameter93.Value", Parameter93Value)); - } - - if (Parameter94Name != null) - { - p.Add(new KeyValuePair("Parameter94.Name", Parameter94Name)); - } - - if (Parameter94Value != null) - { - p.Add(new KeyValuePair("Parameter94.Value", Parameter94Value)); - } - - if (Parameter95Name != null) - { - p.Add(new KeyValuePair("Parameter95.Name", Parameter95Name)); - } - - if (Parameter95Value != null) - { - p.Add(new KeyValuePair("Parameter95.Value", Parameter95Value)); - } - - if (Parameter96Name != null) - { - p.Add(new KeyValuePair("Parameter96.Name", Parameter96Name)); - } - - if (Parameter96Value != null) - { - p.Add(new KeyValuePair("Parameter96.Value", Parameter96Value)); - } - - if (Parameter97Name != null) - { - p.Add(new KeyValuePair("Parameter97.Name", Parameter97Name)); - } - - if (Parameter97Value != null) - { - p.Add(new KeyValuePair("Parameter97.Value", Parameter97Value)); - } - - if (Parameter98Name != null) - { - p.Add(new KeyValuePair("Parameter98.Name", Parameter98Name)); - } - - if (Parameter98Value != null) - { - p.Add(new KeyValuePair("Parameter98.Value", Parameter98Value)); - } - - if (Parameter99Name != null) - { - p.Add(new KeyValuePair("Parameter99.Name", Parameter99Name)); - } - - if (Parameter99Value != null) - { - p.Add(new KeyValuePair("Parameter99.Value", Parameter99Value)); - } - - return p; - } - } - + /// Parameter name + /// + public string Parameter92Name { get; set; } /// - /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource - /// - public class UpdateSiprecOptions : IOptions - { - /// - /// The SID of the Account that created this resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Call the resource is associated with - /// - public string PathCallSid { get; } - /// - /// The SID of the Siprec resource, or the `name` - /// - public string PathSid { get; } - /// - /// The status. Must have the value `stopped` - /// - public SiprecResource.UpdateStatusEnum Status { get; } - - /// - /// Construct a new UpdateSiprecOptions - /// - /// The SID of the Call the resource is associated with - /// The SID of the Siprec resource, or the `name` - /// The status. Must have the value `stopped` - public UpdateSiprecOptions(string pathCallSid, string pathSid, SiprecResource.UpdateStatusEnum status) - { - PathCallSid = pathCallSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + /// Parameter value + /// + public string Parameter92Value { get; set; } + /// + /// Parameter name + /// + public string Parameter93Name { get; set; } + /// + /// Parameter value + /// + public string Parameter93Value { get; set; } + /// + /// Parameter name + /// + public string Parameter94Name { get; set; } + /// + /// Parameter value + /// + public string Parameter94Value { get; set; } + /// + /// Parameter name + /// + public string Parameter95Name { get; set; } + /// + /// Parameter value + /// + public string Parameter95Value { get; set; } + /// + /// Parameter name + /// + public string Parameter96Name { get; set; } + /// + /// Parameter value + /// + public string Parameter96Value { get; set; } + /// + /// Parameter name + /// + public string Parameter97Name { get; set; } + /// + /// Parameter value + /// + public string Parameter97Value { get; set; } + /// + /// Parameter name + /// + public string Parameter98Name { get; set; } + /// + /// Parameter value + /// + public string Parameter98Value { get; set; } + /// + /// Parameter name + /// + public string Parameter99Name { get; set; } + /// + /// Parameter value + /// + public string Parameter99Value { get; set; } + + /// + /// Construct a new CreateSiprecOptions + /// + /// The SID of the Call the resource is associated with + public CreateSiprecOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Name != null) + { + p.Add(new KeyValuePair("Name", Name)); + } + + if (ConnectorName != null) + { + p.Add(new KeyValuePair("ConnectorName", ConnectorName)); + } + + if (Track != null) + { + p.Add(new KeyValuePair("Track", Track.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (Parameter1Name != null) + { + p.Add(new KeyValuePair("Parameter1.Name", Parameter1Name)); + } + + if (Parameter1Value != null) + { + p.Add(new KeyValuePair("Parameter1.Value", Parameter1Value)); + } + + if (Parameter2Name != null) + { + p.Add(new KeyValuePair("Parameter2.Name", Parameter2Name)); + } + + if (Parameter2Value != null) + { + p.Add(new KeyValuePair("Parameter2.Value", Parameter2Value)); + } + + if (Parameter3Name != null) + { + p.Add(new KeyValuePair("Parameter3.Name", Parameter3Name)); + } + + if (Parameter3Value != null) + { + p.Add(new KeyValuePair("Parameter3.Value", Parameter3Value)); + } + + if (Parameter4Name != null) + { + p.Add(new KeyValuePair("Parameter4.Name", Parameter4Name)); + } + + if (Parameter4Value != null) + { + p.Add(new KeyValuePair("Parameter4.Value", Parameter4Value)); + } + + if (Parameter5Name != null) + { + p.Add(new KeyValuePair("Parameter5.Name", Parameter5Name)); + } + + if (Parameter5Value != null) + { + p.Add(new KeyValuePair("Parameter5.Value", Parameter5Value)); + } + + if (Parameter6Name != null) + { + p.Add(new KeyValuePair("Parameter6.Name", Parameter6Name)); + } + + if (Parameter6Value != null) + { + p.Add(new KeyValuePair("Parameter6.Value", Parameter6Value)); + } + + if (Parameter7Name != null) + { + p.Add(new KeyValuePair("Parameter7.Name", Parameter7Name)); + } + + if (Parameter7Value != null) + { + p.Add(new KeyValuePair("Parameter7.Value", Parameter7Value)); + } + + if (Parameter8Name != null) + { + p.Add(new KeyValuePair("Parameter8.Name", Parameter8Name)); + } + + if (Parameter8Value != null) + { + p.Add(new KeyValuePair("Parameter8.Value", Parameter8Value)); + } + + if (Parameter9Name != null) + { + p.Add(new KeyValuePair("Parameter9.Name", Parameter9Name)); + } + + if (Parameter9Value != null) + { + p.Add(new KeyValuePair("Parameter9.Value", Parameter9Value)); + } + + if (Parameter10Name != null) + { + p.Add(new KeyValuePair("Parameter10.Name", Parameter10Name)); + } + + if (Parameter10Value != null) + { + p.Add(new KeyValuePair("Parameter10.Value", Parameter10Value)); + } + + if (Parameter11Name != null) + { + p.Add(new KeyValuePair("Parameter11.Name", Parameter11Name)); + } + + if (Parameter11Value != null) + { + p.Add(new KeyValuePair("Parameter11.Value", Parameter11Value)); + } + + if (Parameter12Name != null) + { + p.Add(new KeyValuePair("Parameter12.Name", Parameter12Name)); + } + + if (Parameter12Value != null) + { + p.Add(new KeyValuePair("Parameter12.Value", Parameter12Value)); + } + + if (Parameter13Name != null) + { + p.Add(new KeyValuePair("Parameter13.Name", Parameter13Name)); + } + + if (Parameter13Value != null) + { + p.Add(new KeyValuePair("Parameter13.Value", Parameter13Value)); + } + + if (Parameter14Name != null) + { + p.Add(new KeyValuePair("Parameter14.Name", Parameter14Name)); + } + + if (Parameter14Value != null) + { + p.Add(new KeyValuePair("Parameter14.Value", Parameter14Value)); + } + + if (Parameter15Name != null) + { + p.Add(new KeyValuePair("Parameter15.Name", Parameter15Name)); + } + + if (Parameter15Value != null) + { + p.Add(new KeyValuePair("Parameter15.Value", Parameter15Value)); + } + + if (Parameter16Name != null) + { + p.Add(new KeyValuePair("Parameter16.Name", Parameter16Name)); + } + + if (Parameter16Value != null) + { + p.Add(new KeyValuePair("Parameter16.Value", Parameter16Value)); + } + + if (Parameter17Name != null) + { + p.Add(new KeyValuePair("Parameter17.Name", Parameter17Name)); + } + + if (Parameter17Value != null) + { + p.Add(new KeyValuePair("Parameter17.Value", Parameter17Value)); + } + + if (Parameter18Name != null) + { + p.Add(new KeyValuePair("Parameter18.Name", Parameter18Name)); + } + + if (Parameter18Value != null) + { + p.Add(new KeyValuePair("Parameter18.Value", Parameter18Value)); + } + + if (Parameter19Name != null) + { + p.Add(new KeyValuePair("Parameter19.Name", Parameter19Name)); + } + + if (Parameter19Value != null) + { + p.Add(new KeyValuePair("Parameter19.Value", Parameter19Value)); + } + + if (Parameter20Name != null) + { + p.Add(new KeyValuePair("Parameter20.Name", Parameter20Name)); + } + + if (Parameter20Value != null) + { + p.Add(new KeyValuePair("Parameter20.Value", Parameter20Value)); + } + + if (Parameter21Name != null) + { + p.Add(new KeyValuePair("Parameter21.Name", Parameter21Name)); + } + + if (Parameter21Value != null) + { + p.Add(new KeyValuePair("Parameter21.Value", Parameter21Value)); + } + + if (Parameter22Name != null) + { + p.Add(new KeyValuePair("Parameter22.Name", Parameter22Name)); + } + + if (Parameter22Value != null) + { + p.Add(new KeyValuePair("Parameter22.Value", Parameter22Value)); + } + + if (Parameter23Name != null) + { + p.Add(new KeyValuePair("Parameter23.Name", Parameter23Name)); + } + + if (Parameter23Value != null) + { + p.Add(new KeyValuePair("Parameter23.Value", Parameter23Value)); + } + + if (Parameter24Name != null) + { + p.Add(new KeyValuePair("Parameter24.Name", Parameter24Name)); + } + + if (Parameter24Value != null) + { + p.Add(new KeyValuePair("Parameter24.Value", Parameter24Value)); + } + + if (Parameter25Name != null) + { + p.Add(new KeyValuePair("Parameter25.Name", Parameter25Name)); + } + + if (Parameter25Value != null) + { + p.Add(new KeyValuePair("Parameter25.Value", Parameter25Value)); + } + + if (Parameter26Name != null) + { + p.Add(new KeyValuePair("Parameter26.Name", Parameter26Name)); + } + + if (Parameter26Value != null) + { + p.Add(new KeyValuePair("Parameter26.Value", Parameter26Value)); + } + + if (Parameter27Name != null) + { + p.Add(new KeyValuePair("Parameter27.Name", Parameter27Name)); + } + + if (Parameter27Value != null) + { + p.Add(new KeyValuePair("Parameter27.Value", Parameter27Value)); + } + + if (Parameter28Name != null) + { + p.Add(new KeyValuePair("Parameter28.Name", Parameter28Name)); + } + + if (Parameter28Value != null) + { + p.Add(new KeyValuePair("Parameter28.Value", Parameter28Value)); + } + + if (Parameter29Name != null) + { + p.Add(new KeyValuePair("Parameter29.Name", Parameter29Name)); + } + + if (Parameter29Value != null) + { + p.Add(new KeyValuePair("Parameter29.Value", Parameter29Value)); + } + + if (Parameter30Name != null) + { + p.Add(new KeyValuePair("Parameter30.Name", Parameter30Name)); + } + + if (Parameter30Value != null) + { + p.Add(new KeyValuePair("Parameter30.Value", Parameter30Value)); + } + + if (Parameter31Name != null) + { + p.Add(new KeyValuePair("Parameter31.Name", Parameter31Name)); + } + + if (Parameter31Value != null) + { + p.Add(new KeyValuePair("Parameter31.Value", Parameter31Value)); + } + + if (Parameter32Name != null) + { + p.Add(new KeyValuePair("Parameter32.Name", Parameter32Name)); + } + + if (Parameter32Value != null) + { + p.Add(new KeyValuePair("Parameter32.Value", Parameter32Value)); + } + + if (Parameter33Name != null) + { + p.Add(new KeyValuePair("Parameter33.Name", Parameter33Name)); + } + + if (Parameter33Value != null) + { + p.Add(new KeyValuePair("Parameter33.Value", Parameter33Value)); + } + + if (Parameter34Name != null) + { + p.Add(new KeyValuePair("Parameter34.Name", Parameter34Name)); + } + + if (Parameter34Value != null) + { + p.Add(new KeyValuePair("Parameter34.Value", Parameter34Value)); + } + + if (Parameter35Name != null) + { + p.Add(new KeyValuePair("Parameter35.Name", Parameter35Name)); + } + + if (Parameter35Value != null) + { + p.Add(new KeyValuePair("Parameter35.Value", Parameter35Value)); + } + + if (Parameter36Name != null) + { + p.Add(new KeyValuePair("Parameter36.Name", Parameter36Name)); + } + + if (Parameter36Value != null) + { + p.Add(new KeyValuePair("Parameter36.Value", Parameter36Value)); + } + + if (Parameter37Name != null) + { + p.Add(new KeyValuePair("Parameter37.Name", Parameter37Name)); + } + + if (Parameter37Value != null) + { + p.Add(new KeyValuePair("Parameter37.Value", Parameter37Value)); + } + + if (Parameter38Name != null) + { + p.Add(new KeyValuePair("Parameter38.Name", Parameter38Name)); + } + + if (Parameter38Value != null) + { + p.Add(new KeyValuePair("Parameter38.Value", Parameter38Value)); + } + + if (Parameter39Name != null) + { + p.Add(new KeyValuePair("Parameter39.Name", Parameter39Name)); + } + + if (Parameter39Value != null) + { + p.Add(new KeyValuePair("Parameter39.Value", Parameter39Value)); + } + + if (Parameter40Name != null) + { + p.Add(new KeyValuePair("Parameter40.Name", Parameter40Name)); + } + + if (Parameter40Value != null) + { + p.Add(new KeyValuePair("Parameter40.Value", Parameter40Value)); + } + + if (Parameter41Name != null) + { + p.Add(new KeyValuePair("Parameter41.Name", Parameter41Name)); + } + + if (Parameter41Value != null) + { + p.Add(new KeyValuePair("Parameter41.Value", Parameter41Value)); + } + + if (Parameter42Name != null) + { + p.Add(new KeyValuePair("Parameter42.Name", Parameter42Name)); + } + + if (Parameter42Value != null) + { + p.Add(new KeyValuePair("Parameter42.Value", Parameter42Value)); + } + + if (Parameter43Name != null) + { + p.Add(new KeyValuePair("Parameter43.Name", Parameter43Name)); + } + + if (Parameter43Value != null) + { + p.Add(new KeyValuePair("Parameter43.Value", Parameter43Value)); + } + + if (Parameter44Name != null) + { + p.Add(new KeyValuePair("Parameter44.Name", Parameter44Name)); + } + + if (Parameter44Value != null) + { + p.Add(new KeyValuePair("Parameter44.Value", Parameter44Value)); + } + + if (Parameter45Name != null) + { + p.Add(new KeyValuePair("Parameter45.Name", Parameter45Name)); + } + + if (Parameter45Value != null) + { + p.Add(new KeyValuePair("Parameter45.Value", Parameter45Value)); + } + + if (Parameter46Name != null) + { + p.Add(new KeyValuePair("Parameter46.Name", Parameter46Name)); + } + + if (Parameter46Value != null) + { + p.Add(new KeyValuePair("Parameter46.Value", Parameter46Value)); + } + + if (Parameter47Name != null) + { + p.Add(new KeyValuePair("Parameter47.Name", Parameter47Name)); + } + + if (Parameter47Value != null) + { + p.Add(new KeyValuePair("Parameter47.Value", Parameter47Value)); + } + + if (Parameter48Name != null) + { + p.Add(new KeyValuePair("Parameter48.Name", Parameter48Name)); + } + + if (Parameter48Value != null) + { + p.Add(new KeyValuePair("Parameter48.Value", Parameter48Value)); + } + + if (Parameter49Name != null) + { + p.Add(new KeyValuePair("Parameter49.Name", Parameter49Name)); + } + + if (Parameter49Value != null) + { + p.Add(new KeyValuePair("Parameter49.Value", Parameter49Value)); + } + + if (Parameter50Name != null) + { + p.Add(new KeyValuePair("Parameter50.Name", Parameter50Name)); + } + + if (Parameter50Value != null) + { + p.Add(new KeyValuePair("Parameter50.Value", Parameter50Value)); + } + + if (Parameter51Name != null) + { + p.Add(new KeyValuePair("Parameter51.Name", Parameter51Name)); + } + + if (Parameter51Value != null) + { + p.Add(new KeyValuePair("Parameter51.Value", Parameter51Value)); + } + + if (Parameter52Name != null) + { + p.Add(new KeyValuePair("Parameter52.Name", Parameter52Name)); + } + + if (Parameter52Value != null) + { + p.Add(new KeyValuePair("Parameter52.Value", Parameter52Value)); + } + + if (Parameter53Name != null) + { + p.Add(new KeyValuePair("Parameter53.Name", Parameter53Name)); + } + + if (Parameter53Value != null) + { + p.Add(new KeyValuePair("Parameter53.Value", Parameter53Value)); + } + + if (Parameter54Name != null) + { + p.Add(new KeyValuePair("Parameter54.Name", Parameter54Name)); + } + + if (Parameter54Value != null) + { + p.Add(new KeyValuePair("Parameter54.Value", Parameter54Value)); + } + + if (Parameter55Name != null) + { + p.Add(new KeyValuePair("Parameter55.Name", Parameter55Name)); + } + + if (Parameter55Value != null) + { + p.Add(new KeyValuePair("Parameter55.Value", Parameter55Value)); + } + + if (Parameter56Name != null) + { + p.Add(new KeyValuePair("Parameter56.Name", Parameter56Name)); + } + + if (Parameter56Value != null) + { + p.Add(new KeyValuePair("Parameter56.Value", Parameter56Value)); + } + + if (Parameter57Name != null) + { + p.Add(new KeyValuePair("Parameter57.Name", Parameter57Name)); + } + + if (Parameter57Value != null) + { + p.Add(new KeyValuePair("Parameter57.Value", Parameter57Value)); + } + + if (Parameter58Name != null) + { + p.Add(new KeyValuePair("Parameter58.Name", Parameter58Name)); + } + + if (Parameter58Value != null) + { + p.Add(new KeyValuePair("Parameter58.Value", Parameter58Value)); + } + + if (Parameter59Name != null) + { + p.Add(new KeyValuePair("Parameter59.Name", Parameter59Name)); + } + + if (Parameter59Value != null) + { + p.Add(new KeyValuePair("Parameter59.Value", Parameter59Value)); + } + + if (Parameter60Name != null) + { + p.Add(new KeyValuePair("Parameter60.Name", Parameter60Name)); + } + + if (Parameter60Value != null) + { + p.Add(new KeyValuePair("Parameter60.Value", Parameter60Value)); + } + + if (Parameter61Name != null) + { + p.Add(new KeyValuePair("Parameter61.Name", Parameter61Name)); + } + + if (Parameter61Value != null) + { + p.Add(new KeyValuePair("Parameter61.Value", Parameter61Value)); + } + + if (Parameter62Name != null) + { + p.Add(new KeyValuePair("Parameter62.Name", Parameter62Name)); + } + + if (Parameter62Value != null) + { + p.Add(new KeyValuePair("Parameter62.Value", Parameter62Value)); + } + + if (Parameter63Name != null) + { + p.Add(new KeyValuePair("Parameter63.Name", Parameter63Name)); + } + + if (Parameter63Value != null) + { + p.Add(new KeyValuePair("Parameter63.Value", Parameter63Value)); + } + + if (Parameter64Name != null) + { + p.Add(new KeyValuePair("Parameter64.Name", Parameter64Name)); + } + + if (Parameter64Value != null) + { + p.Add(new KeyValuePair("Parameter64.Value", Parameter64Value)); + } + + if (Parameter65Name != null) + { + p.Add(new KeyValuePair("Parameter65.Name", Parameter65Name)); + } + + if (Parameter65Value != null) + { + p.Add(new KeyValuePair("Parameter65.Value", Parameter65Value)); + } + + if (Parameter66Name != null) + { + p.Add(new KeyValuePair("Parameter66.Name", Parameter66Name)); + } + + if (Parameter66Value != null) + { + p.Add(new KeyValuePair("Parameter66.Value", Parameter66Value)); + } + + if (Parameter67Name != null) + { + p.Add(new KeyValuePair("Parameter67.Name", Parameter67Name)); + } + + if (Parameter67Value != null) + { + p.Add(new KeyValuePair("Parameter67.Value", Parameter67Value)); + } + + if (Parameter68Name != null) + { + p.Add(new KeyValuePair("Parameter68.Name", Parameter68Name)); + } + + if (Parameter68Value != null) + { + p.Add(new KeyValuePair("Parameter68.Value", Parameter68Value)); + } + + if (Parameter69Name != null) + { + p.Add(new KeyValuePair("Parameter69.Name", Parameter69Name)); + } + + if (Parameter69Value != null) + { + p.Add(new KeyValuePair("Parameter69.Value", Parameter69Value)); + } + + if (Parameter70Name != null) + { + p.Add(new KeyValuePair("Parameter70.Name", Parameter70Name)); + } + + if (Parameter70Value != null) + { + p.Add(new KeyValuePair("Parameter70.Value", Parameter70Value)); + } + + if (Parameter71Name != null) + { + p.Add(new KeyValuePair("Parameter71.Name", Parameter71Name)); + } + + if (Parameter71Value != null) + { + p.Add(new KeyValuePair("Parameter71.Value", Parameter71Value)); + } + + if (Parameter72Name != null) + { + p.Add(new KeyValuePair("Parameter72.Name", Parameter72Name)); + } + + if (Parameter72Value != null) + { + p.Add(new KeyValuePair("Parameter72.Value", Parameter72Value)); + } + + if (Parameter73Name != null) + { + p.Add(new KeyValuePair("Parameter73.Name", Parameter73Name)); + } + + if (Parameter73Value != null) + { + p.Add(new KeyValuePair("Parameter73.Value", Parameter73Value)); + } + + if (Parameter74Name != null) + { + p.Add(new KeyValuePair("Parameter74.Name", Parameter74Name)); + } + + if (Parameter74Value != null) + { + p.Add(new KeyValuePair("Parameter74.Value", Parameter74Value)); + } + + if (Parameter75Name != null) + { + p.Add(new KeyValuePair("Parameter75.Name", Parameter75Name)); + } + + if (Parameter75Value != null) + { + p.Add(new KeyValuePair("Parameter75.Value", Parameter75Value)); + } + + if (Parameter76Name != null) + { + p.Add(new KeyValuePair("Parameter76.Name", Parameter76Name)); + } + + if (Parameter76Value != null) + { + p.Add(new KeyValuePair("Parameter76.Value", Parameter76Value)); + } + + if (Parameter77Name != null) + { + p.Add(new KeyValuePair("Parameter77.Name", Parameter77Name)); + } + + if (Parameter77Value != null) + { + p.Add(new KeyValuePair("Parameter77.Value", Parameter77Value)); + } + + if (Parameter78Name != null) + { + p.Add(new KeyValuePair("Parameter78.Name", Parameter78Name)); + } + + if (Parameter78Value != null) + { + p.Add(new KeyValuePair("Parameter78.Value", Parameter78Value)); + } + + if (Parameter79Name != null) + { + p.Add(new KeyValuePair("Parameter79.Name", Parameter79Name)); + } + + if (Parameter79Value != null) + { + p.Add(new KeyValuePair("Parameter79.Value", Parameter79Value)); + } + + if (Parameter80Name != null) + { + p.Add(new KeyValuePair("Parameter80.Name", Parameter80Name)); + } + + if (Parameter80Value != null) + { + p.Add(new KeyValuePair("Parameter80.Value", Parameter80Value)); + } + + if (Parameter81Name != null) + { + p.Add(new KeyValuePair("Parameter81.Name", Parameter81Name)); + } + + if (Parameter81Value != null) + { + p.Add(new KeyValuePair("Parameter81.Value", Parameter81Value)); + } + + if (Parameter82Name != null) + { + p.Add(new KeyValuePair("Parameter82.Name", Parameter82Name)); + } + + if (Parameter82Value != null) + { + p.Add(new KeyValuePair("Parameter82.Value", Parameter82Value)); + } + + if (Parameter83Name != null) + { + p.Add(new KeyValuePair("Parameter83.Name", Parameter83Name)); + } + + if (Parameter83Value != null) + { + p.Add(new KeyValuePair("Parameter83.Value", Parameter83Value)); + } + + if (Parameter84Name != null) + { + p.Add(new KeyValuePair("Parameter84.Name", Parameter84Name)); + } + + if (Parameter84Value != null) + { + p.Add(new KeyValuePair("Parameter84.Value", Parameter84Value)); + } + + if (Parameter85Name != null) + { + p.Add(new KeyValuePair("Parameter85.Name", Parameter85Name)); + } + + if (Parameter85Value != null) + { + p.Add(new KeyValuePair("Parameter85.Value", Parameter85Value)); + } + + if (Parameter86Name != null) + { + p.Add(new KeyValuePair("Parameter86.Name", Parameter86Name)); + } + + if (Parameter86Value != null) + { + p.Add(new KeyValuePair("Parameter86.Value", Parameter86Value)); + } + + if (Parameter87Name != null) + { + p.Add(new KeyValuePair("Parameter87.Name", Parameter87Name)); + } + + if (Parameter87Value != null) + { + p.Add(new KeyValuePair("Parameter87.Value", Parameter87Value)); + } + + if (Parameter88Name != null) + { + p.Add(new KeyValuePair("Parameter88.Name", Parameter88Name)); + } + + if (Parameter88Value != null) + { + p.Add(new KeyValuePair("Parameter88.Value", Parameter88Value)); + } + + if (Parameter89Name != null) + { + p.Add(new KeyValuePair("Parameter89.Name", Parameter89Name)); + } + + if (Parameter89Value != null) + { + p.Add(new KeyValuePair("Parameter89.Value", Parameter89Value)); + } + + if (Parameter90Name != null) + { + p.Add(new KeyValuePair("Parameter90.Name", Parameter90Name)); + } + + if (Parameter90Value != null) + { + p.Add(new KeyValuePair("Parameter90.Value", Parameter90Value)); + } + + if (Parameter91Name != null) + { + p.Add(new KeyValuePair("Parameter91.Name", Parameter91Name)); + } + + if (Parameter91Value != null) + { + p.Add(new KeyValuePair("Parameter91.Value", Parameter91Value)); + } + + if (Parameter92Name != null) + { + p.Add(new KeyValuePair("Parameter92.Name", Parameter92Name)); + } + + if (Parameter92Value != null) + { + p.Add(new KeyValuePair("Parameter92.Value", Parameter92Value)); + } + + if (Parameter93Name != null) + { + p.Add(new KeyValuePair("Parameter93.Name", Parameter93Name)); + } + + if (Parameter93Value != null) + { + p.Add(new KeyValuePair("Parameter93.Value", Parameter93Value)); + } + + if (Parameter94Name != null) + { + p.Add(new KeyValuePair("Parameter94.Name", Parameter94Name)); + } + + if (Parameter94Value != null) + { + p.Add(new KeyValuePair("Parameter94.Value", Parameter94Value)); + } + + if (Parameter95Name != null) + { + p.Add(new KeyValuePair("Parameter95.Name", Parameter95Name)); + } + + if (Parameter95Value != null) + { + p.Add(new KeyValuePair("Parameter95.Value", Parameter95Value)); + } + + if (Parameter96Name != null) + { + p.Add(new KeyValuePair("Parameter96.Name", Parameter96Name)); + } + + if (Parameter96Value != null) + { + p.Add(new KeyValuePair("Parameter96.Value", Parameter96Value)); + } + + if (Parameter97Name != null) + { + p.Add(new KeyValuePair("Parameter97.Name", Parameter97Name)); + } + + if (Parameter97Value != null) + { + p.Add(new KeyValuePair("Parameter97.Value", Parameter97Value)); + } + + if (Parameter98Name != null) + { + p.Add(new KeyValuePair("Parameter98.Name", Parameter98Name)); + } + + if (Parameter98Value != null) + { + p.Add(new KeyValuePair("Parameter98.Value", Parameter98Value)); + } + + if (Parameter99Name != null) + { + p.Add(new KeyValuePair("Parameter99.Name", Parameter99Name)); + } + + if (Parameter99Value != null) + { + p.Add(new KeyValuePair("Parameter99.Value", Parameter99Value)); + } + + return p; + } + } + + /// + /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource + /// + public class UpdateSiprecOptions : IOptions + { + /// + /// The SID of the Account that created this resource + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Call the resource is associated with + /// + public string PathCallSid { get; } + /// + /// The SID of the Siprec resource, or the `name` + /// + public string PathSid { get; } + /// + /// The status. Must have the value `stopped` + /// + public SiprecResource.UpdateStatusEnum Status { get; } + + /// + /// Construct a new UpdateSiprecOptions + /// + /// The SID of the Call the resource is associated with + /// The SID of the Siprec resource, or the `name` + /// The status. Must have the value `stopped` + public UpdateSiprecOptions(string pathCallSid, string pathSid, SiprecResource.UpdateStatusEnum status) + { + PathCallSid = pathCallSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Call/SiprecResource.cs b/src/Twilio/Rest/Api/V2010/Account/Call/SiprecResource.cs index fc78e6ddf..ec8c2af2c 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Call/SiprecResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Call/SiprecResource.cs @@ -17,1067 +17,1067 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Call -{ - - public class SiprecResource : Resource - { - public sealed class TrackEnum : StringEnum - { - private TrackEnum(string value) : base(value) {} - public TrackEnum() {} - public static implicit operator TrackEnum(string value) - { - return new TrackEnum(value); - } - - public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); - public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); - public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Stopped = new StatusEnum("stopped"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Stopped = new UpdateStatusEnum("stopped"); - } - - private static Request BuildCreateRequest(CreateSiprecOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Siprec.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a Siprec - /// - /// Create Siprec parameters - /// Client to make requests to Twilio - /// A single instance of Siprec - public static SiprecResource Create(CreateSiprecOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a Siprec - /// - /// Create Siprec parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Siprec - public static async System.Threading.Tasks.Task CreateAsync(CreateSiprecOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a Siprec - /// - /// The SID of the Call the resource is associated with - /// The SID of the Account that created this resource - /// The name of this resource - /// Unique name used when configuring the connector via Marketplace Add-on. - /// One of `inbound_track`, `outbound_track`, `both_tracks`. - /// Absolute URL of the status callback. - /// The http method for the status_callback. - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Client to make requests to Twilio - /// A single instance of Siprec - public static SiprecResource Create(string pathCallSid, - string pathAccountSid = null, - string name = null, - string connectorName = null, - SiprecResource.TrackEnum track = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string parameter1Name = null, - string parameter1Value = null, - string parameter2Name = null, - string parameter2Value = null, - string parameter3Name = null, - string parameter3Value = null, - string parameter4Name = null, - string parameter4Value = null, - string parameter5Name = null, - string parameter5Value = null, - string parameter6Name = null, - string parameter6Value = null, - string parameter7Name = null, - string parameter7Value = null, - string parameter8Name = null, - string parameter8Value = null, - string parameter9Name = null, - string parameter9Value = null, - string parameter10Name = null, - string parameter10Value = null, - string parameter11Name = null, - string parameter11Value = null, - string parameter12Name = null, - string parameter12Value = null, - string parameter13Name = null, - string parameter13Value = null, - string parameter14Name = null, - string parameter14Value = null, - string parameter15Name = null, - string parameter15Value = null, - string parameter16Name = null, - string parameter16Value = null, - string parameter17Name = null, - string parameter17Value = null, - string parameter18Name = null, - string parameter18Value = null, - string parameter19Name = null, - string parameter19Value = null, - string parameter20Name = null, - string parameter20Value = null, - string parameter21Name = null, - string parameter21Value = null, - string parameter22Name = null, - string parameter22Value = null, - string parameter23Name = null, - string parameter23Value = null, - string parameter24Name = null, - string parameter24Value = null, - string parameter25Name = null, - string parameter25Value = null, - string parameter26Name = null, - string parameter26Value = null, - string parameter27Name = null, - string parameter27Value = null, - string parameter28Name = null, - string parameter28Value = null, - string parameter29Name = null, - string parameter29Value = null, - string parameter30Name = null, - string parameter30Value = null, - string parameter31Name = null, - string parameter31Value = null, - string parameter32Name = null, - string parameter32Value = null, - string parameter33Name = null, - string parameter33Value = null, - string parameter34Name = null, - string parameter34Value = null, - string parameter35Name = null, - string parameter35Value = null, - string parameter36Name = null, - string parameter36Value = null, - string parameter37Name = null, - string parameter37Value = null, - string parameter38Name = null, - string parameter38Value = null, - string parameter39Name = null, - string parameter39Value = null, - string parameter40Name = null, - string parameter40Value = null, - string parameter41Name = null, - string parameter41Value = null, - string parameter42Name = null, - string parameter42Value = null, - string parameter43Name = null, - string parameter43Value = null, - string parameter44Name = null, - string parameter44Value = null, - string parameter45Name = null, - string parameter45Value = null, - string parameter46Name = null, - string parameter46Value = null, - string parameter47Name = null, - string parameter47Value = null, - string parameter48Name = null, - string parameter48Value = null, - string parameter49Name = null, - string parameter49Value = null, - string parameter50Name = null, - string parameter50Value = null, - string parameter51Name = null, - string parameter51Value = null, - string parameter52Name = null, - string parameter52Value = null, - string parameter53Name = null, - string parameter53Value = null, - string parameter54Name = null, - string parameter54Value = null, - string parameter55Name = null, - string parameter55Value = null, - string parameter56Name = null, - string parameter56Value = null, - string parameter57Name = null, - string parameter57Value = null, - string parameter58Name = null, - string parameter58Value = null, - string parameter59Name = null, - string parameter59Value = null, - string parameter60Name = null, - string parameter60Value = null, - string parameter61Name = null, - string parameter61Value = null, - string parameter62Name = null, - string parameter62Value = null, - string parameter63Name = null, - string parameter63Value = null, - string parameter64Name = null, - string parameter64Value = null, - string parameter65Name = null, - string parameter65Value = null, - string parameter66Name = null, - string parameter66Value = null, - string parameter67Name = null, - string parameter67Value = null, - string parameter68Name = null, - string parameter68Value = null, - string parameter69Name = null, - string parameter69Value = null, - string parameter70Name = null, - string parameter70Value = null, - string parameter71Name = null, - string parameter71Value = null, - string parameter72Name = null, - string parameter72Value = null, - string parameter73Name = null, - string parameter73Value = null, - string parameter74Name = null, - string parameter74Value = null, - string parameter75Name = null, - string parameter75Value = null, - string parameter76Name = null, - string parameter76Value = null, - string parameter77Name = null, - string parameter77Value = null, - string parameter78Name = null, - string parameter78Value = null, - string parameter79Name = null, - string parameter79Value = null, - string parameter80Name = null, - string parameter80Value = null, - string parameter81Name = null, - string parameter81Value = null, - string parameter82Name = null, - string parameter82Value = null, - string parameter83Name = null, - string parameter83Value = null, - string parameter84Name = null, - string parameter84Value = null, - string parameter85Name = null, - string parameter85Value = null, - string parameter86Name = null, - string parameter86Value = null, - string parameter87Name = null, - string parameter87Value = null, - string parameter88Name = null, - string parameter88Value = null, - string parameter89Name = null, - string parameter89Value = null, - string parameter90Name = null, - string parameter90Value = null, - string parameter91Name = null, - string parameter91Value = null, - string parameter92Name = null, - string parameter92Value = null, - string parameter93Name = null, - string parameter93Value = null, - string parameter94Name = null, - string parameter94Value = null, - string parameter95Name = null, - string parameter95Value = null, - string parameter96Name = null, - string parameter96Value = null, - string parameter97Name = null, - string parameter97Value = null, - string parameter98Name = null, - string parameter98Value = null, - string parameter99Name = null, - string parameter99Value = null, - ITwilioRestClient client = null) - { - var options = new CreateSiprecOptions(pathCallSid){PathAccountSid = pathAccountSid, Name = name, ConnectorName = connectorName, Track = track, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Parameter1Name = parameter1Name, Parameter1Value = parameter1Value, Parameter2Name = parameter2Name, Parameter2Value = parameter2Value, Parameter3Name = parameter3Name, Parameter3Value = parameter3Value, Parameter4Name = parameter4Name, Parameter4Value = parameter4Value, Parameter5Name = parameter5Name, Parameter5Value = parameter5Value, Parameter6Name = parameter6Name, Parameter6Value = parameter6Value, Parameter7Name = parameter7Name, Parameter7Value = parameter7Value, Parameter8Name = parameter8Name, Parameter8Value = parameter8Value, Parameter9Name = parameter9Name, Parameter9Value = parameter9Value, Parameter10Name = parameter10Name, Parameter10Value = parameter10Value, Parameter11Name = parameter11Name, Parameter11Value = parameter11Value, Parameter12Name = parameter12Name, Parameter12Value = parameter12Value, Parameter13Name = parameter13Name, Parameter13Value = parameter13Value, Parameter14Name = parameter14Name, Parameter14Value = parameter14Value, Parameter15Name = parameter15Name, Parameter15Value = parameter15Value, Parameter16Name = parameter16Name, Parameter16Value = parameter16Value, Parameter17Name = parameter17Name, Parameter17Value = parameter17Value, Parameter18Name = parameter18Name, Parameter18Value = parameter18Value, Parameter19Name = parameter19Name, Parameter19Value = parameter19Value, Parameter20Name = parameter20Name, Parameter20Value = parameter20Value, Parameter21Name = parameter21Name, Parameter21Value = parameter21Value, Parameter22Name = parameter22Name, Parameter22Value = parameter22Value, Parameter23Name = parameter23Name, Parameter23Value = parameter23Value, Parameter24Name = parameter24Name, Parameter24Value = parameter24Value, Parameter25Name = parameter25Name, Parameter25Value = parameter25Value, Parameter26Name = parameter26Name, Parameter26Value = parameter26Value, Parameter27Name = parameter27Name, Parameter27Value = parameter27Value, Parameter28Name = parameter28Name, Parameter28Value = parameter28Value, Parameter29Name = parameter29Name, Parameter29Value = parameter29Value, Parameter30Name = parameter30Name, Parameter30Value = parameter30Value, Parameter31Name = parameter31Name, Parameter31Value = parameter31Value, Parameter32Name = parameter32Name, Parameter32Value = parameter32Value, Parameter33Name = parameter33Name, Parameter33Value = parameter33Value, Parameter34Name = parameter34Name, Parameter34Value = parameter34Value, Parameter35Name = parameter35Name, Parameter35Value = parameter35Value, Parameter36Name = parameter36Name, Parameter36Value = parameter36Value, Parameter37Name = parameter37Name, Parameter37Value = parameter37Value, Parameter38Name = parameter38Name, Parameter38Value = parameter38Value, Parameter39Name = parameter39Name, Parameter39Value = parameter39Value, Parameter40Name = parameter40Name, Parameter40Value = parameter40Value, Parameter41Name = parameter41Name, Parameter41Value = parameter41Value, Parameter42Name = parameter42Name, Parameter42Value = parameter42Value, Parameter43Name = parameter43Name, Parameter43Value = parameter43Value, Parameter44Name = parameter44Name, Parameter44Value = parameter44Value, Parameter45Name = parameter45Name, Parameter45Value = parameter45Value, Parameter46Name = parameter46Name, Parameter46Value = parameter46Value, Parameter47Name = parameter47Name, Parameter47Value = parameter47Value, Parameter48Name = parameter48Name, Parameter48Value = parameter48Value, Parameter49Name = parameter49Name, Parameter49Value = parameter49Value, Parameter50Name = parameter50Name, Parameter50Value = parameter50Value, Parameter51Name = parameter51Name, Parameter51Value = parameter51Value, Parameter52Name = parameter52Name, Parameter52Value = parameter52Value, Parameter53Name = parameter53Name, Parameter53Value = parameter53Value, Parameter54Name = parameter54Name, Parameter54Value = parameter54Value, Parameter55Name = parameter55Name, Parameter55Value = parameter55Value, Parameter56Name = parameter56Name, Parameter56Value = parameter56Value, Parameter57Name = parameter57Name, Parameter57Value = parameter57Value, Parameter58Name = parameter58Name, Parameter58Value = parameter58Value, Parameter59Name = parameter59Name, Parameter59Value = parameter59Value, Parameter60Name = parameter60Name, Parameter60Value = parameter60Value, Parameter61Name = parameter61Name, Parameter61Value = parameter61Value, Parameter62Name = parameter62Name, Parameter62Value = parameter62Value, Parameter63Name = parameter63Name, Parameter63Value = parameter63Value, Parameter64Name = parameter64Name, Parameter64Value = parameter64Value, Parameter65Name = parameter65Name, Parameter65Value = parameter65Value, Parameter66Name = parameter66Name, Parameter66Value = parameter66Value, Parameter67Name = parameter67Name, Parameter67Value = parameter67Value, Parameter68Name = parameter68Name, Parameter68Value = parameter68Value, Parameter69Name = parameter69Name, Parameter69Value = parameter69Value, Parameter70Name = parameter70Name, Parameter70Value = parameter70Value, Parameter71Name = parameter71Name, Parameter71Value = parameter71Value, Parameter72Name = parameter72Name, Parameter72Value = parameter72Value, Parameter73Name = parameter73Name, Parameter73Value = parameter73Value, Parameter74Name = parameter74Name, Parameter74Value = parameter74Value, Parameter75Name = parameter75Name, Parameter75Value = parameter75Value, Parameter76Name = parameter76Name, Parameter76Value = parameter76Value, Parameter77Name = parameter77Name, Parameter77Value = parameter77Value, Parameter78Name = parameter78Name, Parameter78Value = parameter78Value, Parameter79Name = parameter79Name, Parameter79Value = parameter79Value, Parameter80Name = parameter80Name, Parameter80Value = parameter80Value, Parameter81Name = parameter81Name, Parameter81Value = parameter81Value, Parameter82Name = parameter82Name, Parameter82Value = parameter82Value, Parameter83Name = parameter83Name, Parameter83Value = parameter83Value, Parameter84Name = parameter84Name, Parameter84Value = parameter84Value, Parameter85Name = parameter85Name, Parameter85Value = parameter85Value, Parameter86Name = parameter86Name, Parameter86Value = parameter86Value, Parameter87Name = parameter87Name, Parameter87Value = parameter87Value, Parameter88Name = parameter88Name, Parameter88Value = parameter88Value, Parameter89Name = parameter89Name, Parameter89Value = parameter89Value, Parameter90Name = parameter90Name, Parameter90Value = parameter90Value, Parameter91Name = parameter91Name, Parameter91Value = parameter91Value, Parameter92Name = parameter92Name, Parameter92Value = parameter92Value, Parameter93Name = parameter93Name, Parameter93Value = parameter93Value, Parameter94Name = parameter94Name, Parameter94Value = parameter94Value, Parameter95Name = parameter95Name, Parameter95Value = parameter95Value, Parameter96Name = parameter96Name, Parameter96Value = parameter96Value, Parameter97Name = parameter97Name, Parameter97Value = parameter97Value, Parameter98Name = parameter98Name, Parameter98Value = parameter98Value, Parameter99Name = parameter99Name, Parameter99Value = parameter99Value}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a Siprec - /// - /// The SID of the Call the resource is associated with - /// The SID of the Account that created this resource - /// The name of this resource - /// Unique name used when configuring the connector via Marketplace Add-on. - /// One of `inbound_track`, `outbound_track`, `both_tracks`. - /// Absolute URL of the status callback. - /// The http method for the status_callback. - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Parameter name - /// Parameter value - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Siprec - public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, - string pathAccountSid = null, - string name = null, - string connectorName = null, - SiprecResource.TrackEnum track = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string parameter1Name = null, - string parameter1Value = null, - string parameter2Name = null, - string parameter2Value = null, - string parameter3Name = null, - string parameter3Value = null, - string parameter4Name = null, - string parameter4Value = null, - string parameter5Name = null, - string parameter5Value = null, - string parameter6Name = null, - string parameter6Value = null, - string parameter7Name = null, - string parameter7Value = null, - string parameter8Name = null, - string parameter8Value = null, - string parameter9Name = null, - string parameter9Value = null, - string parameter10Name = null, - string parameter10Value = null, - string parameter11Name = null, - string parameter11Value = null, - string parameter12Name = null, - string parameter12Value = null, - string parameter13Name = null, - string parameter13Value = null, - string parameter14Name = null, - string parameter14Value = null, - string parameter15Name = null, - string parameter15Value = null, - string parameter16Name = null, - string parameter16Value = null, - string parameter17Name = null, - string parameter17Value = null, - string parameter18Name = null, - string parameter18Value = null, - string parameter19Name = null, - string parameter19Value = null, - string parameter20Name = null, - string parameter20Value = null, - string parameter21Name = null, - string parameter21Value = null, - string parameter22Name = null, - string parameter22Value = null, - string parameter23Name = null, - string parameter23Value = null, - string parameter24Name = null, - string parameter24Value = null, - string parameter25Name = null, - string parameter25Value = null, - string parameter26Name = null, - string parameter26Value = null, - string parameter27Name = null, - string parameter27Value = null, - string parameter28Name = null, - string parameter28Value = null, - string parameter29Name = null, - string parameter29Value = null, - string parameter30Name = null, - string parameter30Value = null, - string parameter31Name = null, - string parameter31Value = null, - string parameter32Name = null, - string parameter32Value = null, - string parameter33Name = null, - string parameter33Value = null, - string parameter34Name = null, - string parameter34Value = null, - string parameter35Name = null, - string parameter35Value = null, - string parameter36Name = null, - string parameter36Value = null, - string parameter37Name = null, - string parameter37Value = null, - string parameter38Name = null, - string parameter38Value = null, - string parameter39Name = null, - string parameter39Value = null, - string parameter40Name = null, - string parameter40Value = null, - string parameter41Name = null, - string parameter41Value = null, - string parameter42Name = null, - string parameter42Value = null, - string parameter43Name = null, - string parameter43Value = null, - string parameter44Name = null, - string parameter44Value = null, - string parameter45Name = null, - string parameter45Value = null, - string parameter46Name = null, - string parameter46Value = null, - string parameter47Name = null, - string parameter47Value = null, - string parameter48Name = null, - string parameter48Value = null, - string parameter49Name = null, - string parameter49Value = null, - string parameter50Name = null, - string parameter50Value = null, - string parameter51Name = null, - string parameter51Value = null, - string parameter52Name = null, - string parameter52Value = null, - string parameter53Name = null, - string parameter53Value = null, - string parameter54Name = null, - string parameter54Value = null, - string parameter55Name = null, - string parameter55Value = null, - string parameter56Name = null, - string parameter56Value = null, - string parameter57Name = null, - string parameter57Value = null, - string parameter58Name = null, - string parameter58Value = null, - string parameter59Name = null, - string parameter59Value = null, - string parameter60Name = null, - string parameter60Value = null, - string parameter61Name = null, - string parameter61Value = null, - string parameter62Name = null, - string parameter62Value = null, - string parameter63Name = null, - string parameter63Value = null, - string parameter64Name = null, - string parameter64Value = null, - string parameter65Name = null, - string parameter65Value = null, - string parameter66Name = null, - string parameter66Value = null, - string parameter67Name = null, - string parameter67Value = null, - string parameter68Name = null, - string parameter68Value = null, - string parameter69Name = null, - string parameter69Value = null, - string parameter70Name = null, - string parameter70Value = null, - string parameter71Name = null, - string parameter71Value = null, - string parameter72Name = null, - string parameter72Value = null, - string parameter73Name = null, - string parameter73Value = null, - string parameter74Name = null, - string parameter74Value = null, - string parameter75Name = null, - string parameter75Value = null, - string parameter76Name = null, - string parameter76Value = null, - string parameter77Name = null, - string parameter77Value = null, - string parameter78Name = null, - string parameter78Value = null, - string parameter79Name = null, - string parameter79Value = null, - string parameter80Name = null, - string parameter80Value = null, - string parameter81Name = null, - string parameter81Value = null, - string parameter82Name = null, - string parameter82Value = null, - string parameter83Name = null, - string parameter83Value = null, - string parameter84Name = null, - string parameter84Value = null, - string parameter85Name = null, - string parameter85Value = null, - string parameter86Name = null, - string parameter86Value = null, - string parameter87Name = null, - string parameter87Value = null, - string parameter88Name = null, - string parameter88Value = null, - string parameter89Name = null, - string parameter89Value = null, - string parameter90Name = null, - string parameter90Value = null, - string parameter91Name = null, - string parameter91Value = null, - string parameter92Name = null, - string parameter92Value = null, - string parameter93Name = null, - string parameter93Value = null, - string parameter94Name = null, - string parameter94Value = null, - string parameter95Name = null, - string parameter95Value = null, - string parameter96Name = null, - string parameter96Value = null, - string parameter97Name = null, - string parameter97Value = null, - string parameter98Name = null, - string parameter98Value = null, - string parameter99Name = null, - string parameter99Value = null, - ITwilioRestClient client = null) - { - var options = new CreateSiprecOptions(pathCallSid){PathAccountSid = pathAccountSid, Name = name, ConnectorName = connectorName, Track = track, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Parameter1Name = parameter1Name, Parameter1Value = parameter1Value, Parameter2Name = parameter2Name, Parameter2Value = parameter2Value, Parameter3Name = parameter3Name, Parameter3Value = parameter3Value, Parameter4Name = parameter4Name, Parameter4Value = parameter4Value, Parameter5Name = parameter5Name, Parameter5Value = parameter5Value, Parameter6Name = parameter6Name, Parameter6Value = parameter6Value, Parameter7Name = parameter7Name, Parameter7Value = parameter7Value, Parameter8Name = parameter8Name, Parameter8Value = parameter8Value, Parameter9Name = parameter9Name, Parameter9Value = parameter9Value, Parameter10Name = parameter10Name, Parameter10Value = parameter10Value, Parameter11Name = parameter11Name, Parameter11Value = parameter11Value, Parameter12Name = parameter12Name, Parameter12Value = parameter12Value, Parameter13Name = parameter13Name, Parameter13Value = parameter13Value, Parameter14Name = parameter14Name, Parameter14Value = parameter14Value, Parameter15Name = parameter15Name, Parameter15Value = parameter15Value, Parameter16Name = parameter16Name, Parameter16Value = parameter16Value, Parameter17Name = parameter17Name, Parameter17Value = parameter17Value, Parameter18Name = parameter18Name, Parameter18Value = parameter18Value, Parameter19Name = parameter19Name, Parameter19Value = parameter19Value, Parameter20Name = parameter20Name, Parameter20Value = parameter20Value, Parameter21Name = parameter21Name, Parameter21Value = parameter21Value, Parameter22Name = parameter22Name, Parameter22Value = parameter22Value, Parameter23Name = parameter23Name, Parameter23Value = parameter23Value, Parameter24Name = parameter24Name, Parameter24Value = parameter24Value, Parameter25Name = parameter25Name, Parameter25Value = parameter25Value, Parameter26Name = parameter26Name, Parameter26Value = parameter26Value, Parameter27Name = parameter27Name, Parameter27Value = parameter27Value, Parameter28Name = parameter28Name, Parameter28Value = parameter28Value, Parameter29Name = parameter29Name, Parameter29Value = parameter29Value, Parameter30Name = parameter30Name, Parameter30Value = parameter30Value, Parameter31Name = parameter31Name, Parameter31Value = parameter31Value, Parameter32Name = parameter32Name, Parameter32Value = parameter32Value, Parameter33Name = parameter33Name, Parameter33Value = parameter33Value, Parameter34Name = parameter34Name, Parameter34Value = parameter34Value, Parameter35Name = parameter35Name, Parameter35Value = parameter35Value, Parameter36Name = parameter36Name, Parameter36Value = parameter36Value, Parameter37Name = parameter37Name, Parameter37Value = parameter37Value, Parameter38Name = parameter38Name, Parameter38Value = parameter38Value, Parameter39Name = parameter39Name, Parameter39Value = parameter39Value, Parameter40Name = parameter40Name, Parameter40Value = parameter40Value, Parameter41Name = parameter41Name, Parameter41Value = parameter41Value, Parameter42Name = parameter42Name, Parameter42Value = parameter42Value, Parameter43Name = parameter43Name, Parameter43Value = parameter43Value, Parameter44Name = parameter44Name, Parameter44Value = parameter44Value, Parameter45Name = parameter45Name, Parameter45Value = parameter45Value, Parameter46Name = parameter46Name, Parameter46Value = parameter46Value, Parameter47Name = parameter47Name, Parameter47Value = parameter47Value, Parameter48Name = parameter48Name, Parameter48Value = parameter48Value, Parameter49Name = parameter49Name, Parameter49Value = parameter49Value, Parameter50Name = parameter50Name, Parameter50Value = parameter50Value, Parameter51Name = parameter51Name, Parameter51Value = parameter51Value, Parameter52Name = parameter52Name, Parameter52Value = parameter52Value, Parameter53Name = parameter53Name, Parameter53Value = parameter53Value, Parameter54Name = parameter54Name, Parameter54Value = parameter54Value, Parameter55Name = parameter55Name, Parameter55Value = parameter55Value, Parameter56Name = parameter56Name, Parameter56Value = parameter56Value, Parameter57Name = parameter57Name, Parameter57Value = parameter57Value, Parameter58Name = parameter58Name, Parameter58Value = parameter58Value, Parameter59Name = parameter59Name, Parameter59Value = parameter59Value, Parameter60Name = parameter60Name, Parameter60Value = parameter60Value, Parameter61Name = parameter61Name, Parameter61Value = parameter61Value, Parameter62Name = parameter62Name, Parameter62Value = parameter62Value, Parameter63Name = parameter63Name, Parameter63Value = parameter63Value, Parameter64Name = parameter64Name, Parameter64Value = parameter64Value, Parameter65Name = parameter65Name, Parameter65Value = parameter65Value, Parameter66Name = parameter66Name, Parameter66Value = parameter66Value, Parameter67Name = parameter67Name, Parameter67Value = parameter67Value, Parameter68Name = parameter68Name, Parameter68Value = parameter68Value, Parameter69Name = parameter69Name, Parameter69Value = parameter69Value, Parameter70Name = parameter70Name, Parameter70Value = parameter70Value, Parameter71Name = parameter71Name, Parameter71Value = parameter71Value, Parameter72Name = parameter72Name, Parameter72Value = parameter72Value, Parameter73Name = parameter73Name, Parameter73Value = parameter73Value, Parameter74Name = parameter74Name, Parameter74Value = parameter74Value, Parameter75Name = parameter75Name, Parameter75Value = parameter75Value, Parameter76Name = parameter76Name, Parameter76Value = parameter76Value, Parameter77Name = parameter77Name, Parameter77Value = parameter77Value, Parameter78Name = parameter78Name, Parameter78Value = parameter78Value, Parameter79Name = parameter79Name, Parameter79Value = parameter79Value, Parameter80Name = parameter80Name, Parameter80Value = parameter80Value, Parameter81Name = parameter81Name, Parameter81Value = parameter81Value, Parameter82Name = parameter82Name, Parameter82Value = parameter82Value, Parameter83Name = parameter83Name, Parameter83Value = parameter83Value, Parameter84Name = parameter84Name, Parameter84Value = parameter84Value, Parameter85Name = parameter85Name, Parameter85Value = parameter85Value, Parameter86Name = parameter86Name, Parameter86Value = parameter86Value, Parameter87Name = parameter87Name, Parameter87Value = parameter87Value, Parameter88Name = parameter88Name, Parameter88Value = parameter88Value, Parameter89Name = parameter89Name, Parameter89Value = parameter89Value, Parameter90Name = parameter90Name, Parameter90Value = parameter90Value, Parameter91Name = parameter91Name, Parameter91Value = parameter91Value, Parameter92Name = parameter92Name, Parameter92Value = parameter92Value, Parameter93Name = parameter93Name, Parameter93Value = parameter93Value, Parameter94Name = parameter94Name, Parameter94Value = parameter94Value, Parameter95Name = parameter95Name, Parameter95Value = parameter95Value, Parameter96Name = parameter96Name, Parameter96Value = parameter96Value, Parameter97Name = parameter97Name, Parameter97Value = parameter97Value, Parameter98Name = parameter98Name, Parameter98Value = parameter98Value, Parameter99Name = parameter99Name, Parameter99Value = parameter99Value}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSiprecOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Siprec/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource - /// - /// Update Siprec parameters - /// Client to make requests to Twilio - /// A single instance of Siprec - public static SiprecResource Update(UpdateSiprecOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource - /// - /// Update Siprec parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Siprec - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSiprecOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource - /// - /// The SID of the Call the resource is associated with - /// The SID of the Siprec resource, or the `name` - /// The status. Must have the value `stopped` - /// The SID of the Account that created this resource - /// Client to make requests to Twilio - /// A single instance of Siprec - public static SiprecResource Update(string pathCallSid, - string pathSid, - SiprecResource.UpdateStatusEnum status, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSiprecOptions(pathCallSid, pathSid, status){PathAccountSid = pathAccountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource - /// - /// The SID of the Call the resource is associated with - /// The SID of the Siprec resource, or the `name` - /// The status. Must have the value `stopped` - /// The SID of the Account that created this resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Siprec - public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, - string pathSid, - SiprecResource.UpdateStatusEnum status, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSiprecOptions(pathCallSid, pathSid, status){PathAccountSid = pathAccountSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SiprecResource object - /// - /// Raw JSON string - /// SiprecResource object represented by the provided JSON - public static SiprecResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Siprec resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The name of this resource - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The status - one of `stopped`, `in-progress` - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SiprecResource.StatusEnum Status { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private SiprecResource() - { - - } - } +{ + + public class SiprecResource : Resource + { + public sealed class TrackEnum : StringEnum + { + private TrackEnum(string value) : base(value) { } + public TrackEnum() { } + public static implicit operator TrackEnum(string value) + { + return new TrackEnum(value); + } + + public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); + public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); + public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Stopped = new StatusEnum("stopped"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Stopped = new UpdateStatusEnum("stopped"); + } + + private static Request BuildCreateRequest(CreateSiprecOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Siprec.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a Siprec + /// + /// Create Siprec parameters + /// Client to make requests to Twilio + /// A single instance of Siprec + public static SiprecResource Create(CreateSiprecOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a Siprec + /// + /// Create Siprec parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Siprec + public static async System.Threading.Tasks.Task CreateAsync(CreateSiprecOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a Siprec + /// + /// The SID of the Call the resource is associated with + /// The SID of the Account that created this resource + /// The name of this resource + /// Unique name used when configuring the connector via Marketplace Add-on. + /// One of `inbound_track`, `outbound_track`, `both_tracks`. + /// Absolute URL of the status callback. + /// The http method for the status_callback. + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Client to make requests to Twilio + /// A single instance of Siprec + public static SiprecResource Create(string pathCallSid, + string pathAccountSid = null, + string name = null, + string connectorName = null, + SiprecResource.TrackEnum track = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string parameter1Name = null, + string parameter1Value = null, + string parameter2Name = null, + string parameter2Value = null, + string parameter3Name = null, + string parameter3Value = null, + string parameter4Name = null, + string parameter4Value = null, + string parameter5Name = null, + string parameter5Value = null, + string parameter6Name = null, + string parameter6Value = null, + string parameter7Name = null, + string parameter7Value = null, + string parameter8Name = null, + string parameter8Value = null, + string parameter9Name = null, + string parameter9Value = null, + string parameter10Name = null, + string parameter10Value = null, + string parameter11Name = null, + string parameter11Value = null, + string parameter12Name = null, + string parameter12Value = null, + string parameter13Name = null, + string parameter13Value = null, + string parameter14Name = null, + string parameter14Value = null, + string parameter15Name = null, + string parameter15Value = null, + string parameter16Name = null, + string parameter16Value = null, + string parameter17Name = null, + string parameter17Value = null, + string parameter18Name = null, + string parameter18Value = null, + string parameter19Name = null, + string parameter19Value = null, + string parameter20Name = null, + string parameter20Value = null, + string parameter21Name = null, + string parameter21Value = null, + string parameter22Name = null, + string parameter22Value = null, + string parameter23Name = null, + string parameter23Value = null, + string parameter24Name = null, + string parameter24Value = null, + string parameter25Name = null, + string parameter25Value = null, + string parameter26Name = null, + string parameter26Value = null, + string parameter27Name = null, + string parameter27Value = null, + string parameter28Name = null, + string parameter28Value = null, + string parameter29Name = null, + string parameter29Value = null, + string parameter30Name = null, + string parameter30Value = null, + string parameter31Name = null, + string parameter31Value = null, + string parameter32Name = null, + string parameter32Value = null, + string parameter33Name = null, + string parameter33Value = null, + string parameter34Name = null, + string parameter34Value = null, + string parameter35Name = null, + string parameter35Value = null, + string parameter36Name = null, + string parameter36Value = null, + string parameter37Name = null, + string parameter37Value = null, + string parameter38Name = null, + string parameter38Value = null, + string parameter39Name = null, + string parameter39Value = null, + string parameter40Name = null, + string parameter40Value = null, + string parameter41Name = null, + string parameter41Value = null, + string parameter42Name = null, + string parameter42Value = null, + string parameter43Name = null, + string parameter43Value = null, + string parameter44Name = null, + string parameter44Value = null, + string parameter45Name = null, + string parameter45Value = null, + string parameter46Name = null, + string parameter46Value = null, + string parameter47Name = null, + string parameter47Value = null, + string parameter48Name = null, + string parameter48Value = null, + string parameter49Name = null, + string parameter49Value = null, + string parameter50Name = null, + string parameter50Value = null, + string parameter51Name = null, + string parameter51Value = null, + string parameter52Name = null, + string parameter52Value = null, + string parameter53Name = null, + string parameter53Value = null, + string parameter54Name = null, + string parameter54Value = null, + string parameter55Name = null, + string parameter55Value = null, + string parameter56Name = null, + string parameter56Value = null, + string parameter57Name = null, + string parameter57Value = null, + string parameter58Name = null, + string parameter58Value = null, + string parameter59Name = null, + string parameter59Value = null, + string parameter60Name = null, + string parameter60Value = null, + string parameter61Name = null, + string parameter61Value = null, + string parameter62Name = null, + string parameter62Value = null, + string parameter63Name = null, + string parameter63Value = null, + string parameter64Name = null, + string parameter64Value = null, + string parameter65Name = null, + string parameter65Value = null, + string parameter66Name = null, + string parameter66Value = null, + string parameter67Name = null, + string parameter67Value = null, + string parameter68Name = null, + string parameter68Value = null, + string parameter69Name = null, + string parameter69Value = null, + string parameter70Name = null, + string parameter70Value = null, + string parameter71Name = null, + string parameter71Value = null, + string parameter72Name = null, + string parameter72Value = null, + string parameter73Name = null, + string parameter73Value = null, + string parameter74Name = null, + string parameter74Value = null, + string parameter75Name = null, + string parameter75Value = null, + string parameter76Name = null, + string parameter76Value = null, + string parameter77Name = null, + string parameter77Value = null, + string parameter78Name = null, + string parameter78Value = null, + string parameter79Name = null, + string parameter79Value = null, + string parameter80Name = null, + string parameter80Value = null, + string parameter81Name = null, + string parameter81Value = null, + string parameter82Name = null, + string parameter82Value = null, + string parameter83Name = null, + string parameter83Value = null, + string parameter84Name = null, + string parameter84Value = null, + string parameter85Name = null, + string parameter85Value = null, + string parameter86Name = null, + string parameter86Value = null, + string parameter87Name = null, + string parameter87Value = null, + string parameter88Name = null, + string parameter88Value = null, + string parameter89Name = null, + string parameter89Value = null, + string parameter90Name = null, + string parameter90Value = null, + string parameter91Name = null, + string parameter91Value = null, + string parameter92Name = null, + string parameter92Value = null, + string parameter93Name = null, + string parameter93Value = null, + string parameter94Name = null, + string parameter94Value = null, + string parameter95Name = null, + string parameter95Value = null, + string parameter96Name = null, + string parameter96Value = null, + string parameter97Name = null, + string parameter97Value = null, + string parameter98Name = null, + string parameter98Value = null, + string parameter99Name = null, + string parameter99Value = null, + ITwilioRestClient client = null) + { + var options = new CreateSiprecOptions(pathCallSid) { PathAccountSid = pathAccountSid, Name = name, ConnectorName = connectorName, Track = track, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Parameter1Name = parameter1Name, Parameter1Value = parameter1Value, Parameter2Name = parameter2Name, Parameter2Value = parameter2Value, Parameter3Name = parameter3Name, Parameter3Value = parameter3Value, Parameter4Name = parameter4Name, Parameter4Value = parameter4Value, Parameter5Name = parameter5Name, Parameter5Value = parameter5Value, Parameter6Name = parameter6Name, Parameter6Value = parameter6Value, Parameter7Name = parameter7Name, Parameter7Value = parameter7Value, Parameter8Name = parameter8Name, Parameter8Value = parameter8Value, Parameter9Name = parameter9Name, Parameter9Value = parameter9Value, Parameter10Name = parameter10Name, Parameter10Value = parameter10Value, Parameter11Name = parameter11Name, Parameter11Value = parameter11Value, Parameter12Name = parameter12Name, Parameter12Value = parameter12Value, Parameter13Name = parameter13Name, Parameter13Value = parameter13Value, Parameter14Name = parameter14Name, Parameter14Value = parameter14Value, Parameter15Name = parameter15Name, Parameter15Value = parameter15Value, Parameter16Name = parameter16Name, Parameter16Value = parameter16Value, Parameter17Name = parameter17Name, Parameter17Value = parameter17Value, Parameter18Name = parameter18Name, Parameter18Value = parameter18Value, Parameter19Name = parameter19Name, Parameter19Value = parameter19Value, Parameter20Name = parameter20Name, Parameter20Value = parameter20Value, Parameter21Name = parameter21Name, Parameter21Value = parameter21Value, Parameter22Name = parameter22Name, Parameter22Value = parameter22Value, Parameter23Name = parameter23Name, Parameter23Value = parameter23Value, Parameter24Name = parameter24Name, Parameter24Value = parameter24Value, Parameter25Name = parameter25Name, Parameter25Value = parameter25Value, Parameter26Name = parameter26Name, Parameter26Value = parameter26Value, Parameter27Name = parameter27Name, Parameter27Value = parameter27Value, Parameter28Name = parameter28Name, Parameter28Value = parameter28Value, Parameter29Name = parameter29Name, Parameter29Value = parameter29Value, Parameter30Name = parameter30Name, Parameter30Value = parameter30Value, Parameter31Name = parameter31Name, Parameter31Value = parameter31Value, Parameter32Name = parameter32Name, Parameter32Value = parameter32Value, Parameter33Name = parameter33Name, Parameter33Value = parameter33Value, Parameter34Name = parameter34Name, Parameter34Value = parameter34Value, Parameter35Name = parameter35Name, Parameter35Value = parameter35Value, Parameter36Name = parameter36Name, Parameter36Value = parameter36Value, Parameter37Name = parameter37Name, Parameter37Value = parameter37Value, Parameter38Name = parameter38Name, Parameter38Value = parameter38Value, Parameter39Name = parameter39Name, Parameter39Value = parameter39Value, Parameter40Name = parameter40Name, Parameter40Value = parameter40Value, Parameter41Name = parameter41Name, Parameter41Value = parameter41Value, Parameter42Name = parameter42Name, Parameter42Value = parameter42Value, Parameter43Name = parameter43Name, Parameter43Value = parameter43Value, Parameter44Name = parameter44Name, Parameter44Value = parameter44Value, Parameter45Name = parameter45Name, Parameter45Value = parameter45Value, Parameter46Name = parameter46Name, Parameter46Value = parameter46Value, Parameter47Name = parameter47Name, Parameter47Value = parameter47Value, Parameter48Name = parameter48Name, Parameter48Value = parameter48Value, Parameter49Name = parameter49Name, Parameter49Value = parameter49Value, Parameter50Name = parameter50Name, Parameter50Value = parameter50Value, Parameter51Name = parameter51Name, Parameter51Value = parameter51Value, Parameter52Name = parameter52Name, Parameter52Value = parameter52Value, Parameter53Name = parameter53Name, Parameter53Value = parameter53Value, Parameter54Name = parameter54Name, Parameter54Value = parameter54Value, Parameter55Name = parameter55Name, Parameter55Value = parameter55Value, Parameter56Name = parameter56Name, Parameter56Value = parameter56Value, Parameter57Name = parameter57Name, Parameter57Value = parameter57Value, Parameter58Name = parameter58Name, Parameter58Value = parameter58Value, Parameter59Name = parameter59Name, Parameter59Value = parameter59Value, Parameter60Name = parameter60Name, Parameter60Value = parameter60Value, Parameter61Name = parameter61Name, Parameter61Value = parameter61Value, Parameter62Name = parameter62Name, Parameter62Value = parameter62Value, Parameter63Name = parameter63Name, Parameter63Value = parameter63Value, Parameter64Name = parameter64Name, Parameter64Value = parameter64Value, Parameter65Name = parameter65Name, Parameter65Value = parameter65Value, Parameter66Name = parameter66Name, Parameter66Value = parameter66Value, Parameter67Name = parameter67Name, Parameter67Value = parameter67Value, Parameter68Name = parameter68Name, Parameter68Value = parameter68Value, Parameter69Name = parameter69Name, Parameter69Value = parameter69Value, Parameter70Name = parameter70Name, Parameter70Value = parameter70Value, Parameter71Name = parameter71Name, Parameter71Value = parameter71Value, Parameter72Name = parameter72Name, Parameter72Value = parameter72Value, Parameter73Name = parameter73Name, Parameter73Value = parameter73Value, Parameter74Name = parameter74Name, Parameter74Value = parameter74Value, Parameter75Name = parameter75Name, Parameter75Value = parameter75Value, Parameter76Name = parameter76Name, Parameter76Value = parameter76Value, Parameter77Name = parameter77Name, Parameter77Value = parameter77Value, Parameter78Name = parameter78Name, Parameter78Value = parameter78Value, Parameter79Name = parameter79Name, Parameter79Value = parameter79Value, Parameter80Name = parameter80Name, Parameter80Value = parameter80Value, Parameter81Name = parameter81Name, Parameter81Value = parameter81Value, Parameter82Name = parameter82Name, Parameter82Value = parameter82Value, Parameter83Name = parameter83Name, Parameter83Value = parameter83Value, Parameter84Name = parameter84Name, Parameter84Value = parameter84Value, Parameter85Name = parameter85Name, Parameter85Value = parameter85Value, Parameter86Name = parameter86Name, Parameter86Value = parameter86Value, Parameter87Name = parameter87Name, Parameter87Value = parameter87Value, Parameter88Name = parameter88Name, Parameter88Value = parameter88Value, Parameter89Name = parameter89Name, Parameter89Value = parameter89Value, Parameter90Name = parameter90Name, Parameter90Value = parameter90Value, Parameter91Name = parameter91Name, Parameter91Value = parameter91Value, Parameter92Name = parameter92Name, Parameter92Value = parameter92Value, Parameter93Name = parameter93Name, Parameter93Value = parameter93Value, Parameter94Name = parameter94Name, Parameter94Value = parameter94Value, Parameter95Name = parameter95Name, Parameter95Value = parameter95Value, Parameter96Name = parameter96Name, Parameter96Value = parameter96Value, Parameter97Name = parameter97Name, Parameter97Value = parameter97Value, Parameter98Name = parameter98Name, Parameter98Value = parameter98Value, Parameter99Name = parameter99Name, Parameter99Value = parameter99Value }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a Siprec + /// + /// The SID of the Call the resource is associated with + /// The SID of the Account that created this resource + /// The name of this resource + /// Unique name used when configuring the connector via Marketplace Add-on. + /// One of `inbound_track`, `outbound_track`, `both_tracks`. + /// Absolute URL of the status callback. + /// The http method for the status_callback. + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Parameter name + /// Parameter value + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Siprec + public static async System.Threading.Tasks.Task CreateAsync(string pathCallSid, + string pathAccountSid = null, + string name = null, + string connectorName = null, + SiprecResource.TrackEnum track = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string parameter1Name = null, + string parameter1Value = null, + string parameter2Name = null, + string parameter2Value = null, + string parameter3Name = null, + string parameter3Value = null, + string parameter4Name = null, + string parameter4Value = null, + string parameter5Name = null, + string parameter5Value = null, + string parameter6Name = null, + string parameter6Value = null, + string parameter7Name = null, + string parameter7Value = null, + string parameter8Name = null, + string parameter8Value = null, + string parameter9Name = null, + string parameter9Value = null, + string parameter10Name = null, + string parameter10Value = null, + string parameter11Name = null, + string parameter11Value = null, + string parameter12Name = null, + string parameter12Value = null, + string parameter13Name = null, + string parameter13Value = null, + string parameter14Name = null, + string parameter14Value = null, + string parameter15Name = null, + string parameter15Value = null, + string parameter16Name = null, + string parameter16Value = null, + string parameter17Name = null, + string parameter17Value = null, + string parameter18Name = null, + string parameter18Value = null, + string parameter19Name = null, + string parameter19Value = null, + string parameter20Name = null, + string parameter20Value = null, + string parameter21Name = null, + string parameter21Value = null, + string parameter22Name = null, + string parameter22Value = null, + string parameter23Name = null, + string parameter23Value = null, + string parameter24Name = null, + string parameter24Value = null, + string parameter25Name = null, + string parameter25Value = null, + string parameter26Name = null, + string parameter26Value = null, + string parameter27Name = null, + string parameter27Value = null, + string parameter28Name = null, + string parameter28Value = null, + string parameter29Name = null, + string parameter29Value = null, + string parameter30Name = null, + string parameter30Value = null, + string parameter31Name = null, + string parameter31Value = null, + string parameter32Name = null, + string parameter32Value = null, + string parameter33Name = null, + string parameter33Value = null, + string parameter34Name = null, + string parameter34Value = null, + string parameter35Name = null, + string parameter35Value = null, + string parameter36Name = null, + string parameter36Value = null, + string parameter37Name = null, + string parameter37Value = null, + string parameter38Name = null, + string parameter38Value = null, + string parameter39Name = null, + string parameter39Value = null, + string parameter40Name = null, + string parameter40Value = null, + string parameter41Name = null, + string parameter41Value = null, + string parameter42Name = null, + string parameter42Value = null, + string parameter43Name = null, + string parameter43Value = null, + string parameter44Name = null, + string parameter44Value = null, + string parameter45Name = null, + string parameter45Value = null, + string parameter46Name = null, + string parameter46Value = null, + string parameter47Name = null, + string parameter47Value = null, + string parameter48Name = null, + string parameter48Value = null, + string parameter49Name = null, + string parameter49Value = null, + string parameter50Name = null, + string parameter50Value = null, + string parameter51Name = null, + string parameter51Value = null, + string parameter52Name = null, + string parameter52Value = null, + string parameter53Name = null, + string parameter53Value = null, + string parameter54Name = null, + string parameter54Value = null, + string parameter55Name = null, + string parameter55Value = null, + string parameter56Name = null, + string parameter56Value = null, + string parameter57Name = null, + string parameter57Value = null, + string parameter58Name = null, + string parameter58Value = null, + string parameter59Name = null, + string parameter59Value = null, + string parameter60Name = null, + string parameter60Value = null, + string parameter61Name = null, + string parameter61Value = null, + string parameter62Name = null, + string parameter62Value = null, + string parameter63Name = null, + string parameter63Value = null, + string parameter64Name = null, + string parameter64Value = null, + string parameter65Name = null, + string parameter65Value = null, + string parameter66Name = null, + string parameter66Value = null, + string parameter67Name = null, + string parameter67Value = null, + string parameter68Name = null, + string parameter68Value = null, + string parameter69Name = null, + string parameter69Value = null, + string parameter70Name = null, + string parameter70Value = null, + string parameter71Name = null, + string parameter71Value = null, + string parameter72Name = null, + string parameter72Value = null, + string parameter73Name = null, + string parameter73Value = null, + string parameter74Name = null, + string parameter74Value = null, + string parameter75Name = null, + string parameter75Value = null, + string parameter76Name = null, + string parameter76Value = null, + string parameter77Name = null, + string parameter77Value = null, + string parameter78Name = null, + string parameter78Value = null, + string parameter79Name = null, + string parameter79Value = null, + string parameter80Name = null, + string parameter80Value = null, + string parameter81Name = null, + string parameter81Value = null, + string parameter82Name = null, + string parameter82Value = null, + string parameter83Name = null, + string parameter83Value = null, + string parameter84Name = null, + string parameter84Value = null, + string parameter85Name = null, + string parameter85Value = null, + string parameter86Name = null, + string parameter86Value = null, + string parameter87Name = null, + string parameter87Value = null, + string parameter88Name = null, + string parameter88Value = null, + string parameter89Name = null, + string parameter89Value = null, + string parameter90Name = null, + string parameter90Value = null, + string parameter91Name = null, + string parameter91Value = null, + string parameter92Name = null, + string parameter92Value = null, + string parameter93Name = null, + string parameter93Value = null, + string parameter94Name = null, + string parameter94Value = null, + string parameter95Name = null, + string parameter95Value = null, + string parameter96Name = null, + string parameter96Value = null, + string parameter97Name = null, + string parameter97Value = null, + string parameter98Name = null, + string parameter98Value = null, + string parameter99Name = null, + string parameter99Value = null, + ITwilioRestClient client = null) + { + var options = new CreateSiprecOptions(pathCallSid) { PathAccountSid = pathAccountSid, Name = name, ConnectorName = connectorName, Track = track, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Parameter1Name = parameter1Name, Parameter1Value = parameter1Value, Parameter2Name = parameter2Name, Parameter2Value = parameter2Value, Parameter3Name = parameter3Name, Parameter3Value = parameter3Value, Parameter4Name = parameter4Name, Parameter4Value = parameter4Value, Parameter5Name = parameter5Name, Parameter5Value = parameter5Value, Parameter6Name = parameter6Name, Parameter6Value = parameter6Value, Parameter7Name = parameter7Name, Parameter7Value = parameter7Value, Parameter8Name = parameter8Name, Parameter8Value = parameter8Value, Parameter9Name = parameter9Name, Parameter9Value = parameter9Value, Parameter10Name = parameter10Name, Parameter10Value = parameter10Value, Parameter11Name = parameter11Name, Parameter11Value = parameter11Value, Parameter12Name = parameter12Name, Parameter12Value = parameter12Value, Parameter13Name = parameter13Name, Parameter13Value = parameter13Value, Parameter14Name = parameter14Name, Parameter14Value = parameter14Value, Parameter15Name = parameter15Name, Parameter15Value = parameter15Value, Parameter16Name = parameter16Name, Parameter16Value = parameter16Value, Parameter17Name = parameter17Name, Parameter17Value = parameter17Value, Parameter18Name = parameter18Name, Parameter18Value = parameter18Value, Parameter19Name = parameter19Name, Parameter19Value = parameter19Value, Parameter20Name = parameter20Name, Parameter20Value = parameter20Value, Parameter21Name = parameter21Name, Parameter21Value = parameter21Value, Parameter22Name = parameter22Name, Parameter22Value = parameter22Value, Parameter23Name = parameter23Name, Parameter23Value = parameter23Value, Parameter24Name = parameter24Name, Parameter24Value = parameter24Value, Parameter25Name = parameter25Name, Parameter25Value = parameter25Value, Parameter26Name = parameter26Name, Parameter26Value = parameter26Value, Parameter27Name = parameter27Name, Parameter27Value = parameter27Value, Parameter28Name = parameter28Name, Parameter28Value = parameter28Value, Parameter29Name = parameter29Name, Parameter29Value = parameter29Value, Parameter30Name = parameter30Name, Parameter30Value = parameter30Value, Parameter31Name = parameter31Name, Parameter31Value = parameter31Value, Parameter32Name = parameter32Name, Parameter32Value = parameter32Value, Parameter33Name = parameter33Name, Parameter33Value = parameter33Value, Parameter34Name = parameter34Name, Parameter34Value = parameter34Value, Parameter35Name = parameter35Name, Parameter35Value = parameter35Value, Parameter36Name = parameter36Name, Parameter36Value = parameter36Value, Parameter37Name = parameter37Name, Parameter37Value = parameter37Value, Parameter38Name = parameter38Name, Parameter38Value = parameter38Value, Parameter39Name = parameter39Name, Parameter39Value = parameter39Value, Parameter40Name = parameter40Name, Parameter40Value = parameter40Value, Parameter41Name = parameter41Name, Parameter41Value = parameter41Value, Parameter42Name = parameter42Name, Parameter42Value = parameter42Value, Parameter43Name = parameter43Name, Parameter43Value = parameter43Value, Parameter44Name = parameter44Name, Parameter44Value = parameter44Value, Parameter45Name = parameter45Name, Parameter45Value = parameter45Value, Parameter46Name = parameter46Name, Parameter46Value = parameter46Value, Parameter47Name = parameter47Name, Parameter47Value = parameter47Value, Parameter48Name = parameter48Name, Parameter48Value = parameter48Value, Parameter49Name = parameter49Name, Parameter49Value = parameter49Value, Parameter50Name = parameter50Name, Parameter50Value = parameter50Value, Parameter51Name = parameter51Name, Parameter51Value = parameter51Value, Parameter52Name = parameter52Name, Parameter52Value = parameter52Value, Parameter53Name = parameter53Name, Parameter53Value = parameter53Value, Parameter54Name = parameter54Name, Parameter54Value = parameter54Value, Parameter55Name = parameter55Name, Parameter55Value = parameter55Value, Parameter56Name = parameter56Name, Parameter56Value = parameter56Value, Parameter57Name = parameter57Name, Parameter57Value = parameter57Value, Parameter58Name = parameter58Name, Parameter58Value = parameter58Value, Parameter59Name = parameter59Name, Parameter59Value = parameter59Value, Parameter60Name = parameter60Name, Parameter60Value = parameter60Value, Parameter61Name = parameter61Name, Parameter61Value = parameter61Value, Parameter62Name = parameter62Name, Parameter62Value = parameter62Value, Parameter63Name = parameter63Name, Parameter63Value = parameter63Value, Parameter64Name = parameter64Name, Parameter64Value = parameter64Value, Parameter65Name = parameter65Name, Parameter65Value = parameter65Value, Parameter66Name = parameter66Name, Parameter66Value = parameter66Value, Parameter67Name = parameter67Name, Parameter67Value = parameter67Value, Parameter68Name = parameter68Name, Parameter68Value = parameter68Value, Parameter69Name = parameter69Name, Parameter69Value = parameter69Value, Parameter70Name = parameter70Name, Parameter70Value = parameter70Value, Parameter71Name = parameter71Name, Parameter71Value = parameter71Value, Parameter72Name = parameter72Name, Parameter72Value = parameter72Value, Parameter73Name = parameter73Name, Parameter73Value = parameter73Value, Parameter74Name = parameter74Name, Parameter74Value = parameter74Value, Parameter75Name = parameter75Name, Parameter75Value = parameter75Value, Parameter76Name = parameter76Name, Parameter76Value = parameter76Value, Parameter77Name = parameter77Name, Parameter77Value = parameter77Value, Parameter78Name = parameter78Name, Parameter78Value = parameter78Value, Parameter79Name = parameter79Name, Parameter79Value = parameter79Value, Parameter80Name = parameter80Name, Parameter80Value = parameter80Value, Parameter81Name = parameter81Name, Parameter81Value = parameter81Value, Parameter82Name = parameter82Name, Parameter82Value = parameter82Value, Parameter83Name = parameter83Name, Parameter83Value = parameter83Value, Parameter84Name = parameter84Name, Parameter84Value = parameter84Value, Parameter85Name = parameter85Name, Parameter85Value = parameter85Value, Parameter86Name = parameter86Name, Parameter86Value = parameter86Value, Parameter87Name = parameter87Name, Parameter87Value = parameter87Value, Parameter88Name = parameter88Name, Parameter88Value = parameter88Value, Parameter89Name = parameter89Name, Parameter89Value = parameter89Value, Parameter90Name = parameter90Name, Parameter90Value = parameter90Value, Parameter91Name = parameter91Name, Parameter91Value = parameter91Value, Parameter92Name = parameter92Name, Parameter92Value = parameter92Value, Parameter93Name = parameter93Name, Parameter93Value = parameter93Value, Parameter94Name = parameter94Name, Parameter94Value = parameter94Value, Parameter95Name = parameter95Name, Parameter95Value = parameter95Value, Parameter96Name = parameter96Name, Parameter96Value = parameter96Value, Parameter97Name = parameter97Name, Parameter97Value = parameter97Value, Parameter98Name = parameter98Name, Parameter98Value = parameter98Value, Parameter99Name = parameter99Name, Parameter99Value = parameter99Value }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSiprecOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathCallSid + "/Siprec/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource + /// + /// Update Siprec parameters + /// Client to make requests to Twilio + /// A single instance of Siprec + public static SiprecResource Update(UpdateSiprecOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource + /// + /// Update Siprec parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Siprec + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSiprecOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource + /// + /// The SID of the Call the resource is associated with + /// The SID of the Siprec resource, or the `name` + /// The status. Must have the value `stopped` + /// The SID of the Account that created this resource + /// Client to make requests to Twilio + /// A single instance of Siprec + public static SiprecResource Update(string pathCallSid, + string pathSid, + SiprecResource.UpdateStatusEnum status, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSiprecOptions(pathCallSid, pathSid, status) { PathAccountSid = pathAccountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Stop a Siprec using either the SID of the Siprec resource or the `name` used when creating the resource + /// + /// The SID of the Call the resource is associated with + /// The SID of the Siprec resource, or the `name` + /// The status. Must have the value `stopped` + /// The SID of the Account that created this resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Siprec + public static async System.Threading.Tasks.Task UpdateAsync(string pathCallSid, + string pathSid, + SiprecResource.UpdateStatusEnum status, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSiprecOptions(pathCallSid, pathSid, status) { PathAccountSid = pathAccountSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SiprecResource object + /// + /// Raw JSON string + /// SiprecResource object represented by the provided JSON + public static SiprecResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Siprec resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The name of this resource + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The status - one of `stopped`, `in-progress` + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SiprecResource.StatusEnum Status { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private SiprecResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/CallOptions.cs b/src/Twilio/Rest/Api/V2010/Account/CallOptions.cs index 7eb68a00d..bfcebdd5e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/CallOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/CallOptions.cs @@ -11,654 +11,654 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections + /// + public class CreateCallOptions : IOptions + { /// - /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections - /// - public class CreateCallOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// Phone number, SIP address, or client identifier to call - /// - public IEndpoint To { get; } - /// - /// Twilio number from which to originate the call - /// - public IEndpoint From { get; } - /// - /// The absolute URL that returns TwiML for this call - /// - public Uri Url { get; set; } - /// - /// TwiML instructions for the call - /// - public Types.Twiml Twiml { get; set; } - /// - /// The SID of the Application resource that will handle the call - /// - public string ApplicationSid { get; set; } - /// - /// HTTP method to use to fetch TwiML - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Fallback URL in case of error - /// - public Uri FallbackUrl { get; set; } - /// - /// HTTP Method to use with fallback_url - /// - public Twilio.Http.HttpMethod FallbackMethod { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The call progress events that we send to the `status_callback` URL. - /// - public List StatusCallbackEvent { get; set; } - /// - /// HTTP Method to use with status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The digits to dial after connecting to the number - /// - public string SendDigits { get; set; } - /// - /// Number of seconds to wait for an answer - /// - public int? Timeout { get; set; } - /// - /// Whether to record the call - /// - public bool? Record { get; set; } - /// - /// The number of channels in the final recording - /// - public string RecordingChannels { get; set; } - /// - /// The URL that we call when the recording is available to be accessed - /// - public string RecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use when calling the `recording_status_callback` URL - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// The username used to authenticate the caller making a SIP call - /// - public string SipAuthUsername { get; set; } - /// - /// The password required to authenticate the user account specified in `sip_auth_username`. - /// - public string SipAuthPassword { get; set; } - /// - /// Enable machine detection or end of greeting detection - /// - public string MachineDetection { get; set; } - /// - /// Number of seconds to wait for machine detection - /// - public int? MachineDetectionTimeout { get; set; } - /// - /// The recording status events that will trigger calls to the URL specified in `recording_status_callback` - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// Set this parameter to control trimming of silence on the recording. - /// - public string Trim { get; set; } - /// - /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. - /// - public string CallerId { get; set; } - /// - /// Number of milliseconds for measuring stick for the length of the speech activity - /// - public int? MachineDetectionSpeechThreshold { get; set; } - /// - /// Number of milliseconds of silence after speech activity - /// - public int? MachineDetectionSpeechEndThreshold { get; set; } - /// - /// Number of milliseconds of initial silence - /// - public int? MachineDetectionSilenceTimeout { get; set; } - /// - /// Enable asynchronous AMD - /// - public string AsyncAmd { get; set; } - /// - /// The URL we should call to send amd status information to your application - /// - public Uri AsyncAmdStatusCallback { get; set; } - /// - /// HTTP Method to use with async_amd_status_callback - /// - public Twilio.Http.HttpMethod AsyncAmdStatusCallbackMethod { get; set; } - /// - /// BYOC trunk SID (Beta) - /// - public string Byoc { get; set; } - /// - /// Reason for the call (Branded Calls Beta) - /// - public string CallReason { get; set; } - /// - /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous incoming call - /// - public string CallToken { get; set; } - /// - /// Which track(s) to record - /// - public string RecordingTrack { get; set; } - /// - /// The maximum duration of the call in seconds. - /// - public int? TimeLimit { get; set; } - - /// - /// Construct a new CreateCallOptions - /// - /// Phone number, SIP address, or client identifier to call - /// Twilio number from which to originate the call - public CreateCallOptions(IEndpoint to, IEndpoint from) - { - To = to; - From = from; - StatusCallbackEvent = new List(); - RecordingStatusCallbackEvent = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (Url != null) - { - p.Add(new KeyValuePair("Url", Serializers.Url(Url))); - } - - if (Twiml != null) - { - p.Add(new KeyValuePair("Twiml", Twiml.ToString())); - } - - if (ApplicationSid != null) - { - p.Add(new KeyValuePair("ApplicationSid", ApplicationSid.ToString())); - } - - if (Method != null) - { - p.Add(new KeyValuePair("Method", Method.ToString())); - } - - if (FallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); - } - - if (FallbackMethod != null) - { - p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackEvent != null) - { - p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (SendDigits != null) - { - p.Add(new KeyValuePair("SendDigits", SendDigits)); - } - - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (Record != null) - { - p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); - } - - if (RecordingChannels != null) - { - p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); - } - - if (RecordingStatusCallback != null) - { - p.Add(new KeyValuePair("RecordingStatusCallback", RecordingStatusCallback)); - } - - if (RecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); - } - - if (SipAuthUsername != null) - { - p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); - } - - if (SipAuthPassword != null) - { - p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); - } - - if (MachineDetection != null) - { - p.Add(new KeyValuePair("MachineDetection", MachineDetection)); - } - - if (MachineDetectionTimeout != null) - { - p.Add(new KeyValuePair("MachineDetectionTimeout", MachineDetectionTimeout.ToString())); - } - - if (RecordingStatusCallbackEvent != null) - { - p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim)); - } - - if (CallerId != null) - { - p.Add(new KeyValuePair("CallerId", CallerId)); - } - - if (MachineDetectionSpeechThreshold != null) - { - p.Add(new KeyValuePair("MachineDetectionSpeechThreshold", MachineDetectionSpeechThreshold.ToString())); - } - - if (MachineDetectionSpeechEndThreshold != null) - { - p.Add(new KeyValuePair("MachineDetectionSpeechEndThreshold", MachineDetectionSpeechEndThreshold.ToString())); - } - - if (MachineDetectionSilenceTimeout != null) - { - p.Add(new KeyValuePair("MachineDetectionSilenceTimeout", MachineDetectionSilenceTimeout.ToString())); - } - - if (AsyncAmd != null) - { - p.Add(new KeyValuePair("AsyncAmd", AsyncAmd)); - } - - if (AsyncAmdStatusCallback != null) - { - p.Add(new KeyValuePair("AsyncAmdStatusCallback", Serializers.Url(AsyncAmdStatusCallback))); - } - - if (AsyncAmdStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("AsyncAmdStatusCallbackMethod", AsyncAmdStatusCallbackMethod.ToString())); - } - - if (Byoc != null) - { - p.Add(new KeyValuePair("Byoc", Byoc.ToString())); - } - - if (CallReason != null) - { - p.Add(new KeyValuePair("CallReason", CallReason)); - } - - if (CallToken != null) - { - p.Add(new KeyValuePair("CallToken", CallToken)); - } - - if (RecordingTrack != null) - { - p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); - } - - if (TimeLimit != null) - { - p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account - /// Portal logs. - /// - public class DeleteCallOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCallOptions - /// - /// The unique string that identifies this resource - public DeleteCallOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Phone number, SIP address, or client identifier to call + /// + public IEndpoint To { get; } /// - /// Fetch the call specified by the provided Call SID - /// - public class FetchCallOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Call resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCallOptions - /// - /// The SID of the Call resource to fetch - public FetchCallOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Twilio number from which to originate the call + /// + public IEndpoint From { get; } /// - /// Retrieves a collection of calls made to and from your account - /// - public class ReadCallOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to read - /// - public string PathAccountSid { get; set; } - /// - /// Phone number or Client identifier of calls to include - /// - public Types.PhoneNumber To { get; set; } - /// - /// Phone number or Client identifier to filter `from` on - /// - public Types.PhoneNumber From { get; set; } - /// - /// Parent call SID to filter on - /// - public string ParentCallSid { get; set; } - /// - /// The status of the resources to read - /// - public CallResource.StatusEnum Status { get; set; } - /// - /// Only include calls that started on this date - /// - public DateTime? StartTimeBefore { get; set; } - /// - /// Only include calls that started on this date - /// - public DateTime? StartTime { get; set; } - /// - /// Only include calls that started on this date - /// - public DateTime? StartTimeAfter { get; set; } - /// - /// Only include calls that ended on this date - /// - public DateTime? EndTimeBefore { get; set; } - /// - /// Only include calls that ended on this date - /// - public DateTime? EndTime { get; set; } - /// - /// Only include calls that ended on this date - /// - public DateTime? EndTimeAfter { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (ParentCallSid != null) - { - p.Add(new KeyValuePair("ParentCallSid", ParentCallSid.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (StartTime != null) - { - p.Add(new KeyValuePair("StartTime", Serializers.DateTimeIso8601(StartTime))); - } - else - { - if (StartTimeBefore != null) - { - p.Add(new KeyValuePair("StartTime<", Serializers.DateTimeIso8601(StartTimeBefore))); - } - - if (StartTimeAfter != null) - { - p.Add(new KeyValuePair("StartTime>", Serializers.DateTimeIso8601(StartTimeAfter))); - } - } - - if (EndTime != null) - { - p.Add(new KeyValuePair("EndTime", Serializers.DateTimeIso8601(EndTime))); - } - else - { - if (EndTimeBefore != null) - { - p.Add(new KeyValuePair("EndTime<", Serializers.DateTimeIso8601(EndTimeBefore))); - } - - if (EndTimeAfter != null) - { - p.Add(new KeyValuePair("EndTime>", Serializers.DateTimeIso8601(EndTimeAfter))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The absolute URL that returns TwiML for this call + /// + public Uri Url { get; set; } /// - /// Initiates a call redirect or terminates a call - /// - public class UpdateCallOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - /// - /// The absolute URL that returns TwiML for this call - /// - public Uri Url { get; set; } - /// - /// HTTP method to use to fetch TwiML - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// The new status to update the call with. - /// - public CallResource.UpdateStatusEnum Status { get; set; } - /// - /// Fallback URL in case of error - /// - public Uri FallbackUrl { get; set; } - /// - /// HTTP Method to use with fallback_url - /// - public Twilio.Http.HttpMethod FallbackMethod { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// HTTP Method to use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// TwiML instructions for the call - /// - public Types.Twiml Twiml { get; set; } - /// - /// The maximum duration of the call in seconds. - /// - public int? TimeLimit { get; set; } - - /// - /// Construct a new UpdateCallOptions - /// - /// The unique string that identifies this resource - public UpdateCallOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Url != null) - { - p.Add(new KeyValuePair("Url", Serializers.Url(Url))); - } - - if (Method != null) - { - p.Add(new KeyValuePair("Method", Method.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); - } - - if (FallbackMethod != null) - { - p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (Twiml != null) - { - p.Add(new KeyValuePair("Twiml", Twiml.ToString())); - } - - if (TimeLimit != null) - { - p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); - } - - return p; - } - } + /// TwiML instructions for the call + /// + public Types.Twiml Twiml { get; set; } + /// + /// The SID of the Application resource that will handle the call + /// + public string ApplicationSid { get; set; } + /// + /// HTTP method to use to fetch TwiML + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Fallback URL in case of error + /// + public Uri FallbackUrl { get; set; } + /// + /// HTTP Method to use with fallback_url + /// + public Twilio.Http.HttpMethod FallbackMethod { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The call progress events that we send to the `status_callback` URL. + /// + public List StatusCallbackEvent { get; set; } + /// + /// HTTP Method to use with status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The digits to dial after connecting to the number + /// + public string SendDigits { get; set; } + /// + /// Number of seconds to wait for an answer + /// + public int? Timeout { get; set; } + /// + /// Whether to record the call + /// + public bool? Record { get; set; } + /// + /// The number of channels in the final recording + /// + public string RecordingChannels { get; set; } + /// + /// The URL that we call when the recording is available to be accessed + /// + public string RecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use when calling the `recording_status_callback` URL + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// The username used to authenticate the caller making a SIP call + /// + public string SipAuthUsername { get; set; } + /// + /// The password required to authenticate the user account specified in `sip_auth_username`. + /// + public string SipAuthPassword { get; set; } + /// + /// Enable machine detection or end of greeting detection + /// + public string MachineDetection { get; set; } + /// + /// Number of seconds to wait for machine detection + /// + public int? MachineDetectionTimeout { get; set; } + /// + /// The recording status events that will trigger calls to the URL specified in `recording_status_callback` + /// + public List RecordingStatusCallbackEvent { get; set; } + /// + /// Set this parameter to control trimming of silence on the recording. + /// + public string Trim { get; set; } + /// + /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. + /// + public string CallerId { get; set; } + /// + /// Number of milliseconds for measuring stick for the length of the speech activity + /// + public int? MachineDetectionSpeechThreshold { get; set; } + /// + /// Number of milliseconds of silence after speech activity + /// + public int? MachineDetectionSpeechEndThreshold { get; set; } + /// + /// Number of milliseconds of initial silence + /// + public int? MachineDetectionSilenceTimeout { get; set; } + /// + /// Enable asynchronous AMD + /// + public string AsyncAmd { get; set; } + /// + /// The URL we should call to send amd status information to your application + /// + public Uri AsyncAmdStatusCallback { get; set; } + /// + /// HTTP Method to use with async_amd_status_callback + /// + public Twilio.Http.HttpMethod AsyncAmdStatusCallbackMethod { get; set; } + /// + /// BYOC trunk SID (Beta) + /// + public string Byoc { get; set; } + /// + /// Reason for the call (Branded Calls Beta) + /// + public string CallReason { get; set; } + /// + /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous incoming call + /// + public string CallToken { get; set; } + /// + /// Which track(s) to record + /// + public string RecordingTrack { get; set; } + /// + /// The maximum duration of the call in seconds. + /// + public int? TimeLimit { get; set; } + + /// + /// Construct a new CreateCallOptions + /// + /// Phone number, SIP address, or client identifier to call + /// Twilio number from which to originate the call + public CreateCallOptions(IEndpoint to, IEndpoint from) + { + To = to; + From = from; + StatusCallbackEvent = new List(); + RecordingStatusCallbackEvent = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (Url != null) + { + p.Add(new KeyValuePair("Url", Serializers.Url(Url))); + } + + if (Twiml != null) + { + p.Add(new KeyValuePair("Twiml", Twiml.ToString())); + } + + if (ApplicationSid != null) + { + p.Add(new KeyValuePair("ApplicationSid", ApplicationSid.ToString())); + } + + if (Method != null) + { + p.Add(new KeyValuePair("Method", Method.ToString())); + } + + if (FallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); + } + + if (FallbackMethod != null) + { + p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackEvent != null) + { + p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (SendDigits != null) + { + p.Add(new KeyValuePair("SendDigits", SendDigits)); + } + + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (Record != null) + { + p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); + } + + if (RecordingChannels != null) + { + p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); + } + + if (RecordingStatusCallback != null) + { + p.Add(new KeyValuePair("RecordingStatusCallback", RecordingStatusCallback)); + } + + if (RecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); + } + + if (SipAuthUsername != null) + { + p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); + } + + if (SipAuthPassword != null) + { + p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); + } + + if (MachineDetection != null) + { + p.Add(new KeyValuePair("MachineDetection", MachineDetection)); + } + + if (MachineDetectionTimeout != null) + { + p.Add(new KeyValuePair("MachineDetectionTimeout", MachineDetectionTimeout.ToString())); + } + + if (RecordingStatusCallbackEvent != null) + { + p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim)); + } + + if (CallerId != null) + { + p.Add(new KeyValuePair("CallerId", CallerId)); + } + + if (MachineDetectionSpeechThreshold != null) + { + p.Add(new KeyValuePair("MachineDetectionSpeechThreshold", MachineDetectionSpeechThreshold.ToString())); + } + + if (MachineDetectionSpeechEndThreshold != null) + { + p.Add(new KeyValuePair("MachineDetectionSpeechEndThreshold", MachineDetectionSpeechEndThreshold.ToString())); + } + + if (MachineDetectionSilenceTimeout != null) + { + p.Add(new KeyValuePair("MachineDetectionSilenceTimeout", MachineDetectionSilenceTimeout.ToString())); + } + + if (AsyncAmd != null) + { + p.Add(new KeyValuePair("AsyncAmd", AsyncAmd)); + } + + if (AsyncAmdStatusCallback != null) + { + p.Add(new KeyValuePair("AsyncAmdStatusCallback", Serializers.Url(AsyncAmdStatusCallback))); + } + + if (AsyncAmdStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("AsyncAmdStatusCallbackMethod", AsyncAmdStatusCallbackMethod.ToString())); + } + + if (Byoc != null) + { + p.Add(new KeyValuePair("Byoc", Byoc.ToString())); + } + + if (CallReason != null) + { + p.Add(new KeyValuePair("CallReason", CallReason)); + } + + if (CallToken != null) + { + p.Add(new KeyValuePair("CallToken", CallToken)); + } + + if (RecordingTrack != null) + { + p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); + } + + if (TimeLimit != null) + { + p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); + } + + return p; + } + } + + /// + /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account + /// Portal logs. + /// + public class DeleteCallOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCallOptions + /// + /// The unique string that identifies this resource + public DeleteCallOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch the call specified by the provided Call SID + /// + public class FetchCallOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Call resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCallOptions + /// + /// The SID of the Call resource to fetch + public FetchCallOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieves a collection of calls made to and from your account + /// + public class ReadCallOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to read + /// + public string PathAccountSid { get; set; } + /// + /// Phone number or Client identifier of calls to include + /// + public Types.PhoneNumber To { get; set; } + /// + /// Phone number or Client identifier to filter `from` on + /// + public Types.PhoneNumber From { get; set; } + /// + /// Parent call SID to filter on + /// + public string ParentCallSid { get; set; } + /// + /// The status of the resources to read + /// + public CallResource.StatusEnum Status { get; set; } + /// + /// Only include calls that started on this date + /// + public DateTime? StartTimeBefore { get; set; } + /// + /// Only include calls that started on this date + /// + public DateTime? StartTime { get; set; } + /// + /// Only include calls that started on this date + /// + public DateTime? StartTimeAfter { get; set; } + /// + /// Only include calls that ended on this date + /// + public DateTime? EndTimeBefore { get; set; } + /// + /// Only include calls that ended on this date + /// + public DateTime? EndTime { get; set; } + /// + /// Only include calls that ended on this date + /// + public DateTime? EndTimeAfter { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (ParentCallSid != null) + { + p.Add(new KeyValuePair("ParentCallSid", ParentCallSid.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (StartTime != null) + { + p.Add(new KeyValuePair("StartTime", Serializers.DateTimeIso8601(StartTime))); + } + else + { + if (StartTimeBefore != null) + { + p.Add(new KeyValuePair("StartTime<", Serializers.DateTimeIso8601(StartTimeBefore))); + } + + if (StartTimeAfter != null) + { + p.Add(new KeyValuePair("StartTime>", Serializers.DateTimeIso8601(StartTimeAfter))); + } + } + + if (EndTime != null) + { + p.Add(new KeyValuePair("EndTime", Serializers.DateTimeIso8601(EndTime))); + } + else + { + if (EndTimeBefore != null) + { + p.Add(new KeyValuePair("EndTime<", Serializers.DateTimeIso8601(EndTimeBefore))); + } + + if (EndTimeAfter != null) + { + p.Add(new KeyValuePair("EndTime>", Serializers.DateTimeIso8601(EndTimeAfter))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Initiates a call redirect or terminates a call + /// + public class UpdateCallOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// + /// The absolute URL that returns TwiML for this call + /// + public Uri Url { get; set; } + /// + /// HTTP method to use to fetch TwiML + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// The new status to update the call with. + /// + public CallResource.UpdateStatusEnum Status { get; set; } + /// + /// Fallback URL in case of error + /// + public Uri FallbackUrl { get; set; } + /// + /// HTTP Method to use with fallback_url + /// + public Twilio.Http.HttpMethod FallbackMethod { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// HTTP Method to use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// TwiML instructions for the call + /// + public Types.Twiml Twiml { get; set; } + /// + /// The maximum duration of the call in seconds. + /// + public int? TimeLimit { get; set; } + + /// + /// Construct a new UpdateCallOptions + /// + /// The unique string that identifies this resource + public UpdateCallOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Url != null) + { + p.Add(new KeyValuePair("Url", Serializers.Url(Url))); + } + + if (Method != null) + { + p.Add(new KeyValuePair("Method", Method.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); + } + + if (FallbackMethod != null) + { + p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (Twiml != null) + { + p.Add(new KeyValuePair("Twiml", Twiml.ToString())); + } + + if (TimeLimit != null) + { + p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/CallResource.cs b/src/Twilio/Rest/Api/V2010/Account/CallResource.cs index d449de844..edd168a32 100644 --- a/src/Twilio/Rest/Api/V2010/Account/CallResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/CallResource.cs @@ -17,863 +17,863 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class CallResource : Resource - { - public sealed class EventEnum : StringEnum - { - private EventEnum(string value) : base(value) {} - public EventEnum() {} - public static implicit operator EventEnum(string value) - { - return new EventEnum(value); - } - - public static readonly EventEnum Initiated = new EventEnum("initiated"); - public static readonly EventEnum Ringing = new EventEnum("ringing"); - public static readonly EventEnum Answered = new EventEnum("answered"); - public static readonly EventEnum Completed = new EventEnum("completed"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Ringing = new StatusEnum("ringing"); - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Busy = new StatusEnum("busy"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum NoAnswer = new StatusEnum("no-answer"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); - public static readonly UpdateStatusEnum Completed = new UpdateStatusEnum("completed"); - } - - private static Request BuildCreateRequest(CreateCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections - /// - /// Create Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Create(CreateCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections - /// - /// Create Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections - /// - /// Phone number, SIP address, or client identifier to call - /// Twilio number from which to originate the call - /// The SID of the Account that will create the resource - /// The absolute URL that returns TwiML for this call - /// TwiML instructions for the call - /// The SID of the Application resource that will handle the call - /// HTTP method to use to fetch TwiML - /// Fallback URL in case of error - /// HTTP Method to use with fallback_url - /// The URL we should call to send status information to your application - /// The call progress events that we send to the `status_callback` URL. - /// HTTP Method to use with status_callback - /// The digits to dial after connecting to the number - /// Number of seconds to wait for an answer - /// Whether to record the call - /// The number of channels in the final recording - /// The URL that we call when the recording is available to be accessed - /// The HTTP method we should use when calling the - /// `recording_status_callback` URL - /// The username used to authenticate the caller making a SIP call - /// The password required to authenticate the user account specified in - /// `sip_auth_username`. - /// Enable machine detection or end of greeting detection - /// Number of seconds to wait for machine detection - /// The recording status events that will trigger calls to the URL - /// specified in `recording_status_callback` - /// Set this parameter to control trimming of silence on the recording. - /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are - /// in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. - /// Number of milliseconds for measuring stick for the length of the - /// speech activity - /// Number of milliseconds of silence after speech activity - /// Number of milliseconds of initial silence - /// Enable asynchronous AMD - /// The URL we should call to send amd status information to your application - /// - /// HTTP Method to use with async_amd_status_callback - /// BYOC trunk SID (Beta) - /// Reason for the call (Branded Calls Beta) - /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous - /// incoming call - /// Which track(s) to record - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Create(IEndpoint to, - IEndpoint from, - string pathAccountSid = null, - Uri url = null, - Types.Twiml twiml = null, - string applicationSid = null, - Twilio.Http.HttpMethod method = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - List statusCallbackEvent = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string sendDigits = null, - int? timeout = null, - bool? record = null, - string recordingChannels = null, - string recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - string machineDetection = null, - int? machineDetectionTimeout = null, - List recordingStatusCallbackEvent = null, - string trim = null, - string callerId = null, - int? machineDetectionSpeechThreshold = null, - int? machineDetectionSpeechEndThreshold = null, - int? machineDetectionSilenceTimeout = null, - string asyncAmd = null, - Uri asyncAmdStatusCallback = null, - Twilio.Http.HttpMethod asyncAmdStatusCallbackMethod = null, - string byoc = null, - string callReason = null, - string callToken = null, - string recordingTrack = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateCallOptions(to, from){PathAccountSid = pathAccountSid, Url = url, Twiml = twiml, ApplicationSid = applicationSid, Method = method, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackEvent = statusCallbackEvent, StatusCallbackMethod = statusCallbackMethod, SendDigits = sendDigits, Timeout = timeout, Record = record, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, MachineDetection = machineDetection, MachineDetectionTimeout = machineDetectionTimeout, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Trim = trim, CallerId = callerId, MachineDetectionSpeechThreshold = machineDetectionSpeechThreshold, MachineDetectionSpeechEndThreshold = machineDetectionSpeechEndThreshold, MachineDetectionSilenceTimeout = machineDetectionSilenceTimeout, AsyncAmd = asyncAmd, AsyncAmdStatusCallback = asyncAmdStatusCallback, AsyncAmdStatusCallbackMethod = asyncAmdStatusCallbackMethod, Byoc = byoc, CallReason = callReason, CallToken = callToken, RecordingTrack = recordingTrack, TimeLimit = timeLimit}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections - /// - /// Phone number, SIP address, or client identifier to call - /// Twilio number from which to originate the call - /// The SID of the Account that will create the resource - /// The absolute URL that returns TwiML for this call - /// TwiML instructions for the call - /// The SID of the Application resource that will handle the call - /// HTTP method to use to fetch TwiML - /// Fallback URL in case of error - /// HTTP Method to use with fallback_url - /// The URL we should call to send status information to your application - /// The call progress events that we send to the `status_callback` URL. - /// HTTP Method to use with status_callback - /// The digits to dial after connecting to the number - /// Number of seconds to wait for an answer - /// Whether to record the call - /// The number of channels in the final recording - /// The URL that we call when the recording is available to be accessed - /// The HTTP method we should use when calling the - /// `recording_status_callback` URL - /// The username used to authenticate the caller making a SIP call - /// The password required to authenticate the user account specified in - /// `sip_auth_username`. - /// Enable machine detection or end of greeting detection - /// Number of seconds to wait for machine detection - /// The recording status events that will trigger calls to the URL - /// specified in `recording_status_callback` - /// Set this parameter to control trimming of silence on the recording. - /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are - /// in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. - /// Number of milliseconds for measuring stick for the length of the - /// speech activity - /// Number of milliseconds of silence after speech activity - /// Number of milliseconds of initial silence - /// Enable asynchronous AMD - /// The URL we should call to send amd status information to your application - /// - /// HTTP Method to use with async_amd_status_callback - /// BYOC trunk SID (Beta) - /// Reason for the call (Branded Calls Beta) - /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous - /// incoming call - /// Which track(s) to record - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task CreateAsync(IEndpoint to, - IEndpoint from, - string pathAccountSid = null, - Uri url = null, - Types.Twiml twiml = null, - string applicationSid = null, - Twilio.Http.HttpMethod method = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - List statusCallbackEvent = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string sendDigits = null, - int? timeout = null, - bool? record = null, - string recordingChannels = null, - string recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - string machineDetection = null, - int? machineDetectionTimeout = null, - List recordingStatusCallbackEvent = null, - string trim = null, - string callerId = null, - int? machineDetectionSpeechThreshold = null, - int? machineDetectionSpeechEndThreshold = null, - int? machineDetectionSilenceTimeout = null, - string asyncAmd = null, - Uri asyncAmdStatusCallback = null, - Twilio.Http.HttpMethod asyncAmdStatusCallbackMethod = null, - string byoc = null, - string callReason = null, - string callToken = null, - string recordingTrack = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateCallOptions(to, from){PathAccountSid = pathAccountSid, Url = url, Twiml = twiml, ApplicationSid = applicationSid, Method = method, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackEvent = statusCallbackEvent, StatusCallbackMethod = statusCallbackMethod, SendDigits = sendDigits, Timeout = timeout, Record = record, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, MachineDetection = machineDetection, MachineDetectionTimeout = machineDetectionTimeout, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Trim = trim, CallerId = callerId, MachineDetectionSpeechThreshold = machineDetectionSpeechThreshold, MachineDetectionSpeechEndThreshold = machineDetectionSpeechEndThreshold, MachineDetectionSilenceTimeout = machineDetectionSilenceTimeout, AsyncAmd = asyncAmd, AsyncAmdStatusCallback = asyncAmdStatusCallback, AsyncAmdStatusCallbackMethod = asyncAmdStatusCallbackMethod, Byoc = byoc, CallReason = callReason, CallToken = callToken, RecordingTrack = recordingTrack, TimeLimit = timeLimit}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account - /// Portal logs. - /// - /// Delete Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static bool Delete(DeleteCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account - /// Portal logs. - /// - /// Delete Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account - /// Portal logs. - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// A single instance of Call - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteCallOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account - /// Portal logs. - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCallOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the call specified by the provided Call SID - /// - /// Fetch Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the call specified by the provided Call SID - /// - /// Fetch Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the call specified by the provided Call SID - /// - /// The SID of the Call resource to fetch - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchCallOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the call specified by the provided Call SID - /// - /// The SID of the Call resource to fetch - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCallOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieves a collection of calls made to and from your account - /// - /// Read Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static ResourceSet Read(ReadCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("calls", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of calls made to and from your account - /// - /// Read Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task> ReadAsync(ReadCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("calls", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieves a collection of calls made to and from your account - /// - /// The SID of the Account that created the resource(s) to read - /// Phone number or Client identifier of calls to include - /// Phone number or Client identifier to filter `from` on - /// Parent call SID to filter on - /// The status of the resources to read - /// Only include calls that started on this date - /// Only include calls that started on this date - /// Only include calls that started on this date - /// Only include calls that ended on this date - /// Only include calls that ended on this date - /// Only include calls that ended on this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Call - public static ResourceSet Read(string pathAccountSid = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - string parentCallSid = null, - CallResource.StatusEnum status = null, - DateTime? startTimeBefore = null, - DateTime? startTime = null, - DateTime? startTimeAfter = null, - DateTime? endTimeBefore = null, - DateTime? endTime = null, - DateTime? endTimeAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCallOptions(){PathAccountSid = pathAccountSid, To = to, From = from, ParentCallSid = parentCallSid, Status = status, StartTimeBefore = startTimeBefore, StartTime = startTime, StartTimeAfter = startTimeAfter, EndTimeBefore = endTimeBefore, EndTime = endTime, EndTimeAfter = endTimeAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of calls made to and from your account - /// - /// The SID of the Account that created the resource(s) to read - /// Phone number or Client identifier of calls to include - /// Phone number or Client identifier to filter `from` on - /// Parent call SID to filter on - /// The status of the resources to read - /// Only include calls that started on this date - /// Only include calls that started on this date - /// Only include calls that started on this date - /// Only include calls that ended on this date - /// Only include calls that ended on this date - /// Only include calls that ended on this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - string parentCallSid = null, - CallResource.StatusEnum status = null, - DateTime? startTimeBefore = null, - DateTime? startTime = null, - DateTime? startTimeAfter = null, - DateTime? endTimeBefore = null, - DateTime? endTime = null, - DateTime? endTimeAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCallOptions(){PathAccountSid = pathAccountSid, To = to, From = from, ParentCallSid = parentCallSid, Status = status, StartTimeBefore = startTimeBefore, StartTime = startTime, StartTimeAfter = startTimeAfter, EndTimeBefore = endTimeBefore, EndTime = endTime, EndTimeAfter = endTimeAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("calls", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("calls", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("calls", response.Content); - } - - private static Request BuildUpdateRequest(UpdateCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Initiates a call redirect or terminates a call - /// - /// Update Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Update(UpdateCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Initiates a call redirect or terminates a call - /// - /// Update Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Initiates a call redirect or terminates a call - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// The absolute URL that returns TwiML for this call - /// HTTP method to use to fetch TwiML - /// The new status to update the call with. - /// Fallback URL in case of error - /// HTTP Method to use with fallback_url - /// The URL we should call to send status information to your application - /// HTTP Method to use to call status_callback - /// TwiML instructions for the call - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Update(string pathSid, - string pathAccountSid = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - CallResource.UpdateStatusEnum status = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - Types.Twiml twiml = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new UpdateCallOptions(pathSid){PathAccountSid = pathAccountSid, Url = url, Method = method, Status = status, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Twiml = twiml, TimeLimit = timeLimit}; - return Update(options, client); - } - - #if !NET35 - /// - /// Initiates a call redirect or terminates a call - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// The absolute URL that returns TwiML for this call - /// HTTP method to use to fetch TwiML - /// The new status to update the call with. - /// Fallback URL in case of error - /// HTTP Method to use with fallback_url - /// The URL we should call to send status information to your application - /// HTTP Method to use to call status_callback - /// TwiML instructions for the call - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - CallResource.UpdateStatusEnum status = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - Types.Twiml twiml = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new UpdateCallOptions(pathSid){PathAccountSid = pathAccountSid, Url = url, Method = method, Status = status, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Twiml = twiml, TimeLimit = timeLimit}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CallResource object - /// - /// Raw JSON string - /// CallResource object represented by the provided JSON - public static CallResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID that identifies the call that created this leg. - /// - [JsonProperty("parent_call_sid")] - public string ParentCallSid { get; private set; } - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The phone number, SIP address or Client identifier that received this call. Formatted for display. - /// - [JsonProperty("to_formatted")] - public string ToFormatted { get; private set; } - /// - /// The phone number, SIP address or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The calling phone number, SIP address, or Client identifier formatted for display. - /// - [JsonProperty("from_formatted")] - public string FromFormatted { get; private set; } - /// - /// If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed. - /// - [JsonProperty("phone_number_sid")] - public string PhoneNumberSid { get; private set; } - /// - /// The status of this call. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CallResource.StatusEnum Status { get; private set; } - /// - /// The start time of the call. Null if the call has not yet been dialed. - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end time of the call. Null if the call did not complete successfully. - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The length of the call in seconds. - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. - /// - [JsonProperty("price")] - public string Price { get; private set; } - /// - /// The currency in which `Price` is measured. - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// A string describing the direction of the call. `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb. - /// - [JsonProperty("direction")] - public string Direction { get; private set; } - /// - /// Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise. - /// - [JsonProperty("answered_by")] - public string AnsweredBy { get; private set; } - /// - /// The annotation provided for the call - /// - [JsonProperty("annotation")] - public string Annotation { get; private set; } - /// - /// The API Version used to create the call - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty. - /// - [JsonProperty("forwarded_from")] - public string ForwardedFrom { get; private set; } - /// - /// The Group SID associated with this call. If no Group is associated with the call, the field is empty. - /// - [JsonProperty("group_sid")] - public string GroupSid { get; private set; } - /// - /// The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty. - /// - [JsonProperty("caller_name")] - public string CallerName { get; private set; } - /// - /// The wait time in milliseconds before the call is placed. - /// - [JsonProperty("queue_time")] - public string QueueTime { get; private set; } - /// - /// The (optional) unique identifier of the trunk resource that was used for this call. - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The URI of this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// A list of related subresources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private CallResource() - { - - } - } +{ + + public class CallResource : Resource + { + public sealed class EventEnum : StringEnum + { + private EventEnum(string value) : base(value) { } + public EventEnum() { } + public static implicit operator EventEnum(string value) + { + return new EventEnum(value); + } + + public static readonly EventEnum Initiated = new EventEnum("initiated"); + public static readonly EventEnum Ringing = new EventEnum("ringing"); + public static readonly EventEnum Answered = new EventEnum("answered"); + public static readonly EventEnum Completed = new EventEnum("completed"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Ringing = new StatusEnum("ringing"); + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Busy = new StatusEnum("busy"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum NoAnswer = new StatusEnum("no-answer"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); + public static readonly UpdateStatusEnum Completed = new UpdateStatusEnum("completed"); + } + + private static Request BuildCreateRequest(CreateCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections + /// + /// Create Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Create(CreateCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections + /// + /// Create Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections + /// + /// Phone number, SIP address, or client identifier to call + /// Twilio number from which to originate the call + /// The SID of the Account that will create the resource + /// The absolute URL that returns TwiML for this call + /// TwiML instructions for the call + /// The SID of the Application resource that will handle the call + /// HTTP method to use to fetch TwiML + /// Fallback URL in case of error + /// HTTP Method to use with fallback_url + /// The URL we should call to send status information to your application + /// The call progress events that we send to the `status_callback` URL. + /// HTTP Method to use with status_callback + /// The digits to dial after connecting to the number + /// Number of seconds to wait for an answer + /// Whether to record the call + /// The number of channels in the final recording + /// The URL that we call when the recording is available to be accessed + /// The HTTP method we should use when calling the + /// `recording_status_callback` URL + /// The username used to authenticate the caller making a SIP call + /// The password required to authenticate the user account specified in + /// `sip_auth_username`. + /// Enable machine detection or end of greeting detection + /// Number of seconds to wait for machine detection + /// The recording status events that will trigger calls to the URL + /// specified in `recording_status_callback` + /// Set this parameter to control trimming of silence on the recording. + /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are + /// in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. + /// Number of milliseconds for measuring stick for the length of the + /// speech activity + /// Number of milliseconds of silence after speech activity + /// Number of milliseconds of initial silence + /// Enable asynchronous AMD + /// The URL we should call to send amd status information to your application + /// + /// HTTP Method to use with async_amd_status_callback + /// BYOC trunk SID (Beta) + /// Reason for the call (Branded Calls Beta) + /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous + /// incoming call + /// Which track(s) to record + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Create(IEndpoint to, + IEndpoint from, + string pathAccountSid = null, + Uri url = null, + Types.Twiml twiml = null, + string applicationSid = null, + Twilio.Http.HttpMethod method = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + List statusCallbackEvent = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string sendDigits = null, + int? timeout = null, + bool? record = null, + string recordingChannels = null, + string recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + string machineDetection = null, + int? machineDetectionTimeout = null, + List recordingStatusCallbackEvent = null, + string trim = null, + string callerId = null, + int? machineDetectionSpeechThreshold = null, + int? machineDetectionSpeechEndThreshold = null, + int? machineDetectionSilenceTimeout = null, + string asyncAmd = null, + Uri asyncAmdStatusCallback = null, + Twilio.Http.HttpMethod asyncAmdStatusCallbackMethod = null, + string byoc = null, + string callReason = null, + string callToken = null, + string recordingTrack = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateCallOptions(to, from) { PathAccountSid = pathAccountSid, Url = url, Twiml = twiml, ApplicationSid = applicationSid, Method = method, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackEvent = statusCallbackEvent, StatusCallbackMethod = statusCallbackMethod, SendDigits = sendDigits, Timeout = timeout, Record = record, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, MachineDetection = machineDetection, MachineDetectionTimeout = machineDetectionTimeout, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Trim = trim, CallerId = callerId, MachineDetectionSpeechThreshold = machineDetectionSpeechThreshold, MachineDetectionSpeechEndThreshold = machineDetectionSpeechEndThreshold, MachineDetectionSilenceTimeout = machineDetectionSilenceTimeout, AsyncAmd = asyncAmd, AsyncAmdStatusCallback = asyncAmdStatusCallback, AsyncAmdStatusCallbackMethod = asyncAmdStatusCallbackMethod, Byoc = byoc, CallReason = callReason, CallToken = callToken, RecordingTrack = recordingTrack, TimeLimit = timeLimit }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections + /// + /// Phone number, SIP address, or client identifier to call + /// Twilio number from which to originate the call + /// The SID of the Account that will create the resource + /// The absolute URL that returns TwiML for this call + /// TwiML instructions for the call + /// The SID of the Application resource that will handle the call + /// HTTP method to use to fetch TwiML + /// Fallback URL in case of error + /// HTTP Method to use with fallback_url + /// The URL we should call to send status information to your application + /// The call progress events that we send to the `status_callback` URL. + /// HTTP Method to use with status_callback + /// The digits to dial after connecting to the number + /// Number of seconds to wait for an answer + /// Whether to record the call + /// The number of channels in the final recording + /// The URL that we call when the recording is available to be accessed + /// The HTTP method we should use when calling the + /// `recording_status_callback` URL + /// The username used to authenticate the caller making a SIP call + /// The password required to authenticate the user account specified in + /// `sip_auth_username`. + /// Enable machine detection or end of greeting detection + /// Number of seconds to wait for machine detection + /// The recording status events that will trigger calls to the URL + /// specified in `recording_status_callback` + /// Set this parameter to control trimming of silence on the recording. + /// The phone number, SIP address, or Client identifier that made this call. Phone numbers are + /// in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. + /// Number of milliseconds for measuring stick for the length of the + /// speech activity + /// Number of milliseconds of silence after speech activity + /// Number of milliseconds of initial silence + /// Enable asynchronous AMD + /// The URL we should call to send amd status information to your application + /// + /// HTTP Method to use with async_amd_status_callback + /// BYOC trunk SID (Beta) + /// Reason for the call (Branded Calls Beta) + /// A token string needed to invoke a forwarded call with a CallerId recieved on a previous + /// incoming call + /// Which track(s) to record + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task CreateAsync(IEndpoint to, + IEndpoint from, + string pathAccountSid = null, + Uri url = null, + Types.Twiml twiml = null, + string applicationSid = null, + Twilio.Http.HttpMethod method = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + List statusCallbackEvent = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string sendDigits = null, + int? timeout = null, + bool? record = null, + string recordingChannels = null, + string recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + string machineDetection = null, + int? machineDetectionTimeout = null, + List recordingStatusCallbackEvent = null, + string trim = null, + string callerId = null, + int? machineDetectionSpeechThreshold = null, + int? machineDetectionSpeechEndThreshold = null, + int? machineDetectionSilenceTimeout = null, + string asyncAmd = null, + Uri asyncAmdStatusCallback = null, + Twilio.Http.HttpMethod asyncAmdStatusCallbackMethod = null, + string byoc = null, + string callReason = null, + string callToken = null, + string recordingTrack = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateCallOptions(to, from) { PathAccountSid = pathAccountSid, Url = url, Twiml = twiml, ApplicationSid = applicationSid, Method = method, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackEvent = statusCallbackEvent, StatusCallbackMethod = statusCallbackMethod, SendDigits = sendDigits, Timeout = timeout, Record = record, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, MachineDetection = machineDetection, MachineDetectionTimeout = machineDetectionTimeout, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Trim = trim, CallerId = callerId, MachineDetectionSpeechThreshold = machineDetectionSpeechThreshold, MachineDetectionSpeechEndThreshold = machineDetectionSpeechEndThreshold, MachineDetectionSilenceTimeout = machineDetectionSilenceTimeout, AsyncAmd = asyncAmd, AsyncAmdStatusCallback = asyncAmdStatusCallback, AsyncAmdStatusCallbackMethod = asyncAmdStatusCallbackMethod, Byoc = byoc, CallReason = callReason, CallToken = callToken, RecordingTrack = recordingTrack, TimeLimit = timeLimit }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account + /// Portal logs. + /// + /// Delete Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static bool Delete(DeleteCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account + /// Portal logs. + /// + /// Delete Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account + /// Portal logs. + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// A single instance of Call + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteCallOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account + /// Portal logs. + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCallOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the call specified by the provided Call SID + /// + /// Fetch Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the call specified by the provided Call SID + /// + /// Fetch Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the call specified by the provided Call SID + /// + /// The SID of the Call resource to fetch + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchCallOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the call specified by the provided Call SID + /// + /// The SID of the Call resource to fetch + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCallOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieves a collection of calls made to and from your account + /// + /// Read Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static ResourceSet Read(ReadCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("calls", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of calls made to and from your account + /// + /// Read Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task> ReadAsync(ReadCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("calls", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieves a collection of calls made to and from your account + /// + /// The SID of the Account that created the resource(s) to read + /// Phone number or Client identifier of calls to include + /// Phone number or Client identifier to filter `from` on + /// Parent call SID to filter on + /// The status of the resources to read + /// Only include calls that started on this date + /// Only include calls that started on this date + /// Only include calls that started on this date + /// Only include calls that ended on this date + /// Only include calls that ended on this date + /// Only include calls that ended on this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Call + public static ResourceSet Read(string pathAccountSid = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + string parentCallSid = null, + CallResource.StatusEnum status = null, + DateTime? startTimeBefore = null, + DateTime? startTime = null, + DateTime? startTimeAfter = null, + DateTime? endTimeBefore = null, + DateTime? endTime = null, + DateTime? endTimeAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCallOptions() { PathAccountSid = pathAccountSid, To = to, From = from, ParentCallSid = parentCallSid, Status = status, StartTimeBefore = startTimeBefore, StartTime = startTime, StartTimeAfter = startTimeAfter, EndTimeBefore = endTimeBefore, EndTime = endTime, EndTimeAfter = endTimeAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of calls made to and from your account + /// + /// The SID of the Account that created the resource(s) to read + /// Phone number or Client identifier of calls to include + /// Phone number or Client identifier to filter `from` on + /// Parent call SID to filter on + /// The status of the resources to read + /// Only include calls that started on this date + /// Only include calls that started on this date + /// Only include calls that started on this date + /// Only include calls that ended on this date + /// Only include calls that ended on this date + /// Only include calls that ended on this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + string parentCallSid = null, + CallResource.StatusEnum status = null, + DateTime? startTimeBefore = null, + DateTime? startTime = null, + DateTime? startTimeAfter = null, + DateTime? endTimeBefore = null, + DateTime? endTime = null, + DateTime? endTimeAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCallOptions() { PathAccountSid = pathAccountSid, To = to, From = from, ParentCallSid = parentCallSid, Status = status, StartTimeBefore = startTimeBefore, StartTime = startTime, StartTimeAfter = startTimeAfter, EndTimeBefore = endTimeBefore, EndTime = endTime, EndTimeAfter = endTimeAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("calls", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("calls", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("calls", response.Content); + } + + private static Request BuildUpdateRequest(UpdateCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Calls/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Initiates a call redirect or terminates a call + /// + /// Update Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Update(UpdateCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Initiates a call redirect or terminates a call + /// + /// Update Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Initiates a call redirect or terminates a call + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// The absolute URL that returns TwiML for this call + /// HTTP method to use to fetch TwiML + /// The new status to update the call with. + /// Fallback URL in case of error + /// HTTP Method to use with fallback_url + /// The URL we should call to send status information to your application + /// HTTP Method to use to call status_callback + /// TwiML instructions for the call + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Update(string pathSid, + string pathAccountSid = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + CallResource.UpdateStatusEnum status = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + Types.Twiml twiml = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new UpdateCallOptions(pathSid) { PathAccountSid = pathAccountSid, Url = url, Method = method, Status = status, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Twiml = twiml, TimeLimit = timeLimit }; + return Update(options, client); + } + +#if !NET35 + /// + /// Initiates a call redirect or terminates a call + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// The absolute URL that returns TwiML for this call + /// HTTP method to use to fetch TwiML + /// The new status to update the call with. + /// Fallback URL in case of error + /// HTTP Method to use with fallback_url + /// The URL we should call to send status information to your application + /// HTTP Method to use to call status_callback + /// TwiML instructions for the call + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + CallResource.UpdateStatusEnum status = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + Types.Twiml twiml = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new UpdateCallOptions(pathSid) { PathAccountSid = pathAccountSid, Url = url, Method = method, Status = status, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Twiml = twiml, TimeLimit = timeLimit }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CallResource object + /// + /// Raw JSON string + /// CallResource object represented by the provided JSON + public static CallResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID that identifies the call that created this leg. + /// + [JsonProperty("parent_call_sid")] + public string ParentCallSid { get; private set; } + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The phone number, SIP address or Client identifier that received this call. Formatted for display. + /// + [JsonProperty("to_formatted")] + public string ToFormatted { get; private set; } + /// + /// The phone number, SIP address or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The calling phone number, SIP address, or Client identifier formatted for display. + /// + [JsonProperty("from_formatted")] + public string FromFormatted { get; private set; } + /// + /// If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed. + /// + [JsonProperty("phone_number_sid")] + public string PhoneNumberSid { get; private set; } + /// + /// The status of this call. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CallResource.StatusEnum Status { get; private set; } + /// + /// The start time of the call. Null if the call has not yet been dialed. + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end time of the call. Null if the call did not complete successfully. + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The length of the call in seconds. + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. + /// + [JsonProperty("price")] + public string Price { get; private set; } + /// + /// The currency in which `Price` is measured. + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// A string describing the direction of the call. `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb. + /// + [JsonProperty("direction")] + public string Direction { get; private set; } + /// + /// Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise. + /// + [JsonProperty("answered_by")] + public string AnsweredBy { get; private set; } + /// + /// The annotation provided for the call + /// + [JsonProperty("annotation")] + public string Annotation { get; private set; } + /// + /// The API Version used to create the call + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty. + /// + [JsonProperty("forwarded_from")] + public string ForwardedFrom { get; private set; } + /// + /// The Group SID associated with this call. If no Group is associated with the call, the field is empty. + /// + [JsonProperty("group_sid")] + public string GroupSid { get; private set; } + /// + /// The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty. + /// + [JsonProperty("caller_name")] + public string CallerName { get; private set; } + /// + /// The wait time in milliseconds before the call is placed. + /// + [JsonProperty("queue_time")] + public string QueueTime { get; private set; } + /// + /// The (optional) unique identifier of the trunk resource that was used for this call. + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The URI of this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// A list of related subresources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private CallResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantOptions.cs index f6f294ff9..0767bcad2 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantOptions.cs @@ -11,689 +11,689 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Conference -{ - +{ + + /// + /// Fetch an instance of a participant + /// + public class FetchParticipantOptions : IOptions + { /// - /// Fetch an instance of a participant - /// - public class FetchParticipantOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the conference with the participant to fetch - /// - public string PathConferenceSid { get; } - /// - /// The Call SID or URL encoded label of the participant to fetch - /// - public string PathCallSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The SID of the conference with the participant to fetch - /// The Call SID or URL encoded label of the participant to fetch - public FetchParticipantOptions(string pathConferenceSid, string pathCallSid) - { - PathConferenceSid = pathConferenceSid; - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } /// - /// Update the properties of the participant - /// - public class UpdateParticipantOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the conference with the participant to update - /// - public string PathConferenceSid { get; } - /// - /// The Call SID or URL encoded label of the participant to update - /// - public string PathCallSid { get; } - /// - /// Whether the participant should be muted - /// - public bool? Muted { get; set; } - /// - /// Whether the participant should be on hold - /// - public bool? Hold { get; set; } - /// - /// The URL we call using the `hold_method` for music that plays when the participant is on hold - /// - public Uri HoldUrl { get; set; } - /// - /// The HTTP method we should use to call hold_url - /// - public Twilio.Http.HttpMethod HoldMethod { get; set; } - /// - /// The URL we call using the `announce_method` for an announcement to the participant - /// - public Uri AnnounceUrl { get; set; } - /// - /// The HTTP method we should use to call announce_url - /// - public Twilio.Http.HttpMethod AnnounceMethod { get; set; } - /// - /// URL that hosts pre-conference hold music - /// - public Uri WaitUrl { get; set; } - /// - /// The HTTP method we should use to call `wait_url` - /// - public Twilio.Http.HttpMethod WaitMethod { get; set; } - /// - /// Whether to play a notification beep to the conference when the participant exit - /// - public bool? BeepOnExit { get; set; } - /// - /// Whether to end the conference when the participant leaves - /// - public bool? EndConferenceOnExit { get; set; } - /// - /// Indicates if the participant changed to coach - /// - public bool? Coaching { get; set; } - /// - /// The SID of the participant who is being `coached` - /// - public string CallSidToCoach { get; set; } - - /// - /// Construct a new UpdateParticipantOptions - /// - /// The SID of the conference with the participant to update - /// The Call SID or URL encoded label of the participant to update - public UpdateParticipantOptions(string pathConferenceSid, string pathCallSid) - { - PathConferenceSid = pathConferenceSid; - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Muted != null) - { - p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); - } - - if (Hold != null) - { - p.Add(new KeyValuePair("Hold", Hold.Value.ToString().ToLower())); - } - - if (HoldUrl != null) - { - p.Add(new KeyValuePair("HoldUrl", Serializers.Url(HoldUrl))); - } - - if (HoldMethod != null) - { - p.Add(new KeyValuePair("HoldMethod", HoldMethod.ToString())); - } - - if (AnnounceUrl != null) - { - p.Add(new KeyValuePair("AnnounceUrl", Serializers.Url(AnnounceUrl))); - } - - if (AnnounceMethod != null) - { - p.Add(new KeyValuePair("AnnounceMethod", AnnounceMethod.ToString())); - } - - if (WaitUrl != null) - { - p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); - } - - if (WaitMethod != null) - { - p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); - } - - if (BeepOnExit != null) - { - p.Add(new KeyValuePair("BeepOnExit", BeepOnExit.Value.ToString().ToLower())); - } - - if (EndConferenceOnExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); - } - - if (Coaching != null) - { - p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); - } - - if (CallSidToCoach != null) - { - p.Add(new KeyValuePair("CallSidToCoach", CallSidToCoach.ToString())); - } - - return p; - } - } - + /// The SID of the conference with the participant to fetch + /// + public string PathConferenceSid { get; } /// - /// CreateParticipantOptions - /// - public class CreateParticipantOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the participant's conference - /// - public string PathConferenceSid { get; } - /// - /// The phone number, Client identifier, or username portion of SIP address that made this call. - /// - public IEndpoint From { get; } - /// - /// The phone number, SIP address or Client identifier that received this call. - /// - public IEndpoint To { get; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call `status_callback` - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Set state change events that will trigger a callback - /// - public List StatusCallbackEvent { get; set; } - /// - /// The label of this participant - /// - public string Label { get; set; } - /// - /// he number of seconds that we should wait for an answer - /// - public int? Timeout { get; set; } - /// - /// Whether to record the participant and their conferences - /// - public bool? Record { get; set; } - /// - /// Whether to mute the agent - /// - public bool? Muted { get; set; } - /// - /// Whether to play a notification beep to the conference when the participant joins - /// - public string Beep { get; set; } - /// - /// Whether the conference starts when the participant joins the conference - /// - public bool? StartConferenceOnEnter { get; set; } - /// - /// Whether to end the conference when the participant leaves - /// - public bool? EndConferenceOnExit { get; set; } - /// - /// URL that hosts pre-conference hold music - /// - public Uri WaitUrl { get; set; } - /// - /// The HTTP method we should use to call `wait_url` - /// - public Twilio.Http.HttpMethod WaitMethod { get; set; } - /// - /// Whether agents can hear the state of the outbound call - /// - public bool? EarlyMedia { get; set; } - /// - /// The maximum number of agent conference participants - /// - public int? MaxParticipants { get; set; } - /// - /// Whether to record the conference the participant is joining - /// - public string ConferenceRecord { get; set; } - /// - /// Whether to trim leading and trailing silence from your recorded conference audio files - /// - public string ConferenceTrim { get; set; } - /// - /// The callback URL for conference events - /// - public Uri ConferenceStatusCallback { get; set; } - /// - /// HTTP method for requesting `conference_status_callback` URL - /// - public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } - /// - /// The conference state changes that should generate a call to `conference_status_callback` - /// - public List ConferenceStatusCallbackEvent { get; set; } - /// - /// Specify `mono` or `dual` recording channels - /// - public string RecordingChannels { get; set; } - /// - /// The URL that we should call using the `recording_status_callback_method` when the recording status changes - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use when we call `recording_status_callback` - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// The SIP username used for authentication - /// - public string SipAuthUsername { get; set; } - /// - /// The SIP password for authentication - /// - public string SipAuthPassword { get; set; } - /// - /// The region where we should mix the conference audio - /// - public string Region { get; set; } - /// - /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available - /// - public Uri ConferenceRecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use to call `conference_recording_status_callback` - /// - public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } - /// - /// The recording state changes that should generate a call to `recording_status_callback` - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// The conference recording state changes that should generate a call to `conference_recording_status_callback` - /// - public List ConferenceRecordingStatusCallbackEvent { get; set; } - /// - /// Indicates if the participant changed to coach - /// - public bool? Coaching { get; set; } - /// - /// The SID of the participant who is being `coached` - /// - public string CallSidToCoach { get; set; } - /// - /// Jitter Buffer size for the connecting participant - /// - public string JitterBufferSize { get; set; } - /// - /// BYOC trunk SID (Beta) - /// - public string Byoc { get; set; } - /// - /// The phone number, Client identifier, or username portion of SIP address that made this call. - /// - public string CallerId { get; set; } - /// - /// Reason for the call (Branded Calls Beta) - /// - public string CallReason { get; set; } - /// - /// The track(s) to record - /// - public string RecordingTrack { get; set; } - /// - /// The maximum duration of the call in seconds. - /// - public int? TimeLimit { get; set; } - - /// - /// Construct a new CreateParticipantOptions - /// - /// The SID of the participant's conference - /// The phone number, Client identifier, or username portion of SIP address that made this call. - /// - /// The phone number, SIP address or Client identifier that received this call. - public CreateParticipantOptions(string pathConferenceSid, IEndpoint from, IEndpoint to) - { - PathConferenceSid = pathConferenceSid; - From = from; - To = to; - StatusCallbackEvent = new List(); - ConferenceStatusCallbackEvent = new List(); - RecordingStatusCallbackEvent = new List(); - ConferenceRecordingStatusCallbackEvent = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (StatusCallbackEvent != null) - { - p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop))); - } - - if (Label != null) - { - p.Add(new KeyValuePair("Label", Label)); - } - - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (Record != null) - { - p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); - } - - if (Muted != null) - { - p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); - } - - if (Beep != null) - { - p.Add(new KeyValuePair("Beep", Beep)); - } - - if (StartConferenceOnEnter != null) - { - p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); - } - - if (EndConferenceOnExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); - } - - if (WaitUrl != null) - { - p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); - } - - if (WaitMethod != null) - { - p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); - } - - if (EarlyMedia != null) - { - p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); - } - - if (MaxParticipants != null) - { - p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); - } - - if (ConferenceRecord != null) - { - p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); - } - - if (ConferenceTrim != null) - { - p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); - } - - if (ConferenceStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); - } - - if (ConferenceStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); - } - - if (ConferenceStatusCallbackEvent != null) - { - p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop))); - } - - if (RecordingChannels != null) - { - p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); - } - - if (RecordingStatusCallback != null) - { - p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); - } - - if (RecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); - } - - if (SipAuthUsername != null) - { - p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); - } - - if (SipAuthPassword != null) - { - p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); - } - - if (Region != null) - { - p.Add(new KeyValuePair("Region", Region)); - } - - if (ConferenceRecordingStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); - } - - if (ConferenceRecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); - } - - if (RecordingStatusCallbackEvent != null) - { - p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); - } - - if (ConferenceRecordingStatusCallbackEvent != null) - { - p.AddRange(ConferenceRecordingStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceRecordingStatusCallbackEvent", prop))); - } - - if (Coaching != null) - { - p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); - } - - if (CallSidToCoach != null) - { - p.Add(new KeyValuePair("CallSidToCoach", CallSidToCoach.ToString())); - } - - if (JitterBufferSize != null) - { - p.Add(new KeyValuePair("JitterBufferSize", JitterBufferSize)); - } - - if (Byoc != null) - { - p.Add(new KeyValuePair("Byoc", Byoc.ToString())); - } - - if (CallerId != null) - { - p.Add(new KeyValuePair("CallerId", CallerId)); - } - - if (CallReason != null) - { - p.Add(new KeyValuePair("CallReason", CallReason)); - } - - if (RecordingTrack != null) - { - p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); - } - - if (TimeLimit != null) - { - p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); - } - - return p; - } - } - + /// The Call SID or URL encoded label of the participant to fetch + /// + public string PathCallSid { get; } + /// - /// Kick a participant from a given conference - /// - public class DeleteParticipantOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the conference with the participants to delete - /// - public string PathConferenceSid { get; } - /// - /// The Call SID or URL encoded label of the participant to delete - /// - public string PathCallSid { get; } - - /// - /// Construct a new DeleteParticipantOptions - /// - /// The SID of the conference with the participants to delete - /// The Call SID or URL encoded label of the participant to delete - public DeleteParticipantOptions(string pathConferenceSid, string pathCallSid) - { - PathConferenceSid = pathConferenceSid; - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchParticipantOptions + /// + /// The SID of the conference with the participant to fetch + /// The Call SID or URL encoded label of the participant to fetch + public FetchParticipantOptions(string pathConferenceSid, string pathCallSid) + { + PathConferenceSid = pathConferenceSid; + PathCallSid = pathCallSid; + } + /// - /// Retrieve a list of participants belonging to the account used to make the request - /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the conference with the participants to read - /// - public string PathConferenceSid { get; } - /// - /// Whether to return only participants that are muted - /// - public bool? Muted { get; set; } - /// - /// Whether to return only participants that are on hold - /// - public bool? Hold { get; set; } - /// - /// Whether to return only participants who are coaching another call - /// - public bool? Coaching { get; set; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The SID of the conference with the participants to read - public ReadParticipantOptions(string pathConferenceSid) - { - PathConferenceSid = pathConferenceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Muted != null) - { - p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); - } - - if (Hold != null) - { - p.Add(new KeyValuePair("Hold", Hold.Value.ToString().ToLower())); - } - - if (Coaching != null) - { - p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the properties of the participant + /// + public class UpdateParticipantOptions : IOptions + { + /// + /// The SID of the Account that created the resources to update + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the conference with the participant to update + /// + public string PathConferenceSid { get; } + /// + /// The Call SID or URL encoded label of the participant to update + /// + public string PathCallSid { get; } + /// + /// Whether the participant should be muted + /// + public bool? Muted { get; set; } + /// + /// Whether the participant should be on hold + /// + public bool? Hold { get; set; } + /// + /// The URL we call using the `hold_method` for music that plays when the participant is on hold + /// + public Uri HoldUrl { get; set; } + /// + /// The HTTP method we should use to call hold_url + /// + public Twilio.Http.HttpMethod HoldMethod { get; set; } + /// + /// The URL we call using the `announce_method` for an announcement to the participant + /// + public Uri AnnounceUrl { get; set; } + /// + /// The HTTP method we should use to call announce_url + /// + public Twilio.Http.HttpMethod AnnounceMethod { get; set; } + /// + /// URL that hosts pre-conference hold music + /// + public Uri WaitUrl { get; set; } + /// + /// The HTTP method we should use to call `wait_url` + /// + public Twilio.Http.HttpMethod WaitMethod { get; set; } + /// + /// Whether to play a notification beep to the conference when the participant exit + /// + public bool? BeepOnExit { get; set; } + /// + /// Whether to end the conference when the participant leaves + /// + public bool? EndConferenceOnExit { get; set; } + /// + /// Indicates if the participant changed to coach + /// + public bool? Coaching { get; set; } + /// + /// The SID of the participant who is being `coached` + /// + public string CallSidToCoach { get; set; } + + /// + /// Construct a new UpdateParticipantOptions + /// + /// The SID of the conference with the participant to update + /// The Call SID or URL encoded label of the participant to update + public UpdateParticipantOptions(string pathConferenceSid, string pathCallSid) + { + PathConferenceSid = pathConferenceSid; + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Muted != null) + { + p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); + } + + if (Hold != null) + { + p.Add(new KeyValuePair("Hold", Hold.Value.ToString().ToLower())); + } + + if (HoldUrl != null) + { + p.Add(new KeyValuePair("HoldUrl", Serializers.Url(HoldUrl))); + } + + if (HoldMethod != null) + { + p.Add(new KeyValuePair("HoldMethod", HoldMethod.ToString())); + } + + if (AnnounceUrl != null) + { + p.Add(new KeyValuePair("AnnounceUrl", Serializers.Url(AnnounceUrl))); + } + + if (AnnounceMethod != null) + { + p.Add(new KeyValuePair("AnnounceMethod", AnnounceMethod.ToString())); + } + + if (WaitUrl != null) + { + p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); + } + + if (WaitMethod != null) + { + p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); + } + + if (BeepOnExit != null) + { + p.Add(new KeyValuePair("BeepOnExit", BeepOnExit.Value.ToString().ToLower())); + } + + if (EndConferenceOnExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); + } + + if (Coaching != null) + { + p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); + } + + if (CallSidToCoach != null) + { + p.Add(new KeyValuePair("CallSidToCoach", CallSidToCoach.ToString())); + } + + return p; + } + } + + /// + /// CreateParticipantOptions + /// + public class CreateParticipantOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the participant's conference + /// + public string PathConferenceSid { get; } + /// + /// The phone number, Client identifier, or username portion of SIP address that made this call. + /// + public IEndpoint From { get; } + /// + /// The phone number, SIP address or Client identifier that received this call. + /// + public IEndpoint To { get; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call `status_callback` + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Set state change events that will trigger a callback + /// + public List StatusCallbackEvent { get; set; } + /// + /// The label of this participant + /// + public string Label { get; set; } + /// + /// he number of seconds that we should wait for an answer + /// + public int? Timeout { get; set; } + /// + /// Whether to record the participant and their conferences + /// + public bool? Record { get; set; } + /// + /// Whether to mute the agent + /// + public bool? Muted { get; set; } + /// + /// Whether to play a notification beep to the conference when the participant joins + /// + public string Beep { get; set; } + /// + /// Whether the conference starts when the participant joins the conference + /// + public bool? StartConferenceOnEnter { get; set; } + /// + /// Whether to end the conference when the participant leaves + /// + public bool? EndConferenceOnExit { get; set; } + /// + /// URL that hosts pre-conference hold music + /// + public Uri WaitUrl { get; set; } + /// + /// The HTTP method we should use to call `wait_url` + /// + public Twilio.Http.HttpMethod WaitMethod { get; set; } + /// + /// Whether agents can hear the state of the outbound call + /// + public bool? EarlyMedia { get; set; } + /// + /// The maximum number of agent conference participants + /// + public int? MaxParticipants { get; set; } + /// + /// Whether to record the conference the participant is joining + /// + public string ConferenceRecord { get; set; } + /// + /// Whether to trim leading and trailing silence from your recorded conference audio files + /// + public string ConferenceTrim { get; set; } + /// + /// The callback URL for conference events + /// + public Uri ConferenceStatusCallback { get; set; } + /// + /// HTTP method for requesting `conference_status_callback` URL + /// + public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } + /// + /// The conference state changes that should generate a call to `conference_status_callback` + /// + public List ConferenceStatusCallbackEvent { get; set; } + /// + /// Specify `mono` or `dual` recording channels + /// + public string RecordingChannels { get; set; } + /// + /// The URL that we should call using the `recording_status_callback_method` when the recording status changes + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use when we call `recording_status_callback` + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// The SIP username used for authentication + /// + public string SipAuthUsername { get; set; } + /// + /// The SIP password for authentication + /// + public string SipAuthPassword { get; set; } + /// + /// The region where we should mix the conference audio + /// + public string Region { get; set; } + /// + /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available + /// + public Uri ConferenceRecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use to call `conference_recording_status_callback` + /// + public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } + /// + /// The recording state changes that should generate a call to `recording_status_callback` + /// + public List RecordingStatusCallbackEvent { get; set; } + /// + /// The conference recording state changes that should generate a call to `conference_recording_status_callback` + /// + public List ConferenceRecordingStatusCallbackEvent { get; set; } + /// + /// Indicates if the participant changed to coach + /// + public bool? Coaching { get; set; } + /// + /// The SID of the participant who is being `coached` + /// + public string CallSidToCoach { get; set; } + /// + /// Jitter Buffer size for the connecting participant + /// + public string JitterBufferSize { get; set; } + /// + /// BYOC trunk SID (Beta) + /// + public string Byoc { get; set; } + /// + /// The phone number, Client identifier, or username portion of SIP address that made this call. + /// + public string CallerId { get; set; } + /// + /// Reason for the call (Branded Calls Beta) + /// + public string CallReason { get; set; } + /// + /// The track(s) to record + /// + public string RecordingTrack { get; set; } + /// + /// The maximum duration of the call in seconds. + /// + public int? TimeLimit { get; set; } + + /// + /// Construct a new CreateParticipantOptions + /// + /// The SID of the participant's conference + /// The phone number, Client identifier, or username portion of SIP address that made this call. + /// + /// The phone number, SIP address or Client identifier that received this call. + public CreateParticipantOptions(string pathConferenceSid, IEndpoint from, IEndpoint to) + { + PathConferenceSid = pathConferenceSid; + From = from; + To = to; + StatusCallbackEvent = new List(); + ConferenceStatusCallbackEvent = new List(); + RecordingStatusCallbackEvent = new List(); + ConferenceRecordingStatusCallbackEvent = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (StatusCallbackEvent != null) + { + p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop))); + } + + if (Label != null) + { + p.Add(new KeyValuePair("Label", Label)); + } + + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (Record != null) + { + p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); + } + + if (Muted != null) + { + p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); + } + + if (Beep != null) + { + p.Add(new KeyValuePair("Beep", Beep)); + } + + if (StartConferenceOnEnter != null) + { + p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); + } + + if (EndConferenceOnExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); + } + + if (WaitUrl != null) + { + p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); + } + + if (WaitMethod != null) + { + p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); + } + + if (EarlyMedia != null) + { + p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); + } + + if (MaxParticipants != null) + { + p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); + } + + if (ConferenceRecord != null) + { + p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); + } + + if (ConferenceTrim != null) + { + p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); + } + + if (ConferenceStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); + } + + if (ConferenceStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); + } + + if (ConferenceStatusCallbackEvent != null) + { + p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop))); + } + + if (RecordingChannels != null) + { + p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); + } + + if (RecordingStatusCallback != null) + { + p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); + } + + if (RecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); + } + + if (SipAuthUsername != null) + { + p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); + } + + if (SipAuthPassword != null) + { + p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); + } + + if (Region != null) + { + p.Add(new KeyValuePair("Region", Region)); + } + + if (ConferenceRecordingStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); + } + + if (ConferenceRecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); + } + + if (RecordingStatusCallbackEvent != null) + { + p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair("RecordingStatusCallbackEvent", prop))); + } + + if (ConferenceRecordingStatusCallbackEvent != null) + { + p.AddRange(ConferenceRecordingStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceRecordingStatusCallbackEvent", prop))); + } + + if (Coaching != null) + { + p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); + } + + if (CallSidToCoach != null) + { + p.Add(new KeyValuePair("CallSidToCoach", CallSidToCoach.ToString())); + } + + if (JitterBufferSize != null) + { + p.Add(new KeyValuePair("JitterBufferSize", JitterBufferSize)); + } + + if (Byoc != null) + { + p.Add(new KeyValuePair("Byoc", Byoc.ToString())); + } + + if (CallerId != null) + { + p.Add(new KeyValuePair("CallerId", CallerId)); + } + + if (CallReason != null) + { + p.Add(new KeyValuePair("CallReason", CallReason)); + } + + if (RecordingTrack != null) + { + p.Add(new KeyValuePair("RecordingTrack", RecordingTrack)); + } + + if (TimeLimit != null) + { + p.Add(new KeyValuePair("TimeLimit", TimeLimit.ToString())); + } + + return p; + } + } + + /// + /// Kick a participant from a given conference + /// + public class DeleteParticipantOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the conference with the participants to delete + /// + public string PathConferenceSid { get; } + /// + /// The Call SID or URL encoded label of the participant to delete + /// + public string PathCallSid { get; } + + /// + /// Construct a new DeleteParticipantOptions + /// + /// The SID of the conference with the participants to delete + /// The Call SID or URL encoded label of the participant to delete + public DeleteParticipantOptions(string pathConferenceSid, string pathCallSid) + { + PathConferenceSid = pathConferenceSid; + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of participants belonging to the account used to make the request + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the conference with the participants to read + /// + public string PathConferenceSid { get; } + /// + /// Whether to return only participants that are muted + /// + public bool? Muted { get; set; } + /// + /// Whether to return only participants that are on hold + /// + public bool? Hold { get; set; } + /// + /// Whether to return only participants who are coaching another call + /// + public bool? Coaching { get; set; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The SID of the conference with the participants to read + public ReadParticipantOptions(string pathConferenceSid) + { + PathConferenceSid = pathConferenceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Muted != null) + { + p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); + } + + if (Hold != null) + { + p.Add(new KeyValuePair("Hold", Hold.Value.ToString().ToLower())); + } + + if (Coaching != null) + { + p.Add(new KeyValuePair("Coaching", Coaching.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantResource.cs b/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantResource.cs index 33b208473..5bb884bed 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Conference/ParticipantResource.cs @@ -17,802 +17,802 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Conference -{ - - public class ParticipantResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Connecting = new StatusEnum("connecting"); - public static readonly StatusEnum Ringing = new StatusEnum("ringing"); - public static readonly StatusEnum Connected = new StatusEnum("connected"); - public static readonly StatusEnum Complete = new StatusEnum("complete"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a participant - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a participant - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a participant - /// - /// The SID of the conference with the participant to fetch - /// The Call SID or URL encoded label of the participant to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a participant - /// - /// The SID of the conference with the participant to fetch - /// The Call SID or URL encoded label of the participant to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the properties of the participant - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the properties of the participant - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the properties of the participant - /// - /// The SID of the conference with the participant to update - /// The Call SID or URL encoded label of the participant to update - /// The SID of the Account that created the resources to update - /// Whether the participant should be muted - /// Whether the participant should be on hold - /// The URL we call using the `hold_method` for music that plays when the participant is on - /// hold - /// The HTTP method we should use to call hold_url - /// The URL we call using the `announce_method` for an announcement to the participant - /// - /// The HTTP method we should use to call announce_url - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether to play a notification beep to the conference when the participant exit - /// Whether to end the conference when the participant leaves - /// Indicates if the participant changed to coach - /// The SID of the participant who is being `coached` - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - bool? muted = null, - bool? hold = null, - Uri holdUrl = null, - Twilio.Http.HttpMethod holdMethod = null, - Uri announceUrl = null, - Twilio.Http.HttpMethod announceMethod = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? beepOnExit = null, - bool? endConferenceOnExit = null, - bool? coaching = null, - string callSidToCoach = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, HoldUrl = holdUrl, HoldMethod = holdMethod, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod, WaitUrl = waitUrl, WaitMethod = waitMethod, BeepOnExit = beepOnExit, EndConferenceOnExit = endConferenceOnExit, Coaching = coaching, CallSidToCoach = callSidToCoach}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the properties of the participant - /// - /// The SID of the conference with the participant to update - /// The Call SID or URL encoded label of the participant to update - /// The SID of the Account that created the resources to update - /// Whether the participant should be muted - /// Whether the participant should be on hold - /// The URL we call using the `hold_method` for music that plays when the participant is on - /// hold - /// The HTTP method we should use to call hold_url - /// The URL we call using the `announce_method` for an announcement to the participant - /// - /// The HTTP method we should use to call announce_url - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether to play a notification beep to the conference when the participant exit - /// Whether to end the conference when the participant leaves - /// Indicates if the participant changed to coach - /// The SID of the participant who is being `coached` - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - bool? muted = null, - bool? hold = null, - Uri holdUrl = null, - Twilio.Http.HttpMethod holdMethod = null, - Uri announceUrl = null, - Twilio.Http.HttpMethod announceMethod = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? beepOnExit = null, - bool? endConferenceOnExit = null, - bool? coaching = null, - string callSidToCoach = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, HoldUrl = holdUrl, HoldMethod = holdMethod, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod, WaitUrl = waitUrl, WaitMethod = waitMethod, BeepOnExit = beepOnExit, EndConferenceOnExit = endConferenceOnExit, Coaching = coaching, CallSidToCoach = callSidToCoach}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the participant's conference - /// The phone number, Client identifier, or username portion of SIP address that made this call. - /// - /// The phone number, SIP address or Client identifier that received this call. - /// The SID of the Account that will create the resource - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call `status_callback` - /// Set state change events that will trigger a callback - /// The label of this participant - /// he number of seconds that we should wait for an answer - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep to the conference when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the participant leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// Whether to record the conference the participant is joining - /// Whether to trim leading and trailing silence from your recorded conference audio - /// files - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference state changes that should generate a call to - /// `conference_status_callback` - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The SIP username used for authentication - /// The SIP password for authentication - /// The region where we should mix the conference audio - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The recording state changes that should generate a call to - /// `recording_status_callback` - /// The conference recording state changes that should generate a - /// call to `conference_recording_status_callback` - /// Indicates if the participant changed to coach - /// The SID of the participant who is being `coached` - /// Jitter Buffer size for the connecting participant - /// BYOC trunk SID (Beta) - /// The phone number, Client identifier, or username portion of SIP address that made this - /// call. - /// Reason for the call (Branded Calls Beta) - /// The track(s) to record - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(string pathConferenceSid, - IEndpoint from, - IEndpoint to, - string pathAccountSid = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - string label = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - string conferenceRecord = null, - string conferenceTrim = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - string region = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - List conferenceRecordingStatusCallbackEvent = null, - bool? coaching = null, - string callSidToCoach = null, - string jitterBufferSize = null, - string byoc = null, - string callerId = null, - string callReason = null, - string recordingTrack = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathConferenceSid, from, to){PathAccountSid = pathAccountSid, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Label = label, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, Region = region, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, ConferenceRecordingStatusCallbackEvent = conferenceRecordingStatusCallbackEvent, Coaching = coaching, CallSidToCoach = callSidToCoach, JitterBufferSize = jitterBufferSize, Byoc = byoc, CallerId = callerId, CallReason = callReason, RecordingTrack = recordingTrack, TimeLimit = timeLimit}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the participant's conference - /// The phone number, Client identifier, or username portion of SIP address that made this call. - /// - /// The phone number, SIP address or Client identifier that received this call. - /// The SID of the Account that will create the resource - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call `status_callback` - /// Set state change events that will trigger a callback - /// The label of this participant - /// he number of seconds that we should wait for an answer - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep to the conference when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the participant leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// Whether to record the conference the participant is joining - /// Whether to trim leading and trailing silence from your recorded conference audio - /// files - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference state changes that should generate a call to - /// `conference_status_callback` - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The SIP username used for authentication - /// The SIP password for authentication - /// The region where we should mix the conference audio - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The recording state changes that should generate a call to - /// `recording_status_callback` - /// The conference recording state changes that should generate a - /// call to `conference_recording_status_callback` - /// Indicates if the participant changed to coach - /// The SID of the participant who is being `coached` - /// Jitter Buffer size for the connecting participant - /// BYOC trunk SID (Beta) - /// The phone number, Client identifier, or username portion of SIP address that made this - /// call. - /// Reason for the call (Branded Calls Beta) - /// The track(s) to record - /// The maximum duration of the call in seconds. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(string pathConferenceSid, - IEndpoint from, - IEndpoint to, - string pathAccountSid = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - string label = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - string conferenceRecord = null, - string conferenceTrim = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - string region = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - List conferenceRecordingStatusCallbackEvent = null, - bool? coaching = null, - string callSidToCoach = null, - string jitterBufferSize = null, - string byoc = null, - string callerId = null, - string callReason = null, - string recordingTrack = null, - int? timeLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathConferenceSid, from, to){PathAccountSid = pathAccountSid, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Label = label, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, Region = region, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, ConferenceRecordingStatusCallbackEvent = conferenceRecordingStatusCallbackEvent, Coaching = coaching, CallSidToCoach = callSidToCoach, JitterBufferSize = jitterBufferSize, Byoc = byoc, CallerId = callerId, CallReason = callReason, RecordingTrack = recordingTrack, TimeLimit = timeLimit}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Kick a participant from a given conference - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Kick a participant from a given conference - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Kick a participant from a given conference - /// - /// The SID of the conference with the participants to delete - /// The Call SID or URL encoded label of the participant to delete - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Kick a participant from a given conference - /// - /// The SID of the conference with the participants to delete - /// The Call SID or URL encoded label of the participant to delete - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(string pathConferenceSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathConferenceSid, pathCallSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of participants belonging to the account used to make the request - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of participants belonging to the account used to make the request - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of participants belonging to the account used to make the request - /// - /// The SID of the conference with the participants to read - /// The SID of the Account that created the resources to read - /// Whether to return only participants that are muted - /// Whether to return only participants that are on hold - /// Whether to return only participants who are coaching another call - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathConferenceSid, - string pathAccountSid = null, - bool? muted = null, - bool? hold = null, - bool? coaching = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathConferenceSid){PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, Coaching = coaching, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of participants belonging to the account used to make the request - /// - /// The SID of the conference with the participants to read - /// The SID of the Account that created the resources to read - /// Whether to return only participants that are muted - /// Whether to return only participants that are on hold - /// Whether to return only participants who are coaching another call - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathConferenceSid, - string pathAccountSid = null, - bool? muted = null, - bool? hold = null, - bool? coaching = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathConferenceSid){PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, Coaching = coaching, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The label of this participant - /// - [JsonProperty("label")] - public string Label { get; private set; } - /// - /// The SID of the participant who is being `coached` - /// - [JsonProperty("call_sid_to_coach")] - public string CallSidToCoach { get; private set; } - /// - /// Indicates if the participant changed to coach - /// - [JsonProperty("coaching")] - public bool? Coaching { get; private set; } - /// - /// The SID of the conference the participant is in - /// - [JsonProperty("conference_sid")] - public string ConferenceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Whether the conference ends when the participant leaves - /// - [JsonProperty("end_conference_on_exit")] - public bool? EndConferenceOnExit { get; private set; } - /// - /// Whether the participant is muted - /// - [JsonProperty("muted")] - public bool? Muted { get; private set; } - /// - /// Whether the participant is on hold - /// - [JsonProperty("hold")] - public bool? Hold { get; private set; } - /// - /// Whether the conference starts when the participant joins the conference - /// - [JsonProperty("start_conference_on_enter")] - public bool? StartConferenceOnEnter { get; private set; } - /// - /// The status of the participant's call in a session - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantResource.StatusEnum Status { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Connecting = new StatusEnum("connecting"); + public static readonly StatusEnum Ringing = new StatusEnum("ringing"); + public static readonly StatusEnum Connected = new StatusEnum("connected"); + public static readonly StatusEnum Complete = new StatusEnum("complete"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a participant + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a participant + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a participant + /// + /// The SID of the conference with the participant to fetch + /// The Call SID or URL encoded label of the participant to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a participant + /// + /// The SID of the conference with the participant to fetch + /// The Call SID or URL encoded label of the participant to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the properties of the participant + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the properties of the participant + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the properties of the participant + /// + /// The SID of the conference with the participant to update + /// The Call SID or URL encoded label of the participant to update + /// The SID of the Account that created the resources to update + /// Whether the participant should be muted + /// Whether the participant should be on hold + /// The URL we call using the `hold_method` for music that plays when the participant is on + /// hold + /// The HTTP method we should use to call hold_url + /// The URL we call using the `announce_method` for an announcement to the participant + /// + /// The HTTP method we should use to call announce_url + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether to play a notification beep to the conference when the participant exit + /// Whether to end the conference when the participant leaves + /// Indicates if the participant changed to coach + /// The SID of the participant who is being `coached` + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + bool? muted = null, + bool? hold = null, + Uri holdUrl = null, + Twilio.Http.HttpMethod holdMethod = null, + Uri announceUrl = null, + Twilio.Http.HttpMethod announceMethod = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? beepOnExit = null, + bool? endConferenceOnExit = null, + bool? coaching = null, + string callSidToCoach = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, HoldUrl = holdUrl, HoldMethod = holdMethod, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod, WaitUrl = waitUrl, WaitMethod = waitMethod, BeepOnExit = beepOnExit, EndConferenceOnExit = endConferenceOnExit, Coaching = coaching, CallSidToCoach = callSidToCoach }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the properties of the participant + /// + /// The SID of the conference with the participant to update + /// The Call SID or URL encoded label of the participant to update + /// The SID of the Account that created the resources to update + /// Whether the participant should be muted + /// Whether the participant should be on hold + /// The URL we call using the `hold_method` for music that plays when the participant is on + /// hold + /// The HTTP method we should use to call hold_url + /// The URL we call using the `announce_method` for an announcement to the participant + /// + /// The HTTP method we should use to call announce_url + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether to play a notification beep to the conference when the participant exit + /// Whether to end the conference when the participant leaves + /// Indicates if the participant changed to coach + /// The SID of the participant who is being `coached` + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + bool? muted = null, + bool? hold = null, + Uri holdUrl = null, + Twilio.Http.HttpMethod holdMethod = null, + Uri announceUrl = null, + Twilio.Http.HttpMethod announceMethod = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? beepOnExit = null, + bool? endConferenceOnExit = null, + bool? coaching = null, + string callSidToCoach = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, HoldUrl = holdUrl, HoldMethod = holdMethod, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod, WaitUrl = waitUrl, WaitMethod = waitMethod, BeepOnExit = beepOnExit, EndConferenceOnExit = endConferenceOnExit, Coaching = coaching, CallSidToCoach = callSidToCoach }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the participant's conference + /// The phone number, Client identifier, or username portion of SIP address that made this call. + /// + /// The phone number, SIP address or Client identifier that received this call. + /// The SID of the Account that will create the resource + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call `status_callback` + /// Set state change events that will trigger a callback + /// The label of this participant + /// he number of seconds that we should wait for an answer + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep to the conference when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the participant leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// Whether to record the conference the participant is joining + /// Whether to trim leading and trailing silence from your recorded conference audio + /// files + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference state changes that should generate a call to + /// `conference_status_callback` + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The SIP username used for authentication + /// The SIP password for authentication + /// The region where we should mix the conference audio + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The recording state changes that should generate a call to + /// `recording_status_callback` + /// The conference recording state changes that should generate a + /// call to `conference_recording_status_callback` + /// Indicates if the participant changed to coach + /// The SID of the participant who is being `coached` + /// Jitter Buffer size for the connecting participant + /// BYOC trunk SID (Beta) + /// The phone number, Client identifier, or username portion of SIP address that made this + /// call. + /// Reason for the call (Branded Calls Beta) + /// The track(s) to record + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(string pathConferenceSid, + IEndpoint from, + IEndpoint to, + string pathAccountSid = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + string label = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + string conferenceRecord = null, + string conferenceTrim = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + string region = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + List conferenceRecordingStatusCallbackEvent = null, + bool? coaching = null, + string callSidToCoach = null, + string jitterBufferSize = null, + string byoc = null, + string callerId = null, + string callReason = null, + string recordingTrack = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathConferenceSid, from, to) { PathAccountSid = pathAccountSid, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Label = label, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, Region = region, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, ConferenceRecordingStatusCallbackEvent = conferenceRecordingStatusCallbackEvent, Coaching = coaching, CallSidToCoach = callSidToCoach, JitterBufferSize = jitterBufferSize, Byoc = byoc, CallerId = callerId, CallReason = callReason, RecordingTrack = recordingTrack, TimeLimit = timeLimit }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the participant's conference + /// The phone number, Client identifier, or username portion of SIP address that made this call. + /// + /// The phone number, SIP address or Client identifier that received this call. + /// The SID of the Account that will create the resource + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call `status_callback` + /// Set state change events that will trigger a callback + /// The label of this participant + /// he number of seconds that we should wait for an answer + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep to the conference when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the participant leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// Whether to record the conference the participant is joining + /// Whether to trim leading and trailing silence from your recorded conference audio + /// files + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference state changes that should generate a call to + /// `conference_status_callback` + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The SIP username used for authentication + /// The SIP password for authentication + /// The region where we should mix the conference audio + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The recording state changes that should generate a call to + /// `recording_status_callback` + /// The conference recording state changes that should generate a + /// call to `conference_recording_status_callback` + /// Indicates if the participant changed to coach + /// The SID of the participant who is being `coached` + /// Jitter Buffer size for the connecting participant + /// BYOC trunk SID (Beta) + /// The phone number, Client identifier, or username portion of SIP address that made this + /// call. + /// Reason for the call (Branded Calls Beta) + /// The track(s) to record + /// The maximum duration of the call in seconds. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(string pathConferenceSid, + IEndpoint from, + IEndpoint to, + string pathAccountSid = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + string label = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + string conferenceRecord = null, + string conferenceTrim = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + string region = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + List conferenceRecordingStatusCallbackEvent = null, + bool? coaching = null, + string callSidToCoach = null, + string jitterBufferSize = null, + string byoc = null, + string callerId = null, + string callReason = null, + string recordingTrack = null, + int? timeLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathConferenceSid, from, to) { PathAccountSid = pathAccountSid, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Label = label, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, Region = region, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, ConferenceRecordingStatusCallbackEvent = conferenceRecordingStatusCallbackEvent, Coaching = coaching, CallSidToCoach = callSidToCoach, JitterBufferSize = jitterBufferSize, Byoc = byoc, CallerId = callerId, CallReason = callReason, RecordingTrack = recordingTrack, TimeLimit = timeLimit }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants/" + options.PathCallSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Kick a participant from a given conference + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Kick a participant from a given conference + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Kick a participant from a given conference + /// + /// The SID of the conference with the participants to delete + /// The Call SID or URL encoded label of the participant to delete + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Kick a participant from a given conference + /// + /// The SID of the conference with the participants to delete + /// The Call SID or URL encoded label of the participant to delete + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(string pathConferenceSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathConferenceSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Participants.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of participants belonging to the account used to make the request + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of participants belonging to the account used to make the request + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of participants belonging to the account used to make the request + /// + /// The SID of the conference with the participants to read + /// The SID of the Account that created the resources to read + /// Whether to return only participants that are muted + /// Whether to return only participants that are on hold + /// Whether to return only participants who are coaching another call + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathConferenceSid, + string pathAccountSid = null, + bool? muted = null, + bool? hold = null, + bool? coaching = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathConferenceSid) { PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, Coaching = coaching, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of participants belonging to the account used to make the request + /// + /// The SID of the conference with the participants to read + /// The SID of the Account that created the resources to read + /// Whether to return only participants that are muted + /// Whether to return only participants that are on hold + /// Whether to return only participants who are coaching another call + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathConferenceSid, + string pathAccountSid = null, + bool? muted = null, + bool? hold = null, + bool? coaching = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathConferenceSid) { PathAccountSid = pathAccountSid, Muted = muted, Hold = hold, Coaching = coaching, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The label of this participant + /// + [JsonProperty("label")] + public string Label { get; private set; } + /// + /// The SID of the participant who is being `coached` + /// + [JsonProperty("call_sid_to_coach")] + public string CallSidToCoach { get; private set; } + /// + /// Indicates if the participant changed to coach + /// + [JsonProperty("coaching")] + public bool? Coaching { get; private set; } + /// + /// The SID of the conference the participant is in + /// + [JsonProperty("conference_sid")] + public string ConferenceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Whether the conference ends when the participant leaves + /// + [JsonProperty("end_conference_on_exit")] + public bool? EndConferenceOnExit { get; private set; } + /// + /// Whether the participant is muted + /// + [JsonProperty("muted")] + public bool? Muted { get; private set; } + /// + /// Whether the participant is on hold + /// + [JsonProperty("hold")] + public bool? Hold { get; private set; } + /// + /// Whether the conference starts when the participant joins the conference + /// + [JsonProperty("start_conference_on_enter")] + public bool? StartConferenceOnEnter { get; private set; } + /// + /// The status of the participant's call in a session + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantResource.StatusEnum Status { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingOptions.cs index cb907cf86..2d5e8b937 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingOptions.cs @@ -9,211 +9,211 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Conference -{ - +{ + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as + /// recording sid. + /// + public class UpdateRecordingOptions : IOptions + { /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as - /// recording sid. - /// - public class UpdateRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to update - /// - public string PathAccountSid { get; set; } - /// - /// Update by unique Conference SID for the recording - /// - public string PathConferenceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The new status of the recording - /// - public RecordingResource.StatusEnum Status { get; } - /// - /// Whether to record during a pause - /// - public string PauseBehavior { get; set; } - - /// - /// Construct a new UpdateRecordingOptions - /// - /// Update by unique Conference SID for the recording - /// The unique string that identifies the resource - /// The new status of the recording - public UpdateRecordingOptions(string pathConferenceSid, string pathSid, RecordingResource.StatusEnum status) - { - PathConferenceSid = pathConferenceSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PauseBehavior != null) - { - p.Add(new KeyValuePair("PauseBehavior", PauseBehavior)); - } - - return p; - } - } - + /// The SID of the Account that created the resource to update + /// + public string PathAccountSid { get; set; } /// - /// Fetch an instance of a recording for a call - /// - public class FetchRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// Fetch by unique Conference SID for the recording - /// - public string PathConferenceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRecordingOptions - /// - /// Fetch by unique Conference SID for the recording - /// The unique string that identifies the resource - public FetchRecordingOptions(string pathConferenceSid, string pathSid) - { - PathConferenceSid = pathConferenceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Update by unique Conference SID for the recording + /// + public string PathConferenceSid { get; } /// - /// Delete a recording from your account - /// - public class DeleteRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// Delete by the recording's conference SID - /// - public string PathConferenceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRecordingOptions - /// - /// Delete by the recording's conference SID - /// The unique string that identifies the resource - public DeleteRecordingOptions(string pathConferenceSid, string pathSid) - { - PathConferenceSid = pathConferenceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - public class ReadRecordingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Read by unique Conference SID for the recording - /// - public string PathConferenceSid { get; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreated { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedAfter { get; set; } - - /// - /// Construct a new ReadRecordingOptions - /// - /// Read by unique Conference SID for the recording - public ReadRecordingOptions(string pathConferenceSid) - { - PathConferenceSid = pathConferenceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The new status of the recording + /// + public RecordingResource.StatusEnum Status { get; } + /// + /// Whether to record during a pause + /// + public string PauseBehavior { get; set; } + + /// + /// Construct a new UpdateRecordingOptions + /// + /// Update by unique Conference SID for the recording + /// The unique string that identifies the resource + /// The new status of the recording + public UpdateRecordingOptions(string pathConferenceSid, string pathSid, RecordingResource.StatusEnum status) + { + PathConferenceSid = pathConferenceSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PauseBehavior != null) + { + p.Add(new KeyValuePair("PauseBehavior", PauseBehavior)); + } + + return p; + } + } + + /// + /// Fetch an instance of a recording for a call + /// + public class FetchRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// Fetch by unique Conference SID for the recording + /// + public string PathConferenceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRecordingOptions + /// + /// Fetch by unique Conference SID for the recording + /// The unique string that identifies the resource + public FetchRecordingOptions(string pathConferenceSid, string pathSid) + { + PathConferenceSid = pathConferenceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a recording from your account + /// + public class DeleteRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// Delete by the recording's conference SID + /// + public string PathConferenceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRecordingOptions + /// + /// Delete by the recording's conference SID + /// The unique string that identifies the resource + public DeleteRecordingOptions(string pathConferenceSid, string pathSid) + { + PathConferenceSid = pathConferenceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + public class ReadRecordingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// Read by unique Conference SID for the recording + /// + public string PathConferenceSid { get; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreated { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedAfter { get; set; } + + /// + /// Construct a new ReadRecordingOptions + /// + /// Read by unique Conference SID for the recording + public ReadRecordingOptions(string pathConferenceSid) + { + PathConferenceSid = pathConferenceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingResource.cs index 58ad5b719..b8acf1fdc 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Conference/RecordingResource.cs @@ -17,544 +17,544 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Conference -{ - - public class RecordingResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Paused = new StatusEnum("paused"); - public static readonly StatusEnum Stopped = new StatusEnum("stopped"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Absent = new StatusEnum("absent"); - } - - public sealed class SourceEnum : StringEnum - { - private SourceEnum(string value) : base(value) {} - public SourceEnum() {} - public static implicit operator SourceEnum(string value) - { - return new SourceEnum(value); - } - - public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); - public static readonly SourceEnum Conference = new SourceEnum("Conference"); - public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); - public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); - public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); - public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); - public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); - } - - private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as - /// recording sid. - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as - /// recording sid. - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as - /// recording sid. - /// - /// Update by unique Conference SID for the recording - /// The unique string that identifies the resource - /// The new status of the recording - /// The SID of the Account that created the resource to update - /// Whether to record during a pause - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(string pathConferenceSid, - string pathSid, - RecordingResource.StatusEnum status, - string pathAccountSid = null, - string pauseBehavior = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathConferenceSid, pathSid, status){PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior}; - return Update(options, client); - } - - #if !NET35 - /// - /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as - /// recording sid. - /// - /// Update by unique Conference SID for the recording - /// The unique string that identifies the resource - /// The new status of the recording - /// The SID of the Account that created the resource to update - /// Whether to record during a pause - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(string pathConferenceSid, - string pathSid, - RecordingResource.StatusEnum status, - string pathAccountSid = null, - string pauseBehavior = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathConferenceSid, pathSid, status){PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch by unique Conference SID for the recording - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(string pathConferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathConferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a recording for a call - /// - /// Fetch by unique Conference SID for the recording - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(string pathConferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathConferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a recording from your account - /// - /// Delete by the recording's conference SID - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(string pathConferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathConferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// Delete by the recording's conference SID - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(string pathConferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathConferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read by unique Conference SID for the recording - /// The SID of the Account that created the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(string pathConferenceSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(pathConferenceSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the call used to make the request - /// - /// Read by unique Conference SID for the recording - /// The SID of the Account that created the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(string pathConferenceSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(pathConferenceSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Converts a JSON string into a RecordingResource object - /// - /// Raw JSON string - /// RecordingResource object represented by the provided JSON - public static RecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the recording - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The Conference SID that identifies the conference associated with the recording - /// - [JsonProperty("conference_sid")] - public string ConferenceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The start time of the recording, given in RFC 2822 format - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The length of the recording in seconds - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The one-time cost of creating the recording. - /// - [JsonProperty("price")] - public string Price { get; private set; } - /// - /// The currency used in the price property. - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The status of the recording - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.StatusEnum Status { get; private set; } - /// - /// The number of channels in the final recording file as an integer - /// - [JsonProperty("channels")] - public int? Channels { get; private set; } - /// - /// How the recording was created - /// - [JsonProperty("source")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.SourceEnum Source { get; private set; } - /// - /// More information about why the recording is missing, if status is `absent`. - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// How to decrypt the recording. - /// - [JsonProperty("encryption_details")] - public object EncryptionDetails { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private RecordingResource() - { - - } - } +{ + + public class RecordingResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Paused = new StatusEnum("paused"); + public static readonly StatusEnum Stopped = new StatusEnum("stopped"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Absent = new StatusEnum("absent"); + } + + public sealed class SourceEnum : StringEnum + { + private SourceEnum(string value) : base(value) { } + public SourceEnum() { } + public static implicit operator SourceEnum(string value) + { + return new SourceEnum(value); + } + + public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); + public static readonly SourceEnum Conference = new SourceEnum("Conference"); + public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); + public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); + public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); + public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); + public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); + } + + private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as + /// recording sid. + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as + /// recording sid. + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as + /// recording sid. + /// + /// Update by unique Conference SID for the recording + /// The unique string that identifies the resource + /// The new status of the recording + /// The SID of the Account that created the resource to update + /// Whether to record during a pause + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(string pathConferenceSid, + string pathSid, + RecordingResource.StatusEnum status, + string pathAccountSid = null, + string pauseBehavior = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathConferenceSid, pathSid, status) { PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior }; + return Update(options, client); + } + +#if !NET35 + /// + /// Changes the status of the recording to paused, stopped, or in-progress. Note: To use `Twilio.CURRENT`, pass it as + /// recording sid. + /// + /// Update by unique Conference SID for the recording + /// The unique string that identifies the resource + /// The new status of the recording + /// The SID of the Account that created the resource to update + /// Whether to record during a pause + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(string pathConferenceSid, + string pathSid, + RecordingResource.StatusEnum status, + string pathAccountSid = null, + string pauseBehavior = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathConferenceSid, pathSid, status) { PathAccountSid = pathAccountSid, PauseBehavior = pauseBehavior }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch by unique Conference SID for the recording + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(string pathConferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathConferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a recording for a call + /// + /// Fetch by unique Conference SID for the recording + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(string pathConferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathConferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a recording from your account + /// + /// Delete by the recording's conference SID + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(string pathConferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathConferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// Delete by the recording's conference SID + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(string pathConferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathConferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathConferenceSid + "/Recordings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read by unique Conference SID for the recording + /// The SID of the Account that created the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(string pathConferenceSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions(pathConferenceSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the call used to make the request + /// + /// Read by unique Conference SID for the recording + /// The SID of the Account that created the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(string pathConferenceSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions(pathConferenceSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Converts a JSON string into a RecordingResource object + /// + /// Raw JSON string + /// RecordingResource object represented by the provided JSON + public static RecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the recording + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The Conference SID that identifies the conference associated with the recording + /// + [JsonProperty("conference_sid")] + public string ConferenceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The start time of the recording, given in RFC 2822 format + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The length of the recording in seconds + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The one-time cost of creating the recording. + /// + [JsonProperty("price")] + public string Price { get; private set; } + /// + /// The currency used in the price property. + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The status of the recording + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.StatusEnum Status { get; private set; } + /// + /// The number of channels in the final recording file as an integer + /// + [JsonProperty("channels")] + public int? Channels { get; private set; } + /// + /// How the recording was created + /// + [JsonProperty("source")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.SourceEnum Source { get; private set; } + /// + /// More information about why the recording is missing, if status is `absent`. + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// How to decrypt the recording. + /// + [JsonProperty("encryption_details")] + public object EncryptionDetails { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private RecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ConferenceOptions.cs b/src/Twilio/Rest/Api/V2010/Account/ConferenceOptions.cs index f270a38f6..68f95641b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ConferenceOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ConferenceOptions.cs @@ -9,200 +9,200 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a conference + /// + public class FetchConferenceOptions : IOptions + { /// - /// Fetch an instance of a conference - /// - public class FetchConferenceOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConferenceOptions - /// - /// The unique string that identifies this resource - public FetchConferenceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } /// - /// Retrieve a list of conferences belonging to the account used to make the request - /// - public class ReadConferenceOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to read - /// - public string PathAccountSid { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreated { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateUpdatedBefore { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateUpdated { get; set; } - /// - /// The `YYYY-MM-DD` value of the resources to read - /// - public DateTime? DateUpdatedAfter { get; set; } - /// - /// The string that identifies the Conference resources to read - /// - public string FriendlyName { get; set; } - /// - /// The status of the resources to read - /// - public ConferenceResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", DateUpdated.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (DateUpdatedBefore != null) - { - p.Add(new KeyValuePair("DateUpdated<", DateUpdatedBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (DateUpdatedAfter != null) - { - p.Add(new KeyValuePair("DateUpdated>", DateUpdatedAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// - /// UpdateConferenceOptions - /// - public class UpdateConferenceOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - /// - /// The new status of the resource - /// - public ConferenceResource.UpdateStatusEnum Status { get; set; } - /// - /// The URL we should call to announce something into the conference - /// - public Uri AnnounceUrl { get; set; } - /// - /// he HTTP method used to call announce_url - /// - public Twilio.Http.HttpMethod AnnounceMethod { get; set; } - - /// - /// Construct a new UpdateConferenceOptions - /// - /// The unique string that identifies this resource - public UpdateConferenceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (AnnounceUrl != null) - { - p.Add(new KeyValuePair("AnnounceUrl", Serializers.Url(AnnounceUrl))); - } - - if (AnnounceMethod != null) - { - p.Add(new KeyValuePair("AnnounceMethod", AnnounceMethod.ToString())); - } - - return p; - } - } + /// Construct a new FetchConferenceOptions + /// + /// The unique string that identifies this resource + public FetchConferenceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of conferences belonging to the account used to make the request + /// + public class ReadConferenceOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to read + /// + public string PathAccountSid { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreated { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateUpdatedBefore { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateUpdated { get; set; } + /// + /// The `YYYY-MM-DD` value of the resources to read + /// + public DateTime? DateUpdatedAfter { get; set; } + /// + /// The string that identifies the Conference resources to read + /// + public string FriendlyName { get; set; } + /// + /// The status of the resources to read + /// + public ConferenceResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", DateCreated.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreated<", DateCreatedBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreated>", DateCreatedAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", DateUpdated.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (DateUpdatedBefore != null) + { + p.Add(new KeyValuePair("DateUpdated<", DateUpdatedBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (DateUpdatedAfter != null) + { + p.Add(new KeyValuePair("DateUpdated>", DateUpdatedAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateConferenceOptions + /// + public class UpdateConferenceOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// + /// The new status of the resource + /// + public ConferenceResource.UpdateStatusEnum Status { get; set; } + /// + /// The URL we should call to announce something into the conference + /// + public Uri AnnounceUrl { get; set; } + /// + /// he HTTP method used to call announce_url + /// + public Twilio.Http.HttpMethod AnnounceMethod { get; set; } + + /// + /// Construct a new UpdateConferenceOptions + /// + /// The unique string that identifies this resource + public UpdateConferenceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (AnnounceUrl != null) + { + p.Add(new KeyValuePair("AnnounceUrl", Serializers.Url(AnnounceUrl))); + } + + if (AnnounceMethod != null) + { + p.Add(new KeyValuePair("AnnounceMethod", AnnounceMethod.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ConferenceResource.cs b/src/Twilio/Rest/Api/V2010/Account/ConferenceResource.cs index c641c53ff..cd8fee582 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ConferenceResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ConferenceResource.cs @@ -17,456 +17,456 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class ConferenceResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Init = new StatusEnum("init"); - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Completed = new UpdateStatusEnum("completed"); - } - - public sealed class ReasonConferenceEndedEnum : StringEnum - { - private ReasonConferenceEndedEnum(string value) : base(value) {} - public ReasonConferenceEndedEnum() {} - public static implicit operator ReasonConferenceEndedEnum(string value) - { - return new ReasonConferenceEndedEnum(value); - } - - public static readonly ReasonConferenceEndedEnum ConferenceEndedViaApi = new ReasonConferenceEndedEnum("conference-ended-via-api"); - public static readonly ReasonConferenceEndedEnum ParticipantWithEndConferenceOnExitLeft = new ReasonConferenceEndedEnum("participant-with-end-conference-on-exit-left"); - public static readonly ReasonConferenceEndedEnum ParticipantWithEndConferenceOnExitKicked = new ReasonConferenceEndedEnum("participant-with-end-conference-on-exit-kicked"); - public static readonly ReasonConferenceEndedEnum LastParticipantKicked = new ReasonConferenceEndedEnum("last-participant-kicked"); - public static readonly ReasonConferenceEndedEnum LastParticipantLeft = new ReasonConferenceEndedEnum("last-participant-left"); - } - - private static Request BuildFetchRequest(FetchConferenceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a conference - /// - /// Fetch Conference parameters - /// Client to make requests to Twilio - /// A single instance of Conference - public static ConferenceResource Fetch(FetchConferenceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a conference - /// - /// Fetch Conference parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task FetchAsync(FetchConferenceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a conference - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of Conference - public static ConferenceResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchConferenceOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a conference - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchConferenceOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConferenceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of conferences belonging to the account used to make the request - /// - /// Read Conference parameters - /// Client to make requests to Twilio - /// A single instance of Conference - public static ResourceSet Read(ReadConferenceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conferences", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conferences belonging to the account used to make the request - /// - /// Read Conference parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task> ReadAsync(ReadConferenceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conferences", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of conferences belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The string that identifies the Conference resources to read - /// The status of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Conference - public static ResourceSet Read(string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - DateTime? dateUpdatedBefore = null, - DateTime? dateUpdated = null, - DateTime? dateUpdatedAfter = null, - string friendlyName = null, - ConferenceResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConferenceOptions(){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, DateUpdatedBefore = dateUpdatedBefore, DateUpdated = dateUpdated, DateUpdatedAfter = dateUpdatedAfter, FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conferences belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The `YYYY-MM-DD` value of the resources to read - /// The string that identifies the Conference resources to read - /// The status of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - DateTime? dateUpdatedBefore = null, - DateTime? dateUpdated = null, - DateTime? dateUpdatedAfter = null, - string friendlyName = null, - ConferenceResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConferenceOptions(){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, DateUpdatedBefore = dateUpdatedBefore, DateUpdated = dateUpdated, DateUpdatedAfter = dateUpdatedAfter, FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conferences", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("conferences", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("conferences", response.Content); - } - - private static Request BuildUpdateRequest(UpdateConferenceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Conference parameters - /// Client to make requests to Twilio - /// A single instance of Conference - public static ConferenceResource Update(UpdateConferenceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Conference parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConferenceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// The new status of the resource - /// The URL we should call to announce something into the conference - /// he HTTP method used to call announce_url - /// Client to make requests to Twilio - /// A single instance of Conference - public static ConferenceResource Update(string pathSid, - string pathAccountSid = null, - ConferenceResource.UpdateStatusEnum status = null, - Uri announceUrl = null, - Twilio.Http.HttpMethod announceMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateConferenceOptions(pathSid){PathAccountSid = pathAccountSid, Status = status, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// The new status of the resource - /// The URL we should call to announce something into the conference - /// he HTTP method used to call announce_url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conference - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - ConferenceResource.UpdateStatusEnum status = null, - Uri announceUrl = null, - Twilio.Http.HttpMethod announceMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateConferenceOptions(pathSid){PathAccountSid = pathAccountSid, Status = status, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConferenceResource object - /// - /// Raw JSON string - /// ConferenceResource object represented by the provided JSON - public static ConferenceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The API version used to create this conference - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// A string that you assigned to describe this conference room - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A string that represents the Twilio Region where the conference was mixed - /// - [JsonProperty("region")] - public string Region { get; private set; } - /// - /// The unique string that identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of this conference - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ConferenceResource.StatusEnum Status { get; private set; } - /// - /// The URI of this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The reason why a conference ended. - /// - [JsonProperty("reason_conference_ended")] - [JsonConverter(typeof(StringEnumConverter))] - public ConferenceResource.ReasonConferenceEndedEnum ReasonConferenceEnded { get; private set; } - /// - /// The call SID that caused the conference to end - /// - [JsonProperty("call_sid_ending_conference")] - public string CallSidEndingConference { get; private set; } - - private ConferenceResource() - { - - } - } +{ + + public class ConferenceResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Init = new StatusEnum("init"); + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Completed = new UpdateStatusEnum("completed"); + } + + public sealed class ReasonConferenceEndedEnum : StringEnum + { + private ReasonConferenceEndedEnum(string value) : base(value) { } + public ReasonConferenceEndedEnum() { } + public static implicit operator ReasonConferenceEndedEnum(string value) + { + return new ReasonConferenceEndedEnum(value); + } + + public static readonly ReasonConferenceEndedEnum ConferenceEndedViaApi = new ReasonConferenceEndedEnum("conference-ended-via-api"); + public static readonly ReasonConferenceEndedEnum ParticipantWithEndConferenceOnExitLeft = new ReasonConferenceEndedEnum("participant-with-end-conference-on-exit-left"); + public static readonly ReasonConferenceEndedEnum ParticipantWithEndConferenceOnExitKicked = new ReasonConferenceEndedEnum("participant-with-end-conference-on-exit-kicked"); + public static readonly ReasonConferenceEndedEnum LastParticipantKicked = new ReasonConferenceEndedEnum("last-participant-kicked"); + public static readonly ReasonConferenceEndedEnum LastParticipantLeft = new ReasonConferenceEndedEnum("last-participant-left"); + } + + private static Request BuildFetchRequest(FetchConferenceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a conference + /// + /// Fetch Conference parameters + /// Client to make requests to Twilio + /// A single instance of Conference + public static ConferenceResource Fetch(FetchConferenceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a conference + /// + /// Fetch Conference parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task FetchAsync(FetchConferenceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a conference + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of Conference + public static ConferenceResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchConferenceOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a conference + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchConferenceOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConferenceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of conferences belonging to the account used to make the request + /// + /// Read Conference parameters + /// Client to make requests to Twilio + /// A single instance of Conference + public static ResourceSet Read(ReadConferenceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conferences", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conferences belonging to the account used to make the request + /// + /// Read Conference parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task> ReadAsync(ReadConferenceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conferences", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of conferences belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The string that identifies the Conference resources to read + /// The status of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Conference + public static ResourceSet Read(string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + DateTime? dateUpdatedBefore = null, + DateTime? dateUpdated = null, + DateTime? dateUpdatedAfter = null, + string friendlyName = null, + ConferenceResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConferenceOptions() { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, DateUpdatedBefore = dateUpdatedBefore, DateUpdated = dateUpdated, DateUpdatedAfter = dateUpdatedAfter, FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conferences belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The `YYYY-MM-DD` value of the resources to read + /// The string that identifies the Conference resources to read + /// The status of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + DateTime? dateUpdatedBefore = null, + DateTime? dateUpdated = null, + DateTime? dateUpdatedAfter = null, + string friendlyName = null, + ConferenceResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConferenceOptions() { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, DateUpdatedBefore = dateUpdatedBefore, DateUpdated = dateUpdated, DateUpdatedAfter = dateUpdatedAfter, FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conferences", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("conferences", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("conferences", response.Content); + } + + private static Request BuildUpdateRequest(UpdateConferenceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Conferences/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Conference parameters + /// Client to make requests to Twilio + /// A single instance of Conference + public static ConferenceResource Update(UpdateConferenceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Conference parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConferenceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// The new status of the resource + /// The URL we should call to announce something into the conference + /// he HTTP method used to call announce_url + /// Client to make requests to Twilio + /// A single instance of Conference + public static ConferenceResource Update(string pathSid, + string pathAccountSid = null, + ConferenceResource.UpdateStatusEnum status = null, + Uri announceUrl = null, + Twilio.Http.HttpMethod announceMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateConferenceOptions(pathSid) { PathAccountSid = pathAccountSid, Status = status, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// The new status of the resource + /// The URL we should call to announce something into the conference + /// he HTTP method used to call announce_url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conference + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + ConferenceResource.UpdateStatusEnum status = null, + Uri announceUrl = null, + Twilio.Http.HttpMethod announceMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateConferenceOptions(pathSid) { PathAccountSid = pathAccountSid, Status = status, AnnounceUrl = announceUrl, AnnounceMethod = announceMethod }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConferenceResource object + /// + /// Raw JSON string + /// ConferenceResource object represented by the provided JSON + public static ConferenceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The API version used to create this conference + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// A string that you assigned to describe this conference room + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A string that represents the Twilio Region where the conference was mixed + /// + [JsonProperty("region")] + public string Region { get; private set; } + /// + /// The unique string that identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of this conference + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ConferenceResource.StatusEnum Status { get; private set; } + /// + /// The URI of this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The reason why a conference ended. + /// + [JsonProperty("reason_conference_ended")] + [JsonConverter(typeof(StringEnumConverter))] + public ConferenceResource.ReasonConferenceEndedEnum ReasonConferenceEnded { get; private set; } + /// + /// The call SID that caused the conference to end + /// + [JsonProperty("call_sid_ending_conference")] + public string CallSidEndingConference { get; private set; } + + private ConferenceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ConnectAppOptions.cs b/src/Twilio/Rest/Api/V2010/Account/ConnectAppOptions.cs index 2a3ea7948..0ed4e2302 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ConnectAppOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ConnectAppOptions.cs @@ -10,203 +10,203 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a connect-app + /// + public class FetchConnectAppOptions : IOptions + { /// - /// Fetch an instance of a connect-app - /// - public class FetchConnectAppOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConnectAppOptions - /// - /// The unique string that identifies the resource - public FetchConnectAppOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } /// - /// Update a connect-app with the specified parameters - /// - public class UpdateConnectAppOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The URL to redirect the user to after authorization - /// - public Uri AuthorizeRedirectUrl { get; set; } - /// - /// The company name to set for the Connect App - /// - public string CompanyName { get; set; } - /// - /// The HTTP method to use when calling deauthorize_callback_url - /// - public Twilio.Http.HttpMethod DeauthorizeCallbackMethod { get; set; } - /// - /// The URL to call to de-authorize the Connect App - /// - public Uri DeauthorizeCallbackUrl { get; set; } - /// - /// A description of the Connect App - /// - public string Description { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// A public URL where users can obtain more information - /// - public Uri HomepageUrl { get; set; } - /// - /// The set of permissions that your ConnectApp will request - /// - public List Permissions { get; set; } - - /// - /// Construct a new UpdateConnectAppOptions - /// - /// The unique string that identifies the resource - public UpdateConnectAppOptions(string pathSid) - { - PathSid = pathSid; - Permissions = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AuthorizeRedirectUrl != null) - { - p.Add(new KeyValuePair("AuthorizeRedirectUrl", Serializers.Url(AuthorizeRedirectUrl))); - } - - if (CompanyName != null) - { - p.Add(new KeyValuePair("CompanyName", CompanyName)); - } - - if (DeauthorizeCallbackMethod != null) - { - p.Add(new KeyValuePair("DeauthorizeCallbackMethod", DeauthorizeCallbackMethod.ToString())); - } - - if (DeauthorizeCallbackUrl != null) - { - p.Add(new KeyValuePair("DeauthorizeCallbackUrl", Serializers.Url(DeauthorizeCallbackUrl))); - } - - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (HomepageUrl != null) - { - p.Add(new KeyValuePair("HomepageUrl", Serializers.Url(HomepageUrl))); - } - - if (Permissions != null) - { - p.AddRange(Permissions.Select(prop => new KeyValuePair("Permissions", prop.ToString()))); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// Retrieve a list of connect-apps belonging to the account used to make the request + /// Construct a new FetchConnectAppOptions /// - public class ReadConnectAppOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + public FetchConnectAppOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Delete an instance of a connect-app - /// - public class DeleteConnectAppOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteConnectAppOptions - /// - /// The unique string that identifies the resource - public DeleteConnectAppOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update a connect-app with the specified parameters + /// + public class UpdateConnectAppOptions : IOptions + { + /// + /// The SID of the Account that created the resources to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The URL to redirect the user to after authorization + /// + public Uri AuthorizeRedirectUrl { get; set; } + /// + /// The company name to set for the Connect App + /// + public string CompanyName { get; set; } + /// + /// The HTTP method to use when calling deauthorize_callback_url + /// + public Twilio.Http.HttpMethod DeauthorizeCallbackMethod { get; set; } + /// + /// The URL to call to de-authorize the Connect App + /// + public Uri DeauthorizeCallbackUrl { get; set; } + /// + /// A description of the Connect App + /// + public string Description { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// A public URL where users can obtain more information + /// + public Uri HomepageUrl { get; set; } + /// + /// The set of permissions that your ConnectApp will request + /// + public List Permissions { get; set; } + + /// + /// Construct a new UpdateConnectAppOptions + /// + /// The unique string that identifies the resource + public UpdateConnectAppOptions(string pathSid) + { + PathSid = pathSid; + Permissions = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AuthorizeRedirectUrl != null) + { + p.Add(new KeyValuePair("AuthorizeRedirectUrl", Serializers.Url(AuthorizeRedirectUrl))); + } + + if (CompanyName != null) + { + p.Add(new KeyValuePair("CompanyName", CompanyName)); + } + + if (DeauthorizeCallbackMethod != null) + { + p.Add(new KeyValuePair("DeauthorizeCallbackMethod", DeauthorizeCallbackMethod.ToString())); + } + + if (DeauthorizeCallbackUrl != null) + { + p.Add(new KeyValuePair("DeauthorizeCallbackUrl", Serializers.Url(DeauthorizeCallbackUrl))); + } + + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (HomepageUrl != null) + { + p.Add(new KeyValuePair("HomepageUrl", Serializers.Url(HomepageUrl))); + } + + if (Permissions != null) + { + p.AddRange(Permissions.Select(prop => new KeyValuePair("Permissions", prop.ToString()))); + } + + return p; + } + } + + /// + /// Retrieve a list of connect-apps belonging to the account used to make the request + /// + public class ReadConnectAppOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete an instance of a connect-app + /// + public class DeleteConnectAppOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteConnectAppOptions + /// + /// The unique string that identifies the resource + public DeleteConnectAppOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ConnectAppResource.cs b/src/Twilio/Rest/Api/V2010/Account/ConnectAppResource.cs index 24f4f0e35..930e8e1ca 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ConnectAppResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ConnectAppResource.cs @@ -17,480 +17,480 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class ConnectAppResource : Resource - { - public sealed class PermissionEnum : StringEnum - { - private PermissionEnum(string value) : base(value) {} - public PermissionEnum() {} - public static implicit operator PermissionEnum(string value) - { - return new PermissionEnum(value); - } - - public static readonly PermissionEnum GetAll = new PermissionEnum("get-all"); - public static readonly PermissionEnum PostAll = new PermissionEnum("post-all"); - } - - private static Request BuildFetchRequest(FetchConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a connect-app - /// - /// Fetch ConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ConnectAppResource Fetch(FetchConnectAppOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a connect-app - /// - /// Fetch ConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task FetchAsync(FetchConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a connect-app - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ConnectAppResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchConnectAppOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a connect-app - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchConnectAppOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a connect-app with the specified parameters - /// - /// Update ConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ConnectAppResource Update(UpdateConnectAppOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a connect-app with the specified parameters - /// - /// Update ConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a connect-app with the specified parameters - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The URL to redirect the user to after authorization - /// The company name to set for the Connect App - /// The HTTP method to use when calling deauthorize_callback_url - /// The URL to call to de-authorize the Connect App - /// A description of the Connect App - /// A string to describe the resource - /// A public URL where users can obtain more information - /// The set of permissions that your ConnectApp will request - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ConnectAppResource Update(string pathSid, - string pathAccountSid = null, - Uri authorizeRedirectUrl = null, - string companyName = null, - Twilio.Http.HttpMethod deauthorizeCallbackMethod = null, - Uri deauthorizeCallbackUrl = null, - string description = null, - string friendlyName = null, - Uri homepageUrl = null, - List permissions = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectAppOptions(pathSid){PathAccountSid = pathAccountSid, AuthorizeRedirectUrl = authorizeRedirectUrl, CompanyName = companyName, DeauthorizeCallbackMethod = deauthorizeCallbackMethod, DeauthorizeCallbackUrl = deauthorizeCallbackUrl, Description = description, FriendlyName = friendlyName, HomepageUrl = homepageUrl, Permissions = permissions}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a connect-app with the specified parameters - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The URL to redirect the user to after authorization - /// The company name to set for the Connect App - /// The HTTP method to use when calling deauthorize_callback_url - /// The URL to call to de-authorize the Connect App - /// A description of the Connect App - /// A string to describe the resource - /// A public URL where users can obtain more information - /// The set of permissions that your ConnectApp will request - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - Uri authorizeRedirectUrl = null, - string companyName = null, - Twilio.Http.HttpMethod deauthorizeCallbackMethod = null, - Uri deauthorizeCallbackUrl = null, - string description = null, - string friendlyName = null, - Uri homepageUrl = null, - List permissions = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectAppOptions(pathSid){PathAccountSid = pathAccountSid, AuthorizeRedirectUrl = authorizeRedirectUrl, CompanyName = companyName, DeauthorizeCallbackMethod = deauthorizeCallbackMethod, DeauthorizeCallbackUrl = deauthorizeCallbackUrl, Description = description, FriendlyName = friendlyName, HomepageUrl = homepageUrl, Permissions = permissions}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of connect-apps belonging to the account used to make the request - /// - /// Read ConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ResourceSet Read(ReadConnectAppOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("connect_apps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of connect-apps belonging to the account used to make the request - /// - /// Read ConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("connect_apps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of connect-apps belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectAppOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of connect-apps belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectAppOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("connect_apps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("connect_apps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("connect_apps", response.Content); - } - - private static Request BuildDeleteRequest(DeleteConnectAppOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an instance of a connect-app - /// - /// Delete ConnectApp parameters - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static bool Delete(DeleteConnectAppOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an instance of a connect-app - /// - /// Delete ConnectApp parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectAppOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an instance of a connect-app - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of ConnectApp - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteConnectAppOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an instance of a connect-app - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectApp - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteConnectAppOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConnectAppResource object - /// - /// Raw JSON string - /// ConnectAppResource object represented by the provided JSON - public static ConnectAppResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The URL to redirect the user to after authorization - /// - [JsonProperty("authorize_redirect_url")] - public Uri AuthorizeRedirectUrl { get; private set; } - /// - /// The company name set for the Connect App - /// - [JsonProperty("company_name")] - public string CompanyName { get; private set; } - /// - /// The HTTP method we use to call deauthorize_callback_url - /// - [JsonProperty("deauthorize_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod DeauthorizeCallbackMethod { get; private set; } - /// - /// The URL we call to de-authorize the Connect App - /// - [JsonProperty("deauthorize_callback_url")] - public Uri DeauthorizeCallbackUrl { get; private set; } - /// - /// The description of the Connect App - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The URL users can obtain more information - /// - [JsonProperty("homepage_url")] - public Uri HomepageUrl { get; private set; } - /// - /// The set of permissions that your ConnectApp requests - /// - [JsonProperty("permissions")] - [JsonConverter(typeof(StringEnumConverter))] - public List Permissions { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private ConnectAppResource() - { - - } - } +{ + + public class ConnectAppResource : Resource + { + public sealed class PermissionEnum : StringEnum + { + private PermissionEnum(string value) : base(value) { } + public PermissionEnum() { } + public static implicit operator PermissionEnum(string value) + { + return new PermissionEnum(value); + } + + public static readonly PermissionEnum GetAll = new PermissionEnum("get-all"); + public static readonly PermissionEnum PostAll = new PermissionEnum("post-all"); + } + + private static Request BuildFetchRequest(FetchConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a connect-app + /// + /// Fetch ConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ConnectAppResource Fetch(FetchConnectAppOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a connect-app + /// + /// Fetch ConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task FetchAsync(FetchConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a connect-app + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ConnectAppResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a connect-app + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a connect-app with the specified parameters + /// + /// Update ConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ConnectAppResource Update(UpdateConnectAppOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a connect-app with the specified parameters + /// + /// Update ConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a connect-app with the specified parameters + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The URL to redirect the user to after authorization + /// The company name to set for the Connect App + /// The HTTP method to use when calling deauthorize_callback_url + /// The URL to call to de-authorize the Connect App + /// A description of the Connect App + /// A string to describe the resource + /// A public URL where users can obtain more information + /// The set of permissions that your ConnectApp will request + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ConnectAppResource Update(string pathSid, + string pathAccountSid = null, + Uri authorizeRedirectUrl = null, + string companyName = null, + Twilio.Http.HttpMethod deauthorizeCallbackMethod = null, + Uri deauthorizeCallbackUrl = null, + string description = null, + string friendlyName = null, + Uri homepageUrl = null, + List permissions = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid, AuthorizeRedirectUrl = authorizeRedirectUrl, CompanyName = companyName, DeauthorizeCallbackMethod = deauthorizeCallbackMethod, DeauthorizeCallbackUrl = deauthorizeCallbackUrl, Description = description, FriendlyName = friendlyName, HomepageUrl = homepageUrl, Permissions = permissions }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a connect-app with the specified parameters + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The URL to redirect the user to after authorization + /// The company name to set for the Connect App + /// The HTTP method to use when calling deauthorize_callback_url + /// The URL to call to de-authorize the Connect App + /// A description of the Connect App + /// A string to describe the resource + /// A public URL where users can obtain more information + /// The set of permissions that your ConnectApp will request + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + Uri authorizeRedirectUrl = null, + string companyName = null, + Twilio.Http.HttpMethod deauthorizeCallbackMethod = null, + Uri deauthorizeCallbackUrl = null, + string description = null, + string friendlyName = null, + Uri homepageUrl = null, + List permissions = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid, AuthorizeRedirectUrl = authorizeRedirectUrl, CompanyName = companyName, DeauthorizeCallbackMethod = deauthorizeCallbackMethod, DeauthorizeCallbackUrl = deauthorizeCallbackUrl, Description = description, FriendlyName = friendlyName, HomepageUrl = homepageUrl, Permissions = permissions }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of connect-apps belonging to the account used to make the request + /// + /// Read ConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ResourceSet Read(ReadConnectAppOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("connect_apps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of connect-apps belonging to the account used to make the request + /// + /// Read ConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("connect_apps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of connect-apps belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectAppOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of connect-apps belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectAppOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("connect_apps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("connect_apps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("connect_apps", response.Content); + } + + private static Request BuildDeleteRequest(DeleteConnectAppOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/ConnectApps/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an instance of a connect-app + /// + /// Delete ConnectApp parameters + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static bool Delete(DeleteConnectAppOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an instance of a connect-app + /// + /// Delete ConnectApp parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectAppOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an instance of a connect-app + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of ConnectApp + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an instance of a connect-app + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectApp + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteConnectAppOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConnectAppResource object + /// + /// Raw JSON string + /// ConnectAppResource object represented by the provided JSON + public static ConnectAppResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The URL to redirect the user to after authorization + /// + [JsonProperty("authorize_redirect_url")] + public Uri AuthorizeRedirectUrl { get; private set; } + /// + /// The company name set for the Connect App + /// + [JsonProperty("company_name")] + public string CompanyName { get; private set; } + /// + /// The HTTP method we use to call deauthorize_callback_url + /// + [JsonProperty("deauthorize_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod DeauthorizeCallbackMethod { get; private set; } + /// + /// The URL we call to de-authorize the Connect App + /// + [JsonProperty("deauthorize_callback_url")] + public Uri DeauthorizeCallbackUrl { get; private set; } + /// + /// The description of the Connect App + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The URL users can obtain more information + /// + [JsonProperty("homepage_url")] + public Uri HomepageUrl { get; private set; } + /// + /// The set of permissions that your ConnectApp requests + /// + [JsonProperty("permissions")] + [JsonConverter(typeof(StringEnumConverter))] + public List Permissions { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private ConnectAppResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionOptions.cs index 7a36b10f4..7560114db 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionOptions.cs @@ -9,99 +9,99 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber.AssignedAddOn -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch an instance of an Extension for the Assigned Add-on. + /// + public class FetchAssignedAddOnExtensionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch an instance of an Extension for the Assigned Add-on. + /// The SID of the Account that created the resource to fetch /// - public class FetchAssignedAddOnExtensionOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// - public string PathResourceSid { get; } - /// - /// The SID that uniquely identifies the assigned Add-on installation - /// - public string PathAssignedAddOnSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssignedAddOnExtensionOptions - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - /// The unique string that identifies the resource - public FetchAssignedAddOnExtensionOptions(string pathResourceSid, string pathAssignedAddOnSid, string pathSid) - { - PathResourceSid = pathResourceSid; - PathAssignedAddOnSid = pathAssignedAddOnSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Extensions for the Assigned Add-on. + /// The SID of the Phone Number to which the Add-on is assigned /// - public class ReadAssignedAddOnExtensionOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// - public string PathResourceSid { get; } - /// - /// The SID that uniquely identifies the assigned Add-on installation - /// - public string PathAssignedAddOnSid { get; } - - /// - /// Construct a new ReadAssignedAddOnExtensionOptions - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - public ReadAssignedAddOnExtensionOptions(string pathResourceSid, string pathAssignedAddOnSid) - { - PathResourceSid = pathResourceSid; - PathAssignedAddOnSid = pathAssignedAddOnSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathResourceSid { get; } + /// + /// The SID that uniquely identifies the assigned Add-on installation + /// + public string PathAssignedAddOnSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAssignedAddOnExtensionOptions + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + /// The unique string that identifies the resource + public FetchAssignedAddOnExtensionOptions(string pathResourceSid, string pathAssignedAddOnSid, string pathSid) + { + PathResourceSid = pathResourceSid; + PathAssignedAddOnSid = pathAssignedAddOnSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Extensions for the Assigned Add-on. + /// + public class ReadAssignedAddOnExtensionOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// + public string PathResourceSid { get; } + /// + /// The SID that uniquely identifies the assigned Add-on installation + /// + public string PathAssignedAddOnSid { get; } + + /// + /// Construct a new ReadAssignedAddOnExtensionOptions + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + public ReadAssignedAddOnExtensionOptions(string pathResourceSid, string pathAssignedAddOnSid) + { + PathResourceSid = pathResourceSid; + PathAssignedAddOnSid = pathAssignedAddOnSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionResource.cs index bfe3119f1..46f28b3d6 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOn/AssignedAddOnExtensionResource.cs @@ -18,303 +18,303 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber.AssignedAddOn -{ - - public class AssignedAddOnExtensionResource : Resource - { - private static Request BuildFetchRequest(FetchAssignedAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathAssignedAddOnSid + "/Extensions/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Extension for the Assigned Add-on. - /// - /// Fetch AssignedAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOnExtension - public static AssignedAddOnExtensionResource Fetch(FetchAssignedAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Assigned Add-on. - /// - /// Fetch AssignedAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(FetchAssignedAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Extension for the Assigned Add-on. - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AssignedAddOnExtension - public static AssignedAddOnExtensionResource Fetch(string pathResourceSid, - string pathAssignedAddOnSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Assigned Add-on. - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceSid, - string pathAssignedAddOnSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAssignedAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathAssignedAddOnSid + "/Extensions.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Extensions for the Assigned Add-on. - /// - /// Read AssignedAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOnExtension - public static ResourceSet Read(ReadAssignedAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Assigned Add-on. - /// - /// Read AssignedAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssignedAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Extensions for the Assigned Add-on. - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AssignedAddOnExtension - public static ResourceSet Read(string pathResourceSid, - string pathAssignedAddOnSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Assigned Add-on. - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// The SID that uniquely identifies the assigned Add-on installation - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceSid, - string pathAssignedAddOnSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Converts a JSON string into a AssignedAddOnExtensionResource object - /// - /// Raw JSON string - /// AssignedAddOnExtensionResource object represented by the provided JSON - public static AssignedAddOnExtensionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Phone Number to which the Add-on is assigned - /// - [JsonProperty("resource_sid")] - public string ResourceSid { get; private set; } - /// - /// The SID that uniquely identifies the assigned Add-on installation - /// - [JsonProperty("assigned_add_on_sid")] - public string AssignedAddOnSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A string that you assigned to describe the Product this Extension is used within - /// - [JsonProperty("product_name")] - public string ProductName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// Whether the Extension will be invoked - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - - private AssignedAddOnExtensionResource() - { - - } - } +{ + + public class AssignedAddOnExtensionResource : Resource + { + private static Request BuildFetchRequest(FetchAssignedAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathAssignedAddOnSid + "/Extensions/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Extension for the Assigned Add-on. + /// + /// Fetch AssignedAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOnExtension + public static AssignedAddOnExtensionResource Fetch(FetchAssignedAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Assigned Add-on. + /// + /// Fetch AssignedAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(FetchAssignedAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Extension for the Assigned Add-on. + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AssignedAddOnExtension + public static AssignedAddOnExtensionResource Fetch(string pathResourceSid, + string pathAssignedAddOnSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Assigned Add-on. + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceSid, + string pathAssignedAddOnSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAssignedAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathAssignedAddOnSid + "/Extensions.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Extensions for the Assigned Add-on. + /// + /// Read AssignedAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOnExtension + public static ResourceSet Read(ReadAssignedAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Assigned Add-on. + /// + /// Read AssignedAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssignedAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Extensions for the Assigned Add-on. + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AssignedAddOnExtension + public static ResourceSet Read(string pathResourceSid, + string pathAssignedAddOnSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Assigned Add-on. + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// The SID that uniquely identifies the assigned Add-on installation + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceSid, + string pathAssignedAddOnSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssignedAddOnExtensionOptions(pathResourceSid, pathAssignedAddOnSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Converts a JSON string into a AssignedAddOnExtensionResource object + /// + /// Raw JSON string + /// AssignedAddOnExtensionResource object represented by the provided JSON + public static AssignedAddOnExtensionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Phone Number to which the Add-on is assigned + /// + [JsonProperty("resource_sid")] + public string ResourceSid { get; private set; } + /// + /// The SID that uniquely identifies the assigned Add-on installation + /// + [JsonProperty("assigned_add_on_sid")] + public string AssignedAddOnSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A string that you assigned to describe the Product this Extension is used within + /// + [JsonProperty("product_name")] + public string ProductName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// Whether the Extension will be invoked + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + + private AssignedAddOnExtensionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnOptions.cs index 00aff5c50..3ed08ba0a 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnOptions.cs @@ -9,174 +9,174 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch an instance of an Add-on installation currently assigned to this Number. + /// + public class FetchAssignedAddOnOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch an instance of an Add-on installation currently assigned to this Number. - /// - public class FetchAssignedAddOnOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number that installed this Add-on - /// - public string PathResourceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssignedAddOnOptions - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - public FetchAssignedAddOnOptions(string pathResourceSid, string pathSid) - { - PathResourceSid = pathResourceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Add-on installations currently assigned to this Number. - /// - public class ReadAssignedAddOnOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number that installed this Add-on - /// - public string PathResourceSid { get; } - - /// - /// Construct a new ReadAssignedAddOnOptions - /// - /// The SID of the Phone Number that installed this Add-on - public ReadAssignedAddOnOptions(string pathResourceSid) - { - PathResourceSid = pathResourceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Phone Number that installed this Add-on + /// + public string PathResourceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Assign an Add-on installation to the Number specified. - /// - public class CreateAssignedAddOnOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number to assign the Add-on - /// - public string PathResourceSid { get; } - /// - /// The SID that identifies the Add-on installation - /// - public string InstalledAddOnSid { get; } - - /// - /// Construct a new CreateAssignedAddOnOptions - /// - /// The SID of the Phone Number to assign the Add-on - /// The SID that identifies the Add-on installation - public CreateAssignedAddOnOptions(string pathResourceSid, string installedAddOnSid) - { - PathResourceSid = pathResourceSid; - InstalledAddOnSid = installedAddOnSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (InstalledAddOnSid != null) - { - p.Add(new KeyValuePair("InstalledAddOnSid", InstalledAddOnSid.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Remove the assignment of an Add-on installation from the Number specified. - /// - public class DeleteAssignedAddOnOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Phone Number that installed this Add-on - /// - public string PathResourceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAssignedAddOnOptions - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - public DeleteAssignedAddOnOptions(string pathResourceSid, string pathSid) - { - PathResourceSid = pathResourceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchAssignedAddOnOptions + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + public FetchAssignedAddOnOptions(string pathResourceSid, string pathSid) + { + PathResourceSid = pathResourceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Add-on installations currently assigned to this Number. + /// + public class ReadAssignedAddOnOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Phone Number that installed this Add-on + /// + public string PathResourceSid { get; } + + /// + /// Construct a new ReadAssignedAddOnOptions + /// + /// The SID of the Phone Number that installed this Add-on + public ReadAssignedAddOnOptions(string pathResourceSid) + { + PathResourceSid = pathResourceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Assign an Add-on installation to the Number specified. + /// + public class CreateAssignedAddOnOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Phone Number to assign the Add-on + /// + public string PathResourceSid { get; } + /// + /// The SID that identifies the Add-on installation + /// + public string InstalledAddOnSid { get; } + + /// + /// Construct a new CreateAssignedAddOnOptions + /// + /// The SID of the Phone Number to assign the Add-on + /// The SID that identifies the Add-on installation + public CreateAssignedAddOnOptions(string pathResourceSid, string installedAddOnSid) + { + PathResourceSid = pathResourceSid; + InstalledAddOnSid = installedAddOnSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (InstalledAddOnSid != null) + { + p.Add(new KeyValuePair("InstalledAddOnSid", InstalledAddOnSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Remove the assignment of an Add-on installation from the Number specified. + /// + public class DeleteAssignedAddOnOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Phone Number that installed this Add-on + /// + public string PathResourceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAssignedAddOnOptions + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + public DeleteAssignedAddOnOptions(string pathResourceSid, string pathSid) + { + PathResourceSid = pathResourceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnResource.cs index c21cca29f..e6dbb7fad 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/AssignedAddOnResource.cs @@ -18,454 +18,454 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - - public class AssignedAddOnResource : Resource - { - private static Request BuildFetchRequest(FetchAssignedAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Add-on installation currently assigned to this Number. - /// - /// Fetch AssignedAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static AssignedAddOnResource Fetch(FetchAssignedAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on installation currently assigned to this Number. - /// - /// Fetch AssignedAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task FetchAsync(FetchAssignedAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Add-on installation currently assigned to this Number. - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static AssignedAddOnResource Fetch(string pathResourceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAssignedAddOnOptions(pathResourceSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on installation currently assigned to this Number. - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAssignedAddOnOptions(pathResourceSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAssignedAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Add-on installations currently assigned to this Number. - /// - /// Read AssignedAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static ResourceSet Read(ReadAssignedAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("assigned_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-on installations currently assigned to this Number. - /// - /// Read AssignedAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssignedAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("assigned_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Add-on installations currently assigned to this Number. - /// - /// The SID of the Phone Number that installed this Add-on - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static ResourceSet Read(string pathResourceSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssignedAddOnOptions(pathResourceSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-on installations currently assigned to this Number. - /// - /// The SID of the Phone Number that installed this Add-on - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssignedAddOnOptions(pathResourceSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("assigned_add_ons", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("assigned_add_ons", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("assigned_add_ons", response.Content); - } - - private static Request BuildCreateRequest(CreateAssignedAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Assign an Add-on installation to the Number specified. - /// - /// Create AssignedAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static AssignedAddOnResource Create(CreateAssignedAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Assign an Add-on installation to the Number specified. - /// - /// Create AssignedAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task CreateAsync(CreateAssignedAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Assign an Add-on installation to the Number specified. - /// - /// The SID of the Phone Number to assign the Add-on - /// The SID that identifies the Add-on installation - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static AssignedAddOnResource Create(string pathResourceSid, - string installedAddOnSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAssignedAddOnOptions(pathResourceSid, installedAddOnSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Assign an Add-on installation to the Number specified. - /// - /// The SID of the Phone Number to assign the Add-on - /// The SID that identifies the Add-on installation - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task CreateAsync(string pathResourceSid, - string installedAddOnSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAssignedAddOnOptions(pathResourceSid, installedAddOnSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAssignedAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove the assignment of an Add-on installation from the Number specified. - /// - /// Delete AssignedAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static bool Delete(DeleteAssignedAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove the assignment of an Add-on installation from the Number specified. - /// - /// Delete AssignedAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssignedAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove the assignment of an Add-on installation from the Number specified. - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of AssignedAddOn - public static bool Delete(string pathResourceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAssignedAddOnOptions(pathResourceSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove the assignment of an Add-on installation from the Number specified. - /// - /// The SID of the Phone Number that installed this Add-on - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssignedAddOn - public static async System.Threading.Tasks.Task DeleteAsync(string pathResourceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAssignedAddOnOptions(pathResourceSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssignedAddOnResource object - /// - /// Raw JSON string - /// AssignedAddOnResource object represented by the provided JSON - public static AssignedAddOnResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Phone Number that installed this Add-on - /// - [JsonProperty("resource_sid")] - public string ResourceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A short description of the Add-on functionality - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// A JSON string that represents the current configuration - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private AssignedAddOnResource() - { - - } - } +{ + + public class AssignedAddOnResource : Resource + { + private static Request BuildFetchRequest(FetchAssignedAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Add-on installation currently assigned to this Number. + /// + /// Fetch AssignedAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static AssignedAddOnResource Fetch(FetchAssignedAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on installation currently assigned to this Number. + /// + /// Fetch AssignedAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task FetchAsync(FetchAssignedAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Add-on installation currently assigned to this Number. + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static AssignedAddOnResource Fetch(string pathResourceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAssignedAddOnOptions(pathResourceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on installation currently assigned to this Number. + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAssignedAddOnOptions(pathResourceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAssignedAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Add-on installations currently assigned to this Number. + /// + /// Read AssignedAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static ResourceSet Read(ReadAssignedAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("assigned_add_ons", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-on installations currently assigned to this Number. + /// + /// Read AssignedAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssignedAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("assigned_add_ons", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Add-on installations currently assigned to this Number. + /// + /// The SID of the Phone Number that installed this Add-on + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static ResourceSet Read(string pathResourceSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssignedAddOnOptions(pathResourceSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-on installations currently assigned to this Number. + /// + /// The SID of the Phone Number that installed this Add-on + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssignedAddOnOptions(pathResourceSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("assigned_add_ons", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("assigned_add_ons", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("assigned_add_ons", response.Content); + } + + private static Request BuildCreateRequest(CreateAssignedAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Assign an Add-on installation to the Number specified. + /// + /// Create AssignedAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static AssignedAddOnResource Create(CreateAssignedAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Assign an Add-on installation to the Number specified. + /// + /// Create AssignedAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task CreateAsync(CreateAssignedAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Assign an Add-on installation to the Number specified. + /// + /// The SID of the Phone Number to assign the Add-on + /// The SID that identifies the Add-on installation + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static AssignedAddOnResource Create(string pathResourceSid, + string installedAddOnSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAssignedAddOnOptions(pathResourceSid, installedAddOnSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Assign an Add-on installation to the Number specified. + /// + /// The SID of the Phone Number to assign the Add-on + /// The SID that identifies the Add-on installation + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task CreateAsync(string pathResourceSid, + string installedAddOnSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAssignedAddOnOptions(pathResourceSid, installedAddOnSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAssignedAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathResourceSid + "/AssignedAddOns/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove the assignment of an Add-on installation from the Number specified. + /// + /// Delete AssignedAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static bool Delete(DeleteAssignedAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove the assignment of an Add-on installation from the Number specified. + /// + /// Delete AssignedAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssignedAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove the assignment of an Add-on installation from the Number specified. + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of AssignedAddOn + public static bool Delete(string pathResourceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAssignedAddOnOptions(pathResourceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove the assignment of an Add-on installation from the Number specified. + /// + /// The SID of the Phone Number that installed this Add-on + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssignedAddOn + public static async System.Threading.Tasks.Task DeleteAsync(string pathResourceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAssignedAddOnOptions(pathResourceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssignedAddOnResource object + /// + /// Raw JSON string + /// AssignedAddOnResource object represented by the provided JSON + public static AssignedAddOnResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Phone Number that installed this Add-on + /// + [JsonProperty("resource_sid")] + public string ResourceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A short description of the Add-on functionality + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// A JSON string that represents the current configuration + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private AssignedAddOnResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalOptions.cs index a6bab6200..9d81c99ce 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalOptions.cs @@ -9,303 +9,303 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - +{ + + /// + /// ReadLocalOptions + /// + public class ReadLocalOptions : ReadOptions + { /// - /// ReadLocalOptions - /// - public class ReadLocalOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Whether to include new phone numbers - /// - public bool? Beta { get; set; } - /// - /// A string that identifies the resources to read - /// - public string FriendlyName { get; set; } - /// - /// The phone numbers of the resources to read - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. - /// - public string Origin { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (Origin != null) - { - p.Add(new KeyValuePair("Origin", Origin)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } /// - /// CreateLocalOptions - /// - public class CreateLocalOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The phone number to purchase in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; } - /// - /// The API version to use for incoming calls made to the new phone number - /// - public string ApiVersion { get; set; } - /// - /// A string to describe the new phone number - /// - public string FriendlyName { get; set; } - /// - /// The SID of the application to handle SMS messages - /// - public string SmsApplicationSid { get; set; } - /// - /// The HTTP method we use to call status_callback - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the new phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The SID of the application to handle the new phone number - /// - public string VoiceApplicationSid { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we will call when an error occurs in TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The SID of the Identity resource to associate with the new phone number - /// - public string IdentitySid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string AddressSid { get; set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - public LocalResource.EmergencyStatusEnum EmergencyStatus { get; set; } - /// - /// The emergency address configuration to use for emergency calling - /// - public string EmergencyAddressSid { get; set; } - /// - /// SID of the trunk to handle calls to the new phone number - /// - public string TrunkSid { get; set; } - /// - /// Incoming call type: fax or voice - /// - public LocalResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } - /// - /// The SID of the Bundle resource associated with number - /// - public string BundleSid { get; set; } - - /// - /// Construct a new CreateLocalOptions - /// - /// The phone number to purchase in E.164 format - public CreateLocalOptions(Types.PhoneNumber phoneNumber) - { - PhoneNumber = phoneNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceApplicationSid != null) - { - p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (IdentitySid != null) - { - p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (EmergencyStatus != null) - { - p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); - } - - if (EmergencyAddressSid != null) - { - p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); - } - - if (TrunkSid != null) - { - p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); - } - - if (VoiceReceiveMode != null) - { - p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); - } - - if (BundleSid != null) - { - p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); - } - - return p; - } - } + /// Whether to include new phone numbers + /// + public bool? Beta { get; set; } + /// + /// A string that identifies the resources to read + /// + public string FriendlyName { get; set; } + /// + /// The phone numbers of the resources to read + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. + /// + public string Origin { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (Origin != null) + { + p.Add(new KeyValuePair("Origin", Origin)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateLocalOptions + /// + public class CreateLocalOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The phone number to purchase in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; } + /// + /// The API version to use for incoming calls made to the new phone number + /// + public string ApiVersion { get; set; } + /// + /// A string to describe the new phone number + /// + public string FriendlyName { get; set; } + /// + /// The SID of the application to handle SMS messages + /// + public string SmsApplicationSid { get; set; } + /// + /// The HTTP method we use to call status_callback + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the new phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The SID of the application to handle the new phone number + /// + public string VoiceApplicationSid { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we will call when an error occurs in TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The SID of the Identity resource to associate with the new phone number + /// + public string IdentitySid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string AddressSid { get; set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + public LocalResource.EmergencyStatusEnum EmergencyStatus { get; set; } + /// + /// The emergency address configuration to use for emergency calling + /// + public string EmergencyAddressSid { get; set; } + /// + /// SID of the trunk to handle calls to the new phone number + /// + public string TrunkSid { get; set; } + /// + /// Incoming call type: fax or voice + /// + public LocalResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } + /// + /// The SID of the Bundle resource associated with number + /// + public string BundleSid { get; set; } + + /// + /// Construct a new CreateLocalOptions + /// + /// The phone number to purchase in E.164 format + public CreateLocalOptions(Types.PhoneNumber phoneNumber) + { + PhoneNumber = phoneNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceApplicationSid != null) + { + p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (IdentitySid != null) + { + p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (EmergencyStatus != null) + { + p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); + } + + if (EmergencyAddressSid != null) + { + p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); + } + + if (TrunkSid != null) + { + p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); + } + + if (VoiceReceiveMode != null) + { + p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); + } + + if (BundleSid != null) + { + p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalResource.cs index c26a801f6..33e1069d0 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/LocalResource.cs @@ -17,582 +17,582 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - - public class LocalResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - public sealed class EmergencyStatusEnum : StringEnum - { - private EmergencyStatusEnum(string value) : base(value) {} - public EmergencyStatusEnum() {} - public static implicit operator EmergencyStatusEnum(string value) - { - return new EmergencyStatusEnum(value); - } - - public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); - public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); - } - - public sealed class EmergencyAddressStatusEnum : StringEnum - { - private EmergencyAddressStatusEnum(string value) : base(value) {} - public EmergencyAddressStatusEnum() {} - public static implicit operator EmergencyAddressStatusEnum(string value) - { - return new EmergencyAddressStatusEnum(value); - } - - public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); - public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); - public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); - public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); - public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); - public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); - } - - public sealed class VoiceReceiveModeEnum : StringEnum - { - private VoiceReceiveModeEnum(string value) : base(value) {} - public VoiceReceiveModeEnum() {} - public static implicit operator VoiceReceiveModeEnum(string value) - { - return new VoiceReceiveModeEnum(value); - } - - public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); - public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); - } - - private static Request BuildReadRequest(ReadLocalOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Local.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Local parameters - /// Client to make requests to Twilio - /// A single instance of Local - public static ResourceSet Read(ReadLocalOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Local parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task> ReadAsync(ReadLocalOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Local - public static ResourceSet Read(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLocalOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLocalOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - private static Request BuildCreateRequest(CreateLocalOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Local.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Local parameters - /// Client to make requests to Twilio - /// A single instance of Local - public static LocalResource Create(CreateLocalOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Local parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task CreateAsync(CreateLocalOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// The HTTP method we use to call status_callback - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// A single instance of Local - public static LocalResource Create(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - LocalResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - LocalResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateLocalOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// The HTTP method we use to call status_callback - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Local - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - LocalResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - LocalResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateLocalOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a LocalResource object - /// - /// Raw JSON string - /// LocalResource object represented by the provided JSON - public static LocalResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Address resource associated with the phone number - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio. - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public LocalResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Identity resource associated with number - /// - [JsonProperty("identity_sid")] - public string IdentitySid { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The phone number's origin. Can be twilio or hosted. - /// - [JsonProperty("origin")] - public string Origin { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Application resource to handle SMS messages - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The voice_receive_mode - /// - [JsonProperty("voice_receive_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public LocalResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when this phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - [JsonProperty("emergency_status")] - [JsonConverter(typeof(StringEnumConverter))] - public LocalResource.EmergencyStatusEnum EmergencyStatus { get; private set; } - /// - /// The emergency address configuration to use for emergency calling - /// - [JsonProperty("emergency_address_sid")] - public string EmergencyAddressSid { get; private set; } - /// - /// State of the emergency address configuration for the phone number - /// - [JsonProperty("emergency_address_status")] - [JsonConverter(typeof(StringEnumConverter))] - public LocalResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } - /// - /// The SID of the Bundle resource associated with number - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - - private LocalResource() - { - - } - } +{ + + public class LocalResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + public sealed class EmergencyStatusEnum : StringEnum + { + private EmergencyStatusEnum(string value) : base(value) { } + public EmergencyStatusEnum() { } + public static implicit operator EmergencyStatusEnum(string value) + { + return new EmergencyStatusEnum(value); + } + + public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); + public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); + } + + public sealed class EmergencyAddressStatusEnum : StringEnum + { + private EmergencyAddressStatusEnum(string value) : base(value) { } + public EmergencyAddressStatusEnum() { } + public static implicit operator EmergencyAddressStatusEnum(string value) + { + return new EmergencyAddressStatusEnum(value); + } + + public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); + public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); + public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); + public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); + public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); + public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); + } + + public sealed class VoiceReceiveModeEnum : StringEnum + { + private VoiceReceiveModeEnum(string value) : base(value) { } + public VoiceReceiveModeEnum() { } + public static implicit operator VoiceReceiveModeEnum(string value) + { + return new VoiceReceiveModeEnum(value); + } + + public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); + public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); + } + + private static Request BuildReadRequest(ReadLocalOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Local.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Local parameters + /// Client to make requests to Twilio + /// A single instance of Local + public static ResourceSet Read(ReadLocalOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Local parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task> ReadAsync(ReadLocalOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Local + public static ResourceSet Read(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLocalOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLocalOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + private static Request BuildCreateRequest(CreateLocalOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Local.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Local parameters + /// Client to make requests to Twilio + /// A single instance of Local + public static LocalResource Create(CreateLocalOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Local parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task CreateAsync(CreateLocalOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// The HTTP method we use to call status_callback + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// A single instance of Local + public static LocalResource Create(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + LocalResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + LocalResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateLocalOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// The HTTP method we use to call status_callback + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Local + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + LocalResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + LocalResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateLocalOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a LocalResource object + /// + /// Raw JSON string + /// LocalResource object represented by the provided JSON + public static LocalResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Address resource associated with the phone number + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio. + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public LocalResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Identity resource associated with number + /// + [JsonProperty("identity_sid")] + public string IdentitySid { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The phone number's origin. Can be twilio or hosted. + /// + [JsonProperty("origin")] + public string Origin { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Application resource to handle SMS messages + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The voice_receive_mode + /// + [JsonProperty("voice_receive_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public LocalResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when this phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + [JsonProperty("emergency_status")] + [JsonConverter(typeof(StringEnumConverter))] + public LocalResource.EmergencyStatusEnum EmergencyStatus { get; private set; } + /// + /// The emergency address configuration to use for emergency calling + /// + [JsonProperty("emergency_address_sid")] + public string EmergencyAddressSid { get; private set; } + /// + /// State of the emergency address configuration for the phone number + /// + [JsonProperty("emergency_address_status")] + [JsonConverter(typeof(StringEnumConverter))] + public LocalResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } + /// + /// The SID of the Bundle resource associated with number + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + + private LocalResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileOptions.cs index d71764b45..b1cdc7654 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileOptions.cs @@ -9,303 +9,303 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - +{ + + /// + /// ReadMobileOptions + /// + public class ReadMobileOptions : ReadOptions + { /// - /// ReadMobileOptions - /// - public class ReadMobileOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Whether to include new phone numbers - /// - public bool? Beta { get; set; } - /// - /// A string that identifies the resources to read - /// - public string FriendlyName { get; set; } - /// - /// The phone numbers of the resources to read - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. - /// - public string Origin { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (Origin != null) - { - p.Add(new KeyValuePair("Origin", Origin)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } /// - /// CreateMobileOptions - /// - public class CreateMobileOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The phone number to purchase in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; } - /// - /// The API version to use for incoming calls made to the new phone number - /// - public string ApiVersion { get; set; } - /// - /// A string to describe the new phone number - /// - public string FriendlyName { get; set; } - /// - /// The SID of the application to handle SMS messages - /// - public string SmsApplicationSid { get; set; } - /// - /// HTTP method used with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the new phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The SID of the application to handle the new phone number - /// - public string VoiceApplicationSid { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we will call when an error occurs in TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The SID of the Identity resource to associate with the new phone number - /// - public string IdentitySid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string AddressSid { get; set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - public MobileResource.EmergencyStatusEnum EmergencyStatus { get; set; } - /// - /// The emergency address configuration to use for emergency calling - /// - public string EmergencyAddressSid { get; set; } - /// - /// SID of the trunk to handle calls to the new phone number - /// - public string TrunkSid { get; set; } - /// - /// Incoming call type: fax or voice - /// - public MobileResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } - /// - /// The SID of the Bundle resource associated with number - /// - public string BundleSid { get; set; } - - /// - /// Construct a new CreateMobileOptions - /// - /// The phone number to purchase in E.164 format - public CreateMobileOptions(Types.PhoneNumber phoneNumber) - { - PhoneNumber = phoneNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceApplicationSid != null) - { - p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (IdentitySid != null) - { - p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (EmergencyStatus != null) - { - p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); - } - - if (EmergencyAddressSid != null) - { - p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); - } - - if (TrunkSid != null) - { - p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); - } - - if (VoiceReceiveMode != null) - { - p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); - } - - if (BundleSid != null) - { - p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); - } - - return p; - } - } + /// Whether to include new phone numbers + /// + public bool? Beta { get; set; } + /// + /// A string that identifies the resources to read + /// + public string FriendlyName { get; set; } + /// + /// The phone numbers of the resources to read + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. + /// + public string Origin { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (Origin != null) + { + p.Add(new KeyValuePair("Origin", Origin)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateMobileOptions + /// + public class CreateMobileOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The phone number to purchase in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; } + /// + /// The API version to use for incoming calls made to the new phone number + /// + public string ApiVersion { get; set; } + /// + /// A string to describe the new phone number + /// + public string FriendlyName { get; set; } + /// + /// The SID of the application to handle SMS messages + /// + public string SmsApplicationSid { get; set; } + /// + /// HTTP method used with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the new phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The SID of the application to handle the new phone number + /// + public string VoiceApplicationSid { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we will call when an error occurs in TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The SID of the Identity resource to associate with the new phone number + /// + public string IdentitySid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string AddressSid { get; set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + public MobileResource.EmergencyStatusEnum EmergencyStatus { get; set; } + /// + /// The emergency address configuration to use for emergency calling + /// + public string EmergencyAddressSid { get; set; } + /// + /// SID of the trunk to handle calls to the new phone number + /// + public string TrunkSid { get; set; } + /// + /// Incoming call type: fax or voice + /// + public MobileResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } + /// + /// The SID of the Bundle resource associated with number + /// + public string BundleSid { get; set; } + + /// + /// Construct a new CreateMobileOptions + /// + /// The phone number to purchase in E.164 format + public CreateMobileOptions(Types.PhoneNumber phoneNumber) + { + PhoneNumber = phoneNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceApplicationSid != null) + { + p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (IdentitySid != null) + { + p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (EmergencyStatus != null) + { + p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); + } + + if (EmergencyAddressSid != null) + { + p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); + } + + if (TrunkSid != null) + { + p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); + } + + if (VoiceReceiveMode != null) + { + p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); + } + + if (BundleSid != null) + { + p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileResource.cs index ace42a1b9..17e12a599 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/MobileResource.cs @@ -17,582 +17,582 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - - public class MobileResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - public sealed class EmergencyStatusEnum : StringEnum - { - private EmergencyStatusEnum(string value) : base(value) {} - public EmergencyStatusEnum() {} - public static implicit operator EmergencyStatusEnum(string value) - { - return new EmergencyStatusEnum(value); - } - - public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); - public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); - } - - public sealed class EmergencyAddressStatusEnum : StringEnum - { - private EmergencyAddressStatusEnum(string value) : base(value) {} - public EmergencyAddressStatusEnum() {} - public static implicit operator EmergencyAddressStatusEnum(string value) - { - return new EmergencyAddressStatusEnum(value); - } - - public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); - public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); - public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); - public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); - public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); - public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); - } - - public sealed class VoiceReceiveModeEnum : StringEnum - { - private VoiceReceiveModeEnum(string value) : base(value) {} - public VoiceReceiveModeEnum() {} - public static implicit operator VoiceReceiveModeEnum(string value) - { - return new VoiceReceiveModeEnum(value); - } - - public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); - public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); - } - - private static Request BuildReadRequest(ReadMobileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Mobile.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Mobile parameters - /// Client to make requests to Twilio - /// A single instance of Mobile - public static ResourceSet Read(ReadMobileOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Mobile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task> ReadAsync(ReadMobileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Mobile - public static ResourceSet Read(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMobileOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMobileOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - private static Request BuildCreateRequest(CreateMobileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Mobile.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Mobile parameters - /// Client to make requests to Twilio - /// A single instance of Mobile - public static MobileResource Create(CreateMobileOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Mobile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task CreateAsync(CreateMobileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// A single instance of Mobile - public static MobileResource Create(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - MobileResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - MobileResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMobileOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Mobile - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - MobileResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - MobileResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMobileOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MobileResource object - /// - /// Raw JSON string - /// MobileResource object represented by the provided JSON - public static MobileResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Address resource associated with the phone number - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio. - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public MobileResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Identity resource associated with number - /// - [JsonProperty("identity_sid")] - public string IdentitySid { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The phone number's origin. Can be twilio or hosted. - /// - [JsonProperty("origin")] - public string Origin { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the application that handles SMS messages sent to the phone number - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The voice_receive_mode - /// - [JsonProperty("voice_receive_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public MobileResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - [JsonProperty("emergency_status")] - [JsonConverter(typeof(StringEnumConverter))] - public MobileResource.EmergencyStatusEnum EmergencyStatus { get; private set; } - /// - /// The emergency address configuration to use for emergency calling - /// - [JsonProperty("emergency_address_sid")] - public string EmergencyAddressSid { get; private set; } - /// - /// State of the emergency address configuration for the phone number - /// - [JsonProperty("emergency_address_status")] - [JsonConverter(typeof(StringEnumConverter))] - public MobileResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } - /// - /// The SID of the Bundle resource associated with number - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - - private MobileResource() - { - - } - } +{ + + public class MobileResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + public sealed class EmergencyStatusEnum : StringEnum + { + private EmergencyStatusEnum(string value) : base(value) { } + public EmergencyStatusEnum() { } + public static implicit operator EmergencyStatusEnum(string value) + { + return new EmergencyStatusEnum(value); + } + + public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); + public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); + } + + public sealed class EmergencyAddressStatusEnum : StringEnum + { + private EmergencyAddressStatusEnum(string value) : base(value) { } + public EmergencyAddressStatusEnum() { } + public static implicit operator EmergencyAddressStatusEnum(string value) + { + return new EmergencyAddressStatusEnum(value); + } + + public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); + public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); + public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); + public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); + public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); + public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); + } + + public sealed class VoiceReceiveModeEnum : StringEnum + { + private VoiceReceiveModeEnum(string value) : base(value) { } + public VoiceReceiveModeEnum() { } + public static implicit operator VoiceReceiveModeEnum(string value) + { + return new VoiceReceiveModeEnum(value); + } + + public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); + public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); + } + + private static Request BuildReadRequest(ReadMobileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Mobile.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Mobile parameters + /// Client to make requests to Twilio + /// A single instance of Mobile + public static ResourceSet Read(ReadMobileOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Mobile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task> ReadAsync(ReadMobileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Mobile + public static ResourceSet Read(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMobileOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMobileOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + private static Request BuildCreateRequest(CreateMobileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/Mobile.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Mobile parameters + /// Client to make requests to Twilio + /// A single instance of Mobile + public static MobileResource Create(CreateMobileOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Mobile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task CreateAsync(CreateMobileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// A single instance of Mobile + public static MobileResource Create(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + MobileResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + MobileResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMobileOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Mobile + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + MobileResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + MobileResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMobileOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MobileResource object + /// + /// Raw JSON string + /// MobileResource object represented by the provided JSON + public static MobileResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Address resource associated with the phone number + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio. + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public MobileResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Identity resource associated with number + /// + [JsonProperty("identity_sid")] + public string IdentitySid { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The phone number's origin. Can be twilio or hosted. + /// + [JsonProperty("origin")] + public string Origin { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the application that handles SMS messages sent to the phone number + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The voice_receive_mode + /// + [JsonProperty("voice_receive_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public MobileResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + [JsonProperty("emergency_status")] + [JsonConverter(typeof(StringEnumConverter))] + public MobileResource.EmergencyStatusEnum EmergencyStatus { get; private set; } + /// + /// The emergency address configuration to use for emergency calling + /// + [JsonProperty("emergency_address_sid")] + public string EmergencyAddressSid { get; private set; } + /// + /// State of the emergency address configuration for the phone number + /// + [JsonProperty("emergency_address_status")] + [JsonConverter(typeof(StringEnumConverter))] + public MobileResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } + /// + /// The SID of the Bundle resource associated with number + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + + private MobileResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeOptions.cs index 226e8dd12..c093015e3 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeOptions.cs @@ -9,303 +9,303 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - +{ + + /// + /// ReadTollFreeOptions + /// + public class ReadTollFreeOptions : ReadOptions + { /// - /// ReadTollFreeOptions - /// - public class ReadTollFreeOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Whether to include new phone numbers - /// - public bool? Beta { get; set; } - /// - /// A string that identifies the resources to read - /// - public string FriendlyName { get; set; } - /// - /// The phone numbers of the resources to read - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. - /// - public string Origin { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (Origin != null) - { - p.Add(new KeyValuePair("Origin", Origin)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } /// - /// CreateTollFreeOptions - /// - public class CreateTollFreeOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The phone number to purchase in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; } - /// - /// The API version to use for incoming calls made to the new phone number - /// - public string ApiVersion { get; set; } - /// - /// A string to describe the new phone number - /// - public string FriendlyName { get; set; } - /// - /// The SID of the application to handle SMS messages - /// - public string SmsApplicationSid { get; set; } - /// - /// HTTP method used with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms_url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the new phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The URL to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The SID of the application to handle the new phone number - /// - public string VoiceApplicationSid { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we will call when an error occurs in TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The SID of the Identity resource to associate with the new phone number - /// - public string IdentitySid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string AddressSid { get; set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - public TollFreeResource.EmergencyStatusEnum EmergencyStatus { get; set; } - /// - /// The emergency address configuration to use for emergency calling - /// - public string EmergencyAddressSid { get; set; } - /// - /// SID of the trunk to handle calls to the new phone number - /// - public string TrunkSid { get; set; } - /// - /// Incoming call type: fax or voice - /// - public TollFreeResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } - /// - /// The SID of the Bundle resource associated with number - /// - public string BundleSid { get; set; } - - /// - /// Construct a new CreateTollFreeOptions - /// - /// The phone number to purchase in E.164 format - public CreateTollFreeOptions(Types.PhoneNumber phoneNumber) - { - PhoneNumber = phoneNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceApplicationSid != null) - { - p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (IdentitySid != null) - { - p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (EmergencyStatus != null) - { - p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); - } - - if (EmergencyAddressSid != null) - { - p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); - } - - if (TrunkSid != null) - { - p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); - } - - if (VoiceReceiveMode != null) - { - p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); - } - - if (BundleSid != null) - { - p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); - } - - return p; - } - } + /// Whether to include new phone numbers + /// + public bool? Beta { get; set; } + /// + /// A string that identifies the resources to read + /// + public string FriendlyName { get; set; } + /// + /// The phone numbers of the resources to read + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. + /// + public string Origin { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (Origin != null) + { + p.Add(new KeyValuePair("Origin", Origin)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateTollFreeOptions + /// + public class CreateTollFreeOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The phone number to purchase in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; } + /// + /// The API version to use for incoming calls made to the new phone number + /// + public string ApiVersion { get; set; } + /// + /// A string to describe the new phone number + /// + public string FriendlyName { get; set; } + /// + /// The SID of the application to handle SMS messages + /// + public string SmsApplicationSid { get; set; } + /// + /// HTTP method used with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms_url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the new phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The URL to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The SID of the application to handle the new phone number + /// + public string VoiceApplicationSid { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we will call when an error occurs in TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The SID of the Identity resource to associate with the new phone number + /// + public string IdentitySid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string AddressSid { get; set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + public TollFreeResource.EmergencyStatusEnum EmergencyStatus { get; set; } + /// + /// The emergency address configuration to use for emergency calling + /// + public string EmergencyAddressSid { get; set; } + /// + /// SID of the trunk to handle calls to the new phone number + /// + public string TrunkSid { get; set; } + /// + /// Incoming call type: fax or voice + /// + public TollFreeResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } + /// + /// The SID of the Bundle resource associated with number + /// + public string BundleSid { get; set; } + + /// + /// Construct a new CreateTollFreeOptions + /// + /// The phone number to purchase in E.164 format + public CreateTollFreeOptions(Types.PhoneNumber phoneNumber) + { + PhoneNumber = phoneNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceApplicationSid != null) + { + p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (IdentitySid != null) + { + p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (EmergencyStatus != null) + { + p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); + } + + if (EmergencyAddressSid != null) + { + p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); + } + + if (TrunkSid != null) + { + p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); + } + + if (VoiceReceiveMode != null) + { + p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); + } + + if (BundleSid != null) + { + p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeResource.cs index c08d4cda7..3914804ae 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumber/TollFreeResource.cs @@ -17,582 +17,582 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.IncomingPhoneNumber -{ - - public class TollFreeResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - public sealed class EmergencyStatusEnum : StringEnum - { - private EmergencyStatusEnum(string value) : base(value) {} - public EmergencyStatusEnum() {} - public static implicit operator EmergencyStatusEnum(string value) - { - return new EmergencyStatusEnum(value); - } - - public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); - public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); - } - - public sealed class EmergencyAddressStatusEnum : StringEnum - { - private EmergencyAddressStatusEnum(string value) : base(value) {} - public EmergencyAddressStatusEnum() {} - public static implicit operator EmergencyAddressStatusEnum(string value) - { - return new EmergencyAddressStatusEnum(value); - } - - public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); - public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); - public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); - public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); - public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); - public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); - } - - public sealed class VoiceReceiveModeEnum : StringEnum - { - private VoiceReceiveModeEnum(string value) : base(value) {} - public VoiceReceiveModeEnum() {} - public static implicit operator VoiceReceiveModeEnum(string value) - { - return new VoiceReceiveModeEnum(value); - } - - public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); - public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); - } - - private static Request BuildReadRequest(ReadTollFreeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/TollFree.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read TollFree parameters - /// Client to make requests to Twilio - /// A single instance of TollFree - public static ResourceSet Read(ReadTollFreeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read TollFree parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task> ReadAsync(ReadTollFreeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TollFree - public static ResourceSet Read(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTollFreeOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the resources to read - /// The phone numbers of the resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTollFreeOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - private static Request BuildCreateRequest(CreateTollFreeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/TollFree.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create TollFree parameters - /// Client to make requests to Twilio - /// A single instance of TollFree - public static TollFreeResource Create(CreateTollFreeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create TollFree parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task CreateAsync(CreateTollFreeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms_url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// A single instance of TollFree - public static TollFreeResource Create(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - TollFreeResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - TollFreeResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateTollFreeOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The phone number to purchase in E.164 format - /// The SID of the Account that will create the resource - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms_url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TollFree - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - string identitySid = null, - string addressSid = null, - TollFreeResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - TollFreeResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateTollFreeOptions(phoneNumber){PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TollFreeResource object - /// - /// Raw JSON string - /// TollFreeResource object represented by the provided JSON - public static TollFreeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Address resource associated with the phone number - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio. - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public TollFreeResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Identity resource associated with number - /// - [JsonProperty("identity_sid")] - public string IdentitySid { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The phone number's origin. Can be twilio or hosted. - /// - [JsonProperty("origin")] - public string Origin { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the application that handles SMS messages sent to the phone number - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The voice_receive_mode - /// - [JsonProperty("voice_receive_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public TollFreeResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - [JsonProperty("emergency_status")] - [JsonConverter(typeof(StringEnumConverter))] - public TollFreeResource.EmergencyStatusEnum EmergencyStatus { get; private set; } - /// - /// The emergency address configuration to use for emergency calling - /// - [JsonProperty("emergency_address_sid")] - public string EmergencyAddressSid { get; private set; } - /// - /// State of the emergency address configuration for the phone number - /// - [JsonProperty("emergency_address_status")] - [JsonConverter(typeof(StringEnumConverter))] - public TollFreeResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } - /// - /// The SID of the Bundle resource associated with number - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - - private TollFreeResource() - { - - } - } +{ + + public class TollFreeResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + public sealed class EmergencyStatusEnum : StringEnum + { + private EmergencyStatusEnum(string value) : base(value) { } + public EmergencyStatusEnum() { } + public static implicit operator EmergencyStatusEnum(string value) + { + return new EmergencyStatusEnum(value); + } + + public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); + public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); + } + + public sealed class EmergencyAddressStatusEnum : StringEnum + { + private EmergencyAddressStatusEnum(string value) : base(value) { } + public EmergencyAddressStatusEnum() { } + public static implicit operator EmergencyAddressStatusEnum(string value) + { + return new EmergencyAddressStatusEnum(value); + } + + public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); + public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); + public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); + public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); + public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); + public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); + } + + public sealed class VoiceReceiveModeEnum : StringEnum + { + private VoiceReceiveModeEnum(string value) : base(value) { } + public VoiceReceiveModeEnum() { } + public static implicit operator VoiceReceiveModeEnum(string value) + { + return new VoiceReceiveModeEnum(value); + } + + public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); + public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); + } + + private static Request BuildReadRequest(ReadTollFreeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/TollFree.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read TollFree parameters + /// Client to make requests to Twilio + /// A single instance of TollFree + public static ResourceSet Read(ReadTollFreeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read TollFree parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task> ReadAsync(ReadTollFreeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TollFree + public static ResourceSet Read(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTollFreeOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the resources to read + /// The phone numbers of the resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTollFreeOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + private static Request BuildCreateRequest(CreateTollFreeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/TollFree.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create TollFree parameters + /// Client to make requests to Twilio + /// A single instance of TollFree + public static TollFreeResource Create(CreateTollFreeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create TollFree parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task CreateAsync(CreateTollFreeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms_url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// A single instance of TollFree + public static TollFreeResource Create(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + TollFreeResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + TollFreeResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateTollFreeOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The phone number to purchase in E.164 format + /// The SID of the Account that will create the resource + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms_url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TollFree + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + string identitySid = null, + string addressSid = null, + TollFreeResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + TollFreeResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateTollFreeOptions(phoneNumber) { PathAccountSid = pathAccountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, IdentitySid = identitySid, AddressSid = addressSid, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TollFreeResource object + /// + /// Raw JSON string + /// TollFreeResource object represented by the provided JSON + public static TollFreeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Address resource associated with the phone number + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio. + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public TollFreeResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Identity resource associated with number + /// + [JsonProperty("identity_sid")] + public string IdentitySid { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The phone number's origin. Can be twilio or hosted. + /// + [JsonProperty("origin")] + public string Origin { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the application that handles SMS messages sent to the phone number + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The voice_receive_mode + /// + [JsonProperty("voice_receive_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public TollFreeResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + [JsonProperty("emergency_status")] + [JsonConverter(typeof(StringEnumConverter))] + public TollFreeResource.EmergencyStatusEnum EmergencyStatus { get; private set; } + /// + /// The emergency address configuration to use for emergency calling + /// + [JsonProperty("emergency_address_sid")] + public string EmergencyAddressSid { get; private set; } + /// + /// State of the emergency address configuration for the phone number + /// + [JsonProperty("emergency_address_status")] + [JsonConverter(typeof(StringEnumConverter))] + public TollFreeResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } + /// + /// The SID of the Bundle resource associated with number + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + + private TollFreeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberOptions.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberOptions.cs index 9c8bf2874..43c23bfc1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberOptions.cs @@ -9,609 +9,609 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Update an incoming-phone-number instance. + /// + public class UpdateIncomingPhoneNumberOptions : IOptions + { /// - /// Update an incoming-phone-number instance. - /// - public class UpdateIncomingPhoneNumberOptions : IOptions - { - /// - /// The SID of the Account that created the resource to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The SID of the Account that created the resource to update - /// - public string AccountSid { get; set; } - /// - /// The API version to use for incoming calls made to the phone number - /// - public string ApiVersion { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// Unique string that identifies the application - /// - public string SmsApplicationSid { get; set; } - /// - /// HTTP method used with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms_url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The SID of the application to handle the phone number - /// - public string VoiceApplicationSid { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The HTTP method used with fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we will call when an error occurs in TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; set; } - /// - /// The emergency address configuration to use for emergency calling - /// - public string EmergencyAddressSid { get; set; } - /// - /// SID of the trunk to handle phone calls to the phone number - /// - public string TrunkSid { get; set; } - /// - /// Incoming call type: fax or voice - /// - public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } - /// - /// Unique string that identifies the identity associated with number - /// - public string IdentitySid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string AddressSid { get; set; } - /// - /// The SID of the Bundle resource associated with number - /// - public string BundleSid { get; set; } - - /// - /// Construct a new UpdateIncomingPhoneNumberOptions - /// - /// The unique string that identifies the resource - public UpdateIncomingPhoneNumberOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceApplicationSid != null) - { - p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (EmergencyStatus != null) - { - p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); - } - - if (EmergencyAddressSid != null) - { - p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); - } - - if (TrunkSid != null) - { - p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); - } - - if (VoiceReceiveMode != null) - { - p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); - } - - if (IdentitySid != null) - { - p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (BundleSid != null) - { - p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); - } - - return p; - } - } - + /// The SID of the Account that created the resource to update + /// + public string PathAccountSid { get; set; } /// - /// Fetch an incoming-phone-number belonging to the account used to make the request. - /// - public class FetchIncomingPhoneNumberOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIncomingPhoneNumberOptions - /// - /// The unique string that identifies the resource - public FetchIncomingPhoneNumberOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } /// - /// Delete a phone-numbers belonging to the account used to make the request. - /// - public class DeleteIncomingPhoneNumberOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIncomingPhoneNumberOptions - /// - /// The unique string that identifies the resource - public DeleteIncomingPhoneNumberOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to update + /// + public string AccountSid { get; set; } /// - /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. - /// - public class ReadIncomingPhoneNumberOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Whether to include new phone numbers - /// - public bool? Beta { get; set; } - /// - /// A string that identifies the IncomingPhoneNumber resources to read - /// - public string FriendlyName { get; set; } - /// - /// The phone numbers of the IncomingPhoneNumber resources to read - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. - /// - public string Origin { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Beta != null) - { - p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (Origin != null) - { - p.Add(new KeyValuePair("Origin", Origin)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The API version to use for incoming calls made to the phone number + /// + public string ApiVersion { get; set; } /// - /// Purchase a phone-number for the account. - /// - public class CreateIncomingPhoneNumberOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The phone number to purchase in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// The desired area code for the new phone number - /// - public string AreaCode { get; set; } - /// - /// The API version to use for incoming calls made to the new phone number - /// - public string ApiVersion { get; set; } - /// - /// A string to describe the new phone number - /// - public string FriendlyName { get; set; } - /// - /// The SID of the application to handle SMS messages - /// - public string SmsApplicationSid { get; set; } - /// - /// HTTP method used with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method to use with sms url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the new phone number receives an incoming SMS message - /// - public Uri SmsUrl { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The SID of the application to handle the new phone number - /// - public string VoiceApplicationSid { get; set; } - /// - /// Whether to lookup the caller's name - /// - public bool? VoiceCallerIdLookup { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we will call when an error occurs in TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with the voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when the phone number receives a call - /// - public Uri VoiceUrl { get; set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; set; } - /// - /// The emergency address configuration to use for emergency calling - /// - public string EmergencyAddressSid { get; set; } - /// - /// SID of the trunk to handle calls to the new phone number - /// - public string TrunkSid { get; set; } - /// - /// The SID of the Identity resource to associate with the new phone number - /// - public string IdentitySid { get; set; } - /// - /// The SID of the Address resource associated with the phone number - /// - public string AddressSid { get; set; } - /// - /// Incoming call type: fax or voice - /// - public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } - /// - /// The SID of the Bundle resource associated with number - /// - public string BundleSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (AreaCode != null) - { - p.Add(new KeyValuePair("AreaCode", AreaCode)); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (VoiceApplicationSid != null) - { - p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); - } - - if (VoiceCallerIdLookup != null) - { - p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (EmergencyStatus != null) - { - p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); - } - - if (EmergencyAddressSid != null) - { - p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); - } - - if (TrunkSid != null) - { - p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); - } - - if (IdentitySid != null) - { - p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (VoiceReceiveMode != null) - { - p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); - } - - if (BundleSid != null) - { - p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); - } - - return p; - } - } + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// Unique string that identifies the application + /// + public string SmsApplicationSid { get; set; } + /// + /// HTTP method used with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms_url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The SID of the application to handle the phone number + /// + public string VoiceApplicationSid { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The HTTP method used with fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we will call when an error occurs in TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; set; } + /// + /// The emergency address configuration to use for emergency calling + /// + public string EmergencyAddressSid { get; set; } + /// + /// SID of the trunk to handle phone calls to the phone number + /// + public string TrunkSid { get; set; } + /// + /// Incoming call type: fax or voice + /// + public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } + /// + /// Unique string that identifies the identity associated with number + /// + public string IdentitySid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string AddressSid { get; set; } + /// + /// The SID of the Bundle resource associated with number + /// + public string BundleSid { get; set; } + + /// + /// Construct a new UpdateIncomingPhoneNumberOptions + /// + /// The unique string that identifies the resource + public UpdateIncomingPhoneNumberOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceApplicationSid != null) + { + p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (EmergencyStatus != null) + { + p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); + } + + if (EmergencyAddressSid != null) + { + p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); + } + + if (TrunkSid != null) + { + p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); + } + + if (VoiceReceiveMode != null) + { + p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); + } + + if (IdentitySid != null) + { + p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (BundleSid != null) + { + p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch an incoming-phone-number belonging to the account used to make the request. + /// + public class FetchIncomingPhoneNumberOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchIncomingPhoneNumberOptions + /// + /// The unique string that identifies the resource + public FetchIncomingPhoneNumberOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a phone-numbers belonging to the account used to make the request. + /// + public class DeleteIncomingPhoneNumberOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIncomingPhoneNumberOptions + /// + /// The unique string that identifies the resource + public DeleteIncomingPhoneNumberOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. + /// + public class ReadIncomingPhoneNumberOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// Whether to include new phone numbers + /// + public bool? Beta { get; set; } + /// + /// A string that identifies the IncomingPhoneNumber resources to read + /// + public string FriendlyName { get; set; } + /// + /// The phone numbers of the IncomingPhoneNumber resources to read + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// Include phone numbers based on their origin. By default, phone numbers of all origin are included. + /// + public string Origin { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Beta != null) + { + p.Add(new KeyValuePair("Beta", Beta.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (Origin != null) + { + p.Add(new KeyValuePair("Origin", Origin)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Purchase a phone-number for the account. + /// + public class CreateIncomingPhoneNumberOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The phone number to purchase in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// The desired area code for the new phone number + /// + public string AreaCode { get; set; } + /// + /// The API version to use for incoming calls made to the new phone number + /// + public string ApiVersion { get; set; } + /// + /// A string to describe the new phone number + /// + public string FriendlyName { get; set; } + /// + /// The SID of the application to handle SMS messages + /// + public string SmsApplicationSid { get; set; } + /// + /// HTTP method used with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method to use with sms url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the new phone number receives an incoming SMS message + /// + public Uri SmsUrl { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The SID of the application to handle the new phone number + /// + public string VoiceApplicationSid { get; set; } + /// + /// Whether to lookup the caller's name + /// + public bool? VoiceCallerIdLookup { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we will call when an error occurs in TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with the voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when the phone number receives a call + /// + public Uri VoiceUrl { get; set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; set; } + /// + /// The emergency address configuration to use for emergency calling + /// + public string EmergencyAddressSid { get; set; } + /// + /// SID of the trunk to handle calls to the new phone number + /// + public string TrunkSid { get; set; } + /// + /// The SID of the Identity resource to associate with the new phone number + /// + public string IdentitySid { get; set; } + /// + /// The SID of the Address resource associated with the phone number + /// + public string AddressSid { get; set; } + /// + /// Incoming call type: fax or voice + /// + public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; set; } + /// + /// The SID of the Bundle resource associated with number + /// + public string BundleSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (AreaCode != null) + { + p.Add(new KeyValuePair("AreaCode", AreaCode)); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (VoiceApplicationSid != null) + { + p.Add(new KeyValuePair("VoiceApplicationSid", VoiceApplicationSid.ToString())); + } + + if (VoiceCallerIdLookup != null) + { + p.Add(new KeyValuePair("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower())); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (EmergencyStatus != null) + { + p.Add(new KeyValuePair("EmergencyStatus", EmergencyStatus.ToString())); + } + + if (EmergencyAddressSid != null) + { + p.Add(new KeyValuePair("EmergencyAddressSid", EmergencyAddressSid.ToString())); + } + + if (TrunkSid != null) + { + p.Add(new KeyValuePair("TrunkSid", TrunkSid.ToString())); + } + + if (IdentitySid != null) + { + p.Add(new KeyValuePair("IdentitySid", IdentitySid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (VoiceReceiveMode != null) + { + p.Add(new KeyValuePair("VoiceReceiveMode", VoiceReceiveMode.ToString())); + } + + if (BundleSid != null) + { + p.Add(new KeyValuePair("BundleSid", BundleSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberResource.cs b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberResource.cs index 0eb22ecaf..bf9567b15 100644 --- a/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberResource.cs @@ -17,898 +17,898 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class IncomingPhoneNumberResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - public sealed class EmergencyStatusEnum : StringEnum - { - private EmergencyStatusEnum(string value) : base(value) {} - public EmergencyStatusEnum() {} - public static implicit operator EmergencyStatusEnum(string value) - { - return new EmergencyStatusEnum(value); - } - - public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); - public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); - } - - public sealed class EmergencyAddressStatusEnum : StringEnum - { - private EmergencyAddressStatusEnum(string value) : base(value) {} - public EmergencyAddressStatusEnum() {} - public static implicit operator EmergencyAddressStatusEnum(string value) - { - return new EmergencyAddressStatusEnum(value); - } - - public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); - public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); - public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); - public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); - public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); - public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); - } - - public sealed class VoiceReceiveModeEnum : StringEnum - { - private VoiceReceiveModeEnum(string value) : base(value) {} - public VoiceReceiveModeEnum() {} - public static implicit operator VoiceReceiveModeEnum(string value) - { - return new VoiceReceiveModeEnum(value); - } - - public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); - public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); - } - - private static Request BuildUpdateRequest(UpdateIncomingPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an incoming-phone-number instance. - /// - /// Update IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Update(UpdateIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an incoming-phone-number instance. - /// - /// Update IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task UpdateAsync(UpdateIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an incoming-phone-number instance. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to update - /// The SID of the Account that created the resource to update - /// The API version to use for incoming calls made to the phone number - /// A string to describe the resource - /// Unique string that identifies the application - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms_url - /// The URL we should call when the phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the phone number - /// Whether to lookup the caller's name - /// The HTTP method used with fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle phone calls to the phone number - /// Incoming call type: fax or voice - /// Unique string that identifies the identity associated with number - /// The SID of the Address resource associated with the phone number - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Update(string pathSid, - string pathAccountSid = null, - string accountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string identitySid = null, - string addressSid = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid, AccountSid = accountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, IdentitySid = identitySid, AddressSid = addressSid, BundleSid = bundleSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an incoming-phone-number instance. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to update - /// The SID of the Account that created the resource to update - /// The API version to use for incoming calls made to the phone number - /// A string to describe the resource - /// Unique string that identifies the application - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms_url - /// The URL we should call when the phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The SID of the application to handle the phone number - /// Whether to lookup the caller's name - /// The HTTP method used with fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle phone calls to the phone number - /// Incoming call type: fax or voice - /// Unique string that identifies the identity associated with number - /// The SID of the Address resource associated with the phone number - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string accountSid = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string identitySid = null, - string addressSid = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid, AccountSid = accountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, IdentitySid = identitySid, AddressSid = addressSid, BundleSid = bundleSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchIncomingPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an incoming-phone-number belonging to the account used to make the request. - /// - /// Fetch IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Fetch(FetchIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an incoming-phone-number belonging to the account used to make the request. - /// - /// Fetch IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(FetchIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an incoming-phone-number belonging to the account used to make the request. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an incoming-phone-number belonging to the account used to make the request. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteIncomingPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a phone-numbers belonging to the account used to make the request. - /// - /// Delete IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static bool Delete(DeleteIncomingPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a phone-numbers belonging to the account used to make the request. - /// - /// Delete IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a phone-numbers belonging to the account used to make the request. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a phone-numbers belonging to the account used to make the request. - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIncomingPhoneNumberOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadIncomingPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. - /// - /// Read IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static ResourceSet Read(ReadIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. - /// - /// Read IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(ReadIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("incoming_phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the IncomingPhoneNumber resources to read - /// The phone numbers of the IncomingPhoneNumber resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static ResourceSet Read(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIncomingPhoneNumberOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. - /// - /// The SID of the Account that created the resources to read - /// Whether to include new phone numbers - /// A string that identifies the IncomingPhoneNumber resources to read - /// The phone numbers of the IncomingPhoneNumber resources to read - /// Include phone numbers based on their origin. By default, phone numbers of all origin are - /// included. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - bool? beta = null, - string friendlyName = null, - Types.PhoneNumber phoneNumber = null, - string origin = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIncomingPhoneNumberOptions(){PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("incoming_phone_numbers", response.Content); - } - - private static Request BuildCreateRequest(CreateIncomingPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Purchase a phone-number for the account. - /// - /// Create IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Create(CreateIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Purchase a phone-number for the account. - /// - /// Create IncomingPhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(CreateIncomingPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Purchase a phone-number for the account. - /// - /// The SID of the Account that will create the resource - /// The phone number to purchase in E.164 format - /// The desired area code for the new phone number - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// A single instance of IncomingPhoneNumber - public static IncomingPhoneNumberResource Create(string pathAccountSid = null, - Types.PhoneNumber phoneNumber = null, - string areaCode = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - string identitySid = null, - string addressSid = null, - IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIncomingPhoneNumberOptions(){PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, AreaCode = areaCode, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, IdentitySid = identitySid, AddressSid = addressSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Purchase a phone-number for the account. - /// - /// The SID of the Account that will create the resource - /// The phone number to purchase in E.164 format - /// The desired area code for the new phone number - /// The API version to use for incoming calls made to the new phone number - /// A string to describe the new phone number - /// The SID of the application to handle SMS messages - /// HTTP method used with sms_fallback_url - /// The URL we call when an error occurs while executing TwiML - /// The HTTP method to use with sms url - /// The URL we should call when the new phone number receives an incoming SMS message - /// The URL we should call to send status information to your application - /// HTTP method we should use to call status_callback - /// The SID of the application to handle the new phone number - /// Whether to lookup the caller's name - /// The HTTP method used with voice_fallback_url - /// The URL we will call when an error occurs in TwiML - /// The HTTP method used with the voice_url - /// The URL we should call when the phone number receives a call - /// Displays if emergency calling is enabled for this number. - /// The emergency address configuration to use for emergency calling - /// SID of the trunk to handle calls to the new phone number - /// The SID of the Identity resource to associate with the new phone number - /// The SID of the Address resource associated with the phone number - /// Incoming call type: fax or voice - /// The SID of the Bundle resource associated with number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IncomingPhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, - Types.PhoneNumber phoneNumber = null, - string areaCode = null, - string apiVersion = null, - string friendlyName = null, - string smsApplicationSid = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string voiceApplicationSid = null, - bool? voiceCallerIdLookup = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, - string emergencyAddressSid = null, - string trunkSid = null, - string identitySid = null, - string addressSid = null, - IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, - string bundleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIncomingPhoneNumberOptions(){PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, AreaCode = areaCode, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, IdentitySid = identitySid, AddressSid = addressSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a IncomingPhoneNumberResource object - /// - /// Raw JSON string - /// IncomingPhoneNumberResource object represented by the provided JSON - public static IncomingPhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Address resource associated with the phone number - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio. - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public IncomingPhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Identity resource associated with number - /// - [JsonProperty("identity_sid")] - public string IdentitySid { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The phone number's origin. Can be twilio or hosted. - /// - [JsonProperty("origin")] - public string Origin { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the application that handles SMS messages sent to the phone number - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The voice_receive_mode - /// - [JsonProperty("voice_receive_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// Displays if emergency calling is enabled for this number. - /// - [JsonProperty("emergency_status")] - [JsonConverter(typeof(StringEnumConverter))] - public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; private set; } - /// - /// The emergency address configuration to use for emergency calling - /// - [JsonProperty("emergency_address_sid")] - public string EmergencyAddressSid { get; private set; } - /// - /// State of the emergency address configuration for the phone number - /// - [JsonProperty("emergency_address_status")] - [JsonConverter(typeof(StringEnumConverter))] - public IncomingPhoneNumberResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } - /// - /// The SID of the Bundle resource associated with number - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - - private IncomingPhoneNumberResource() - { - - } - } +{ + + public class IncomingPhoneNumberResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + public sealed class EmergencyStatusEnum : StringEnum + { + private EmergencyStatusEnum(string value) : base(value) { } + public EmergencyStatusEnum() { } + public static implicit operator EmergencyStatusEnum(string value) + { + return new EmergencyStatusEnum(value); + } + + public static readonly EmergencyStatusEnum Active = new EmergencyStatusEnum("Active"); + public static readonly EmergencyStatusEnum Inactive = new EmergencyStatusEnum("Inactive"); + } + + public sealed class EmergencyAddressStatusEnum : StringEnum + { + private EmergencyAddressStatusEnum(string value) : base(value) { } + public EmergencyAddressStatusEnum() { } + public static implicit operator EmergencyAddressStatusEnum(string value) + { + return new EmergencyAddressStatusEnum(value); + } + + public static readonly EmergencyAddressStatusEnum Registered = new EmergencyAddressStatusEnum("registered"); + public static readonly EmergencyAddressStatusEnum Unregistered = new EmergencyAddressStatusEnum("unregistered"); + public static readonly EmergencyAddressStatusEnum PendingRegistration = new EmergencyAddressStatusEnum("pending-registration"); + public static readonly EmergencyAddressStatusEnum RegistrationFailure = new EmergencyAddressStatusEnum("registration-failure"); + public static readonly EmergencyAddressStatusEnum PendingUnregistration = new EmergencyAddressStatusEnum("pending-unregistration"); + public static readonly EmergencyAddressStatusEnum UnregistrationFailure = new EmergencyAddressStatusEnum("unregistration-failure"); + } + + public sealed class VoiceReceiveModeEnum : StringEnum + { + private VoiceReceiveModeEnum(string value) : base(value) { } + public VoiceReceiveModeEnum() { } + public static implicit operator VoiceReceiveModeEnum(string value) + { + return new VoiceReceiveModeEnum(value); + } + + public static readonly VoiceReceiveModeEnum Voice = new VoiceReceiveModeEnum("voice"); + public static readonly VoiceReceiveModeEnum Fax = new VoiceReceiveModeEnum("fax"); + } + + private static Request BuildUpdateRequest(UpdateIncomingPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an incoming-phone-number instance. + /// + /// Update IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Update(UpdateIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an incoming-phone-number instance. + /// + /// Update IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task UpdateAsync(UpdateIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an incoming-phone-number instance. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to update + /// The SID of the Account that created the resource to update + /// The API version to use for incoming calls made to the phone number + /// A string to describe the resource + /// Unique string that identifies the application + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms_url + /// The URL we should call when the phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the phone number + /// Whether to lookup the caller's name + /// The HTTP method used with fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle phone calls to the phone number + /// Incoming call type: fax or voice + /// Unique string that identifies the identity associated with number + /// The SID of the Address resource associated with the phone number + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Update(string pathSid, + string pathAccountSid = null, + string accountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string identitySid = null, + string addressSid = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid, AccountSid = accountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, IdentitySid = identitySid, AddressSid = addressSid, BundleSid = bundleSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an incoming-phone-number instance. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to update + /// The SID of the Account that created the resource to update + /// The API version to use for incoming calls made to the phone number + /// A string to describe the resource + /// Unique string that identifies the application + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms_url + /// The URL we should call when the phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The SID of the application to handle the phone number + /// Whether to lookup the caller's name + /// The HTTP method used with fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle phone calls to the phone number + /// Incoming call type: fax or voice + /// Unique string that identifies the identity associated with number + /// The SID of the Address resource associated with the phone number + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string accountSid = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string identitySid = null, + string addressSid = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid, AccountSid = accountSid, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, VoiceReceiveMode = voiceReceiveMode, IdentitySid = identitySid, AddressSid = addressSid, BundleSid = bundleSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchIncomingPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an incoming-phone-number belonging to the account used to make the request. + /// + /// Fetch IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Fetch(FetchIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an incoming-phone-number belonging to the account used to make the request. + /// + /// Fetch IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(FetchIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an incoming-phone-number belonging to the account used to make the request. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an incoming-phone-number belonging to the account used to make the request. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteIncomingPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a phone-numbers belonging to the account used to make the request. + /// + /// Delete IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static bool Delete(DeleteIncomingPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a phone-numbers belonging to the account used to make the request. + /// + /// Delete IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a phone-numbers belonging to the account used to make the request. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a phone-numbers belonging to the account used to make the request. + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIncomingPhoneNumberOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadIncomingPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. + /// + /// Read IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static ResourceSet Read(ReadIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. + /// + /// Read IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(ReadIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("incoming_phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the IncomingPhoneNumber resources to read + /// The phone numbers of the IncomingPhoneNumber resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static ResourceSet Read(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIncomingPhoneNumberOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of incoming-phone-numbers belonging to the account used to make the request. + /// + /// The SID of the Account that created the resources to read + /// Whether to include new phone numbers + /// A string that identifies the IncomingPhoneNumber resources to read + /// The phone numbers of the IncomingPhoneNumber resources to read + /// Include phone numbers based on their origin. By default, phone numbers of all origin are + /// included. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + bool? beta = null, + string friendlyName = null, + Types.PhoneNumber phoneNumber = null, + string origin = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIncomingPhoneNumberOptions() { PathAccountSid = pathAccountSid, Beta = beta, FriendlyName = friendlyName, PhoneNumber = phoneNumber, Origin = origin, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("incoming_phone_numbers", response.Content); + } + + private static Request BuildCreateRequest(CreateIncomingPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Purchase a phone-number for the account. + /// + /// Create IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Create(CreateIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Purchase a phone-number for the account. + /// + /// Create IncomingPhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(CreateIncomingPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Purchase a phone-number for the account. + /// + /// The SID of the Account that will create the resource + /// The phone number to purchase in E.164 format + /// The desired area code for the new phone number + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// A single instance of IncomingPhoneNumber + public static IncomingPhoneNumberResource Create(string pathAccountSid = null, + Types.PhoneNumber phoneNumber = null, + string areaCode = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + string identitySid = null, + string addressSid = null, + IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIncomingPhoneNumberOptions() { PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, AreaCode = areaCode, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, IdentitySid = identitySid, AddressSid = addressSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Purchase a phone-number for the account. + /// + /// The SID of the Account that will create the resource + /// The phone number to purchase in E.164 format + /// The desired area code for the new phone number + /// The API version to use for incoming calls made to the new phone number + /// A string to describe the new phone number + /// The SID of the application to handle SMS messages + /// HTTP method used with sms_fallback_url + /// The URL we call when an error occurs while executing TwiML + /// The HTTP method to use with sms url + /// The URL we should call when the new phone number receives an incoming SMS message + /// The URL we should call to send status information to your application + /// HTTP method we should use to call status_callback + /// The SID of the application to handle the new phone number + /// Whether to lookup the caller's name + /// The HTTP method used with voice_fallback_url + /// The URL we will call when an error occurs in TwiML + /// The HTTP method used with the voice_url + /// The URL we should call when the phone number receives a call + /// Displays if emergency calling is enabled for this number. + /// The emergency address configuration to use for emergency calling + /// SID of the trunk to handle calls to the new phone number + /// The SID of the Identity resource to associate with the new phone number + /// The SID of the Address resource associated with the phone number + /// Incoming call type: fax or voice + /// The SID of the Bundle resource associated with number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IncomingPhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, + Types.PhoneNumber phoneNumber = null, + string areaCode = null, + string apiVersion = null, + string friendlyName = null, + string smsApplicationSid = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string voiceApplicationSid = null, + bool? voiceCallerIdLookup = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, + string emergencyAddressSid = null, + string trunkSid = null, + string identitySid = null, + string addressSid = null, + IncomingPhoneNumberResource.VoiceReceiveModeEnum voiceReceiveMode = null, + string bundleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIncomingPhoneNumberOptions() { PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, AreaCode = areaCode, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid, IdentitySid = identitySid, AddressSid = addressSid, VoiceReceiveMode = voiceReceiveMode, BundleSid = bundleSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a IncomingPhoneNumberResource object + /// + /// Raw JSON string + /// IncomingPhoneNumberResource object represented by the provided JSON + public static IncomingPhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Address resource associated with the phone number + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio. + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public IncomingPhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Identity resource associated with number + /// + [JsonProperty("identity_sid")] + public string IdentitySid { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The phone number's origin. Can be twilio or hosted. + /// + [JsonProperty("origin")] + public string Origin { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the application that handles SMS messages sent to the phone number + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The voice_receive_mode + /// + [JsonProperty("voice_receive_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public IncomingPhoneNumberResource.VoiceReceiveModeEnum VoiceReceiveMode { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// Displays if emergency calling is enabled for this number. + /// + [JsonProperty("emergency_status")] + [JsonConverter(typeof(StringEnumConverter))] + public IncomingPhoneNumberResource.EmergencyStatusEnum EmergencyStatus { get; private set; } + /// + /// The emergency address configuration to use for emergency calling + /// + [JsonProperty("emergency_address_sid")] + public string EmergencyAddressSid { get; private set; } + /// + /// State of the emergency address configuration for the phone number + /// + [JsonProperty("emergency_address_status")] + [JsonConverter(typeof(StringEnumConverter))] + public IncomingPhoneNumberResource.EmergencyAddressStatusEnum EmergencyAddressStatus { get; private set; } + /// + /// The SID of the Bundle resource associated with number + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + + private IncomingPhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/KeyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/KeyOptions.cs index 2e6b16271..be21d6886 100644 --- a/src/Twilio/Rest/Api/V2010/Account/KeyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/KeyOptions.cs @@ -9,139 +9,139 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// FetchKeyOptions + /// + public class FetchKeyOptions : IOptions + { /// - /// FetchKeyOptions + /// The SID of the Account that created the resource to fetch /// - public class FetchKeyOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchKeyOptions - /// - /// The unique string that identifies the resource - public FetchKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// UpdateKeyOptions + /// The unique string that identifies the resource /// - public class UpdateKeyOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateKeyOptions - /// - /// The unique string that identifies the resource - public UpdateKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteKeyOptions + /// Construct a new FetchKeyOptions /// - public class DeleteKeyOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteKeyOptions - /// - /// The unique string that identifies the resource - public DeleteKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + public FetchKeyOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// ReadKeyOptions + /// Generate the necessary parameters /// - public class ReadKeyOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateKeyOptions + /// + public class UpdateKeyOptions : IOptions + { + /// + /// The SID of the Account that created the resources to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateKeyOptions + /// + /// The unique string that identifies the resource + public UpdateKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteKeyOptions + /// + public class DeleteKeyOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteKeyOptions + /// + /// The unique string that identifies the resource + public DeleteKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadKeyOptions + /// + public class ReadKeyOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/KeyResource.cs b/src/Twilio/Rest/Api/V2010/Account/KeyResource.cs index b39df70f3..fa62af6e0 100644 --- a/src/Twilio/Rest/Api/V2010/Account/KeyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/KeyResource.cs @@ -16,402 +16,402 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class KeyResource : Resource - { - private static Request BuildFetchRequest(FetchKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Fetch(FetchKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task FetchAsync(FetchKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Update(UpdateKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task UpdateAsync(UpdateKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateKeyOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateKeyOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static bool Delete(DeleteKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task DeleteAsync(DeleteKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Key - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static ResourceSet Read(ReadKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("keys", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task> ReadAsync(ReadKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("keys", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Key - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadKeyOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadKeyOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - /// - /// Converts a JSON string into a KeyResource object - /// - /// Raw JSON string - /// KeyResource object represented by the provided JSON - public static KeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private KeyResource() - { - - } - } +{ + + public class KeyResource : Resource + { + private static Request BuildFetchRequest(FetchKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Fetch(FetchKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task FetchAsync(FetchKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Update(UpdateKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task UpdateAsync(UpdateKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateKeyOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateKeyOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static bool Delete(DeleteKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task DeleteAsync(DeleteKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Key + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static ResourceSet Read(ReadKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("keys", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task> ReadAsync(ReadKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("keys", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Key + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadKeyOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadKeyOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + /// + /// Converts a JSON string into a KeyResource object + /// + /// Raw JSON string + /// KeyResource object represented by the provided JSON + public static KeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private KeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackOptions.cs index be36d3224..e0546ba7d 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackOptions.cs @@ -9,48 +9,48 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Message -{ - +{ + + /// + /// CreateFeedbackOptions + /// + public class CreateFeedbackOptions : IOptions + { /// - /// CreateFeedbackOptions + /// The SID of the Account that will create the resource /// - public class CreateFeedbackOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Message resource for which the feedback was provided - /// - public string PathMessageSid { get; } - /// - /// Whether the feedback has arrived - /// - public FeedbackResource.OutcomeEnum Outcome { get; set; } - - /// - /// Construct a new CreateFeedbackOptions - /// - /// The SID of the Message resource for which the feedback was provided - public CreateFeedbackOptions(string pathMessageSid) - { - PathMessageSid = pathMessageSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Outcome != null) - { - p.Add(new KeyValuePair("Outcome", Outcome.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The SID of the Message resource for which the feedback was provided + /// + public string PathMessageSid { get; } + /// + /// Whether the feedback has arrived + /// + public FeedbackResource.OutcomeEnum Outcome { get; set; } + + /// + /// Construct a new CreateFeedbackOptions + /// + /// The SID of the Message resource for which the feedback was provided + public CreateFeedbackOptions(string pathMessageSid) + { + PathMessageSid = pathMessageSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Outcome != null) + { + p.Add(new KeyValuePair("Outcome", Outcome.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackResource.cs b/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackResource.cs index 6952048ab..733dd9fe1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Message/FeedbackResource.cs @@ -17,153 +17,153 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Message -{ - - public class FeedbackResource : Resource - { - public sealed class OutcomeEnum : StringEnum - { - private OutcomeEnum(string value) : base(value) {} - public OutcomeEnum() {} - public static implicit operator OutcomeEnum(string value) - { - return new OutcomeEnum(value); - } - - public static readonly OutcomeEnum Confirmed = new OutcomeEnum("confirmed"); - public static readonly OutcomeEnum Unconfirmed = new OutcomeEnum("unconfirmed"); - } - - private static Request BuildCreateRequest(CreateFeedbackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Feedback.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Feedback parameters - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Create(CreateFeedbackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Feedback parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Message resource for which the feedback was provided - /// The SID of the Account that will create the resource - /// Whether the feedback has arrived - /// Client to make requests to Twilio - /// A single instance of Feedback - public static FeedbackResource Create(string pathMessageSid, - string pathAccountSid = null, - FeedbackResource.OutcomeEnum outcome = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackOptions(pathMessageSid){PathAccountSid = pathAccountSid, Outcome = outcome}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Message resource for which the feedback was provided - /// The SID of the Account that will create the resource - /// Whether the feedback has arrived - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Feedback - public static async System.Threading.Tasks.Task CreateAsync(string pathMessageSid, - string pathAccountSid = null, - FeedbackResource.OutcomeEnum outcome = null, - ITwilioRestClient client = null) - { - var options = new CreateFeedbackOptions(pathMessageSid){PathAccountSid = pathAccountSid, Outcome = outcome}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FeedbackResource object - /// - /// Raw JSON string - /// FeedbackResource object represented by the provided JSON - public static FeedbackResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Message resource for which the feedback was provided - /// - [JsonProperty("message_sid")] - public string MessageSid { get; private set; } - /// - /// Whether the feedback has arrived - /// - [JsonProperty("outcome")] - [JsonConverter(typeof(StringEnumConverter))] - public FeedbackResource.OutcomeEnum Outcome { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private FeedbackResource() - { - - } - } +{ + + public class FeedbackResource : Resource + { + public sealed class OutcomeEnum : StringEnum + { + private OutcomeEnum(string value) : base(value) { } + public OutcomeEnum() { } + public static implicit operator OutcomeEnum(string value) + { + return new OutcomeEnum(value); + } + + public static readonly OutcomeEnum Confirmed = new OutcomeEnum("confirmed"); + public static readonly OutcomeEnum Unconfirmed = new OutcomeEnum("unconfirmed"); + } + + private static Request BuildCreateRequest(CreateFeedbackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Feedback.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Feedback parameters + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Create(CreateFeedbackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Feedback parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task CreateAsync(CreateFeedbackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Message resource for which the feedback was provided + /// The SID of the Account that will create the resource + /// Whether the feedback has arrived + /// Client to make requests to Twilio + /// A single instance of Feedback + public static FeedbackResource Create(string pathMessageSid, + string pathAccountSid = null, + FeedbackResource.OutcomeEnum outcome = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackOptions(pathMessageSid) { PathAccountSid = pathAccountSid, Outcome = outcome }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Message resource for which the feedback was provided + /// The SID of the Account that will create the resource + /// Whether the feedback has arrived + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Feedback + public static async System.Threading.Tasks.Task CreateAsync(string pathMessageSid, + string pathAccountSid = null, + FeedbackResource.OutcomeEnum outcome = null, + ITwilioRestClient client = null) + { + var options = new CreateFeedbackOptions(pathMessageSid) { PathAccountSid = pathAccountSid, Outcome = outcome }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FeedbackResource object + /// + /// Raw JSON string + /// FeedbackResource object represented by the provided JSON + public static FeedbackResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Message resource for which the feedback was provided + /// + [JsonProperty("message_sid")] + public string MessageSid { get; private set; } + /// + /// Whether the feedback has arrived + /// + [JsonProperty("outcome")] + [JsonConverter(typeof(StringEnumConverter))] + public FeedbackResource.OutcomeEnum Outcome { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private FeedbackResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Message/MediaOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Message/MediaOptions.cs index e811f1412..0a4eb958e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Message/MediaOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Message/MediaOptions.cs @@ -9,151 +9,151 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Message -{ - +{ + + /// + /// Delete media from your account. Once delete, you will no longer be billed + /// + public class DeleteMediaOptions : IOptions + { /// - /// Delete media from your account. Once delete, you will no longer be billed - /// - public class DeleteMediaOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Message resource that this Media resource belongs to - /// - public string PathMessageSid { get; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMediaOptions - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - public DeleteMediaOptions(string pathMessageSid, string pathSid) - { - PathMessageSid = pathMessageSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource(s) to delete + /// + public string PathAccountSid { get; set; } /// - /// Fetch a single media instance belonging to the account used to make the request - /// - public class FetchMediaOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Message resource that this Media resource belongs to - /// - public string PathMessageSid { get; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMediaOptions - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - public FetchMediaOptions(string pathMessageSid, string pathSid) - { - PathMessageSid = pathMessageSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Message resource that this Media resource belongs to + /// + public string PathMessageSid { get; } /// - /// Retrieve a list of Media resources belonging to the account used to make the request - /// - public class ReadMediaOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Message resource that this Media resource belongs to - /// - public string PathMessageSid { get; } - /// - /// Only include media that was created on this date - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Only include media that was created on this date - /// - public DateTime? DateCreated { get; set; } - /// - /// Only include media that was created on this date - /// - public DateTime? DateCreatedAfter { get; set; } - - /// - /// Construct a new ReadMediaOptions - /// - /// The SID of the Message resource that this Media resource belongs to - public ReadMediaOptions(string pathMessageSid) - { - PathMessageSid = pathMessageSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - else - { - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreated<", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreated>", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The unique string that identifies this resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMediaOptions + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + public DeleteMediaOptions(string pathMessageSid, string pathSid) + { + PathMessageSid = pathMessageSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a single media instance belonging to the account used to make the request + /// + public class FetchMediaOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Message resource that this Media resource belongs to + /// + public string PathMessageSid { get; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMediaOptions + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + public FetchMediaOptions(string pathMessageSid, string pathSid) + { + PathMessageSid = pathMessageSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of Media resources belonging to the account used to make the request + /// + public class ReadMediaOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Message resource that this Media resource belongs to + /// + public string PathMessageSid { get; } + /// + /// Only include media that was created on this date + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// Only include media that was created on this date + /// + public DateTime? DateCreated { get; set; } + /// + /// Only include media that was created on this date + /// + public DateTime? DateCreatedAfter { get; set; } + + /// + /// Construct a new ReadMediaOptions + /// + /// The SID of the Message resource that this Media resource belongs to + public ReadMediaOptions(string pathMessageSid) + { + PathMessageSid = pathMessageSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + else + { + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreated<", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreated>", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Message/MediaResource.cs b/src/Twilio/Rest/Api/V2010/Account/Message/MediaResource.cs index ae656e21f..987143584 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Message/MediaResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Message/MediaResource.cs @@ -16,369 +16,369 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Message -{ - - public class MediaResource : Resource - { - private static Request BuildDeleteRequest(DeleteMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete media from your account. Once delete, you will no longer be billed - /// - /// Delete Media parameters - /// Client to make requests to Twilio - /// A single instance of Media - public static bool Delete(DeleteMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete media from your account. Once delete, you will no longer be billed - /// - /// Delete Media parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete media from your account. Once delete, you will no longer be billed - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// A single instance of Media - public static bool Delete(string pathMessageSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteMediaOptions(pathMessageSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete media from your account. Once delete, you will no longer be billed - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task DeleteAsync(string pathMessageSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteMediaOptions(pathMessageSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a single media instance belonging to the account used to make the request - /// - /// Fetch Media parameters - /// Client to make requests to Twilio - /// A single instance of Media - public static MediaResource Fetch(FetchMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a single media instance belonging to the account used to make the request - /// - /// Fetch Media parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task FetchAsync(FetchMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a single media instance belonging to the account used to make the request - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of Media - public static MediaResource Fetch(string pathMessageSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchMediaOptions(pathMessageSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a single media instance belonging to the account used to make the request - /// - /// The SID of the Message resource that this Media resource belongs to - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task FetchAsync(string pathMessageSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchMediaOptions(pathMessageSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Media resources belonging to the account used to make the request - /// - /// Read Media parameters - /// Client to make requests to Twilio - /// A single instance of Media - public static ResourceSet Read(ReadMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("media_list", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Media resources belonging to the account used to make the request - /// - /// Read Media parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task> ReadAsync(ReadMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("media_list", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Media resources belonging to the account used to make the request - /// - /// The SID of the Message resource that this Media resource belongs to - /// The SID of the Account that created the resource(s) to read - /// Only include media that was created on this date - /// Only include media that was created on this date - /// Only include media that was created on this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Media - public static ResourceSet Read(string pathMessageSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMediaOptions(pathMessageSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Media resources belonging to the account used to make the request - /// - /// The SID of the Message resource that this Media resource belongs to - /// The SID of the Account that created the resource(s) to read - /// Only include media that was created on this date - /// Only include media that was created on this date - /// Only include media that was created on this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Media - public static async System.Threading.Tasks.Task> ReadAsync(string pathMessageSid, - string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMediaOptions(pathMessageSid){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("media_list", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("media_list", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("media_list", response.Content); - } - - /// - /// Converts a JSON string into a MediaResource object - /// - /// Raw JSON string - /// MediaResource object represented by the provided JSON - public static MediaResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The default mime-type of the media - /// - [JsonProperty("content_type")] - public string ContentType { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the resource that created the media - /// - [JsonProperty("parent_sid")] - public string ParentSid { get; private set; } - /// - /// The unique string that identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI of this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private MediaResource() - { - - } - } +{ + + public class MediaResource : Resource + { + private static Request BuildDeleteRequest(DeleteMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete media from your account. Once delete, you will no longer be billed + /// + /// Delete Media parameters + /// Client to make requests to Twilio + /// A single instance of Media + public static bool Delete(DeleteMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete media from your account. Once delete, you will no longer be billed + /// + /// Delete Media parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete media from your account. Once delete, you will no longer be billed + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// A single instance of Media + public static bool Delete(string pathMessageSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteMediaOptions(pathMessageSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete media from your account. Once delete, you will no longer be billed + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task DeleteAsync(string pathMessageSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteMediaOptions(pathMessageSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a single media instance belonging to the account used to make the request + /// + /// Fetch Media parameters + /// Client to make requests to Twilio + /// A single instance of Media + public static MediaResource Fetch(FetchMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a single media instance belonging to the account used to make the request + /// + /// Fetch Media parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task FetchAsync(FetchMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a single media instance belonging to the account used to make the request + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of Media + public static MediaResource Fetch(string pathMessageSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchMediaOptions(pathMessageSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a single media instance belonging to the account used to make the request + /// + /// The SID of the Message resource that this Media resource belongs to + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task FetchAsync(string pathMessageSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchMediaOptions(pathMessageSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathMessageSid + "/Media.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Media resources belonging to the account used to make the request + /// + /// Read Media parameters + /// Client to make requests to Twilio + /// A single instance of Media + public static ResourceSet Read(ReadMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("media_list", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Media resources belonging to the account used to make the request + /// + /// Read Media parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task> ReadAsync(ReadMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("media_list", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Media resources belonging to the account used to make the request + /// + /// The SID of the Message resource that this Media resource belongs to + /// The SID of the Account that created the resource(s) to read + /// Only include media that was created on this date + /// Only include media that was created on this date + /// Only include media that was created on this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Media + public static ResourceSet Read(string pathMessageSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMediaOptions(pathMessageSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Media resources belonging to the account used to make the request + /// + /// The SID of the Message resource that this Media resource belongs to + /// The SID of the Account that created the resource(s) to read + /// Only include media that was created on this date + /// Only include media that was created on this date + /// Only include media that was created on this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Media + public static async System.Threading.Tasks.Task> ReadAsync(string pathMessageSid, + string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMediaOptions(pathMessageSid) { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("media_list", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("media_list", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("media_list", response.Content); + } + + /// + /// Converts a JSON string into a MediaResource object + /// + /// Raw JSON string + /// MediaResource object represented by the provided JSON + public static MediaResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The default mime-type of the media + /// + [JsonProperty("content_type")] + public string ContentType { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the resource that created the media + /// + [JsonProperty("parent_sid")] + public string ParentSid { get; private set; } + /// + /// The unique string that identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI of this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private MediaResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/MessageOptions.cs b/src/Twilio/Rest/Api/V2010/Account/MessageOptions.cs index 58b0d02c8..ade492061 100644 --- a/src/Twilio/Rest/Api/V2010/Account/MessageOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/MessageOptions.cs @@ -10,370 +10,370 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Send a message from the account used to make the request + /// + public class CreateMessageOptions : IOptions + { /// - /// Send a message from the account used to make the request - /// - public class CreateMessageOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The destination phone number - /// - public Types.PhoneNumber To { get; } - /// - /// The phone number that initiated the message - /// - public Types.PhoneNumber From { get; set; } - /// - /// The SID of the Messaging Service you want to associate with the message. - /// - public string MessagingServiceSid { get; set; } - /// - /// The text of the message you want to send. Can be up to 1,600 characters in length. - /// - public string Body { get; set; } - /// - /// The URL of the media to send with the message - /// - public List MediaUrl { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The application to use for callbacks - /// - public string ApplicationSid { get; set; } - /// - /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to be delivered. - /// - public decimal? MaxPrice { get; set; } - /// - /// Whether to confirm delivery of the message - /// - public bool? ProvideFeedback { get; set; } - /// - /// Total numer of attempts made , this inclusive to send out the message - /// - public int? Attempt { get; set; } - /// - /// The number of seconds that the message can remain in our outgoing queue. - /// - public int? ValidityPeriod { get; set; } - /// - /// Reserved - /// - public bool? ForceDelivery { get; set; } - /// - /// Determines if the message content can be stored or redacted based on privacy settings - /// - public MessageResource.ContentRetentionEnum ContentRetention { get; set; } - /// - /// Determines if the address can be stored or obfuscated based on privacy settings - /// - public MessageResource.AddressRetentionEnum AddressRetention { get; set; } - /// - /// Whether to detect Unicode characters that have a similar GSM-7 character and replace them - /// - public bool? SmartEncoded { get; set; } - /// - /// Rich actions for Channels Messages. - /// - public List PersistentAction { get; set; } - /// - /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media - /// - public bool? SendAsMms { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The destination phone number - public CreateMessageOptions(Types.PhoneNumber to) - { - To = to; - MediaUrl = new List(); - PersistentAction = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (MediaUrl != null) - { - p.AddRange(MediaUrl.Select(prop => new KeyValuePair("MediaUrl", Serializers.Url(prop)))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (ApplicationSid != null) - { - p.Add(new KeyValuePair("ApplicationSid", ApplicationSid.ToString())); - } - - if (MaxPrice != null) - { - p.Add(new KeyValuePair("MaxPrice", MaxPrice.Value.ToString())); - } - - if (ProvideFeedback != null) - { - p.Add(new KeyValuePair("ProvideFeedback", ProvideFeedback.Value.ToString().ToLower())); - } - - if (Attempt != null) - { - p.Add(new KeyValuePair("Attempt", Attempt.ToString())); - } - - if (ValidityPeriod != null) - { - p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); - } - - if (ForceDelivery != null) - { - p.Add(new KeyValuePair("ForceDelivery", ForceDelivery.Value.ToString().ToLower())); - } - - if (ContentRetention != null) - { - p.Add(new KeyValuePair("ContentRetention", ContentRetention.ToString())); - } - - if (AddressRetention != null) - { - p.Add(new KeyValuePair("AddressRetention", AddressRetention.ToString())); - } - - if (SmartEncoded != null) - { - p.Add(new KeyValuePair("SmartEncoded", SmartEncoded.Value.ToString().ToLower())); - } - - if (PersistentAction != null) - { - p.AddRange(PersistentAction.Select(prop => new KeyValuePair("PersistentAction", prop))); - } - - if (SendAsMms != null) - { - p.Add(new KeyValuePair("SendAsMms", SendAsMms.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Deletes a message record from your account - /// - public class DeleteMessageOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The unique string that identifies the resource - public DeleteMessageOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The destination phone number + /// + public Types.PhoneNumber To { get; } /// - /// Fetch a message belonging to the account used to make the request - /// - public class FetchMessageOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The unique string that identifies the resource - public FetchMessageOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The phone number that initiated the message + /// + public Types.PhoneNumber From { get; set; } /// - /// Retrieve a list of messages belonging to the account used to make the request - /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Filter by messages sent to this number - /// - public Types.PhoneNumber To { get; set; } - /// - /// Filter by from number - /// - public Types.PhoneNumber From { get; set; } - /// - /// Filter by date sent - /// - public DateTime? DateSentBefore { get; set; } - /// - /// Filter by date sent - /// - public DateTime? DateSent { get; set; } - /// - /// Filter by date sent - /// - public DateTime? DateSentAfter { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (DateSent != null) - { - p.Add(new KeyValuePair("DateSent", Serializers.DateTimeIso8601(DateSent))); - } - else - { - if (DateSentBefore != null) - { - p.Add(new KeyValuePair("DateSent<", Serializers.DateTimeIso8601(DateSentBefore))); - } - - if (DateSentAfter != null) - { - p.Add(new KeyValuePair("DateSent>", Serializers.DateTimeIso8601(DateSentAfter))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Messaging Service you want to associate with the message. + /// + public string MessagingServiceSid { get; set; } /// - /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body - /// - public class UpdateMessageOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The text of the message you want to send - /// - public string Body { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The unique string that identifies the resource - public UpdateMessageOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - return p; - } - } + /// The text of the message you want to send. Can be up to 1,600 characters in length. + /// + public string Body { get; set; } + /// + /// The URL of the media to send with the message + /// + public List MediaUrl { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The application to use for callbacks + /// + public string ApplicationSid { get; set; } + /// + /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to be delivered. + /// + public decimal? MaxPrice { get; set; } + /// + /// Whether to confirm delivery of the message + /// + public bool? ProvideFeedback { get; set; } + /// + /// Total numer of attempts made , this inclusive to send out the message + /// + public int? Attempt { get; set; } + /// + /// The number of seconds that the message can remain in our outgoing queue. + /// + public int? ValidityPeriod { get; set; } + /// + /// Reserved + /// + public bool? ForceDelivery { get; set; } + /// + /// Determines if the message content can be stored or redacted based on privacy settings + /// + public MessageResource.ContentRetentionEnum ContentRetention { get; set; } + /// + /// Determines if the address can be stored or obfuscated based on privacy settings + /// + public MessageResource.AddressRetentionEnum AddressRetention { get; set; } + /// + /// Whether to detect Unicode characters that have a similar GSM-7 character and replace them + /// + public bool? SmartEncoded { get; set; } + /// + /// Rich actions for Channels Messages. + /// + public List PersistentAction { get; set; } + /// + /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media + /// + public bool? SendAsMms { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The destination phone number + public CreateMessageOptions(Types.PhoneNumber to) + { + To = to; + MediaUrl = new List(); + PersistentAction = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (MediaUrl != null) + { + p.AddRange(MediaUrl.Select(prop => new KeyValuePair("MediaUrl", Serializers.Url(prop)))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (ApplicationSid != null) + { + p.Add(new KeyValuePair("ApplicationSid", ApplicationSid.ToString())); + } + + if (MaxPrice != null) + { + p.Add(new KeyValuePair("MaxPrice", MaxPrice.Value.ToString())); + } + + if (ProvideFeedback != null) + { + p.Add(new KeyValuePair("ProvideFeedback", ProvideFeedback.Value.ToString().ToLower())); + } + + if (Attempt != null) + { + p.Add(new KeyValuePair("Attempt", Attempt.ToString())); + } + + if (ValidityPeriod != null) + { + p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); + } + + if (ForceDelivery != null) + { + p.Add(new KeyValuePair("ForceDelivery", ForceDelivery.Value.ToString().ToLower())); + } + + if (ContentRetention != null) + { + p.Add(new KeyValuePair("ContentRetention", ContentRetention.ToString())); + } + + if (AddressRetention != null) + { + p.Add(new KeyValuePair("AddressRetention", AddressRetention.ToString())); + } + + if (SmartEncoded != null) + { + p.Add(new KeyValuePair("SmartEncoded", SmartEncoded.Value.ToString().ToLower())); + } + + if (PersistentAction != null) + { + p.AddRange(PersistentAction.Select(prop => new KeyValuePair("PersistentAction", prop))); + } + + if (SendAsMms != null) + { + p.Add(new KeyValuePair("SendAsMms", SendAsMms.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// Deletes a message record from your account + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The unique string that identifies the resource + public DeleteMessageOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a message belonging to the account used to make the request + /// + public class FetchMessageOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMessageOptions + /// + /// The unique string that identifies the resource + public FetchMessageOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of messages belonging to the account used to make the request + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// Filter by messages sent to this number + /// + public Types.PhoneNumber To { get; set; } + /// + /// Filter by from number + /// + public Types.PhoneNumber From { get; set; } + /// + /// Filter by date sent + /// + public DateTime? DateSentBefore { get; set; } + /// + /// Filter by date sent + /// + public DateTime? DateSent { get; set; } + /// + /// Filter by date sent + /// + public DateTime? DateSentAfter { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (DateSent != null) + { + p.Add(new KeyValuePair("DateSent", Serializers.DateTimeIso8601(DateSent))); + } + else + { + if (DateSentBefore != null) + { + p.Add(new KeyValuePair("DateSent<", Serializers.DateTimeIso8601(DateSentBefore))); + } + + if (DateSentAfter != null) + { + p.Add(new KeyValuePair("DateSent>", Serializers.DateTimeIso8601(DateSentAfter))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The SID of the Account that created the resources to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The text of the message you want to send + /// + public string Body { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The unique string that identifies the resource + public UpdateMessageOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/MessageResource.cs b/src/Twilio/Rest/Api/V2010/Account/MessageResource.cs index 56ac37356..6e2575632 100644 --- a/src/Twilio/Rest/Api/V2010/Account/MessageResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/MessageResource.cs @@ -17,751 +17,751 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class MessageResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Sending = new StatusEnum("sending"); - public static readonly StatusEnum Sent = new StatusEnum("sent"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Delivered = new StatusEnum("delivered"); - public static readonly StatusEnum Undelivered = new StatusEnum("undelivered"); - public static readonly StatusEnum Receiving = new StatusEnum("receiving"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum Accepted = new StatusEnum("accepted"); - public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); - public static readonly StatusEnum Read = new StatusEnum("read"); - public static readonly StatusEnum PartiallyDelivered = new StatusEnum("partially_delivered"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); - } - - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum Inbound = new DirectionEnum("inbound"); - public static readonly DirectionEnum OutboundApi = new DirectionEnum("outbound-api"); - public static readonly DirectionEnum OutboundCall = new DirectionEnum("outbound-call"); - public static readonly DirectionEnum OutboundReply = new DirectionEnum("outbound-reply"); - } - - public sealed class ContentRetentionEnum : StringEnum - { - private ContentRetentionEnum(string value) : base(value) {} - public ContentRetentionEnum() {} - public static implicit operator ContentRetentionEnum(string value) - { - return new ContentRetentionEnum(value); - } - - public static readonly ContentRetentionEnum Retain = new ContentRetentionEnum("retain"); - } - - public sealed class AddressRetentionEnum : StringEnum - { - private AddressRetentionEnum(string value) : base(value) {} - public AddressRetentionEnum() {} - public static implicit operator AddressRetentionEnum(string value) - { - return new AddressRetentionEnum(value); - } - - public static readonly AddressRetentionEnum Retain = new AddressRetentionEnum("retain"); - } - - public sealed class TrafficTypeEnum : StringEnum - { - private TrafficTypeEnum(string value) : base(value) {} - public TrafficTypeEnum() {} - public static implicit operator TrafficTypeEnum(string value) - { - return new TrafficTypeEnum(value); - } - - public static readonly TrafficTypeEnum Free = new TrafficTypeEnum("free"); - } - - public sealed class ScheduleTypeEnum : StringEnum - { - private ScheduleTypeEnum(string value) : base(value) {} - public ScheduleTypeEnum() {} - public static implicit operator ScheduleTypeEnum(string value) - { - return new ScheduleTypeEnum(value); - } - - public static readonly ScheduleTypeEnum Fixed = new ScheduleTypeEnum("fixed"); - public static readonly ScheduleTypeEnum Optimize = new ScheduleTypeEnum("optimize"); - } - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Send a message from the account used to make the request - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Send a message from the account used to make the request - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Send a message from the account used to make the request - /// - /// The destination phone number - /// The SID of the Account that will create the resource - /// The phone number that initiated the message - /// The SID of the Messaging Service you want to associate with the message. - /// The text of the message you want to send. Can be up to 1,600 characters in length. - /// The URL of the media to send with the message - /// The URL we should call to send status information to your application - /// The application to use for callbacks - /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to - /// be delivered. - /// Whether to confirm delivery of the message - /// Total numer of attempts made , this inclusive to send out the message - /// The number of seconds that the message can remain in our outgoing queue. - /// Reserved - /// Determines if the message content can be stored or redacted based on privacy - /// settings - /// Determines if the address can be stored or obfuscated based on privacy settings - /// - /// Whether to detect Unicode characters that have a similar GSM-7 character and replace - /// them - /// Rich actions for Channels Messages. - /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the - /// presence of media - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(Types.PhoneNumber to, - string pathAccountSid = null, - Types.PhoneNumber from = null, - string messagingServiceSid = null, - string body = null, - List mediaUrl = null, - Uri statusCallback = null, - string applicationSid = null, - decimal? maxPrice = null, - bool? provideFeedback = null, - int? attempt = null, - int? validityPeriod = null, - bool? forceDelivery = null, - MessageResource.ContentRetentionEnum contentRetention = null, - MessageResource.AddressRetentionEnum addressRetention = null, - bool? smartEncoded = null, - List persistentAction = null, - bool? sendAsMms = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(to){PathAccountSid = pathAccountSid, From = from, MessagingServiceSid = messagingServiceSid, Body = body, MediaUrl = mediaUrl, StatusCallback = statusCallback, ApplicationSid = applicationSid, MaxPrice = maxPrice, ProvideFeedback = provideFeedback, Attempt = attempt, ValidityPeriod = validityPeriod, ForceDelivery = forceDelivery, ContentRetention = contentRetention, AddressRetention = addressRetention, SmartEncoded = smartEncoded, PersistentAction = persistentAction, SendAsMms = sendAsMms}; - return Create(options, client); - } - - #if !NET35 - /// - /// Send a message from the account used to make the request - /// - /// The destination phone number - /// The SID of the Account that will create the resource - /// The phone number that initiated the message - /// The SID of the Messaging Service you want to associate with the message. - /// The text of the message you want to send. Can be up to 1,600 characters in length. - /// The URL of the media to send with the message - /// The URL we should call to send status information to your application - /// The application to use for callbacks - /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to - /// be delivered. - /// Whether to confirm delivery of the message - /// Total numer of attempts made , this inclusive to send out the message - /// The number of seconds that the message can remain in our outgoing queue. - /// Reserved - /// Determines if the message content can be stored or redacted based on privacy - /// settings - /// Determines if the address can be stored or obfuscated based on privacy settings - /// - /// Whether to detect Unicode characters that have a similar GSM-7 character and replace - /// them - /// Rich actions for Channels Messages. - /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the - /// presence of media - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber to, - string pathAccountSid = null, - Types.PhoneNumber from = null, - string messagingServiceSid = null, - string body = null, - List mediaUrl = null, - Uri statusCallback = null, - string applicationSid = null, - decimal? maxPrice = null, - bool? provideFeedback = null, - int? attempt = null, - int? validityPeriod = null, - bool? forceDelivery = null, - MessageResource.ContentRetentionEnum contentRetention = null, - MessageResource.AddressRetentionEnum addressRetention = null, - bool? smartEncoded = null, - List persistentAction = null, - bool? sendAsMms = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(to){PathAccountSid = pathAccountSid, From = from, MessagingServiceSid = messagingServiceSid, Body = body, MediaUrl = mediaUrl, StatusCallback = statusCallback, ApplicationSid = applicationSid, MaxPrice = maxPrice, ProvideFeedback = provideFeedback, Attempt = attempt, ValidityPeriod = validityPeriod, ForceDelivery = forceDelivery, ContentRetention = contentRetention, AddressRetention = addressRetention, SmartEncoded = smartEncoded, PersistentAction = persistentAction, SendAsMms = sendAsMms}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Deletes a message record from your account - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Deletes a message record from your account - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Deletes a message record from your account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Deletes a message record from your account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a message belonging to the account used to make the request - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a message belonging to the account used to make the request - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a message belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a message belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of messages belonging to the account used to make the request - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of messages belonging to the account used to make the request - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of messages belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Filter by messages sent to this number - /// Filter by from number - /// Filter by date sent - /// Filter by date sent - /// Filter by date sent - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathAccountSid = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - DateTime? dateSentBefore = null, - DateTime? dateSent = null, - DateTime? dateSentAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(){PathAccountSid = pathAccountSid, To = to, From = from, DateSentBefore = dateSentBefore, DateSent = dateSent, DateSentAfter = dateSentAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of messages belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Filter by messages sent to this number - /// Filter by from number - /// Filter by date sent - /// Filter by date sent - /// Filter by date sent - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - DateTime? dateSentBefore = null, - DateTime? dateSent = null, - DateTime? dateSentAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(){PathAccountSid = pathAccountSid, To = to, From = from, DateSentBefore = dateSentBefore, DateSent = dateSent, DateSentAfter = dateSentAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The text of the message you want to send - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathSid, - string pathAccountSid = null, - string body = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathSid){PathAccountSid = pathAccountSid, Body = body}; - return Update(options, client); - } - - #if !NET35 - /// - /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The text of the message you want to send - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string body = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathSid){PathAccountSid = pathAccountSid, Body = body}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The message text - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The number of messages used to deliver the message body - /// - [JsonProperty("num_segments")] - public string NumSegments { get; private set; } - /// - /// The direction of the message - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public MessageResource.DirectionEnum Direction { get; private set; } - /// - /// The phone number that initiated the message - /// - [JsonProperty("from")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber From { get; private set; } - /// - /// The phone number that received the message - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The amount billed for the message - /// - [JsonProperty("price")] - public string Price { get; private set; } - /// - /// The description of the error_code - /// - [JsonProperty("error_message")] - public string ErrorMessage { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number of media files associated with the message - /// - [JsonProperty("num_media")] - public string NumMedia { get; private set; } - /// - /// The status of the message - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public MessageResource.StatusEnum Status { get; private set; } - /// - /// The SID of the Messaging Service used with the message. - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the message was sent - /// - [JsonProperty("date_sent")] - public DateTime? DateSent { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The error code associated with the message - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// The currency in which price is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The API version used to process the message - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Sending = new StatusEnum("sending"); + public static readonly StatusEnum Sent = new StatusEnum("sent"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Delivered = new StatusEnum("delivered"); + public static readonly StatusEnum Undelivered = new StatusEnum("undelivered"); + public static readonly StatusEnum Receiving = new StatusEnum("receiving"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum Accepted = new StatusEnum("accepted"); + public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); + public static readonly StatusEnum Read = new StatusEnum("read"); + public static readonly StatusEnum PartiallyDelivered = new StatusEnum("partially_delivered"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); + } + + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum Inbound = new DirectionEnum("inbound"); + public static readonly DirectionEnum OutboundApi = new DirectionEnum("outbound-api"); + public static readonly DirectionEnum OutboundCall = new DirectionEnum("outbound-call"); + public static readonly DirectionEnum OutboundReply = new DirectionEnum("outbound-reply"); + } + + public sealed class ContentRetentionEnum : StringEnum + { + private ContentRetentionEnum(string value) : base(value) { } + public ContentRetentionEnum() { } + public static implicit operator ContentRetentionEnum(string value) + { + return new ContentRetentionEnum(value); + } + + public static readonly ContentRetentionEnum Retain = new ContentRetentionEnum("retain"); + } + + public sealed class AddressRetentionEnum : StringEnum + { + private AddressRetentionEnum(string value) : base(value) { } + public AddressRetentionEnum() { } + public static implicit operator AddressRetentionEnum(string value) + { + return new AddressRetentionEnum(value); + } + + public static readonly AddressRetentionEnum Retain = new AddressRetentionEnum("retain"); + } + + public sealed class TrafficTypeEnum : StringEnum + { + private TrafficTypeEnum(string value) : base(value) { } + public TrafficTypeEnum() { } + public static implicit operator TrafficTypeEnum(string value) + { + return new TrafficTypeEnum(value); + } + + public static readonly TrafficTypeEnum Free = new TrafficTypeEnum("free"); + } + + public sealed class ScheduleTypeEnum : StringEnum + { + private ScheduleTypeEnum(string value) : base(value) { } + public ScheduleTypeEnum() { } + public static implicit operator ScheduleTypeEnum(string value) + { + return new ScheduleTypeEnum(value); + } + + public static readonly ScheduleTypeEnum Fixed = new ScheduleTypeEnum("fixed"); + public static readonly ScheduleTypeEnum Optimize = new ScheduleTypeEnum("optimize"); + } + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Send a message from the account used to make the request + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Send a message from the account used to make the request + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Send a message from the account used to make the request + /// + /// The destination phone number + /// The SID of the Account that will create the resource + /// The phone number that initiated the message + /// The SID of the Messaging Service you want to associate with the message. + /// The text of the message you want to send. Can be up to 1,600 characters in length. + /// The URL of the media to send with the message + /// The URL we should call to send status information to your application + /// The application to use for callbacks + /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to + /// be delivered. + /// Whether to confirm delivery of the message + /// Total numer of attempts made , this inclusive to send out the message + /// The number of seconds that the message can remain in our outgoing queue. + /// Reserved + /// Determines if the message content can be stored or redacted based on privacy + /// settings + /// Determines if the address can be stored or obfuscated based on privacy settings + /// + /// Whether to detect Unicode characters that have a similar GSM-7 character and replace + /// them + /// Rich actions for Channels Messages. + /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the + /// presence of media + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(Types.PhoneNumber to, + string pathAccountSid = null, + Types.PhoneNumber from = null, + string messagingServiceSid = null, + string body = null, + List mediaUrl = null, + Uri statusCallback = null, + string applicationSid = null, + decimal? maxPrice = null, + bool? provideFeedback = null, + int? attempt = null, + int? validityPeriod = null, + bool? forceDelivery = null, + MessageResource.ContentRetentionEnum contentRetention = null, + MessageResource.AddressRetentionEnum addressRetention = null, + bool? smartEncoded = null, + List persistentAction = null, + bool? sendAsMms = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(to) { PathAccountSid = pathAccountSid, From = from, MessagingServiceSid = messagingServiceSid, Body = body, MediaUrl = mediaUrl, StatusCallback = statusCallback, ApplicationSid = applicationSid, MaxPrice = maxPrice, ProvideFeedback = provideFeedback, Attempt = attempt, ValidityPeriod = validityPeriod, ForceDelivery = forceDelivery, ContentRetention = contentRetention, AddressRetention = addressRetention, SmartEncoded = smartEncoded, PersistentAction = persistentAction, SendAsMms = sendAsMms }; + return Create(options, client); + } + +#if !NET35 + /// + /// Send a message from the account used to make the request + /// + /// The destination phone number + /// The SID of the Account that will create the resource + /// The phone number that initiated the message + /// The SID of the Messaging Service you want to associate with the message. + /// The text of the message you want to send. Can be up to 1,600 characters in length. + /// The URL of the media to send with the message + /// The URL we should call to send status information to your application + /// The application to use for callbacks + /// The total maximum price up to 4 decimal places in US dollars acceptable for the message to + /// be delivered. + /// Whether to confirm delivery of the message + /// Total numer of attempts made , this inclusive to send out the message + /// The number of seconds that the message can remain in our outgoing queue. + /// Reserved + /// Determines if the message content can be stored or redacted based on privacy + /// settings + /// Determines if the address can be stored or obfuscated based on privacy settings + /// + /// Whether to detect Unicode characters that have a similar GSM-7 character and replace + /// them + /// Rich actions for Channels Messages. + /// If set to True, Twilio will deliver the message as a single MMS message, regardless of the + /// presence of media + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber to, + string pathAccountSid = null, + Types.PhoneNumber from = null, + string messagingServiceSid = null, + string body = null, + List mediaUrl = null, + Uri statusCallback = null, + string applicationSid = null, + decimal? maxPrice = null, + bool? provideFeedback = null, + int? attempt = null, + int? validityPeriod = null, + bool? forceDelivery = null, + MessageResource.ContentRetentionEnum contentRetention = null, + MessageResource.AddressRetentionEnum addressRetention = null, + bool? smartEncoded = null, + List persistentAction = null, + bool? sendAsMms = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(to) { PathAccountSid = pathAccountSid, From = from, MessagingServiceSid = messagingServiceSid, Body = body, MediaUrl = mediaUrl, StatusCallback = statusCallback, ApplicationSid = applicationSid, MaxPrice = maxPrice, ProvideFeedback = provideFeedback, Attempt = attempt, ValidityPeriod = validityPeriod, ForceDelivery = forceDelivery, ContentRetention = contentRetention, AddressRetention = addressRetention, SmartEncoded = smartEncoded, PersistentAction = persistentAction, SendAsMms = sendAsMms }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Deletes a message record from your account + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Deletes a message record from your account + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Deletes a message record from your account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Deletes a message record from your account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a message belonging to the account used to make the request + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a message belonging to the account used to make the request + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a message belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a message belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of messages belonging to the account used to make the request + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of messages belonging to the account used to make the request + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of messages belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Filter by messages sent to this number + /// Filter by from number + /// Filter by date sent + /// Filter by date sent + /// Filter by date sent + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathAccountSid = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + DateTime? dateSentBefore = null, + DateTime? dateSent = null, + DateTime? dateSentAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions() { PathAccountSid = pathAccountSid, To = to, From = from, DateSentBefore = dateSentBefore, DateSent = dateSent, DateSentAfter = dateSentAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of messages belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Filter by messages sent to this number + /// Filter by from number + /// Filter by date sent + /// Filter by date sent + /// Filter by date sent + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + DateTime? dateSentBefore = null, + DateTime? dateSent = null, + DateTime? dateSentAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions() { PathAccountSid = pathAccountSid, To = to, From = from, DateSentBefore = dateSentBefore, DateSent = dateSent, DateSentAfter = dateSentAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Messages/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The text of the message you want to send + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathSid, + string pathAccountSid = null, + string body = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathSid) { PathAccountSid = pathAccountSid, Body = body }; + return Update(options, client); + } + +#if !NET35 + /// + /// To redact a message-body from a post-flight message record, post to the message instance resource with an empty body + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The text of the message you want to send + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string body = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathSid) { PathAccountSid = pathAccountSid, Body = body }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The message text + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The number of messages used to deliver the message body + /// + [JsonProperty("num_segments")] + public string NumSegments { get; private set; } + /// + /// The direction of the message + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public MessageResource.DirectionEnum Direction { get; private set; } + /// + /// The phone number that initiated the message + /// + [JsonProperty("from")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber From { get; private set; } + /// + /// The phone number that received the message + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The amount billed for the message + /// + [JsonProperty("price")] + public string Price { get; private set; } + /// + /// The description of the error_code + /// + [JsonProperty("error_message")] + public string ErrorMessage { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number of media files associated with the message + /// + [JsonProperty("num_media")] + public string NumMedia { get; private set; } + /// + /// The status of the message + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public MessageResource.StatusEnum Status { get; private set; } + /// + /// The SID of the Messaging Service used with the message. + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the message was sent + /// + [JsonProperty("date_sent")] + public DateTime? DateSent { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The error code associated with the message + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// The currency in which price is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The API version used to process the message + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NewKeyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/NewKeyOptions.cs index c8ad71ce2..85ba02ad6 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NewKeyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NewKeyOptions.cs @@ -9,35 +9,35 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// CreateNewKeyOptions + /// + public class CreateNewKeyOptions : IOptions + { /// - /// CreateNewKeyOptions + /// The SID of the Account that will be responsible for the new Key resource /// - public class CreateNewKeyOptions : IOptions - { - /// - /// The SID of the Account that will be responsible for the new Key resource - /// - public string PathAccountSid { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NewKeyResource.cs b/src/Twilio/Rest/Api/V2010/Account/NewKeyResource.cs index 04d61631c..22ab1034f 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NewKeyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NewKeyResource.cs @@ -16,130 +16,130 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class NewKeyResource : Resource - { - private static Request BuildCreateRequest(CreateNewKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create NewKey parameters - /// Client to make requests to Twilio - /// A single instance of NewKey - public static NewKeyResource Create(CreateNewKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create NewKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewKey - public static async System.Threading.Tasks.Task CreateAsync(CreateNewKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Account that will be responsible for the new Key resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of NewKey - public static NewKeyResource Create(string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateNewKeyOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Account that will be responsible for the new Key resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewKey - public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateNewKeyOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NewKeyResource object - /// - /// Raw JSON string - /// NewKeyResource object represented by the provided JSON - public static NewKeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The secret your application uses to sign Access Tokens and to authenticate to the REST API. - /// - [JsonProperty("secret")] - public string Secret { get; private set; } - - private NewKeyResource() - { - - } - } +{ + + public class NewKeyResource : Resource + { + private static Request BuildCreateRequest(CreateNewKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Keys.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create NewKey parameters + /// Client to make requests to Twilio + /// A single instance of NewKey + public static NewKeyResource Create(CreateNewKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create NewKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewKey + public static async System.Threading.Tasks.Task CreateAsync(CreateNewKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Account that will be responsible for the new Key resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of NewKey + public static NewKeyResource Create(string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateNewKeyOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Account that will be responsible for the new Key resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewKey + public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateNewKeyOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NewKeyResource object + /// + /// Raw JSON string + /// NewKeyResource object represented by the provided JSON + public static NewKeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The secret your application uses to sign Access Tokens and to authenticate to the REST API. + /// + [JsonProperty("secret")] + public string Secret { get; private set; } + + private NewKeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyOptions.cs index f10231695..516928c29 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyOptions.cs @@ -9,35 +9,35 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Create a new Signing Key for the account making the request. + /// + public class CreateNewSigningKeyOptions : IOptions + { /// - /// Create a new Signing Key for the account making the request. + /// The SID of the Account that will be responsible for the new Key resource /// - public class CreateNewSigningKeyOptions : IOptions - { - /// - /// The SID of the Account that will be responsible for the new Key resource - /// - public string PathAccountSid { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyResource.cs b/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyResource.cs index 4efc24c78..61a10fed2 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NewSigningKeyResource.cs @@ -16,130 +16,130 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class NewSigningKeyResource : Resource - { - private static Request BuildCreateRequest(CreateNewSigningKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Signing Key for the account making the request. - /// - /// Create NewSigningKey parameters - /// Client to make requests to Twilio - /// A single instance of NewSigningKey - public static NewSigningKeyResource Create(CreateNewSigningKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Signing Key for the account making the request. - /// - /// Create NewSigningKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewSigningKey - public static async System.Threading.Tasks.Task CreateAsync(CreateNewSigningKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Signing Key for the account making the request. - /// - /// The SID of the Account that will be responsible for the new Key resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of NewSigningKey - public static NewSigningKeyResource Create(string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateNewSigningKeyOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Signing Key for the account making the request. - /// - /// The SID of the Account that will be responsible for the new Key resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewSigningKey - public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateNewSigningKeyOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NewSigningKeyResource object - /// - /// Raw JSON string - /// NewSigningKeyResource object represented by the provided JSON - public static NewSigningKeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The secret your application uses to sign Access Tokens and to authenticate to the REST API. - /// - [JsonProperty("secret")] - public string Secret { get; private set; } - - private NewSigningKeyResource() - { - - } - } +{ + + public class NewSigningKeyResource : Resource + { + private static Request BuildCreateRequest(CreateNewSigningKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Signing Key for the account making the request. + /// + /// Create NewSigningKey parameters + /// Client to make requests to Twilio + /// A single instance of NewSigningKey + public static NewSigningKeyResource Create(CreateNewSigningKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Signing Key for the account making the request. + /// + /// Create NewSigningKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewSigningKey + public static async System.Threading.Tasks.Task CreateAsync(CreateNewSigningKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Signing Key for the account making the request. + /// + /// The SID of the Account that will be responsible for the new Key resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of NewSigningKey + public static NewSigningKeyResource Create(string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateNewSigningKeyOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Signing Key for the account making the request. + /// + /// The SID of the Account that will be responsible for the new Key resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewSigningKey + public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateNewSigningKeyOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NewSigningKeyResource object + /// + /// Raw JSON string + /// NewSigningKeyResource object represented by the provided JSON + public static NewSigningKeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The secret your application uses to sign Access Tokens and to authenticate to the REST API. + /// + [JsonProperty("secret")] + public string Secret { get; private set; } + + private NewSigningKeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NotificationOptions.cs b/src/Twilio/Rest/Api/V2010/Account/NotificationOptions.cs index e563d6afd..6a1f49d96 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NotificationOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NotificationOptions.cs @@ -9,102 +9,102 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch a notification belonging to the account used to make the request + /// + public class FetchNotificationOptions : IOptions + { /// - /// Fetch a notification belonging to the account used to make the request + /// The SID of the Account that created the resource to fetch /// - public class FetchNotificationOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchNotificationOptions - /// - /// The unique string that identifies the resource - public FetchNotificationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Retrieve a list of notifications belonging to the account used to make the request + /// The unique string that identifies the resource /// - public class ReadNotificationOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Filter by log level - /// - public int? Log { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDateBefore { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDate { get; set; } - /// - /// Filter by date - /// - public DateTime? MessageDateAfter { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Log != null) - { - p.Add(new KeyValuePair("Log", Log.ToString())); - } - - if (MessageDate != null) - { - p.Add(new KeyValuePair("MessageDate", MessageDate.Value.ToString("yyyy-MM-dd"))); - } - else - { - if (MessageDateBefore != null) - { - p.Add(new KeyValuePair("MessageDate<", MessageDateBefore.Value.ToString("yyyy-MM-dd"))); - } - - if (MessageDateAfter != null) - { - p.Add(new KeyValuePair("MessageDate>", MessageDateAfter.Value.ToString("yyyy-MM-dd"))); - } - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchNotificationOptions + /// + /// The unique string that identifies the resource + public FetchNotificationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of notifications belonging to the account used to make the request + /// + public class ReadNotificationOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// Filter by log level + /// + public int? Log { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDateBefore { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDate { get; set; } + /// + /// Filter by date + /// + public DateTime? MessageDateAfter { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Log != null) + { + p.Add(new KeyValuePair("Log", Log.ToString())); + } + + if (MessageDate != null) + { + p.Add(new KeyValuePair("MessageDate", MessageDate.Value.ToString("yyyy-MM-dd"))); + } + else + { + if (MessageDateBefore != null) + { + p.Add(new KeyValuePair("MessageDate<", MessageDateBefore.Value.ToString("yyyy-MM-dd"))); + } + + if (MessageDateAfter != null) + { + p.Add(new KeyValuePair("MessageDate>", MessageDateAfter.Value.ToString("yyyy-MM-dd"))); + } + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/NotificationResource.cs b/src/Twilio/Rest/Api/V2010/Account/NotificationResource.cs index 7899eb773..a07acf5d9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/NotificationResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/NotificationResource.cs @@ -16,341 +16,341 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class NotificationResource : Resource - { - private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Notifications/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a notification belonging to the account used to make the request - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a notification belonging to the account used to make the request - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a notification belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a notification belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Notifications.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of notifications belonging to the account used to make the request - /// - /// Read Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static ResourceSet Read(ReadNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("notifications", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of notifications belonging to the account used to make the request - /// - /// Read Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task> ReadAsync(ReadNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("notifications", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of notifications belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Filter by log level - /// Filter by date - /// Filter by date - /// Filter by date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Notification - public static ResourceSet Read(string pathAccountSid = null, - int? log = null, - DateTime? messageDateBefore = null, - DateTime? messageDate = null, - DateTime? messageDateAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNotificationOptions(){PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of notifications belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Filter by log level - /// Filter by date - /// Filter by date - /// Filter by date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? log = null, - DateTime? messageDateBefore = null, - DateTime? messageDate = null, - DateTime? messageDateAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNotificationOptions(){PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("notifications", response.Content); - } - - /// - /// Converts a JSON string into a NotificationResource object - /// - /// Raw JSON string - /// NotificationResource object represented by the provided JSON - public static NotificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to generate the notification - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A unique error code corresponding to the notification - /// - [JsonProperty("error_code")] - public string ErrorCode { get; private set; } - /// - /// An integer log level - /// - [JsonProperty("log")] - public string Log { get; private set; } - /// - /// The date the notification was generated - /// - [JsonProperty("message_date")] - public DateTime? MessageDate { get; private set; } - /// - /// The text of the notification - /// - [JsonProperty("message_text")] - public string MessageText { get; private set; } - /// - /// A URL for more information about the error code - /// - [JsonProperty("more_info")] - public Uri MoreInfo { get; private set; } - /// - /// HTTP method used with the request url - /// - [JsonProperty("request_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod RequestMethod { get; private set; } - /// - /// URL of the resource that generated the notification - /// - [JsonProperty("request_url")] - public Uri RequestUrl { get; private set; } - /// - /// Twilio-generated HTTP variables sent to the server - /// - [JsonProperty("request_variables")] - public string RequestVariables { get; private set; } - /// - /// The HTTP body returned by your server - /// - [JsonProperty("response_body")] - public string ResponseBody { get; private set; } - /// - /// The HTTP headers returned by your server - /// - [JsonProperty("response_headers")] - public string ResponseHeaders { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private NotificationResource() - { - - } - } +{ + + public class NotificationResource : Resource + { + private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Notifications/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a notification belonging to the account used to make the request + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a notification belonging to the account used to make the request + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a notification belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a notification belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Notifications.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of notifications belonging to the account used to make the request + /// + /// Read Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static ResourceSet Read(ReadNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("notifications", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of notifications belonging to the account used to make the request + /// + /// Read Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task> ReadAsync(ReadNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("notifications", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of notifications belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Filter by log level + /// Filter by date + /// Filter by date + /// Filter by date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Notification + public static ResourceSet Read(string pathAccountSid = null, + int? log = null, + DateTime? messageDateBefore = null, + DateTime? messageDate = null, + DateTime? messageDateAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNotificationOptions() { PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of notifications belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Filter by log level + /// Filter by date + /// Filter by date + /// Filter by date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? log = null, + DateTime? messageDateBefore = null, + DateTime? messageDate = null, + DateTime? messageDateAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNotificationOptions() { PathAccountSid = pathAccountSid, Log = log, MessageDateBefore = messageDateBefore, MessageDate = messageDate, MessageDateAfter = messageDateAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("notifications", response.Content); + } + + /// + /// Converts a JSON string into a NotificationResource object + /// + /// Raw JSON string + /// NotificationResource object represented by the provided JSON + public static NotificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to generate the notification + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A unique error code corresponding to the notification + /// + [JsonProperty("error_code")] + public string ErrorCode { get; private set; } + /// + /// An integer log level + /// + [JsonProperty("log")] + public string Log { get; private set; } + /// + /// The date the notification was generated + /// + [JsonProperty("message_date")] + public DateTime? MessageDate { get; private set; } + /// + /// The text of the notification + /// + [JsonProperty("message_text")] + public string MessageText { get; private set; } + /// + /// A URL for more information about the error code + /// + [JsonProperty("more_info")] + public Uri MoreInfo { get; private set; } + /// + /// HTTP method used with the request url + /// + [JsonProperty("request_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod RequestMethod { get; private set; } + /// + /// URL of the resource that generated the notification + /// + [JsonProperty("request_url")] + public Uri RequestUrl { get; private set; } + /// + /// Twilio-generated HTTP variables sent to the server + /// + [JsonProperty("request_variables")] + public string RequestVariables { get; private set; } + /// + /// The HTTP body returned by your server + /// + [JsonProperty("response_body")] + public string ResponseBody { get; private set; } + /// + /// The HTTP headers returned by your server + /// + [JsonProperty("response_headers")] + public string ResponseHeaders { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private NotificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdOptions.cs b/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdOptions.cs index c501c7a69..c220c2733 100644 --- a/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdOptions.cs @@ -9,157 +9,157 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an outgoing-caller-id belonging to the account used to make the request + /// + public class FetchOutgoingCallerIdOptions : IOptions + { /// - /// Fetch an outgoing-caller-id belonging to the account used to make the request - /// - public class FetchOutgoingCallerIdOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchOutgoingCallerIdOptions - /// - /// The unique string that identifies the resource - public FetchOutgoingCallerIdOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } /// - /// Updates the caller-id - /// - public class UpdateOutgoingCallerIdOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateOutgoingCallerIdOptions - /// - /// The unique string that identifies the resource - public UpdateOutgoingCallerIdOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// Delete the caller-id specified from the account - /// - public class DeleteOutgoingCallerIdOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteOutgoingCallerIdOptions - /// - /// The unique string that identifies the resource - public DeleteOutgoingCallerIdOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchOutgoingCallerIdOptions + /// + /// The unique string that identifies the resource + public FetchOutgoingCallerIdOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request - /// - public class ReadOutgoingCallerIdOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The phone number of the OutgoingCallerId resources to read - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// The string that identifies the OutgoingCallerId resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Updates the caller-id + /// + public class UpdateOutgoingCallerIdOptions : IOptions + { + /// + /// The SID of the Account that created the resources to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateOutgoingCallerIdOptions + /// + /// The unique string that identifies the resource + public UpdateOutgoingCallerIdOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete the caller-id specified from the account + /// + public class DeleteOutgoingCallerIdOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteOutgoingCallerIdOptions + /// + /// The unique string that identifies the resource + public DeleteOutgoingCallerIdOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request + /// + public class ReadOutgoingCallerIdOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The phone number of the OutgoingCallerId resources to read + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// The string that identifies the OutgoingCallerId resources to read + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdResource.cs b/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdResource.cs index 3115ab484..063436101 100644 --- a/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/OutgoingCallerIdResource.cs @@ -16,430 +16,430 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class OutgoingCallerIdResource : Resource - { - private static Request BuildFetchRequest(FetchOutgoingCallerIdOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an outgoing-caller-id belonging to the account used to make the request - /// - /// Fetch OutgoingCallerId parameters - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static OutgoingCallerIdResource Fetch(FetchOutgoingCallerIdOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an outgoing-caller-id belonging to the account used to make the request - /// - /// Fetch OutgoingCallerId parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task FetchAsync(FetchOutgoingCallerIdOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an outgoing-caller-id belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static OutgoingCallerIdResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an outgoing-caller-id belonging to the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateOutgoingCallerIdOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the caller-id - /// - /// Update OutgoingCallerId parameters - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static OutgoingCallerIdResource Update(UpdateOutgoingCallerIdOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the caller-id - /// - /// Update OutgoingCallerId parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task UpdateAsync(UpdateOutgoingCallerIdOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the caller-id - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static OutgoingCallerIdResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the caller-id - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteOutgoingCallerIdOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete the caller-id specified from the account - /// - /// Delete OutgoingCallerId parameters - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static bool Delete(DeleteOutgoingCallerIdOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete the caller-id specified from the account - /// - /// Delete OutgoingCallerId parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task DeleteAsync(DeleteOutgoingCallerIdOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete the caller-id specified from the account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete the caller-id specified from the account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteOutgoingCallerIdOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadOutgoingCallerIdOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request - /// - /// Read OutgoingCallerId parameters - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static ResourceSet Read(ReadOutgoingCallerIdOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("outgoing_caller_ids", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request - /// - /// Read OutgoingCallerId parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task> ReadAsync(ReadOutgoingCallerIdOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("outgoing_caller_ids", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The phone number of the OutgoingCallerId resources to read - /// The string that identifies the OutgoingCallerId resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of OutgoingCallerId - public static ResourceSet Read(string pathAccountSid = null, - Types.PhoneNumber phoneNumber = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadOutgoingCallerIdOptions(){PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The phone number of the OutgoingCallerId resources to read - /// The string that identifies the OutgoingCallerId resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OutgoingCallerId - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - Types.PhoneNumber phoneNumber = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadOutgoingCallerIdOptions(){PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("outgoing_caller_ids", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("outgoing_caller_ids", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("outgoing_caller_ids", response.Content); - } - - /// - /// Converts a JSON string into a OutgoingCallerIdResource object - /// - /// Raw JSON string - /// OutgoingCallerIdResource object represented by the provided JSON - public static OutgoingCallerIdResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private OutgoingCallerIdResource() - { - - } - } +{ + + public class OutgoingCallerIdResource : Resource + { + private static Request BuildFetchRequest(FetchOutgoingCallerIdOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an outgoing-caller-id belonging to the account used to make the request + /// + /// Fetch OutgoingCallerId parameters + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static OutgoingCallerIdResource Fetch(FetchOutgoingCallerIdOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an outgoing-caller-id belonging to the account used to make the request + /// + /// Fetch OutgoingCallerId parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task FetchAsync(FetchOutgoingCallerIdOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an outgoing-caller-id belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static OutgoingCallerIdResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an outgoing-caller-id belonging to the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateOutgoingCallerIdOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the caller-id + /// + /// Update OutgoingCallerId parameters + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static OutgoingCallerIdResource Update(UpdateOutgoingCallerIdOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the caller-id + /// + /// Update OutgoingCallerId parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task UpdateAsync(UpdateOutgoingCallerIdOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the caller-id + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static OutgoingCallerIdResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the caller-id + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteOutgoingCallerIdOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete the caller-id specified from the account + /// + /// Delete OutgoingCallerId parameters + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static bool Delete(DeleteOutgoingCallerIdOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete the caller-id specified from the account + /// + /// Delete OutgoingCallerId parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task DeleteAsync(DeleteOutgoingCallerIdOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete the caller-id specified from the account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete the caller-id specified from the account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteOutgoingCallerIdOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadOutgoingCallerIdOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request + /// + /// Read OutgoingCallerId parameters + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static ResourceSet Read(ReadOutgoingCallerIdOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("outgoing_caller_ids", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request + /// + /// Read OutgoingCallerId parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task> ReadAsync(ReadOutgoingCallerIdOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("outgoing_caller_ids", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The phone number of the OutgoingCallerId resources to read + /// The string that identifies the OutgoingCallerId resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of OutgoingCallerId + public static ResourceSet Read(string pathAccountSid = null, + Types.PhoneNumber phoneNumber = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadOutgoingCallerIdOptions() { PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of outgoing-caller-ids belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The phone number of the OutgoingCallerId resources to read + /// The string that identifies the OutgoingCallerId resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OutgoingCallerId + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + Types.PhoneNumber phoneNumber = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadOutgoingCallerIdOptions() { PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("outgoing_caller_ids", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("outgoing_caller_ids", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("outgoing_caller_ids", response.Content); + } + + /// + /// Converts a JSON string into a OutgoingCallerIdResource object + /// + /// Raw JSON string + /// OutgoingCallerIdResource object represented by the provided JSON + public static OutgoingCallerIdResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private OutgoingCallerIdResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Queue/MemberOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Queue/MemberOptions.cs index 35176a255..9d03c722f 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Queue/MemberOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Queue/MemberOptions.cs @@ -9,142 +9,142 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Queue -{ - +{ + + /// + /// Fetch a specific member from the queue + /// + public class FetchMemberOptions : IOptions + { /// - /// Fetch a specific member from the queue - /// - public class FetchMemberOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Queue in which to find the members - /// - public string PathQueueSid { get; } - /// - /// The Call SID of the resource(s) to fetch - /// - public string PathCallSid { get; } - - /// - /// Construct a new FetchMemberOptions - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to fetch - public FetchMemberOptions(string pathQueueSid, string pathCallSid) - { - PathQueueSid = pathQueueSid; - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } /// - /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL - /// - public class UpdateMemberOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to update - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Queue in which to find the members - /// - public string PathQueueSid { get; } - /// - /// The Call SID of the resource(s) to update - /// - public string PathCallSid { get; } - /// - /// The absolute URL of the Queue resource - /// - public Uri Url { get; } - /// - /// How to pass the update request data - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Construct a new UpdateMemberOptions - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to update - /// The absolute URL of the Queue resource - public UpdateMemberOptions(string pathQueueSid, string pathCallSid, Uri url) - { - PathQueueSid = pathQueueSid; - PathCallSid = pathCallSid; - Url = url; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Url != null) - { - p.Add(new KeyValuePair("Url", Serializers.Url(Url))); - } - - if (Method != null) - { - p.Add(new KeyValuePair("Method", Method.ToString())); - } - - return p; - } - } - + /// The SID of the Queue in which to find the members + /// + public string PathQueueSid { get; } /// - /// Retrieve the members of the queue - /// - public class ReadMemberOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the Queue in which to find the members - /// - public string PathQueueSid { get; } - - /// - /// Construct a new ReadMemberOptions - /// - /// The SID of the Queue in which to find the members - public ReadMemberOptions(string pathQueueSid) - { - PathQueueSid = pathQueueSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The Call SID of the resource(s) to fetch + /// + public string PathCallSid { get; } + + /// + /// Construct a new FetchMemberOptions + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to fetch + public FetchMemberOptions(string pathQueueSid, string pathCallSid) + { + PathQueueSid = pathQueueSid; + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL + /// + public class UpdateMemberOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to update + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Queue in which to find the members + /// + public string PathQueueSid { get; } + /// + /// The Call SID of the resource(s) to update + /// + public string PathCallSid { get; } + /// + /// The absolute URL of the Queue resource + /// + public Uri Url { get; } + /// + /// How to pass the update request data + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Construct a new UpdateMemberOptions + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to update + /// The absolute URL of the Queue resource + public UpdateMemberOptions(string pathQueueSid, string pathCallSid, Uri url) + { + PathQueueSid = pathQueueSid; + PathCallSid = pathCallSid; + Url = url; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Url != null) + { + p.Add(new KeyValuePair("Url", Serializers.Url(Url))); + } + + if (Method != null) + { + p.Add(new KeyValuePair("Method", Method.ToString())); + } + + return p; + } + } + + /// + /// Retrieve the members of the queue + /// + public class ReadMemberOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the Queue in which to find the members + /// + public string PathQueueSid { get; } + + /// + /// Construct a new ReadMemberOptions + /// + /// The SID of the Queue in which to find the members + public ReadMemberOptions(string pathQueueSid) + { + PathQueueSid = pathQueueSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Queue/MemberResource.cs b/src/Twilio/Rest/Api/V2010/Account/Queue/MemberResource.cs index 0431d4592..a862fcba7 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Queue/MemberResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Queue/MemberResource.cs @@ -16,360 +16,360 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Queue -{ - - public class MemberResource : Resource - { - private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members/" + options.PathCallSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific member from the queue - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific member from the queue - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific member from the queue - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to fetch - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(string pathQueueSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathQueueSid, pathCallSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific member from the queue - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to fetch - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(string pathQueueSid, - string pathCallSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathQueueSid, pathCallSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members/" + options.PathCallSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to update - /// The absolute URL of the Queue resource - /// The SID of the Account that created the resource(s) to update - /// How to pass the update request data - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(string pathQueueSid, - string pathCallSid, - Uri url, - string pathAccountSid = null, - Twilio.Http.HttpMethod method = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathQueueSid, pathCallSid, url){PathAccountSid = pathAccountSid, Method = method}; - return Update(options, client); - } - - #if !NET35 - /// - /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL - /// - /// The SID of the Queue in which to find the members - /// The Call SID of the resource(s) to update - /// The absolute URL of the Queue resource - /// The SID of the Account that created the resource(s) to update - /// How to pass the update request data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(string pathQueueSid, - string pathCallSid, - Uri url, - string pathAccountSid = null, - Twilio.Http.HttpMethod method = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathQueueSid, pathCallSid, url){PathAccountSid = pathAccountSid, Method = method}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the members of the queue - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("queue_members", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve the members of the queue - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("queue_members", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve the members of the queue - /// - /// The SID of the Queue in which to find the members - /// The SID of the Account that created the resource(s) to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(string pathQueueSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathQueueSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve the members of the queue - /// - /// The SID of the Queue in which to find the members - /// The SID of the Account that created the resource(s) to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(string pathQueueSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathQueueSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("queue_members", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("queue_members", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("queue_members", response.Content); - } - - /// - /// Converts a JSON string into a MemberResource object - /// - /// Raw JSON string - /// MemberResource object represented by the provided JSON - public static MemberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The date the member was enqueued - /// - [JsonProperty("date_enqueued")] - public DateTime? DateEnqueued { get; private set; } - /// - /// This member's current position in the queue. - /// - [JsonProperty("position")] - public int? Position { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The number of seconds the member has been in the queue. - /// - [JsonProperty("wait_time")] - public int? WaitTime { get; private set; } - /// - /// The SID of the Queue the member is in - /// - [JsonProperty("queue_sid")] - public string QueueSid { get; private set; } - - private MemberResource() - { - - } - } +{ + + public class MemberResource : Resource + { + private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members/" + options.PathCallSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific member from the queue + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific member from the queue + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific member from the queue + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to fetch + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(string pathQueueSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathQueueSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific member from the queue + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to fetch + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(string pathQueueSid, + string pathCallSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathQueueSid, pathCallSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members/" + options.PathCallSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to update + /// The absolute URL of the Queue resource + /// The SID of the Account that created the resource(s) to update + /// How to pass the update request data + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(string pathQueueSid, + string pathCallSid, + Uri url, + string pathAccountSid = null, + Twilio.Http.HttpMethod method = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathQueueSid, pathCallSid, url) { PathAccountSid = pathAccountSid, Method = method }; + return Update(options, client); + } + +#if !NET35 + /// + /// Dequeue a member from a queue and have the member's call begin executing the TwiML document at that URL + /// + /// The SID of the Queue in which to find the members + /// The Call SID of the resource(s) to update + /// The absolute URL of the Queue resource + /// The SID of the Account that created the resource(s) to update + /// How to pass the update request data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(string pathQueueSid, + string pathCallSid, + Uri url, + string pathAccountSid = null, + Twilio.Http.HttpMethod method = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathQueueSid, pathCallSid, url) { PathAccountSid = pathAccountSid, Method = method }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathQueueSid + "/Members.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the members of the queue + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("queue_members", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve the members of the queue + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("queue_members", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve the members of the queue + /// + /// The SID of the Queue in which to find the members + /// The SID of the Account that created the resource(s) to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(string pathQueueSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathQueueSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve the members of the queue + /// + /// The SID of the Queue in which to find the members + /// The SID of the Account that created the resource(s) to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(string pathQueueSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathQueueSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("queue_members", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("queue_members", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("queue_members", response.Content); + } + + /// + /// Converts a JSON string into a MemberResource object + /// + /// Raw JSON string + /// MemberResource object represented by the provided JSON + public static MemberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The date the member was enqueued + /// + [JsonProperty("date_enqueued")] + public DateTime? DateEnqueued { get; private set; } + /// + /// This member's current position in the queue. + /// + [JsonProperty("position")] + public int? Position { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The number of seconds the member has been in the queue. + /// + [JsonProperty("wait_time")] + public int? WaitTime { get; private set; } + /// + /// The SID of the Queue the member is in + /// + [JsonProperty("queue_sid")] + public string QueueSid { get; private set; } + + private MemberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/QueueOptions.cs b/src/Twilio/Rest/Api/V2010/Account/QueueOptions.cs index b01ff65f9..a0090240f 100644 --- a/src/Twilio/Rest/Api/V2010/Account/QueueOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/QueueOptions.cs @@ -9,195 +9,195 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a queue identified by the QueueSid + /// + public class FetchQueueOptions : IOptions + { /// - /// Fetch an instance of a queue identified by the QueueSid - /// - public class FetchQueueOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchQueueOptions - /// - /// The unique string that identifies this resource - public FetchQueueOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } /// - /// Update the queue with the new parameters - /// - public class UpdateQueueOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - /// - /// A string to describe this resource - /// - public string FriendlyName { get; set; } - /// - /// The max number of calls allowed in the queue - /// - public int? MaxSize { get; set; } - - /// - /// Construct a new UpdateQueueOptions - /// - /// The unique string that identifies this resource - public UpdateQueueOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (MaxSize != null) - { - p.Add(new KeyValuePair("MaxSize", MaxSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// - /// Remove an empty queue - /// - public class DeleteQueueOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteQueueOptions - /// - /// The unique string that identifies this resource - public DeleteQueueOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchQueueOptions + /// + /// The unique string that identifies this resource + public FetchQueueOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Retrieve a list of queues belonging to the account used to make the request + /// Generate the necessary parameters /// - public class ReadQueueOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the queue with the new parameters + /// + public class UpdateQueueOptions : IOptions + { /// - /// Create a queue - /// - public class CreateQueueOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// A string to describe this resource - /// - public string FriendlyName { get; } - /// - /// The max number of calls allowed in the queue - /// - public int? MaxSize { get; set; } - - /// - /// Construct a new CreateQueueOptions - /// - /// A string to describe this resource - public CreateQueueOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (MaxSize != null) - { - p.Add(new KeyValuePair("MaxSize", MaxSize.ToString())); - } - - return p; - } - } + /// The SID of the Account that created the resource(s) to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// + /// A string to describe this resource + /// + public string FriendlyName { get; set; } + /// + /// The max number of calls allowed in the queue + /// + public int? MaxSize { get; set; } + + /// + /// Construct a new UpdateQueueOptions + /// + /// The unique string that identifies this resource + public UpdateQueueOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (MaxSize != null) + { + p.Add(new KeyValuePair("MaxSize", MaxSize.ToString())); + } + + return p; + } + } + + /// + /// Remove an empty queue + /// + public class DeleteQueueOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteQueueOptions + /// + /// The unique string that identifies this resource + public DeleteQueueOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of queues belonging to the account used to make the request + /// + public class ReadQueueOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a queue + /// + public class CreateQueueOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// A string to describe this resource + /// + public string FriendlyName { get; } + /// + /// The max number of calls allowed in the queue + /// + public int? MaxSize { get; set; } + + /// + /// Construct a new CreateQueueOptions + /// + /// A string to describe this resource + public CreateQueueOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (MaxSize != null) + { + p.Add(new KeyValuePair("MaxSize", MaxSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/QueueResource.cs b/src/Twilio/Rest/Api/V2010/Account/QueueResource.cs index dedc66885..c8a2dbb01 100644 --- a/src/Twilio/Rest/Api/V2010/Account/QueueResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/QueueResource.cs @@ -16,507 +16,507 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class QueueResource : Resource - { - private static Request BuildFetchRequest(FetchQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a queue identified by the QueueSid - /// - /// Fetch Queue parameters - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Fetch(FetchQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a queue identified by the QueueSid - /// - /// Fetch Queue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task FetchAsync(FetchQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a queue identified by the QueueSid - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchQueueOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a queue identified by the QueueSid - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchQueueOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the queue with the new parameters - /// - /// Update Queue parameters - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Update(UpdateQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the queue with the new parameters - /// - /// Update Queue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the queue with the new parameters - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// A string to describe this resource - /// The max number of calls allowed in the queue - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - int? maxSize = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueueOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, MaxSize = maxSize}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the queue with the new parameters - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// A string to describe this resource - /// The max number of calls allowed in the queue - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - int? maxSize = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueueOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, MaxSize = maxSize}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an empty queue - /// - /// Delete Queue parameters - /// Client to make requests to Twilio - /// A single instance of Queue - public static bool Delete(DeleteQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an empty queue - /// - /// Delete Queue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an empty queue - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// A single instance of Queue - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteQueueOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an empty queue - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteQueueOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of queues belonging to the account used to make the request - /// - /// Read Queue parameters - /// Client to make requests to Twilio - /// A single instance of Queue - public static ResourceSet Read(ReadQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("queues", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of queues belonging to the account used to make the request - /// - /// Read Queue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task> ReadAsync(ReadQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("queues", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of queues belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to fetch - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Queue - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueueOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of queues belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to fetch - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueueOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("queues", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("queues", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("queues", response.Content); - } - - private static Request BuildCreateRequest(CreateQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a queue - /// - /// Create Queue parameters - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Create(CreateQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a queue - /// - /// Create Queue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task CreateAsync(CreateQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a queue - /// - /// A string to describe this resource - /// The SID of the Account that will create the resource - /// The max number of calls allowed in the queue - /// Client to make requests to Twilio - /// A single instance of Queue - public static QueueResource Create(string friendlyName, - string pathAccountSid = null, - int? maxSize = null, - ITwilioRestClient client = null) - { - var options = new CreateQueueOptions(friendlyName){PathAccountSid = pathAccountSid, MaxSize = maxSize}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a queue - /// - /// A string to describe this resource - /// The SID of the Account that will create the resource - /// The max number of calls allowed in the queue - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Queue - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string pathAccountSid = null, - int? maxSize = null, - ITwilioRestClient client = null) - { - var options = new CreateQueueOptions(friendlyName){PathAccountSid = pathAccountSid, MaxSize = maxSize}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a QueueResource object - /// - /// Raw JSON string - /// QueueResource object represented by the provided JSON - public static QueueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The number of calls currently in the queue. - /// - [JsonProperty("current_size")] - public int? CurrentSize { get; private set; } - /// - /// A string that you assigned to describe this resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The URI of this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Average wait time of members in the queue - /// - [JsonProperty("average_wait_time")] - public int? AverageWaitTime { get; private set; } - /// - /// The unique string that identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The max number of calls allowed in the queue - /// - [JsonProperty("max_size")] - public int? MaxSize { get; private set; } - - private QueueResource() - { - - } - } +{ + + public class QueueResource : Resource + { + private static Request BuildFetchRequest(FetchQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a queue identified by the QueueSid + /// + /// Fetch Queue parameters + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Fetch(FetchQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a queue identified by the QueueSid + /// + /// Fetch Queue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task FetchAsync(FetchQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a queue identified by the QueueSid + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchQueueOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a queue identified by the QueueSid + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchQueueOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the queue with the new parameters + /// + /// Update Queue parameters + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Update(UpdateQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the queue with the new parameters + /// + /// Update Queue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the queue with the new parameters + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// A string to describe this resource + /// The max number of calls allowed in the queue + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + int? maxSize = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueueOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, MaxSize = maxSize }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the queue with the new parameters + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// A string to describe this resource + /// The max number of calls allowed in the queue + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + int? maxSize = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueueOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, MaxSize = maxSize }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an empty queue + /// + /// Delete Queue parameters + /// Client to make requests to Twilio + /// A single instance of Queue + public static bool Delete(DeleteQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an empty queue + /// + /// Delete Queue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an empty queue + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// A single instance of Queue + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteQueueOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an empty queue + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteQueueOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of queues belonging to the account used to make the request + /// + /// Read Queue parameters + /// Client to make requests to Twilio + /// A single instance of Queue + public static ResourceSet Read(ReadQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("queues", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of queues belonging to the account used to make the request + /// + /// Read Queue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task> ReadAsync(ReadQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("queues", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of queues belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to fetch + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Queue + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueueOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of queues belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to fetch + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueueOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("queues", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("queues", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("queues", response.Content); + } + + private static Request BuildCreateRequest(CreateQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Queues.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a queue + /// + /// Create Queue parameters + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Create(CreateQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a queue + /// + /// Create Queue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task CreateAsync(CreateQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a queue + /// + /// A string to describe this resource + /// The SID of the Account that will create the resource + /// The max number of calls allowed in the queue + /// Client to make requests to Twilio + /// A single instance of Queue + public static QueueResource Create(string friendlyName, + string pathAccountSid = null, + int? maxSize = null, + ITwilioRestClient client = null) + { + var options = new CreateQueueOptions(friendlyName) { PathAccountSid = pathAccountSid, MaxSize = maxSize }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a queue + /// + /// A string to describe this resource + /// The SID of the Account that will create the resource + /// The max number of calls allowed in the queue + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Queue + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string pathAccountSid = null, + int? maxSize = null, + ITwilioRestClient client = null) + { + var options = new CreateQueueOptions(friendlyName) { PathAccountSid = pathAccountSid, MaxSize = maxSize }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a QueueResource object + /// + /// Raw JSON string + /// QueueResource object represented by the provided JSON + public static QueueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The number of calls currently in the queue. + /// + [JsonProperty("current_size")] + public int? CurrentSize { get; private set; } + /// + /// A string that you assigned to describe this resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The URI of this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Average wait time of members in the queue + /// + [JsonProperty("average_wait_time")] + public int? AverageWaitTime { get; private set; } + /// + /// The unique string that identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The max number of calls allowed in the queue + /// + [JsonProperty("max_size")] + public int? MaxSize { get; private set; } + + private QueueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadOptions.cs index 6e9575482..a3b5670f2 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadOptions.cs @@ -9,143 +9,143 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Recording.AddOnResult -{ - +{ + + /// + /// Fetch an instance of a result payload + /// + public class FetchPayloadOptions : IOptions + { /// - /// Fetch an instance of a result payload - /// - public class FetchPayloadOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs - /// - public string PathReferenceSid { get; } - /// - /// The SID of the AddOnResult to which the payload to fetch belongs - /// - public string PathAddOnResultSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPayloadOptions - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payload to fetch belongs - /// The SID of the AddOnResult to which the payload to fetch belongs - /// The unique string that identifies the resource to fetch - public FetchPayloadOptions(string pathReferenceSid, string pathAddOnResultSid, string pathSid) - { - PathReferenceSid = pathReferenceSid; - PathAddOnResultSid = pathAddOnResultSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } /// - /// Retrieve a list of payloads belonging to the AddOnResult - /// - public class ReadPayloadOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the AddOnResult resource that contains the payloads to read belongs - /// - public string PathReferenceSid { get; } - /// - /// The SID of the AddOnResult to which the payloads to read belongs - /// - public string PathAddOnResultSid { get; } - - /// - /// Construct a new ReadPayloadOptions - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to read belongs - /// The SID of the AddOnResult to which the payloads to read belongs - public ReadPayloadOptions(string pathReferenceSid, string pathAddOnResultSid) - { - PathReferenceSid = pathReferenceSid; - PathAddOnResultSid = pathAddOnResultSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs + /// + public string PathReferenceSid { get; } /// - /// Delete a payload from the result along with all associated Data - /// - public class DeletePayloadOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the AddOnResult resource that contains the payloads to delete belongs - /// - public string PathReferenceSid { get; } - /// - /// The SID of the AddOnResult to which the payloads to delete belongs - /// - public string PathAddOnResultSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeletePayloadOptions - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to delete belongs - /// The SID of the AddOnResult to which the payloads to delete belongs - /// The unique string that identifies the resource - public DeletePayloadOptions(string pathReferenceSid, string pathAddOnResultSid, string pathSid) - { - PathReferenceSid = pathReferenceSid; - PathAddOnResultSid = pathAddOnResultSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the AddOnResult to which the payload to fetch belongs + /// + public string PathAddOnResultSid { get; } + /// + /// The unique string that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPayloadOptions + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payload to fetch belongs + /// The SID of the AddOnResult to which the payload to fetch belongs + /// The unique string that identifies the resource to fetch + public FetchPayloadOptions(string pathReferenceSid, string pathAddOnResultSid, string pathSid) + { + PathReferenceSid = pathReferenceSid; + PathAddOnResultSid = pathAddOnResultSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of payloads belonging to the AddOnResult + /// + public class ReadPayloadOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording to which the AddOnResult resource that contains the payloads to read belongs + /// + public string PathReferenceSid { get; } + /// + /// The SID of the AddOnResult to which the payloads to read belongs + /// + public string PathAddOnResultSid { get; } + + /// + /// Construct a new ReadPayloadOptions + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to read belongs + /// The SID of the AddOnResult to which the payloads to read belongs + public ReadPayloadOptions(string pathReferenceSid, string pathAddOnResultSid) + { + PathReferenceSid = pathReferenceSid; + PathAddOnResultSid = pathAddOnResultSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a payload from the result along with all associated Data + /// + public class DeletePayloadOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording to which the AddOnResult resource that contains the payloads to delete belongs + /// + public string PathReferenceSid { get; } + /// + /// The SID of the AddOnResult to which the payloads to delete belongs + /// + public string PathAddOnResultSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeletePayloadOptions + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to delete belongs + /// The SID of the AddOnResult to which the payloads to delete belongs + /// The unique string that identifies the resource + public DeletePayloadOptions(string pathReferenceSid, string pathAddOnResultSid, string pathSid) + { + PathReferenceSid = pathReferenceSid; + PathAddOnResultSid = pathAddOnResultSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadResource.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadResource.cs index ac0b76719..8c3208864 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResult/PayloadResource.cs @@ -16,395 +16,395 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Recording.AddOnResult -{ - - public class PayloadResource : Resource - { - private static Request BuildFetchRequest(FetchPayloadOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a result payload - /// - /// Fetch Payload parameters - /// Client to make requests to Twilio - /// A single instance of Payload - public static PayloadResource Fetch(FetchPayloadOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a result payload - /// - /// Fetch Payload parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task FetchAsync(FetchPayloadOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a result payload - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payload to fetch belongs - /// The SID of the AddOnResult to which the payload to fetch belongs - /// The unique string that identifies the resource to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Payload - public static PayloadResource Fetch(string pathReferenceSid, - string pathAddOnResultSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchPayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a result payload - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payload to fetch belongs - /// The SID of the AddOnResult to which the payload to fetch belongs - /// The unique string that identifies the resource to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task FetchAsync(string pathReferenceSid, - string pathAddOnResultSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchPayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPayloadOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of payloads belonging to the AddOnResult - /// - /// Read Payload parameters - /// Client to make requests to Twilio - /// A single instance of Payload - public static ResourceSet Read(ReadPayloadOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("payloads", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of payloads belonging to the AddOnResult - /// - /// Read Payload parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task> ReadAsync(ReadPayloadOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("payloads", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of payloads belonging to the AddOnResult - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to read belongs - /// The SID of the AddOnResult to which the payloads to read belongs - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Payload - public static ResourceSet Read(string pathReferenceSid, - string pathAddOnResultSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPayloadOptions(pathReferenceSid, pathAddOnResultSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of payloads belonging to the AddOnResult - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to read belongs - /// The SID of the AddOnResult to which the payloads to read belongs - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task> ReadAsync(string pathReferenceSid, - string pathAddOnResultSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPayloadOptions(pathReferenceSid, pathAddOnResultSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("payloads", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("payloads", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("payloads", response.Content); - } - - private static Request BuildDeleteRequest(DeletePayloadOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a payload from the result along with all associated Data - /// - /// Delete Payload parameters - /// Client to make requests to Twilio - /// A single instance of Payload - public static bool Delete(DeletePayloadOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a payload from the result along with all associated Data - /// - /// Delete Payload parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task DeleteAsync(DeletePayloadOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a payload from the result along with all associated Data - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to delete belongs - /// The SID of the AddOnResult to which the payloads to delete belongs - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Payload - public static bool Delete(string pathReferenceSid, - string pathAddOnResultSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeletePayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a payload from the result along with all associated Data - /// - /// The SID of the recording to which the AddOnResult resource that contains the - /// payloads to delete belongs - /// The SID of the AddOnResult to which the payloads to delete belongs - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Payload - public static async System.Threading.Tasks.Task DeleteAsync(string pathReferenceSid, - string pathAddOnResultSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeletePayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PayloadResource object - /// - /// Raw JSON string - /// PayloadResource object represented by the provided JSON - public static PayloadResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the AddOnResult to which the payload belongs - /// - [JsonProperty("add_on_result_sid")] - public string AddOnResultSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that describes the payload - /// - [JsonProperty("label")] - public string Label { get; private set; } - /// - /// The SID of the Add-on to which the result belongs - /// - [JsonProperty("add_on_sid")] - public string AddOnSid { get; private set; } - /// - /// The SID of the Add-on configuration - /// - [JsonProperty("add_on_configuration_sid")] - public string AddOnConfigurationSid { get; private set; } - /// - /// The MIME type of the payload - /// - [JsonProperty("content_type")] - public string ContentType { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the recording to which the AddOnResult resource that contains the payload belongs - /// - [JsonProperty("reference_sid")] - public string ReferenceSid { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private PayloadResource() - { - - } - } +{ + + public class PayloadResource : Resource + { + private static Request BuildFetchRequest(FetchPayloadOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a result payload + /// + /// Fetch Payload parameters + /// Client to make requests to Twilio + /// A single instance of Payload + public static PayloadResource Fetch(FetchPayloadOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a result payload + /// + /// Fetch Payload parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task FetchAsync(FetchPayloadOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a result payload + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payload to fetch belongs + /// The SID of the AddOnResult to which the payload to fetch belongs + /// The unique string that identifies the resource to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Payload + public static PayloadResource Fetch(string pathReferenceSid, + string pathAddOnResultSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchPayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a result payload + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payload to fetch belongs + /// The SID of the AddOnResult to which the payload to fetch belongs + /// The unique string that identifies the resource to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task FetchAsync(string pathReferenceSid, + string pathAddOnResultSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchPayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPayloadOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of payloads belonging to the AddOnResult + /// + /// Read Payload parameters + /// Client to make requests to Twilio + /// A single instance of Payload + public static ResourceSet Read(ReadPayloadOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("payloads", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of payloads belonging to the AddOnResult + /// + /// Read Payload parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task> ReadAsync(ReadPayloadOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("payloads", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of payloads belonging to the AddOnResult + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to read belongs + /// The SID of the AddOnResult to which the payloads to read belongs + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Payload + public static ResourceSet Read(string pathReferenceSid, + string pathAddOnResultSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPayloadOptions(pathReferenceSid, pathAddOnResultSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of payloads belonging to the AddOnResult + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to read belongs + /// The SID of the AddOnResult to which the payloads to read belongs + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task> ReadAsync(string pathReferenceSid, + string pathAddOnResultSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPayloadOptions(pathReferenceSid, pathAddOnResultSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("payloads", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("payloads", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("payloads", response.Content); + } + + private static Request BuildDeleteRequest(DeletePayloadOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathAddOnResultSid + "/Payloads/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a payload from the result along with all associated Data + /// + /// Delete Payload parameters + /// Client to make requests to Twilio + /// A single instance of Payload + public static bool Delete(DeletePayloadOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a payload from the result along with all associated Data + /// + /// Delete Payload parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task DeleteAsync(DeletePayloadOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a payload from the result along with all associated Data + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to delete belongs + /// The SID of the AddOnResult to which the payloads to delete belongs + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Payload + public static bool Delete(string pathReferenceSid, + string pathAddOnResultSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeletePayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a payload from the result along with all associated Data + /// + /// The SID of the recording to which the AddOnResult resource that contains the + /// payloads to delete belongs + /// The SID of the AddOnResult to which the payloads to delete belongs + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Payload + public static async System.Threading.Tasks.Task DeleteAsync(string pathReferenceSid, + string pathAddOnResultSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeletePayloadOptions(pathReferenceSid, pathAddOnResultSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PayloadResource object + /// + /// Raw JSON string + /// PayloadResource object represented by the provided JSON + public static PayloadResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the AddOnResult to which the payload belongs + /// + [JsonProperty("add_on_result_sid")] + public string AddOnResultSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that describes the payload + /// + [JsonProperty("label")] + public string Label { get; private set; } + /// + /// The SID of the Add-on to which the result belongs + /// + [JsonProperty("add_on_sid")] + public string AddOnSid { get; private set; } + /// + /// The SID of the Add-on configuration + /// + [JsonProperty("add_on_configuration_sid")] + public string AddOnConfigurationSid { get; private set; } + /// + /// The MIME type of the payload + /// + [JsonProperty("content_type")] + public string ContentType { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the recording to which the AddOnResult resource that contains the payload belongs + /// + [JsonProperty("reference_sid")] + public string ReferenceSid { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private PayloadResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultOptions.cs index 4f0fdab4e..a4539f53e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultOptions.cs @@ -9,122 +9,122 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Recording -{ - +{ + + /// + /// Fetch an instance of an AddOnResult + /// + public class FetchAddOnResultOptions : IOptions + { /// - /// Fetch an instance of an AddOnResult + /// The SID of the Account that created the resource to fetch /// - public class FetchAddOnResultOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the result to fetch belongs - /// - public string PathReferenceSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAddOnResultOptions - /// - /// The SID of the recording to which the result to fetch belongs - /// The unique string that identifies the resource to fetch - public FetchAddOnResultOptions(string pathReferenceSid, string pathSid) - { - PathReferenceSid = pathReferenceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Retrieve a list of results belonging to the recording + /// The SID of the recording to which the result to fetch belongs /// - public class ReadAddOnResultOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the result to read belongs - /// - public string PathReferenceSid { get; } - - /// - /// Construct a new ReadAddOnResultOptions - /// - /// The SID of the recording to which the result to read belongs - public ReadAddOnResultOptions(string pathReferenceSid) - { - PathReferenceSid = pathReferenceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathReferenceSid { get; } /// - /// Delete a result and purge all associated Payloads + /// The unique string that identifies the resource to fetch /// - public class DeleteAddOnResultOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording to which the result to delete belongs - /// - public string PathReferenceSid { get; } - /// - /// The unique string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAddOnResultOptions - /// - /// The SID of the recording to which the result to delete belongs - /// The unique string that identifies the resource to delete - public DeleteAddOnResultOptions(string pathReferenceSid, string pathSid) - { - PathReferenceSid = pathReferenceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchAddOnResultOptions + /// + /// The SID of the recording to which the result to fetch belongs + /// The unique string that identifies the resource to fetch + public FetchAddOnResultOptions(string pathReferenceSid, string pathSid) + { + PathReferenceSid = pathReferenceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of results belonging to the recording + /// + public class ReadAddOnResultOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording to which the result to read belongs + /// + public string PathReferenceSid { get; } + + /// + /// Construct a new ReadAddOnResultOptions + /// + /// The SID of the recording to which the result to read belongs + public ReadAddOnResultOptions(string pathReferenceSid) + { + PathReferenceSid = pathReferenceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a result and purge all associated Payloads + /// + public class DeleteAddOnResultOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording to which the result to delete belongs + /// + public string PathReferenceSid { get; } + /// + /// The unique string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAddOnResultOptions + /// + /// The SID of the recording to which the result to delete belongs + /// The unique string that identifies the resource to delete + public DeleteAddOnResultOptions(string pathReferenceSid, string pathSid) + { + PathReferenceSid = pathReferenceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultResource.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultResource.cs index 5a7a56a19..5a7363cb9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/AddOnResultResource.cs @@ -17,392 +17,392 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Recording -{ - - public class AddOnResultResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Deleted = new StatusEnum("deleted"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Init = new StatusEnum("init"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Queued = new StatusEnum("queued"); - } - - private static Request BuildFetchRequest(FetchAddOnResultOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an AddOnResult - /// - /// Fetch AddOnResult parameters - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static AddOnResultResource Fetch(FetchAddOnResultOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an AddOnResult - /// - /// Fetch AddOnResult parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task FetchAsync(FetchAddOnResultOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an AddOnResult - /// - /// The SID of the recording to which the result to fetch belongs - /// The unique string that identifies the resource to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static AddOnResultResource Fetch(string pathReferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAddOnResultOptions(pathReferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an AddOnResult - /// - /// The SID of the recording to which the result to fetch belongs - /// The unique string that identifies the resource to fetch - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task FetchAsync(string pathReferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAddOnResultOptions(pathReferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAddOnResultOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of results belonging to the recording - /// - /// Read AddOnResult parameters - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static ResourceSet Read(ReadAddOnResultOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("add_on_results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of results belonging to the recording - /// - /// Read AddOnResult parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task> ReadAsync(ReadAddOnResultOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("add_on_results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of results belonging to the recording - /// - /// The SID of the recording to which the result to read belongs - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static ResourceSet Read(string pathReferenceSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAddOnResultOptions(pathReferenceSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of results belonging to the recording - /// - /// The SID of the recording to which the result to read belongs - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task> ReadAsync(string pathReferenceSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAddOnResultOptions(pathReferenceSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("add_on_results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("add_on_results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("add_on_results", response.Content); - } - - private static Request BuildDeleteRequest(DeleteAddOnResultOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a result and purge all associated Payloads - /// - /// Delete AddOnResult parameters - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static bool Delete(DeleteAddOnResultOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a result and purge all associated Payloads - /// - /// Delete AddOnResult parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAddOnResultOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a result and purge all associated Payloads - /// - /// The SID of the recording to which the result to delete belongs - /// The unique string that identifies the resource to delete - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of AddOnResult - public static bool Delete(string pathReferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAddOnResultOptions(pathReferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a result and purge all associated Payloads - /// - /// The SID of the recording to which the result to delete belongs - /// The unique string that identifies the resource to delete - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AddOnResult - public static async System.Threading.Tasks.Task DeleteAsync(string pathReferenceSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAddOnResultOptions(pathReferenceSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AddOnResultResource object - /// - /// Raw JSON string - /// AddOnResultResource object represented by the provided JSON - public static AddOnResultResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The status of the result - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public AddOnResultResource.StatusEnum Status { get; private set; } - /// - /// The SID of the Add-on to which the result belongs - /// - [JsonProperty("add_on_sid")] - public string AddOnSid { get; private set; } - /// - /// The SID of the Add-on configuration - /// - [JsonProperty("add_on_configuration_sid")] - public string AddOnConfigurationSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The date and time in GMT that the result was completed - /// - [JsonProperty("date_completed")] - public DateTime? DateCompleted { get; private set; } - /// - /// The SID of the recording to which the AddOnResult resource belongs - /// - [JsonProperty("reference_sid")] - public string ReferenceSid { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private AddOnResultResource() - { - - } - } +{ + + public class AddOnResultResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Deleted = new StatusEnum("deleted"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Init = new StatusEnum("init"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Queued = new StatusEnum("queued"); + } + + private static Request BuildFetchRequest(FetchAddOnResultOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an AddOnResult + /// + /// Fetch AddOnResult parameters + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static AddOnResultResource Fetch(FetchAddOnResultOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an AddOnResult + /// + /// Fetch AddOnResult parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task FetchAsync(FetchAddOnResultOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an AddOnResult + /// + /// The SID of the recording to which the result to fetch belongs + /// The unique string that identifies the resource to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static AddOnResultResource Fetch(string pathReferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAddOnResultOptions(pathReferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an AddOnResult + /// + /// The SID of the recording to which the result to fetch belongs + /// The unique string that identifies the resource to fetch + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task FetchAsync(string pathReferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAddOnResultOptions(pathReferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAddOnResultOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of results belonging to the recording + /// + /// Read AddOnResult parameters + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static ResourceSet Read(ReadAddOnResultOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("add_on_results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of results belonging to the recording + /// + /// Read AddOnResult parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task> ReadAsync(ReadAddOnResultOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("add_on_results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of results belonging to the recording + /// + /// The SID of the recording to which the result to read belongs + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static ResourceSet Read(string pathReferenceSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAddOnResultOptions(pathReferenceSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of results belonging to the recording + /// + /// The SID of the recording to which the result to read belongs + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task> ReadAsync(string pathReferenceSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAddOnResultOptions(pathReferenceSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("add_on_results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("add_on_results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("add_on_results", response.Content); + } + + private static Request BuildDeleteRequest(DeleteAddOnResultOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathReferenceSid + "/AddOnResults/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a result and purge all associated Payloads + /// + /// Delete AddOnResult parameters + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static bool Delete(DeleteAddOnResultOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a result and purge all associated Payloads + /// + /// Delete AddOnResult parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAddOnResultOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a result and purge all associated Payloads + /// + /// The SID of the recording to which the result to delete belongs + /// The unique string that identifies the resource to delete + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of AddOnResult + public static bool Delete(string pathReferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAddOnResultOptions(pathReferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a result and purge all associated Payloads + /// + /// The SID of the recording to which the result to delete belongs + /// The unique string that identifies the resource to delete + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AddOnResult + public static async System.Threading.Tasks.Task DeleteAsync(string pathReferenceSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAddOnResultOptions(pathReferenceSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AddOnResultResource object + /// + /// Raw JSON string + /// AddOnResultResource object represented by the provided JSON + public static AddOnResultResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The status of the result + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public AddOnResultResource.StatusEnum Status { get; private set; } + /// + /// The SID of the Add-on to which the result belongs + /// + [JsonProperty("add_on_sid")] + public string AddOnSid { get; private set; } + /// + /// The SID of the Add-on configuration + /// + [JsonProperty("add_on_configuration_sid")] + public string AddOnConfigurationSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The date and time in GMT that the result was completed + /// + [JsonProperty("date_completed")] + public DateTime? DateCompleted { get; private set; } + /// + /// The SID of the recording to which the AddOnResult resource belongs + /// + [JsonProperty("reference_sid")] + public string ReferenceSid { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private AddOnResultResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionOptions.cs index 0529edd94..1f83098a7 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionOptions.cs @@ -9,122 +9,122 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Recording -{ - +{ + + /// + /// FetchTranscriptionOptions + /// + public class FetchTranscriptionOptions : IOptions + { /// - /// FetchTranscriptionOptions + /// The SID of the Account that created the resource to fetch /// - public class FetchTranscriptionOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording that created the transcriptions to fetch - /// - public string PathRecordingSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTranscriptionOptions - /// - /// The SID of the recording that created the transcriptions to fetch - /// The unique string that identifies the resource - public FetchTranscriptionOptions(string pathRecordingSid, string pathSid) - { - PathRecordingSid = pathRecordingSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// DeleteTranscriptionOptions + /// The SID of the recording that created the transcriptions to fetch /// - public class DeleteTranscriptionOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording that created the transcription to delete - /// - public string PathRecordingSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTranscriptionOptions - /// - /// The SID of the recording that created the transcription to delete - /// The unique string that identifies the resource - public DeleteTranscriptionOptions(string pathRecordingSid, string pathSid) - { - PathRecordingSid = pathRecordingSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRecordingSid { get; } /// - /// ReadTranscriptionOptions + /// The unique string that identifies the resource /// - public class ReadTranscriptionOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the recording that created the transcriptions to read - /// - public string PathRecordingSid { get; } - - /// - /// Construct a new ReadTranscriptionOptions - /// - /// The SID of the recording that created the transcriptions to read - public ReadTranscriptionOptions(string pathRecordingSid) - { - PathRecordingSid = pathRecordingSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchTranscriptionOptions + /// + /// The SID of the recording that created the transcriptions to fetch + /// The unique string that identifies the resource + public FetchTranscriptionOptions(string pathRecordingSid, string pathSid) + { + PathRecordingSid = pathRecordingSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteTranscriptionOptions + /// + public class DeleteTranscriptionOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording that created the transcription to delete + /// + public string PathRecordingSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTranscriptionOptions + /// + /// The SID of the recording that created the transcription to delete + /// The unique string that identifies the resource + public DeleteTranscriptionOptions(string pathRecordingSid, string pathSid) + { + PathRecordingSid = pathRecordingSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadTranscriptionOptions + /// + public class ReadTranscriptionOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the recording that created the transcriptions to read + /// + public string PathRecordingSid { get; } + + /// + /// Construct a new ReadTranscriptionOptions + /// + /// The SID of the recording that created the transcriptions to read + public ReadTranscriptionOptions(string pathRecordingSid) + { + PathRecordingSid = pathRecordingSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionResource.cs b/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionResource.cs index b6453291e..a2c136023 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Recording/TranscriptionResource.cs @@ -17,403 +17,403 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Recording -{ - - public class TranscriptionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - private static Request BuildFetchRequest(FetchTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static TranscriptionResource Fetch(FetchTranscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task FetchAsync(FetchTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the recording that created the transcriptions to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Transcription - public static TranscriptionResource Fetch(string pathRecordingSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchTranscriptionOptions(pathRecordingSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the recording that created the transcriptions to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task FetchAsync(string pathRecordingSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchTranscriptionOptions(pathRecordingSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static bool Delete(DeleteTranscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the recording that created the transcription to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Transcription - public static bool Delete(string pathRecordingSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteTranscriptionOptions(pathRecordingSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the recording that created the transcription to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task DeleteAsync(string pathRecordingSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteTranscriptionOptions(pathRecordingSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static ResourceSet Read(ReadTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("transcriptions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task> ReadAsync(ReadTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("transcriptions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the recording that created the transcriptions to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Transcription - public static ResourceSet Read(string pathRecordingSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTranscriptionOptions(pathRecordingSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the recording that created the transcriptions to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task> ReadAsync(string pathRecordingSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTranscriptionOptions(pathRecordingSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Converts a JSON string into a TranscriptionResource object - /// - /// Raw JSON string - /// TranscriptionResource object represented by the provided JSON - public static TranscriptionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the transcription - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The duration of the transcribed audio in seconds. - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The charge for the transcription - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which price is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The SID that identifies the transcription's recording - /// - [JsonProperty("recording_sid")] - public string RecordingSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the transcription - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public TranscriptionResource.StatusEnum Status { get; private set; } - /// - /// The text content of the transcription. - /// - [JsonProperty("transcription_text")] - public string TranscriptionText { get; private set; } - /// - /// The transcription type - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private TranscriptionResource() - { - - } - } +{ + + public class TranscriptionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + private static Request BuildFetchRequest(FetchTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static TranscriptionResource Fetch(FetchTranscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task FetchAsync(FetchTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the recording that created the transcriptions to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Transcription + public static TranscriptionResource Fetch(string pathRecordingSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchTranscriptionOptions(pathRecordingSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the recording that created the transcriptions to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task FetchAsync(string pathRecordingSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchTranscriptionOptions(pathRecordingSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static bool Delete(DeleteTranscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the recording that created the transcription to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Transcription + public static bool Delete(string pathRecordingSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteTranscriptionOptions(pathRecordingSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the recording that created the transcription to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task DeleteAsync(string pathRecordingSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteTranscriptionOptions(pathRecordingSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathRecordingSid + "/Transcriptions.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static ResourceSet Read(ReadTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("transcriptions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task> ReadAsync(ReadTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("transcriptions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the recording that created the transcriptions to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Transcription + public static ResourceSet Read(string pathRecordingSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTranscriptionOptions(pathRecordingSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the recording that created the transcriptions to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task> ReadAsync(string pathRecordingSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTranscriptionOptions(pathRecordingSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Converts a JSON string into a TranscriptionResource object + /// + /// Raw JSON string + /// TranscriptionResource object represented by the provided JSON + public static TranscriptionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the transcription + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The duration of the transcribed audio in seconds. + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The charge for the transcription + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which price is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The SID that identifies the transcription's recording + /// + [JsonProperty("recording_sid")] + public string RecordingSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the transcription + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public TranscriptionResource.StatusEnum Status { get; private set; } + /// + /// The text content of the transcription. + /// + [JsonProperty("transcription_text")] + public string TranscriptionText { get; private set; } + /// + /// The transcription type + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private TranscriptionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/RecordingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/RecordingOptions.cs index a80aba121..0e6ad1128 100644 --- a/src/Twilio/Rest/Api/V2010/Account/RecordingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/RecordingOptions.cs @@ -9,144 +9,144 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a recording + /// + public class FetchRecordingOptions : IOptions + { /// - /// Fetch an instance of a recording + /// The SID of the Account that created the resource to fetch /// - public class FetchRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRecordingOptions - /// - /// The unique string that identifies the resource - public FetchRecordingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Delete a recording from your account + /// The unique string that identifies the resource /// - public class DeleteRecordingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRecordingOptions - /// - /// The unique string that identifies the resource - public DeleteRecordingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a list of recordings belonging to the account used to make the request + /// Construct a new FetchRecordingOptions /// - public class ReadRecordingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// Only include recordings that were created on this date - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Only include recordings that were created on this date - /// - public DateTime? DateCreated { get; set; } - /// - /// Only include recordings that were created on this date - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// The Call SID of the resources to read - /// - public string CallSid { get; set; } - /// - /// Read by unique Conference SID for the recording - /// - public string ConferenceSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - else - { - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreated<", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreated>", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - } - - if (CallSid != null) - { - p.Add(new KeyValuePair("CallSid", CallSid.ToString())); - } - - if (ConferenceSid != null) - { - p.Add(new KeyValuePair("ConferenceSid", ConferenceSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The unique string that identifies the resource + public FetchRecordingOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a recording from your account + /// + public class DeleteRecordingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRecordingOptions + /// + /// The unique string that identifies the resource + public DeleteRecordingOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of recordings belonging to the account used to make the request + /// + public class ReadRecordingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// Only include recordings that were created on this date + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// Only include recordings that were created on this date + /// + public DateTime? DateCreated { get; set; } + /// + /// Only include recordings that were created on this date + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// The Call SID of the resources to read + /// + public string CallSid { get; set; } + /// + /// Read by unique Conference SID for the recording + /// + public string ConferenceSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + else + { + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreated<", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreated>", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + } + + if (CallSid != null) + { + p.Add(new KeyValuePair("CallSid", CallSid.ToString())); + } + + if (ConferenceSid != null) + { + p.Add(new KeyValuePair("ConferenceSid", ConferenceSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/RecordingResource.cs b/src/Twilio/Rest/Api/V2010/Account/RecordingResource.cs index ee3444e25..124aa3b67 100644 --- a/src/Twilio/Rest/Api/V2010/Account/RecordingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/RecordingResource.cs @@ -17,453 +17,453 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class RecordingResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Paused = new StatusEnum("paused"); - public static readonly StatusEnum Stopped = new StatusEnum("stopped"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Absent = new StatusEnum("absent"); - } - - public sealed class SourceEnum : StringEnum - { - private SourceEnum(string value) : base(value) {} - public SourceEnum() {} - public static implicit operator SourceEnum(string value) - { - return new SourceEnum(value); - } - - public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); - public static readonly SourceEnum Conference = new SourceEnum("Conference"); - public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); - public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); - public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); - public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); - public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); - } - - private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a recording - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a recording - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a recording - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a recording - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a recording from your account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a recording from your account - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of recordings belonging to the account used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the account used to make the request - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of recordings belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Only include recordings that were created on this date - /// Only include recordings that were created on this date - /// Only include recordings that were created on this date - /// The Call SID of the resources to read - /// Read by unique Conference SID for the recording - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - string callSid = null, - string conferenceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, CallSid = callSid, ConferenceSid = conferenceSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of recordings belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Only include recordings that were created on this date - /// Only include recordings that were created on this date - /// Only include recordings that were created on this date - /// The Call SID of the resources to read - /// Read by unique Conference SID for the recording - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - DateTime? dateCreatedBefore = null, - DateTime? dateCreated = null, - DateTime? dateCreatedAfter = null, - string callSid = null, - string conferenceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(){PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, CallSid = callSid, ConferenceSid = conferenceSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Converts a JSON string into a RecordingResource object - /// - /// Raw JSON string - /// RecordingResource object represented by the provided JSON - public static RecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used during the recording. - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The unique ID for the conference associated with the recording. - /// - [JsonProperty("conference_sid")] - public string ConferenceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The start time of the recording, given in RFC 2822 format - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The length of the recording in seconds. - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The one-time cost of creating the recording. - /// - [JsonProperty("price")] - public string Price { get; private set; } - /// - /// The currency used in the price property. - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The status of the recording. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.StatusEnum Status { get; private set; } - /// - /// The number of channels in the final recording file as an integer. - /// - [JsonProperty("channels")] - public int? Channels { get; private set; } - /// - /// How the recording was created - /// - [JsonProperty("source")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.SourceEnum Source { get; private set; } - /// - /// More information about why the recording is missing, if status is `absent`. - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// How to decrypt the recording. - /// - [JsonProperty("encryption_details")] - public object EncryptionDetails { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - - private RecordingResource() - { - - } - } +{ + + public class RecordingResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Paused = new StatusEnum("paused"); + public static readonly StatusEnum Stopped = new StatusEnum("stopped"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Absent = new StatusEnum("absent"); + } + + public sealed class SourceEnum : StringEnum + { + private SourceEnum(string value) : base(value) { } + public SourceEnum() { } + public static implicit operator SourceEnum(string value) + { + return new SourceEnum(value); + } + + public static readonly SourceEnum Dialverb = new SourceEnum("DialVerb"); + public static readonly SourceEnum Conference = new SourceEnum("Conference"); + public static readonly SourceEnum Outboundapi = new SourceEnum("OutboundAPI"); + public static readonly SourceEnum Trunking = new SourceEnum("Trunking"); + public static readonly SourceEnum Recordverb = new SourceEnum("RecordVerb"); + public static readonly SourceEnum Startcallrecordingapi = new SourceEnum("StartCallRecordingAPI"); + public static readonly SourceEnum Startconferencerecordingapi = new SourceEnum("StartConferenceRecordingAPI"); + } + + private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a recording + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a recording + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a recording + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a recording + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a recording from your account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a recording from your account + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Recordings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of recordings belonging to the account used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the account used to make the request + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of recordings belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Only include recordings that were created on this date + /// Only include recordings that were created on this date + /// Only include recordings that were created on this date + /// The Call SID of the resources to read + /// Read by unique Conference SID for the recording + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + string callSid = null, + string conferenceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions() { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, CallSid = callSid, ConferenceSid = conferenceSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of recordings belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Only include recordings that were created on this date + /// Only include recordings that were created on this date + /// Only include recordings that were created on this date + /// The Call SID of the resources to read + /// Read by unique Conference SID for the recording + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + DateTime? dateCreatedBefore = null, + DateTime? dateCreated = null, + DateTime? dateCreatedAfter = null, + string callSid = null, + string conferenceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions() { PathAccountSid = pathAccountSid, DateCreatedBefore = dateCreatedBefore, DateCreated = dateCreated, DateCreatedAfter = dateCreatedAfter, CallSid = callSid, ConferenceSid = conferenceSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Converts a JSON string into a RecordingResource object + /// + /// Raw JSON string + /// RecordingResource object represented by the provided JSON + public static RecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used during the recording. + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The unique ID for the conference associated with the recording. + /// + [JsonProperty("conference_sid")] + public string ConferenceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The start time of the recording, given in RFC 2822 format + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The length of the recording in seconds. + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The one-time cost of creating the recording. + /// + [JsonProperty("price")] + public string Price { get; private set; } + /// + /// The currency used in the price property. + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The status of the recording. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.StatusEnum Status { get; private set; } + /// + /// The number of channels in the final recording file as an integer. + /// + [JsonProperty("channels")] + public int? Channels { get; private set; } + /// + /// How the recording was created + /// + [JsonProperty("source")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.SourceEnum Source { get; private set; } + /// + /// More information about why the recording is missing, if status is `absent`. + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// How to decrypt the recording. + /// + [JsonProperty("encryption_details")] + public object EncryptionDetails { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + + private RecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ShortCodeOptions.cs b/src/Twilio/Rest/Api/V2010/Account/ShortCodeOptions.cs index 8321052b0..75c980942 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ShortCodeOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ShortCodeOptions.cs @@ -9,169 +9,169 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a short code + /// + public class FetchShortCodeOptions : IOptions + { /// - /// Fetch an instance of a short code - /// - public class FetchShortCodeOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchShortCodeOptions - /// - /// The unique string that identifies this resource - public FetchShortCodeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that created the resource(s) to fetch + /// + public string PathAccountSid { get; set; } /// - /// Update a short code with the following parameters - /// - public class UpdateShortCodeOptions : IOptions - { - /// - /// The SID of the Account that created the resource(s) to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - /// - /// A string to describe this resource - /// - public string FriendlyName { get; set; } - /// - /// The API version to use to start a new TwiML session - /// - public string ApiVersion { get; set; } - /// - /// URL Twilio will request when receiving an SMS - /// - public Uri SmsUrl { get; set; } - /// - /// HTTP method to use when requesting the sms url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// URL Twilio will request if an error occurs in executing TwiML - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// HTTP method Twilio will use with sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - - /// - /// Construct a new UpdateShortCodeOptions - /// - /// The unique string that identifies this resource - public UpdateShortCodeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ApiVersion != null) - { - p.Add(new KeyValuePair("ApiVersion", ApiVersion)); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - return p; - } - } - + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// - /// Retrieve a list of short-codes belonging to the account used to make the request - /// - public class ReadShortCodeOptions : ReadOptions - { - /// - /// The SID of the Account that created the resource(s) to read - /// - public string PathAccountSid { get; set; } - /// - /// The string that identifies the ShortCode resources to read - /// - public string FriendlyName { get; set; } - /// - /// Filter by ShortCode - /// - public string ShortCode { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ShortCode != null) - { - p.Add(new KeyValuePair("ShortCode", ShortCode)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Construct a new FetchShortCodeOptions + /// + /// The unique string that identifies this resource + public FetchShortCodeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update a short code with the following parameters + /// + public class UpdateShortCodeOptions : IOptions + { + /// + /// The SID of the Account that created the resource(s) to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + /// + /// A string to describe this resource + /// + public string FriendlyName { get; set; } + /// + /// The API version to use to start a new TwiML session + /// + public string ApiVersion { get; set; } + /// + /// URL Twilio will request when receiving an SMS + /// + public Uri SmsUrl { get; set; } + /// + /// HTTP method to use when requesting the sms url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// URL Twilio will request if an error occurs in executing TwiML + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// HTTP method Twilio will use with sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + + /// + /// Construct a new UpdateShortCodeOptions + /// + /// The unique string that identifies this resource + public UpdateShortCodeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ApiVersion != null) + { + p.Add(new KeyValuePair("ApiVersion", ApiVersion)); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of short-codes belonging to the account used to make the request + /// + public class ReadShortCodeOptions : ReadOptions + { + /// + /// The SID of the Account that created the resource(s) to read + /// + public string PathAccountSid { get; set; } + /// + /// The string that identifies the ShortCode resources to read + /// + public string FriendlyName { get; set; } + /// + /// Filter by ShortCode + /// + public string ShortCode { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ShortCode != null) + { + p.Add(new KeyValuePair("ShortCode", ShortCode)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ShortCodeResource.cs b/src/Twilio/Rest/Api/V2010/Account/ShortCodeResource.cs index 5c65faba6..6b1d1842d 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ShortCodeResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ShortCodeResource.cs @@ -16,402 +16,402 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class ShortCodeResource : Resource - { - private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a short code - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a short code - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a short code - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a short code - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a short code with the following parameters - /// - /// Update ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Update(UpdateShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a short code with the following parameters - /// - /// Update ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task UpdateAsync(UpdateShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a short code with the following parameters - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// A string to describe this resource - /// The API version to use to start a new TwiML session - /// URL Twilio will request when receiving an SMS - /// HTTP method to use when requesting the sms url - /// URL Twilio will request if an error occurs in executing TwiML - /// HTTP method Twilio will use with sms_fallback_url - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string apiVersion = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateShortCodeOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a short code with the following parameters - /// - /// The unique string that identifies this resource - /// The SID of the Account that created the resource(s) to update - /// A string to describe this resource - /// The API version to use to start a new TwiML session - /// URL Twilio will request when receiving an SMS - /// HTTP method to use when requesting the sms url - /// URL Twilio will request if an error occurs in executing TwiML - /// HTTP method Twilio will use with sms_fallback_url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - string apiVersion = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateShortCodeOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of short-codes belonging to the account used to make the request - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of short-codes belonging to the account used to make the request - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of short-codes belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to read - /// The string that identifies the ShortCode resources to read - /// Filter by ShortCode - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(string pathAccountSid = null, - string friendlyName = null, - string shortCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ShortCode = shortCode, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of short-codes belonging to the account used to make the request - /// - /// The SID of the Account that created the resource(s) to read - /// The string that identifies the ShortCode resources to read - /// Filter by ShortCode - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - string friendlyName = null, - string shortCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ShortCode = shortCode, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Converts a JSON string into a ShortCodeResource object - /// - /// Raw JSON string - /// ShortCodeResource object represented by the provided JSON - public static ShortCodeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created this resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A string that you assigned to describe this resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The short code. e.g., 894546. - /// - [JsonProperty("short_code")] - public string ShortCode { get; private set; } - /// - /// The unique string that identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// HTTP method we use to call the sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// URL Twilio will request if an error occurs in executing TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// HTTP method to use when requesting the sms url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// URL we call when receiving an incoming SMS message to this short code - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URI of this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private ShortCodeResource() - { - - } - } +{ + + public class ShortCodeResource : Resource + { + private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a short code + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a short code + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a short code + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a short code + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a short code with the following parameters + /// + /// Update ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Update(UpdateShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a short code with the following parameters + /// + /// Update ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task UpdateAsync(UpdateShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a short code with the following parameters + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// A string to describe this resource + /// The API version to use to start a new TwiML session + /// URL Twilio will request when receiving an SMS + /// HTTP method to use when requesting the sms url + /// URL Twilio will request if an error occurs in executing TwiML + /// HTTP method Twilio will use with sms_fallback_url + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string apiVersion = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateShortCodeOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a short code with the following parameters + /// + /// The unique string that identifies this resource + /// The SID of the Account that created the resource(s) to update + /// A string to describe this resource + /// The API version to use to start a new TwiML session + /// URL Twilio will request when receiving an SMS + /// HTTP method to use when requesting the sms url + /// URL Twilio will request if an error occurs in executing TwiML + /// HTTP method Twilio will use with sms_fallback_url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + string apiVersion = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateShortCodeOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ApiVersion = apiVersion, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SMS/ShortCodes.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of short-codes belonging to the account used to make the request + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of short-codes belonging to the account used to make the request + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of short-codes belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to read + /// The string that identifies the ShortCode resources to read + /// Filter by ShortCode + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(string pathAccountSid = null, + string friendlyName = null, + string shortCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ShortCode = shortCode, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of short-codes belonging to the account used to make the request + /// + /// The SID of the Account that created the resource(s) to read + /// The string that identifies the ShortCode resources to read + /// Filter by ShortCode + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + string friendlyName = null, + string shortCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions() { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, ShortCode = shortCode, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Converts a JSON string into a ShortCodeResource object + /// + /// Raw JSON string + /// ShortCodeResource object represented by the provided JSON + public static ShortCodeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created this resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A string that you assigned to describe this resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The short code. e.g., 894546. + /// + [JsonProperty("short_code")] + public string ShortCode { get; private set; } + /// + /// The unique string that identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// HTTP method we use to call the sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// URL Twilio will request if an error occurs in executing TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// HTTP method to use when requesting the sms url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// URL we call when receiving an incoming SMS message to this short code + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URI of this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private ShortCodeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/SigningKeyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/SigningKeyOptions.cs index 484177364..93c316c75 100644 --- a/src/Twilio/Rest/Api/V2010/Account/SigningKeyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/SigningKeyOptions.cs @@ -9,139 +9,139 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// FetchSigningKeyOptions + /// + public class FetchSigningKeyOptions : IOptions + { /// - /// FetchSigningKeyOptions + /// The account_sid /// - public class FetchSigningKeyOptions : IOptions - { - /// - /// The account_sid - /// - public string PathAccountSid { get; set; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSigningKeyOptions - /// - /// The sid - public FetchSigningKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// UpdateSigningKeyOptions + /// The sid /// - public class UpdateSigningKeyOptions : IOptions - { - /// - /// The account_sid - /// - public string PathAccountSid { get; set; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateSigningKeyOptions - /// - /// The sid - public UpdateSigningKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteSigningKeyOptions + /// Construct a new FetchSigningKeyOptions /// - public class DeleteSigningKeyOptions : IOptions - { - /// - /// The account_sid - /// - public string PathAccountSid { get; set; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSigningKeyOptions - /// - /// The sid - public DeleteSigningKeyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + public FetchSigningKeyOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// ReadSigningKeyOptions + /// Generate the necessary parameters /// - public class ReadSigningKeyOptions : ReadOptions - { - /// - /// The account_sid - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateSigningKeyOptions + /// + public class UpdateSigningKeyOptions : IOptions + { + /// + /// The account_sid + /// + public string PathAccountSid { get; set; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateSigningKeyOptions + /// + /// The sid + public UpdateSigningKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteSigningKeyOptions + /// + public class DeleteSigningKeyOptions : IOptions + { + /// + /// The account_sid + /// + public string PathAccountSid { get; set; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSigningKeyOptions + /// + /// The sid + public DeleteSigningKeyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadSigningKeyOptions + /// + public class ReadSigningKeyOptions : ReadOptions + { + /// + /// The account_sid + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/SigningKeyResource.cs b/src/Twilio/Rest/Api/V2010/Account/SigningKeyResource.cs index 834bb1452..05ecda86a 100644 --- a/src/Twilio/Rest/Api/V2010/Account/SigningKeyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/SigningKeyResource.cs @@ -16,402 +16,402 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class SigningKeyResource : Resource - { - private static Request BuildFetchRequest(FetchSigningKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SigningKey parameters - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static SigningKeyResource Fetch(FetchSigningKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SigningKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task FetchAsync(FetchSigningKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// The account_sid - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static SigningKeyResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// The account_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSigningKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update SigningKey parameters - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static SigningKeyResource Update(UpdateSigningKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SigningKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSigningKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The account_sid - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static SigningKeyResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The account_sid - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSigningKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SigningKey parameters - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static bool Delete(DeleteSigningKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SigningKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSigningKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// The account_sid - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// The account_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteSigningKeyOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSigningKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SigningKey parameters - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static ResourceSet Read(ReadSigningKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("signing_keys", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SigningKey parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task> ReadAsync(ReadSigningKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("signing_keys", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The account_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SigningKey - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSigningKeyOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The account_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SigningKey - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSigningKeyOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("signing_keys", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("signing_keys", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("signing_keys", response.Content); - } - - /// - /// Converts a JSON string into a SigningKeyResource object - /// - /// Raw JSON string - /// SigningKeyResource object represented by the provided JSON - public static SigningKeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private SigningKeyResource() - { - - } - } +{ + + public class SigningKeyResource : Resource + { + private static Request BuildFetchRequest(FetchSigningKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SigningKey parameters + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static SigningKeyResource Fetch(FetchSigningKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SigningKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task FetchAsync(FetchSigningKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// The account_sid + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static SigningKeyResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// The account_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSigningKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update SigningKey parameters + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static SigningKeyResource Update(UpdateSigningKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SigningKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSigningKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The account_sid + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static SigningKeyResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The account_sid + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSigningKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SigningKey parameters + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static bool Delete(DeleteSigningKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SigningKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSigningKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// The account_sid + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// The account_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteSigningKeyOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSigningKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SigningKeys.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SigningKey parameters + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static ResourceSet Read(ReadSigningKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("signing_keys", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SigningKey parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task> ReadAsync(ReadSigningKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("signing_keys", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The account_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SigningKey + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSigningKeyOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The account_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SigningKey + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSigningKeyOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("signing_keys", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("signing_keys", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("signing_keys", response.Content); + } + + /// + /// Converts a JSON string into a SigningKeyResource object + /// + /// Raw JSON string + /// SigningKeyResource object represented by the provided JSON + public static SigningKeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private SigningKeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialOptions.cs index c10de0370..0d9bed07e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialOptions.cs @@ -9,230 +9,230 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.CredentialList -{ - +{ + + /// + /// Retrieve a list of credentials. + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// Retrieve a list of credentials. - /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// The unique id that identifies the credential list that contains the desired credentials - /// - public string PathCredentialListSid { get; } - - /// - /// Construct a new ReadCredentialOptions - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - public ReadCredentialOptions(string pathCredentialListSid) - { - PathCredentialListSid = pathCredentialListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } /// - /// Create a new credential resource. - /// - public class CreateCredentialOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// The unique id that identifies the credential list to include the created credential - /// - public string PathCredentialListSid { get; } - /// - /// The username for this credential. - /// - public string Username { get; } - /// - /// The password will not be returned in the response. - /// - public string Password { get; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The unique id that identifies the credential list to include the created - /// credential - /// The username for this credential. - /// The password will not be returned in the response. - public CreateCredentialOptions(string pathCredentialListSid, string username, string password) - { - PathCredentialListSid = pathCredentialListSid; - Username = username; - Password = password; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Username != null) - { - p.Add(new KeyValuePair("Username", Username)); - } - - if (Password != null) - { - p.Add(new KeyValuePair("Password", Password)); - } - - return p; - } - } - + /// The unique id that identifies the credential list that contains the desired credentials + /// + public string PathCredentialListSid { get; } + /// - /// Fetch a single credential. - /// - public class FetchCredentialOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// The unique id that identifies the credential list that contains the desired credential - /// - public string PathCredentialListSid { get; } - /// - /// The unique id that identifies the resource to fetch. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The unique id that identifies the credential list that contains the desired - /// credential - /// The unique id that identifies the resource to fetch. - public FetchCredentialOptions(string pathCredentialListSid, string pathSid) - { - PathCredentialListSid = pathCredentialListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadCredentialOptions + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + public ReadCredentialOptions(string pathCredentialListSid) + { + PathCredentialListSid = pathCredentialListSid; + } + /// - /// Update a credential resource. - /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource - /// - public string PathAccountSid { get; set; } - /// - /// The unique id that identifies the credential list that includes this credential - /// - public string PathCredentialListSid { get; } - /// - /// The unique id that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The password will not be returned in the response - /// - public string Password { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The unique id that identifies the credential list that includes this - /// credential - /// The unique id that identifies the resource to update - public UpdateCredentialOptions(string pathCredentialListSid, string pathSid) - { - PathCredentialListSid = pathCredentialListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Password != null) - { - p.Add(new KeyValuePair("Password", Password)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new credential resource. + /// + public class CreateCredentialOptions : IOptions + { /// - /// Delete a credential resource. - /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// The unique id that identifies the credential list that contains the desired credentials - /// - public string PathCredentialListSid { get; } - /// - /// The unique id that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - /// The unique id that identifies the resource to delete - public DeleteCredentialOptions(string pathCredentialListSid, string pathSid) - { - PathCredentialListSid = pathCredentialListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// The unique id that identifies the credential list to include the created credential + /// + public string PathCredentialListSid { get; } + /// + /// The username for this credential. + /// + public string Username { get; } + /// + /// The password will not be returned in the response. + /// + public string Password { get; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The unique id that identifies the credential list to include the created + /// credential + /// The username for this credential. + /// The password will not be returned in the response. + public CreateCredentialOptions(string pathCredentialListSid, string username, string password) + { + PathCredentialListSid = pathCredentialListSid; + Username = username; + Password = password; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Username != null) + { + p.Add(new KeyValuePair("Username", Username)); + } + + if (Password != null) + { + p.Add(new KeyValuePair("Password", Password)); + } + + return p; + } + } + + /// + /// Fetch a single credential. + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// The unique id that identifies the credential list that contains the desired credential + /// + public string PathCredentialListSid { get; } + /// + /// The unique id that identifies the resource to fetch. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The unique id that identifies the credential list that contains the desired + /// credential + /// The unique id that identifies the resource to fetch. + public FetchCredentialOptions(string pathCredentialListSid, string pathSid) + { + PathCredentialListSid = pathCredentialListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update a credential resource. + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource + /// + public string PathAccountSid { get; set; } + /// + /// The unique id that identifies the credential list that includes this credential + /// + public string PathCredentialListSid { get; } + /// + /// The unique id that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The password will not be returned in the response + /// + public string Password { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The unique id that identifies the credential list that includes this + /// credential + /// The unique id that identifies the resource to update + public UpdateCredentialOptions(string pathCredentialListSid, string pathSid) + { + PathCredentialListSid = pathCredentialListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Password != null) + { + p.Add(new KeyValuePair("Password", Password)); + } + + return p; + } + } + + /// + /// Delete a credential resource. + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// The unique id that identifies the credential list that contains the desired credentials + /// + public string PathCredentialListSid { get; } + /// + /// The unique id that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + /// The unique id that identifies the resource to delete + public DeleteCredentialOptions(string pathCredentialListSid, string pathSid) + { + PathCredentialListSid = pathCredentialListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialResource.cs index e294391e2..b167a3cbe 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialList/CredentialResource.cs @@ -16,527 +16,527 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.CredentialList -{ - - public class CredentialResource : Resource - { - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of credentials. - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credentials. - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of credentials. - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(string pathCredentialListSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(pathCredentialListSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credentials. - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(string pathCredentialListSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(pathCredentialListSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new credential resource. - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new credential resource. - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new credential resource. - /// - /// The unique id that identifies the credential list to include the created - /// credential - /// The username for this credential. - /// The password will not be returned in the response. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(string pathCredentialListSid, - string username, - string password, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(pathCredentialListSid, username, password){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new credential resource. - /// - /// The unique id that identifies the credential list to include the created - /// credential - /// The username for this credential. - /// The password will not be returned in the response. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(string pathCredentialListSid, - string username, - string password, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(pathCredentialListSid, username, password){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a single credential. - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a single credential. - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a single credential. - /// - /// The unique id that identifies the credential list that contains the desired - /// credential - /// The unique id that identifies the resource to fetch. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a single credential. - /// - /// The unique id that identifies the credential list that contains the desired - /// credential - /// The unique id that identifies the resource to fetch. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a credential resource. - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a credential resource. - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a credential resource. - /// - /// The unique id that identifies the credential list that includes this - /// credential - /// The unique id that identifies the resource to update - /// The unique id of the Account that is responsible for this resource - /// The password will not be returned in the response - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - string password = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid, Password = password}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a credential resource. - /// - /// The unique id that identifies the credential list that includes this - /// credential - /// The unique id that identifies the resource to update - /// The unique id of the Account that is responsible for this resource - /// The password will not be returned in the response - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - string password = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid, Password = password}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a credential resource. - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a credential resource. - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a credential resource. - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - /// The unique id that identifies the resource to delete - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a credential resource. - /// - /// The unique id that identifies the credential list that contains the desired - /// credentials - /// The unique id that identifies the resource to delete - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathCredentialListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathCredentialListSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique id of the Account that is responsible for this resource. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique id that identifies the credential list that includes this credential - /// - [JsonProperty("credential_list_sid")] - public string CredentialListSid { get; private set; } - /// - /// The username for this credential. - /// - [JsonProperty("username")] - public string Username { get; private set; } - /// - /// The date that this resource was created, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI for this resource, relative to https://api.twilio.com - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of credentials. + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credentials. + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of credentials. + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(string pathCredentialListSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions(pathCredentialListSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credentials. + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(string pathCredentialListSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions(pathCredentialListSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new credential resource. + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new credential resource. + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new credential resource. + /// + /// The unique id that identifies the credential list to include the created + /// credential + /// The username for this credential. + /// The password will not be returned in the response. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(string pathCredentialListSid, + string username, + string password, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(pathCredentialListSid, username, password) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new credential resource. + /// + /// The unique id that identifies the credential list to include the created + /// credential + /// The username for this credential. + /// The password will not be returned in the response. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(string pathCredentialListSid, + string username, + string password, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(pathCredentialListSid, username, password) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a single credential. + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a single credential. + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a single credential. + /// + /// The unique id that identifies the credential list that contains the desired + /// credential + /// The unique id that identifies the resource to fetch. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a single credential. + /// + /// The unique id that identifies the credential list that contains the desired + /// credential + /// The unique id that identifies the resource to fetch. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a credential resource. + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a credential resource. + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a credential resource. + /// + /// The unique id that identifies the credential list that includes this + /// credential + /// The unique id that identifies the resource to update + /// The unique id of the Account that is responsible for this resource + /// The password will not be returned in the response + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + string password = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid, Password = password }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a credential resource. + /// + /// The unique id that identifies the credential list that includes this + /// credential + /// The unique id that identifies the resource to update + /// The unique id of the Account that is responsible for this resource + /// The password will not be returned in the response + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + string password = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid, Password = password }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathCredentialListSid + "/Credentials/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a credential resource. + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a credential resource. + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a credential resource. + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + /// The unique id that identifies the resource to delete + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a credential resource. + /// + /// The unique id that identifies the credential list that contains the desired + /// credentials + /// The unique id that identifies the resource to delete + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathCredentialListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathCredentialListSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique id of the Account that is responsible for this resource. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique id that identifies the credential list that includes this credential + /// + [JsonProperty("credential_list_sid")] + public string CredentialListSid { get; private set; } + /// + /// The username for this credential. + /// + [JsonProperty("username")] + public string Username { get; private set; } + /// + /// The date that this resource was created, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI for this resource, relative to https://api.twilio.com + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListOptions.cs index 2c5d1245a..bfcac61e9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListOptions.cs @@ -9,179 +9,179 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - +{ + + /// + /// Get All Credential Lists + /// + public class ReadCredentialListOptions : ReadOptions + { /// - /// Get All Credential Lists + /// The unique id of the Account that is responsible for this resource. /// - public class ReadCredentialListOptions : ReadOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathAccountSid { get; set; } + /// - /// Create a Credential List - /// - public class CreateCredentialListOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// Human readable descriptive text - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateCredentialListOptions - /// - /// Human readable descriptive text - public CreateCredentialListOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a Credential List + /// + public class CreateCredentialListOptions : IOptions + { /// - /// Get a Credential List - /// - public class FetchCredentialListOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// Fetch by unique credential list Sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialListOptions - /// - /// Fetch by unique credential list Sid - public FetchCredentialListOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } /// - /// Update a Credential List - /// - public class UpdateCredentialListOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// Update by unique credential list Sid - /// - public string PathSid { get; } - /// - /// Human readable descriptive text - /// - public string FriendlyName { get; } - - /// - /// Construct a new UpdateCredentialListOptions - /// - /// Update by unique credential list Sid - /// Human readable descriptive text - public UpdateCredentialListOptions(string pathSid, string friendlyName) - { - PathSid = pathSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Human readable descriptive text + /// + public string FriendlyName { get; } + /// - /// Delete a Credential List - /// - public class DeleteCredentialListOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// Delete by unique credential list Sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialListOptions - /// - /// Delete by unique credential list Sid - public DeleteCredentialListOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateCredentialListOptions + /// + /// Human readable descriptive text + public CreateCredentialListOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Get a Credential List + /// + public class FetchCredentialListOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// Fetch by unique credential list Sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialListOptions + /// + /// Fetch by unique credential list Sid + public FetchCredentialListOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update a Credential List + /// + public class UpdateCredentialListOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// Update by unique credential list Sid + /// + public string PathSid { get; } + /// + /// Human readable descriptive text + /// + public string FriendlyName { get; } + + /// + /// Construct a new UpdateCredentialListOptions + /// + /// Update by unique credential list Sid + /// Human readable descriptive text + public UpdateCredentialListOptions(string pathSid, string friendlyName) + { + PathSid = pathSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete a Credential List + /// + public class DeleteCredentialListOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// Delete by unique credential list Sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialListOptions + /// + /// Delete by unique credential list Sid + public DeleteCredentialListOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListResource.cs index b4e7158aa..c492fcf49 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/CredentialListResource.cs @@ -16,492 +16,492 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - - public class CredentialListResource : Resource - { - private static Request BuildReadRequest(ReadCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get All Credential Lists - /// - /// Read CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static ResourceSet Read(ReadCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Get All Credential Lists - /// - /// Read CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Get All Credential Lists - /// - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Get All Credential Lists - /// - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a Credential List - /// - /// Create CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Create(CreateCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a Credential List - /// - /// Create CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a Credential List - /// - /// Human readable descriptive text - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Create(string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListOptions(friendlyName){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a Credential List - /// - /// Human readable descriptive text - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListOptions(friendlyName){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get a Credential List - /// - /// Fetch CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Fetch(FetchCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Get a Credential List - /// - /// Fetch CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Get a Credential List - /// - /// Fetch by unique credential list Sid - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialListOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Get a Credential List - /// - /// Fetch by unique credential list Sid - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialListOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a Credential List - /// - /// Update CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Update(UpdateCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a Credential List - /// - /// Update CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a Credential List - /// - /// Update by unique credential list Sid - /// Human readable descriptive text - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Update(string pathSid, - string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialListOptions(pathSid, friendlyName){PathAccountSid = pathAccountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a Credential List - /// - /// Update by unique credential list Sid - /// Human readable descriptive text - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialListOptions(pathSid, friendlyName){PathAccountSid = pathAccountSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Credential List - /// - /// Delete CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static bool Delete(DeleteCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Credential List - /// - /// Delete CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Credential List - /// - /// Delete by unique credential list Sid - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteCredentialListOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Credential List - /// - /// Delete by unique credential list Sid - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialListOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialListResource object - /// - /// Raw JSON string - /// CredentialListResource object represented by the provided JSON - public static CredentialListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique sid that identifies this account - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Human readable descriptive text - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A string that uniquely identifies this credential - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The list of credentials associated with this credential list. - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI for this resource - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private CredentialListResource() - { - - } - } +{ + + public class CredentialListResource : Resource + { + private static Request BuildReadRequest(ReadCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get All Credential Lists + /// + /// Read CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static ResourceSet Read(ReadCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Get All Credential Lists + /// + /// Read CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Get All Credential Lists + /// + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Get All Credential Lists + /// + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a Credential List + /// + /// Create CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Create(CreateCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a Credential List + /// + /// Create CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a Credential List + /// + /// Human readable descriptive text + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Create(string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListOptions(friendlyName) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a Credential List + /// + /// Human readable descriptive text + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListOptions(friendlyName) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get a Credential List + /// + /// Fetch CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Fetch(FetchCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Get a Credential List + /// + /// Fetch CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Get a Credential List + /// + /// Fetch by unique credential list Sid + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Get a Credential List + /// + /// Fetch by unique credential list Sid + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a Credential List + /// + /// Update CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Update(UpdateCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a Credential List + /// + /// Update CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a Credential List + /// + /// Update by unique credential list Sid + /// Human readable descriptive text + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Update(string pathSid, + string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialListOptions(pathSid, friendlyName) { PathAccountSid = pathAccountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a Credential List + /// + /// Update by unique credential list Sid + /// Human readable descriptive text + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialListOptions(pathSid, friendlyName) { PathAccountSid = pathAccountSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/CredentialLists/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Credential List + /// + /// Delete CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static bool Delete(DeleteCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Credential List + /// + /// Delete CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Credential List + /// + /// Delete by unique credential list Sid + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteCredentialListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Credential List + /// + /// Delete by unique credential list Sid + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialListResource object + /// + /// Raw JSON string + /// CredentialListResource object represented by the provided JSON + public static CredentialListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique sid that identifies this account + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Human readable descriptive text + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A string that uniquely identifies this credential + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The list of credentials associated with this credential list. + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI for this resource + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private CredentialListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingOptions.cs index 6d580efd5..8813767a6 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingOptions.cs @@ -9,166 +9,166 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeCalls -{ - +{ + + /// + /// Create a new credential list mapping resource + /// + public class CreateAuthCallsCredentialListMappingOptions : IOptions + { /// - /// Create a new credential list mapping resource - /// - public class CreateAuthCallsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that will contain the new resource - /// - public string PathDomainSid { get; } - /// - /// The SID of the CredentialList resource to map to the SIP domain - /// - public string CredentialListSid { get; } - - /// - /// Construct a new CreateAuthCallsCredentialListMappingOptions - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - public CreateAuthCallsCredentialListMappingOptions(string pathDomainSid, string credentialListSid) - { - PathDomainSid = pathDomainSid; - CredentialListSid = credentialListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CredentialListSid != null) - { - p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - public class ReadAuthCallsCredentialListMappingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resources to read - /// - public string PathDomainSid { get; } - - /// - /// Construct a new ReadAuthCallsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resources to read - public ReadAuthCallsCredentialListMappingOptions(string pathDomainSid) - { - PathDomainSid = pathDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the SIP domain that will contain the new resource + /// + public string PathDomainSid { get; } /// - /// Fetch a specific instance of a credential list mapping - /// - public class FetchAuthCallsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resource to fetch - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAuthCallsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - public FetchAuthCallsCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the CredentialList resource to map to the SIP domain + /// + public string CredentialListSid { get; } + /// - /// Delete a credential list mapping from the requested domain - /// - public class DeleteAuthCallsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resource to delete - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAuthCallsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resource to delete - /// The unique string that identifies the resource - public DeleteAuthCallsCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateAuthCallsCredentialListMappingOptions + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + public CreateAuthCallsCredentialListMappingOptions(string pathDomainSid, string credentialListSid) + { + PathDomainSid = pathDomainSid; + CredentialListSid = credentialListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CredentialListSid != null) + { + p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + public class ReadAuthCallsCredentialListMappingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resources to read + /// + public string PathDomainSid { get; } + + /// + /// Construct a new ReadAuthCallsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resources to read + public ReadAuthCallsCredentialListMappingOptions(string pathDomainSid) + { + PathDomainSid = pathDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific instance of a credential list mapping + /// + public class FetchAuthCallsCredentialListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resource to fetch + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAuthCallsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + public FetchAuthCallsCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a credential list mapping from the requested domain + /// + public class DeleteAuthCallsCredentialListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resource to delete + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAuthCallsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resource to delete + /// The unique string that identifies the resource + public DeleteAuthCallsCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingResource.cs index 343cf20dd..aaead31eb 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsCredentialListMappingResource.cs @@ -16,431 +16,431 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeCalls -{ - - public class AuthCallsCredentialListMappingResource : Resource - { - private static Request BuildCreateRequest(CreateAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new credential list mapping resource - /// - /// Create AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static AuthCallsCredentialListMappingResource Create(CreateAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new credential list mapping resource - /// - /// Create AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new credential list mapping resource - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static AuthCallsCredentialListMappingResource Create(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthCallsCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new credential list mapping resource - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthCallsCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAuthCallsCredentialListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// Read AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static ResourceSet Read(ReadAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// Read AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static ResourceSet Read(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthCallsCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthCallsCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - private static Request BuildFetchRequest(FetchAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific instance of a credential list mapping - /// - /// Fetch AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static AuthCallsCredentialListMappingResource Fetch(FetchAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific instance of a credential list mapping - /// - /// Fetch AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific instance of a credential list mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static AuthCallsCredentialListMappingResource Fetch(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific instance of a credential list mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a credential list mapping from the requested domain - /// - /// Delete AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static bool Delete(DeleteAuthCallsCredentialListMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a credential list mapping from the requested domain - /// - /// Delete AuthCallsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthCallsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a credential list mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resource to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of AuthCallsCredentialListMapping - public static bool Delete(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a credential list mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resource to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsCredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AuthCallsCredentialListMappingResource object - /// - /// Raw JSON string - /// AuthCallsCredentialListMappingResource object represented by the provided JSON - public static AuthCallsCredentialListMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - - private AuthCallsCredentialListMappingResource() - { - - } - } +{ + + public class AuthCallsCredentialListMappingResource : Resource + { + private static Request BuildCreateRequest(CreateAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new credential list mapping resource + /// + /// Create AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static AuthCallsCredentialListMappingResource Create(CreateAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new credential list mapping resource + /// + /// Create AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new credential list mapping resource + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static AuthCallsCredentialListMappingResource Create(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthCallsCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new credential list mapping resource + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthCallsCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAuthCallsCredentialListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// Read AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static ResourceSet Read(ReadAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// Read AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static ResourceSet Read(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthCallsCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthCallsCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + private static Request BuildFetchRequest(FetchAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific instance of a credential list mapping + /// + /// Fetch AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static AuthCallsCredentialListMappingResource Fetch(FetchAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific instance of a credential list mapping + /// + /// Fetch AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific instance of a credential list mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static AuthCallsCredentialListMappingResource Fetch(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific instance of a credential list mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a credential list mapping from the requested domain + /// + /// Delete AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static bool Delete(DeleteAuthCallsCredentialListMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a credential list mapping from the requested domain + /// + /// Delete AuthCallsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthCallsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a credential list mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resource to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of AuthCallsCredentialListMapping + public static bool Delete(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a credential list mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resource to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsCredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthCallsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AuthCallsCredentialListMappingResource object + /// + /// Raw JSON string + /// AuthCallsCredentialListMappingResource object represented by the provided JSON + public static AuthCallsCredentialListMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + + private AuthCallsCredentialListMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingOptions.cs index f11d5c259..8011b8b38 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingOptions.cs @@ -9,166 +9,166 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeCalls -{ - +{ + + /// + /// Create a new IP Access Control List mapping + /// + public class CreateAuthCallsIpAccessControlListMappingOptions : IOptions + { /// - /// Create a new IP Access Control List mapping - /// - public class CreateAuthCallsIpAccessControlListMappingOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that will contain the new resource - /// - public string PathDomainSid { get; } - /// - /// The SID of the IpAccessControlList resource to map to the SIP domain - /// - public string IpAccessControlListSid { get; } - - /// - /// Construct a new CreateAuthCallsIpAccessControlListMappingOptions - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the IpAccessControlList resource to map to the SIP domain - public CreateAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string ipAccessControlListSid) - { - PathDomainSid = pathDomainSid; - IpAccessControlListSid = ipAccessControlListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpAccessControlListSid != null) - { - p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request - /// - public class ReadAuthCallsIpAccessControlListMappingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resources to read - /// - public string PathDomainSid { get; } - - /// - /// Construct a new ReadAuthCallsIpAccessControlListMappingOptions - /// - /// The SID of the SIP domain that contains the resources to read - public ReadAuthCallsIpAccessControlListMappingOptions(string pathDomainSid) - { - PathDomainSid = pathDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the SIP domain that will contain the new resource + /// + public string PathDomainSid { get; } /// - /// Fetch a specific instance of an IP Access Control List mapping - /// - public class FetchAuthCallsIpAccessControlListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resource to fetch - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAuthCallsIpAccessControlListMappingOptions - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - public FetchAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the IpAccessControlList resource to map to the SIP domain + /// + public string IpAccessControlListSid { get; } + /// - /// Delete an IP Access Control List mapping from the requested domain - /// - public class DeleteAuthCallsIpAccessControlListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resources to delete - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAuthCallsIpAccessControlListMappingOptions - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - public DeleteAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateAuthCallsIpAccessControlListMappingOptions + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the IpAccessControlList resource to map to the SIP domain + public CreateAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string ipAccessControlListSid) + { + PathDomainSid = pathDomainSid; + IpAccessControlListSid = ipAccessControlListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IpAccessControlListSid != null) + { + p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request + /// + public class ReadAuthCallsIpAccessControlListMappingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resources to read + /// + public string PathDomainSid { get; } + + /// + /// Construct a new ReadAuthCallsIpAccessControlListMappingOptions + /// + /// The SID of the SIP domain that contains the resources to read + public ReadAuthCallsIpAccessControlListMappingOptions(string pathDomainSid) + { + PathDomainSid = pathDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific instance of an IP Access Control List mapping + /// + public class FetchAuthCallsIpAccessControlListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resource to fetch + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAuthCallsIpAccessControlListMappingOptions + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + public FetchAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete an IP Access Control List mapping from the requested domain + /// + public class DeleteAuthCallsIpAccessControlListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resources to delete + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAuthCallsIpAccessControlListMappingOptions + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + public DeleteAuthCallsIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingResource.cs index b54718e29..e8e5489dc 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeCalls/AuthCallsIpAccessControlListMappingResource.cs @@ -16,432 +16,432 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeCalls -{ - - public class AuthCallsIpAccessControlListMappingResource : Resource - { - private static Request BuildCreateRequest(CreateAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new IP Access Control List mapping - /// - /// Create AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static AuthCallsIpAccessControlListMappingResource Create(CreateAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new IP Access Control List mapping - /// - /// Create AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new IP Access Control List mapping - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the IpAccessControlList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static AuthCallsIpAccessControlListMappingResource Create(string pathDomainSid, - string ipAccessControlListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthCallsIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new IP Access Control List mapping - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the IpAccessControlList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, - string ipAccessControlListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthCallsIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request - /// - /// Read AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static ResourceSet Read(ReadAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request - /// - /// Read AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static ResourceSet Read(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthCallsIpAccessControlListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthCallsIpAccessControlListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - private static Request BuildFetchRequest(FetchAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific instance of an IP Access Control List mapping - /// - /// Fetch AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static AuthCallsIpAccessControlListMappingResource Fetch(FetchAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific instance of an IP Access Control List mapping - /// - /// Fetch AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific instance of an IP Access Control List mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static AuthCallsIpAccessControlListMappingResource Fetch(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific instance of an IP Access Control List mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an IP Access Control List mapping from the requested domain - /// - /// Delete AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static bool Delete(DeleteAuthCallsIpAccessControlListMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an IP Access Control List mapping from the requested domain - /// - /// Delete AuthCallsIpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthCallsIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an IP Access Control List mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of AuthCallsIpAccessControlListMapping - public static bool Delete(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an IP Access Control List mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AuthCallsIpAccessControlListMappingResource object - /// - /// Raw JSON string - /// AuthCallsIpAccessControlListMappingResource object represented by the provided JSON - public static AuthCallsIpAccessControlListMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - - private AuthCallsIpAccessControlListMappingResource() - { - - } - } +{ + + public class AuthCallsIpAccessControlListMappingResource : Resource + { + private static Request BuildCreateRequest(CreateAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new IP Access Control List mapping + /// + /// Create AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static AuthCallsIpAccessControlListMappingResource Create(CreateAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new IP Access Control List mapping + /// + /// Create AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new IP Access Control List mapping + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the IpAccessControlList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static AuthCallsIpAccessControlListMappingResource Create(string pathDomainSid, + string ipAccessControlListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthCallsIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new IP Access Control List mapping + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the IpAccessControlList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, + string ipAccessControlListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthCallsIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request + /// + /// Read AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static ResourceSet Read(ReadAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request + /// + /// Read AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static ResourceSet Read(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthCallsIpAccessControlListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IP Access Control List mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthCallsIpAccessControlListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + private static Request BuildFetchRequest(FetchAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific instance of an IP Access Control List mapping + /// + /// Fetch AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static AuthCallsIpAccessControlListMappingResource Fetch(FetchAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific instance of an IP Access Control List mapping + /// + /// Fetch AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific instance of an IP Access Control List mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static AuthCallsIpAccessControlListMappingResource Fetch(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific instance of an IP Access Control List mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Calls/IpAccessControlListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an IP Access Control List mapping from the requested domain + /// + /// Delete AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static bool Delete(DeleteAuthCallsIpAccessControlListMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an IP Access Control List mapping from the requested domain + /// + /// Delete AuthCallsIpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthCallsIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an IP Access Control List mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of AuthCallsIpAccessControlListMapping + public static bool Delete(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an IP Access Control List mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthCallsIpAccessControlListMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthCallsIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AuthCallsIpAccessControlListMappingResource object + /// + /// Raw JSON string + /// AuthCallsIpAccessControlListMappingResource object represented by the provided JSON + public static AuthCallsIpAccessControlListMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + + private AuthCallsIpAccessControlListMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingOptions.cs index 5bc9e046b..4b371af32 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingOptions.cs @@ -9,166 +9,166 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeRegistrations -{ - +{ + + /// + /// Create a new credential list mapping resource + /// + public class CreateAuthRegistrationsCredentialListMappingOptions : IOptions + { /// - /// Create a new credential list mapping resource - /// - public class CreateAuthRegistrationsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that will contain the new resource - /// - public string PathDomainSid { get; } - /// - /// The SID of the CredentialList resource to map to the SIP domain - /// - public string CredentialListSid { get; } - - /// - /// Construct a new CreateAuthRegistrationsCredentialListMappingOptions - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - public CreateAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string credentialListSid) - { - PathDomainSid = pathDomainSid; - CredentialListSid = credentialListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CredentialListSid != null) - { - p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); - } - - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - public class ReadAuthRegistrationsCredentialListMappingOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resources to read - /// - public string PathDomainSid { get; } - - /// - /// Construct a new ReadAuthRegistrationsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resources to read - public ReadAuthRegistrationsCredentialListMappingOptions(string pathDomainSid) - { - PathDomainSid = pathDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the SIP domain that will contain the new resource + /// + public string PathDomainSid { get; } /// - /// Fetch a specific instance of a credential list mapping - /// - public class FetchAuthRegistrationsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resource to fetch - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAuthRegistrationsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - public FetchAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the CredentialList resource to map to the SIP domain + /// + public string CredentialListSid { get; } + /// - /// Delete a credential list mapping from the requested domain - /// - public class DeleteAuthRegistrationsCredentialListMappingOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The SID of the SIP domain that contains the resources to delete - /// - public string PathDomainSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAuthRegistrationsCredentialListMappingOptions - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - public DeleteAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateAuthRegistrationsCredentialListMappingOptions + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + public CreateAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string credentialListSid) + { + PathDomainSid = pathDomainSid; + CredentialListSid = credentialListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CredentialListSid != null) + { + p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + public class ReadAuthRegistrationsCredentialListMappingOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resources to read + /// + public string PathDomainSid { get; } + + /// + /// Construct a new ReadAuthRegistrationsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resources to read + public ReadAuthRegistrationsCredentialListMappingOptions(string pathDomainSid) + { + PathDomainSid = pathDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific instance of a credential list mapping + /// + public class FetchAuthRegistrationsCredentialListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resource to fetch + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAuthRegistrationsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + public FetchAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a credential list mapping from the requested domain + /// + public class DeleteAuthRegistrationsCredentialListMappingOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The SID of the SIP domain that contains the resources to delete + /// + public string PathDomainSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAuthRegistrationsCredentialListMappingOptions + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + public DeleteAuthRegistrationsCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingResource.cs index deca09641..01edc068c 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/AuthTypes/AuthTypeRegistrations/AuthRegistrationsCredentialListMappingResource.cs @@ -16,434 +16,434 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain.AuthTypes.AuthTypeRegistrations -{ - - public class AuthRegistrationsCredentialListMappingResource : Resource - { - private static Request BuildCreateRequest(CreateAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new credential list mapping resource - /// - /// Create AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static AuthRegistrationsCredentialListMappingResource Create(CreateAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new credential list mapping resource - /// - /// Create AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new credential list mapping resource - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static AuthRegistrationsCredentialListMappingResource Create(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthRegistrationsCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new credential list mapping resource - /// - /// The SID of the SIP domain that will contain the new resource - /// The SID of the CredentialList resource to map to the SIP domain - /// The SID of the Account that will create the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthRegistrationsCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// Read AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static ResourceSet Read(ReadAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// Read AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("contents", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static ResourceSet Read(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthRegistrationsCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of credential list mappings belonging to the domain used in the request - /// - /// The SID of the SIP domain that contains the resources to read - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthRegistrationsCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, - ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("contents", response.Content); - } - - private static Request BuildFetchRequest(FetchAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific instance of a credential list mapping - /// - /// Fetch AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static AuthRegistrationsCredentialListMappingResource Fetch(FetchAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific instance of a credential list mapping - /// - /// Fetch AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific instance of a credential list mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static AuthRegistrationsCredentialListMappingResource Fetch(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific instance of a credential list mapping - /// - /// The SID of the SIP domain that contains the resource to fetch - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a credential list mapping from the requested domain - /// - /// Delete AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static bool Delete(DeleteAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a credential list mapping from the requested domain - /// - /// Delete AuthRegistrationsCredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthRegistrationsCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a credential list mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of AuthRegistrationsCredentialListMapping - public static bool Delete(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a credential list mapping from the requested domain - /// - /// The SID of the SIP domain that contains the resources to delete - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AuthRegistrationsCredentialListMappingResource object - /// - /// Raw JSON string - /// AuthRegistrationsCredentialListMappingResource object represented by the provided JSON - public static AuthRegistrationsCredentialListMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - - private AuthRegistrationsCredentialListMappingResource() - { - - } - } +{ + + public class AuthRegistrationsCredentialListMappingResource : Resource + { + private static Request BuildCreateRequest(CreateAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new credential list mapping resource + /// + /// Create AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static AuthRegistrationsCredentialListMappingResource Create(CreateAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new credential list mapping resource + /// + /// Create AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new credential list mapping resource + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static AuthRegistrationsCredentialListMappingResource Create(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthRegistrationsCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new credential list mapping resource + /// + /// The SID of the SIP domain that will contain the new resource + /// The SID of the CredentialList resource to map to the SIP domain + /// The SID of the Account that will create the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthRegistrationsCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// Read AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static ResourceSet Read(ReadAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// Read AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("contents", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static ResourceSet Read(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthRegistrationsCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of credential list mappings belonging to the domain used in the request + /// + /// The SID of the SIP domain that contains the resources to read + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthRegistrationsCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, + ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("contents", response.Content); + } + + private static Request BuildFetchRequest(FetchAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific instance of a credential list mapping + /// + /// Fetch AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static AuthRegistrationsCredentialListMappingResource Fetch(FetchAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific instance of a credential list mapping + /// + /// Fetch AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific instance of a credential list mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static AuthRegistrationsCredentialListMappingResource Fetch(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific instance of a credential list mapping + /// + /// The SID of the SIP domain that contains the resource to fetch + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/Auth/Registrations/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a credential list mapping from the requested domain + /// + /// Delete AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static bool Delete(DeleteAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a credential list mapping from the requested domain + /// + /// Delete AuthRegistrationsCredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAuthRegistrationsCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a credential list mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of AuthRegistrationsCredentialListMapping + public static bool Delete(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a credential list mapping from the requested domain + /// + /// The SID of the SIP domain that contains the resources to delete + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthRegistrationsCredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteAuthRegistrationsCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AuthRegistrationsCredentialListMappingResource object + /// + /// Raw JSON string + /// AuthRegistrationsCredentialListMappingResource object represented by the provided JSON + public static AuthRegistrationsCredentialListMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + + private AuthRegistrationsCredentialListMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingOptions.cs index 980f0eac8..46aa71549 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingOptions.cs @@ -9,168 +9,168 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain -{ - +{ + + /// + /// Create a CredentialListMapping resource for an account. + /// + public class CreateCredentialListMappingOptions : IOptions + { /// - /// Create a CredentialListMapping resource for an account. - /// - public class CreateCredentialListMappingOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the SIP Domain for which the CredentialList resource will be mapped - /// - public string PathDomainSid { get; } - /// - /// A string that identifies the CredentialList resource to map to the SIP domain - /// - public string CredentialListSid { get; } - - /// - /// Construct a new CreateCredentialListMappingOptions - /// - /// A string that identifies the SIP Domain for which the CredentialList resource will be - /// mapped - /// A string that identifies the CredentialList resource to map to the SIP domain - /// - public CreateCredentialListMappingOptions(string pathDomainSid, string credentialListSid) - { - PathDomainSid = pathDomainSid; - CredentialListSid = credentialListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CredentialListSid != null) - { - p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); - } - - return p; - } - } - + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } /// - /// Read multiple CredentialListMapping resources from an account. - /// - public class ReadCredentialListMappingOptions : ReadOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the SIP Domain that includes the resource to read - /// - public string PathDomainSid { get; } - - /// - /// Construct a new ReadCredentialListMappingOptions - /// - /// A string that identifies the SIP Domain that includes the resource to read - public ReadCredentialListMappingOptions(string pathDomainSid) - { - PathDomainSid = pathDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// A string that identifies the SIP Domain for which the CredentialList resource will be mapped + /// + public string PathDomainSid { get; } /// - /// Fetch a single CredentialListMapping resource from an account. - /// - public class FetchCredentialListMappingOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the SIP Domain that includes the resource to fetch - /// - public string PathDomainSid { get; } - /// - /// A string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialListMappingOptions - /// - /// A string that identifies the SIP Domain that includes the resource to fetch - /// A string that identifies the resource to fetch - public FetchCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string that identifies the CredentialList resource to map to the SIP domain + /// + public string CredentialListSid { get; } + /// - /// Delete a CredentialListMapping resource from an account. - /// - public class DeleteCredentialListMappingOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the SIP Domain that includes the resource to delete - /// - public string PathDomainSid { get; } - /// - /// A string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialListMappingOptions - /// - /// A string that identifies the SIP Domain that includes the resource to delete - /// A string that identifies the resource to delete - public DeleteCredentialListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateCredentialListMappingOptions + /// + /// A string that identifies the SIP Domain for which the CredentialList resource will be + /// mapped + /// A string that identifies the CredentialList resource to map to the SIP domain + /// + public CreateCredentialListMappingOptions(string pathDomainSid, string credentialListSid) + { + PathDomainSid = pathDomainSid; + CredentialListSid = credentialListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CredentialListSid != null) + { + p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); + } + + return p; + } + } + + /// + /// Read multiple CredentialListMapping resources from an account. + /// + public class ReadCredentialListMappingOptions : ReadOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the SIP Domain that includes the resource to read + /// + public string PathDomainSid { get; } + + /// + /// Construct a new ReadCredentialListMappingOptions + /// + /// A string that identifies the SIP Domain that includes the resource to read + public ReadCredentialListMappingOptions(string pathDomainSid) + { + PathDomainSid = pathDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a single CredentialListMapping resource from an account. + /// + public class FetchCredentialListMappingOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the SIP Domain that includes the resource to fetch + /// + public string PathDomainSid { get; } + /// + /// A string that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialListMappingOptions + /// + /// A string that identifies the SIP Domain that includes the resource to fetch + /// A string that identifies the resource to fetch + public FetchCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a CredentialListMapping resource from an account. + /// + public class DeleteCredentialListMappingOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the SIP Domain that includes the resource to delete + /// + public string PathDomainSid { get; } + /// + /// A string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialListMappingOptions + /// + /// A string that identifies the SIP Domain that includes the resource to delete + /// A string that identifies the resource to delete + public DeleteCredentialListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingResource.cs index f79fbb906..abde01748 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingResource.cs @@ -16,442 +16,442 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain -{ - - public class CredentialListMappingResource : Resource - { - private static Request BuildCreateRequest(CreateCredentialListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a CredentialListMapping resource for an account. - /// - /// Create CredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static CredentialListMappingResource Create(CreateCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a CredentialListMapping resource for an account. - /// - /// Create CredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a CredentialListMapping resource for an account. - /// - /// A string that identifies the SIP Domain for which the CredentialList resource will be - /// mapped - /// A string that identifies the CredentialList resource to map to the SIP domain - /// - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static CredentialListMappingResource Create(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a CredentialListMapping resource for an account. - /// - /// A string that identifies the SIP Domain for which the CredentialList resource will be - /// mapped - /// A string that identifies the CredentialList resource to map to the SIP domain - /// - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, - string credentialListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListMappingOptions(pathDomainSid, credentialListSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCredentialListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Read multiple CredentialListMapping resources from an account. - /// - /// Read CredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static ResourceSet Read(ReadCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_list_mappings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Read multiple CredentialListMapping resources from an account. - /// - /// Read CredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_list_mappings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Read multiple CredentialListMapping resources from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to read - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static ResourceSet Read(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Read multiple CredentialListMapping resources from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to read - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credential_list_mappings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credential_list_mappings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("credential_list_mappings", response.Content); - } - - private static Request BuildFetchRequest(FetchCredentialListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a single CredentialListMapping resource from an account. - /// - /// Fetch CredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static CredentialListMappingResource Fetch(FetchCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a single CredentialListMapping resource from an account. - /// - /// Fetch CredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a single CredentialListMapping resource from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to fetch - /// A string that identifies the resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static CredentialListMappingResource Fetch(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a single CredentialListMapping resource from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to fetch - /// A string that identifies the resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a CredentialListMapping resource from an account. - /// - /// Delete CredentialListMapping parameters - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static bool Delete(DeleteCredentialListMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a CredentialListMapping resource from an account. - /// - /// Delete CredentialListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a CredentialListMapping resource from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to delete - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of CredentialListMapping - public static bool Delete(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a CredentialListMapping resource from an account. - /// - /// A string that identifies the SIP Domain that includes the resource to delete - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialListMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialListMappingResource object - /// - /// Raw JSON string - /// CredentialListMappingResource object represented by the provided JSON - public static CredentialListMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique id of the Account that is responsible for this resource. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the SipDomain resource. - /// - [JsonProperty("domain_sid")] - public string DomainSid { get; private set; } - /// - /// A human readable descriptive text for this resource, up to 64 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI for this resource, relative to https://api.twilio.com - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private CredentialListMappingResource() - { - - } - } +{ + + public class CredentialListMappingResource : Resource + { + private static Request BuildCreateRequest(CreateCredentialListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a CredentialListMapping resource for an account. + /// + /// Create CredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static CredentialListMappingResource Create(CreateCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a CredentialListMapping resource for an account. + /// + /// Create CredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a CredentialListMapping resource for an account. + /// + /// A string that identifies the SIP Domain for which the CredentialList resource will be + /// mapped + /// A string that identifies the CredentialList resource to map to the SIP domain + /// + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static CredentialListMappingResource Create(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a CredentialListMapping resource for an account. + /// + /// A string that identifies the SIP Domain for which the CredentialList resource will be + /// mapped + /// A string that identifies the CredentialList resource to map to the SIP domain + /// + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, + string credentialListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListMappingOptions(pathDomainSid, credentialListSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCredentialListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Read multiple CredentialListMapping resources from an account. + /// + /// Read CredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static ResourceSet Read(ReadCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_list_mappings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Read multiple CredentialListMapping resources from an account. + /// + /// Read CredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_list_mappings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Read multiple CredentialListMapping resources from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to read + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static ResourceSet Read(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Read multiple CredentialListMapping resources from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to read + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credential_list_mappings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credential_list_mappings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("credential_list_mappings", response.Content); + } + + private static Request BuildFetchRequest(FetchCredentialListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a single CredentialListMapping resource from an account. + /// + /// Fetch CredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static CredentialListMappingResource Fetch(FetchCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a single CredentialListMapping resource from an account. + /// + /// Fetch CredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a single CredentialListMapping resource from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to fetch + /// A string that identifies the resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static CredentialListMappingResource Fetch(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a single CredentialListMapping resource from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to fetch + /// A string that identifies the resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/CredentialListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a CredentialListMapping resource from an account. + /// + /// Delete CredentialListMapping parameters + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static bool Delete(DeleteCredentialListMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a CredentialListMapping resource from an account. + /// + /// Delete CredentialListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a CredentialListMapping resource from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to delete + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of CredentialListMapping + public static bool Delete(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a CredentialListMapping resource from an account. + /// + /// A string that identifies the SIP Domain that includes the resource to delete + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialListMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialListMappingResource object + /// + /// Raw JSON string + /// CredentialListMappingResource object represented by the provided JSON + public static CredentialListMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique id of the Account that is responsible for this resource. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the SipDomain resource. + /// + [JsonProperty("domain_sid")] + public string DomainSid { get; private set; } + /// + /// A human readable descriptive text for this resource, up to 64 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI for this resource, relative to https://api.twilio.com + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private CredentialListMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingOptions.cs index 04b6c40ad..d350eec0b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingOptions.cs @@ -9,166 +9,166 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain -{ - +{ + + /// + /// Fetch an IpAccessControlListMapping resource. + /// + public class FetchIpAccessControlListMappingOptions : IOptions + { /// - /// Fetch an IpAccessControlListMapping resource. - /// - public class FetchIpAccessControlListMappingOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies the SIP Domain - /// - public string PathDomainSid { get; } - /// - /// A 34 character string that uniquely identifies the resource to fetch. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpAccessControlListMappingOptions - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to fetch. - public FetchIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } /// - /// Create a new IpAccessControlListMapping resource. - /// - public class CreateIpAccessControlListMappingOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies the SIP Domain - /// - public string PathDomainSid { get; } - /// - /// The unique id of the IP access control list to map to the SIP domain - /// - public string IpAccessControlListSid { get; } - - /// - /// Construct a new CreateIpAccessControlListMappingOptions - /// - /// A string that uniquely identifies the SIP Domain - /// The unique id of the IP access control list to map to the SIP domain - public CreateIpAccessControlListMappingOptions(string pathDomainSid, string ipAccessControlListSid) - { - PathDomainSid = pathDomainSid; - IpAccessControlListSid = ipAccessControlListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpAccessControlListSid != null) - { - p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); - } - - return p; - } - } - + /// A string that uniquely identifies the SIP Domain + /// + public string PathDomainSid { get; } /// - /// Retrieve a list of IpAccessControlListMapping resources. - /// - public class ReadIpAccessControlListMappingOptions : ReadOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies the SIP Domain - /// - public string PathDomainSid { get; } - - /// - /// Construct a new ReadIpAccessControlListMappingOptions - /// - /// A string that uniquely identifies the SIP Domain - public ReadIpAccessControlListMappingOptions(string pathDomainSid) - { - PathDomainSid = pathDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// A 34 character string that uniquely identifies the resource to fetch. + /// + public string PathSid { get; } + /// - /// Delete an IpAccessControlListMapping resource. - /// - public class DeleteIpAccessControlListMappingOptions : IOptions - { - /// - /// The unique id of the Account that is responsible for this resource. - /// - public string PathAccountSid { get; set; } - /// - /// A string that uniquely identifies the SIP Domain - /// - public string PathDomainSid { get; } - /// - /// A 34 character string that uniquely identifies the resource to delete. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIpAccessControlListMappingOptions - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to delete. - public DeleteIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) - { - PathDomainSid = pathDomainSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchIpAccessControlListMappingOptions + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to fetch. + public FetchIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Create a new IpAccessControlListMapping resource. + /// + public class CreateIpAccessControlListMappingOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// A string that uniquely identifies the SIP Domain + /// + public string PathDomainSid { get; } + /// + /// The unique id of the IP access control list to map to the SIP domain + /// + public string IpAccessControlListSid { get; } + + /// + /// Construct a new CreateIpAccessControlListMappingOptions + /// + /// A string that uniquely identifies the SIP Domain + /// The unique id of the IP access control list to map to the SIP domain + public CreateIpAccessControlListMappingOptions(string pathDomainSid, string ipAccessControlListSid) + { + PathDomainSid = pathDomainSid; + IpAccessControlListSid = ipAccessControlListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IpAccessControlListSid != null) + { + p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of IpAccessControlListMapping resources. + /// + public class ReadIpAccessControlListMappingOptions : ReadOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// A string that uniquely identifies the SIP Domain + /// + public string PathDomainSid { get; } + + /// + /// Construct a new ReadIpAccessControlListMappingOptions + /// + /// A string that uniquely identifies the SIP Domain + public ReadIpAccessControlListMappingOptions(string pathDomainSid) + { + PathDomainSid = pathDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete an IpAccessControlListMapping resource. + /// + public class DeleteIpAccessControlListMappingOptions : IOptions + { + /// + /// The unique id of the Account that is responsible for this resource. + /// + public string PathAccountSid { get; set; } + /// + /// A string that uniquely identifies the SIP Domain + /// + public string PathDomainSid { get; } + /// + /// A 34 character string that uniquely identifies the resource to delete. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIpAccessControlListMappingOptions + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to delete. + public DeleteIpAccessControlListMappingOptions(string pathDomainSid, string pathSid) + { + PathDomainSid = pathDomainSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingResource.cs index bbdddc887..7e07d2f08 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/Domain/IpAccessControlListMappingResource.cs @@ -16,438 +16,438 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.Domain -{ - - public class IpAccessControlListMappingResource : Resource - { - private static Request BuildFetchRequest(FetchIpAccessControlListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an IpAccessControlListMapping resource. - /// - /// Fetch IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static IpAccessControlListMappingResource Fetch(FetchIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an IpAccessControlListMapping resource. - /// - /// Fetch IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to fetch. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static IpAccessControlListMappingResource Fetch(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to fetch. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateIpAccessControlListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new IpAccessControlListMapping resource. - /// - /// Create IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static IpAccessControlListMappingResource Create(CreateIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new IpAccessControlListMapping resource. - /// - /// Create IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// The unique id of the IP access control list to map to the SIP domain - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static IpAccessControlListMappingResource Create(string pathDomainSid, - string ipAccessControlListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// The unique id of the IP access control list to map to the SIP domain - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, - string ipAccessControlListSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadIpAccessControlListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of IpAccessControlListMapping resources. - /// - /// Read IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static ResourceSet Read(ReadIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_list_mappings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IpAccessControlListMapping resources. - /// - /// Read IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_list_mappings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of IpAccessControlListMapping resources. - /// - /// A string that uniquely identifies the SIP Domain - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static ResourceSet Read(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IpAccessControlListMapping resources. - /// - /// A string that uniquely identifies the SIP Domain - /// The unique id of the Account that is responsible for this resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListMappingOptions(pathDomainSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_list_mappings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_list_mappings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_list_mappings", response.Content); - } - - private static Request BuildDeleteRequest(DeleteIpAccessControlListMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an IpAccessControlListMapping resource. - /// - /// Delete IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static bool Delete(DeleteIpAccessControlListMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an IpAccessControlListMapping resource. - /// - /// Delete IpAccessControlListMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to delete. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// A single instance of IpAccessControlListMapping - public static bool Delete(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an IpAccessControlListMapping resource. - /// - /// A string that uniquely identifies the SIP Domain - /// A 34 character string that uniquely identifies the resource to delete. - /// The unique id of the Account that is responsible for this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlListMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListMappingOptions(pathDomainSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a IpAccessControlListMappingResource object - /// - /// Raw JSON string - /// IpAccessControlListMappingResource object represented by the provided JSON - public static IpAccessControlListMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique id of the Account that is responsible for this resource. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the SipDomain resource. - /// - [JsonProperty("domain_sid")] - public string DomainSid { get; private set; } - /// - /// A human readable descriptive text for this resource, up to 64 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI for this resource, relative to https://api.twilio.com - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private IpAccessControlListMappingResource() - { - - } - } +{ + + public class IpAccessControlListMappingResource : Resource + { + private static Request BuildFetchRequest(FetchIpAccessControlListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an IpAccessControlListMapping resource. + /// + /// Fetch IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static IpAccessControlListMappingResource Fetch(FetchIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an IpAccessControlListMapping resource. + /// + /// Fetch IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to fetch. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static IpAccessControlListMappingResource Fetch(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to fetch. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateIpAccessControlListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new IpAccessControlListMapping resource. + /// + /// Create IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static IpAccessControlListMappingResource Create(CreateIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new IpAccessControlListMapping resource. + /// + /// Create IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// The unique id of the IP access control list to map to the SIP domain + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static IpAccessControlListMappingResource Create(string pathDomainSid, + string ipAccessControlListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// The unique id of the IP access control list to map to the SIP domain + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task CreateAsync(string pathDomainSid, + string ipAccessControlListSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListMappingOptions(pathDomainSid, ipAccessControlListSid) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadIpAccessControlListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of IpAccessControlListMapping resources. + /// + /// Read IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static ResourceSet Read(ReadIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_list_mappings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IpAccessControlListMapping resources. + /// + /// Read IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_list_mappings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of IpAccessControlListMapping resources. + /// + /// A string that uniquely identifies the SIP Domain + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static ResourceSet Read(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IpAccessControlListMapping resources. + /// + /// A string that uniquely identifies the SIP Domain + /// The unique id of the Account that is responsible for this resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task> ReadAsync(string pathDomainSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListMappingOptions(pathDomainSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_list_mappings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_list_mappings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_list_mappings", response.Content); + } + + private static Request BuildDeleteRequest(DeleteIpAccessControlListMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathDomainSid + "/IpAccessControlListMappings/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an IpAccessControlListMapping resource. + /// + /// Delete IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static bool Delete(DeleteIpAccessControlListMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an IpAccessControlListMapping resource. + /// + /// Delete IpAccessControlListMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to delete. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// A single instance of IpAccessControlListMapping + public static bool Delete(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an IpAccessControlListMapping resource. + /// + /// A string that uniquely identifies the SIP Domain + /// A 34 character string that uniquely identifies the resource to delete. + /// The unique id of the Account that is responsible for this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlListMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathDomainSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListMappingOptions(pathDomainSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a IpAccessControlListMappingResource object + /// + /// Raw JSON string + /// IpAccessControlListMappingResource object represented by the provided JSON + public static IpAccessControlListMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique id of the Account that is responsible for this resource. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the SipDomain resource. + /// + [JsonProperty("domain_sid")] + public string DomainSid { get; private set; } + /// + /// A human readable descriptive text for this resource, up to 64 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI for this resource, relative to https://api.twilio.com + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private IpAccessControlListMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/DomainOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/DomainOptions.cs index 929e8d40d..09b6aed6e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/DomainOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/DomainOptions.cs @@ -9,393 +9,393 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - +{ + + /// + /// Retrieve a list of domains belonging to the account used to make the request + /// + public class ReadDomainOptions : ReadOptions + { /// - /// Retrieve a list of domains belonging to the account used to make the request + /// The SID of the Account that created the resources to read /// - public class ReadDomainOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathAccountSid { get; set; } + /// - /// Create a new Domain - /// - public class CreateDomainOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The unique address on Twilio to route SIP traffic - /// - public string DomainName { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The URL we should call when receiving a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The HTTP method to use with voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when an error occurs in executing TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method to use with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL that we should call to pass status updates - /// - public Uri VoiceStatusCallbackUrl { get; set; } - /// - /// The HTTP method we should use to call `voice_status_callback_url` - /// - public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; set; } - /// - /// Whether SIP registration is allowed - /// - public bool? SipRegistration { get; set; } - /// - /// Whether emergency calling is enabled for the domain. - /// - public bool? EmergencyCallingEnabled { get; set; } - /// - /// Whether secure SIP is enabled for the domain - /// - public bool? Secure { get; set; } - /// - /// The SID of the BYOC Trunk resource. - /// - public string ByocTrunkSid { get; set; } - /// - /// Whether an emergency caller sid is configured for the domain. - /// - public string EmergencyCallerSid { get; set; } - - /// - /// Construct a new CreateDomainOptions - /// - /// The unique address on Twilio to route SIP traffic - public CreateDomainOptions(string domainName) - { - DomainName = domainName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DomainName != null) - { - p.Add(new KeyValuePair("DomainName", DomainName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceStatusCallbackUrl", Serializers.Url(VoiceStatusCallbackUrl))); - } - - if (VoiceStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceStatusCallbackMethod", VoiceStatusCallbackMethod.ToString())); - } - - if (SipRegistration != null) - { - p.Add(new KeyValuePair("SipRegistration", SipRegistration.Value.ToString().ToLower())); - } - - if (EmergencyCallingEnabled != null) - { - p.Add(new KeyValuePair("EmergencyCallingEnabled", EmergencyCallingEnabled.Value.ToString().ToLower())); - } - - if (Secure != null) - { - p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); - } - - if (ByocTrunkSid != null) - { - p.Add(new KeyValuePair("ByocTrunkSid", ByocTrunkSid.ToString())); - } - - if (EmergencyCallerSid != null) - { - p.Add(new KeyValuePair("EmergencyCallerSid", EmergencyCallerSid.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new Domain + /// + public class CreateDomainOptions : IOptions + { /// - /// Fetch an instance of a Domain - /// - public class FetchDomainOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDomainOptions - /// - /// The unique string that identifies the resource - public FetchDomainOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } /// - /// Update the attributes of a domain - /// - public class UpdateDomainOptions : IOptions - { - /// - /// The SID of the Account that created the resource to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL we should call when an error occurs in executing TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method we should use with voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The HTTP method we should use to call voice_status_callback_url - /// - public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; set; } - /// - /// The URL that we should call to pass status updates - /// - public Uri VoiceStatusCallbackUrl { get; set; } - /// - /// The URL we should call when receiving a call - /// - public Uri VoiceUrl { get; set; } - /// - /// Whether SIP registration is allowed - /// - public bool? SipRegistration { get; set; } - /// - /// The unique address on Twilio to route SIP traffic - /// - public string DomainName { get; set; } - /// - /// Whether emergency calling is enabled for the domain. - /// - public bool? EmergencyCallingEnabled { get; set; } - /// - /// Whether secure SIP is enabled for the domain - /// - public bool? Secure { get; set; } - /// - /// The SID of the BYOC Trunk resource. - /// - public string ByocTrunkSid { get; set; } - /// - /// Whether an emergency caller sid is configured for the domain. - /// - public string EmergencyCallerSid { get; set; } - - /// - /// Construct a new UpdateDomainOptions - /// - /// The unique string that identifies the resource - public UpdateDomainOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceStatusCallbackMethod", VoiceStatusCallbackMethod.ToString())); - } - - if (VoiceStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceStatusCallbackUrl", Serializers.Url(VoiceStatusCallbackUrl))); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (SipRegistration != null) - { - p.Add(new KeyValuePair("SipRegistration", SipRegistration.Value.ToString().ToLower())); - } - - if (DomainName != null) - { - p.Add(new KeyValuePair("DomainName", DomainName)); - } - - if (EmergencyCallingEnabled != null) - { - p.Add(new KeyValuePair("EmergencyCallingEnabled", EmergencyCallingEnabled.Value.ToString().ToLower())); - } - - if (Secure != null) - { - p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); - } - - if (ByocTrunkSid != null) - { - p.Add(new KeyValuePair("ByocTrunkSid", ByocTrunkSid.ToString())); - } - - if (EmergencyCallerSid != null) - { - p.Add(new KeyValuePair("EmergencyCallerSid", EmergencyCallerSid.ToString())); - } - - return p; - } - } - + /// The unique address on Twilio to route SIP traffic + /// + public string DomainName { get; } /// - /// Delete an instance of a Domain - /// - public class DeleteDomainOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteDomainOptions - /// - /// The unique string that identifies the resource - public DeleteDomainOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The URL we should call when receiving a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The HTTP method to use with voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when an error occurs in executing TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method to use with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL that we should call to pass status updates + /// + public Uri VoiceStatusCallbackUrl { get; set; } + /// + /// The HTTP method we should use to call `voice_status_callback_url` + /// + public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; set; } + /// + /// Whether SIP registration is allowed + /// + public bool? SipRegistration { get; set; } + /// + /// Whether emergency calling is enabled for the domain. + /// + public bool? EmergencyCallingEnabled { get; set; } + /// + /// Whether secure SIP is enabled for the domain + /// + public bool? Secure { get; set; } + /// + /// The SID of the BYOC Trunk resource. + /// + public string ByocTrunkSid { get; set; } + /// + /// Whether an emergency caller sid is configured for the domain. + /// + public string EmergencyCallerSid { get; set; } + + /// + /// Construct a new CreateDomainOptions + /// + /// The unique address on Twilio to route SIP traffic + public CreateDomainOptions(string domainName) + { + DomainName = domainName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DomainName != null) + { + p.Add(new KeyValuePair("DomainName", DomainName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceStatusCallbackUrl", Serializers.Url(VoiceStatusCallbackUrl))); + } + + if (VoiceStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceStatusCallbackMethod", VoiceStatusCallbackMethod.ToString())); + } + + if (SipRegistration != null) + { + p.Add(new KeyValuePair("SipRegistration", SipRegistration.Value.ToString().ToLower())); + } + + if (EmergencyCallingEnabled != null) + { + p.Add(new KeyValuePair("EmergencyCallingEnabled", EmergencyCallingEnabled.Value.ToString().ToLower())); + } + + if (Secure != null) + { + p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); + } + + if (ByocTrunkSid != null) + { + p.Add(new KeyValuePair("ByocTrunkSid", ByocTrunkSid.ToString())); + } + + if (EmergencyCallerSid != null) + { + p.Add(new KeyValuePair("EmergencyCallerSid", EmergencyCallerSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch an instance of a Domain + /// + public class FetchDomainOptions : IOptions + { + /// + /// The SID of the Account that created the resource to fetch + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDomainOptions + /// + /// The unique string that identifies the resource + public FetchDomainOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the attributes of a domain + /// + public class UpdateDomainOptions : IOptions + { + /// + /// The SID of the Account that created the resource to update + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL we should call when an error occurs in executing TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method we should use with voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The HTTP method we should use to call voice_status_callback_url + /// + public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; set; } + /// + /// The URL that we should call to pass status updates + /// + public Uri VoiceStatusCallbackUrl { get; set; } + /// + /// The URL we should call when receiving a call + /// + public Uri VoiceUrl { get; set; } + /// + /// Whether SIP registration is allowed + /// + public bool? SipRegistration { get; set; } + /// + /// The unique address on Twilio to route SIP traffic + /// + public string DomainName { get; set; } + /// + /// Whether emergency calling is enabled for the domain. + /// + public bool? EmergencyCallingEnabled { get; set; } + /// + /// Whether secure SIP is enabled for the domain + /// + public bool? Secure { get; set; } + /// + /// The SID of the BYOC Trunk resource. + /// + public string ByocTrunkSid { get; set; } + /// + /// Whether an emergency caller sid is configured for the domain. + /// + public string EmergencyCallerSid { get; set; } + + /// + /// Construct a new UpdateDomainOptions + /// + /// The unique string that identifies the resource + public UpdateDomainOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceStatusCallbackMethod", VoiceStatusCallbackMethod.ToString())); + } + + if (VoiceStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceStatusCallbackUrl", Serializers.Url(VoiceStatusCallbackUrl))); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (SipRegistration != null) + { + p.Add(new KeyValuePair("SipRegistration", SipRegistration.Value.ToString().ToLower())); + } + + if (DomainName != null) + { + p.Add(new KeyValuePair("DomainName", DomainName)); + } + + if (EmergencyCallingEnabled != null) + { + p.Add(new KeyValuePair("EmergencyCallingEnabled", EmergencyCallingEnabled.Value.ToString().ToLower())); + } + + if (Secure != null) + { + p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); + } + + if (ByocTrunkSid != null) + { + p.Add(new KeyValuePair("ByocTrunkSid", ByocTrunkSid.ToString())); + } + + if (EmergencyCallerSid != null) + { + p.Add(new KeyValuePair("EmergencyCallerSid", EmergencyCallerSid.ToString())); + } + + return p; + } + } + + /// + /// Delete an instance of a Domain + /// + public class DeleteDomainOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteDomainOptions + /// + /// The unique string that identifies the resource + public DeleteDomainOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/DomainResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/DomainResource.cs index a21831f7d..1db334b72 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/DomainResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/DomainResource.cs @@ -16,658 +16,658 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - - public class DomainResource : Resource - { - private static Request BuildReadRequest(ReadDomainOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of domains belonging to the account used to make the request - /// - /// Read Domain parameters - /// Client to make requests to Twilio - /// A single instance of Domain - public static ResourceSet Read(ReadDomainOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("domains", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of domains belonging to the account used to make the request - /// - /// Read Domain parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task> ReadAsync(ReadDomainOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("domains", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of domains belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Domain - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDomainOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of domains belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDomainOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("domains", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("domains", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("domains", response.Content); - } - - private static Request BuildCreateRequest(CreateDomainOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Domain - /// - /// Create Domain parameters - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Create(CreateDomainOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Domain - /// - /// Create Domain parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task CreateAsync(CreateDomainOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Domain - /// - /// The unique address on Twilio to route SIP traffic - /// The SID of the Account that will create the resource - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method to use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method to use with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call `voice_status_callback_url` - /// Whether SIP registration is allowed - /// Whether emergency calling is enabled for the domain. - /// Whether secure SIP is enabled for the domain - /// The SID of the BYOC Trunk resource. - /// Whether an emergency caller sid is configured for the domain. - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Create(string domainName, - string pathAccountSid = null, - string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceStatusCallbackUrl = null, - Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, - bool? sipRegistration = null, - bool? emergencyCallingEnabled = null, - bool? secure = null, - string byocTrunkSid = null, - string emergencyCallerSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDomainOptions(domainName){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, SipRegistration = sipRegistration, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Domain - /// - /// The unique address on Twilio to route SIP traffic - /// The SID of the Account that will create the resource - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method to use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method to use with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call `voice_status_callback_url` - /// Whether SIP registration is allowed - /// Whether emergency calling is enabled for the domain. - /// Whether secure SIP is enabled for the domain - /// The SID of the BYOC Trunk resource. - /// Whether an emergency caller sid is configured for the domain. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task CreateAsync(string domainName, - string pathAccountSid = null, - string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceStatusCallbackUrl = null, - Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, - bool? sipRegistration = null, - bool? emergencyCallingEnabled = null, - bool? secure = null, - string byocTrunkSid = null, - string emergencyCallerSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDomainOptions(domainName){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, SipRegistration = sipRegistration, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchDomainOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a Domain - /// - /// Fetch Domain parameters - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Fetch(FetchDomainOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a Domain - /// - /// Fetch Domain parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task FetchAsync(FetchDomainOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a Domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchDomainOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a Domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchDomainOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateDomainOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the attributes of a domain - /// - /// Update Domain parameters - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Update(UpdateDomainOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the attributes of a domain - /// - /// Update Domain parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDomainOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the attributes of a domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to update - /// A string to describe the resource - /// The HTTP method used with voice_fallback_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method we should use with voice_url - /// The HTTP method we should use to call voice_status_callback_url - /// The URL that we should call to pass status updates - /// The URL we should call when receiving a call - /// Whether SIP registration is allowed - /// The unique address on Twilio to route SIP traffic - /// Whether emergency calling is enabled for the domain. - /// Whether secure SIP is enabled for the domain - /// The SID of the BYOC Trunk resource. - /// Whether an emergency caller sid is configured for the domain. - /// Client to make requests to Twilio - /// A single instance of Domain - public static DomainResource Update(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, - Uri voiceStatusCallbackUrl = null, - Uri voiceUrl = null, - bool? sipRegistration = null, - string domainName = null, - bool? emergencyCallingEnabled = null, - bool? secure = null, - string byocTrunkSid = null, - string emergencyCallerSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateDomainOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceUrl = voiceUrl, SipRegistration = sipRegistration, DomainName = domainName, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the attributes of a domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to update - /// A string to describe the resource - /// The HTTP method used with voice_fallback_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method we should use with voice_url - /// The HTTP method we should use to call voice_status_callback_url - /// The URL that we should call to pass status updates - /// The URL we should call when receiving a call - /// Whether SIP registration is allowed - /// The unique address on Twilio to route SIP traffic - /// Whether emergency calling is enabled for the domain. - /// Whether secure SIP is enabled for the domain - /// The SID of the BYOC Trunk resource. - /// Whether an emergency caller sid is configured for the domain. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - string friendlyName = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, - Uri voiceStatusCallbackUrl = null, - Uri voiceUrl = null, - bool? sipRegistration = null, - string domainName = null, - bool? emergencyCallingEnabled = null, - bool? secure = null, - string byocTrunkSid = null, - string emergencyCallerSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateDomainOptions(pathSid){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceUrl = voiceUrl, SipRegistration = sipRegistration, DomainName = domainName, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDomainOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an instance of a Domain - /// - /// Delete Domain parameters - /// Client to make requests to Twilio - /// A single instance of Domain - public static bool Delete(DeleteDomainOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an instance of a Domain - /// - /// Delete Domain parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDomainOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an instance of a Domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Domain - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteDomainOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an instance of a Domain - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Domain - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteDomainOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DomainResource object - /// - /// Raw JSON string - /// DomainResource object represented by the provided JSON - public static DomainResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to process the call - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The types of authentication mapped to the domain - /// - [JsonProperty("auth_type")] - public string AuthType { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique address on Twilio to route SIP traffic - /// - [JsonProperty("domain_name")] - public string DomainName { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method to use with voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The HTTP method we use to call voice_status_callback_url - /// - [JsonProperty("voice_status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; private set; } - /// - /// The URL that we call with status updates - /// - [JsonProperty("voice_status_callback_url")] - public Uri VoiceStatusCallbackUrl { get; private set; } - /// - /// The URL we call when receiving a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// A list mapping resources associated with the SIP Domain resource - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// Whether SIP registration is allowed - /// - [JsonProperty("sip_registration")] - public bool? SipRegistration { get; private set; } - /// - /// Whether emergency calling is enabled for the domain. - /// - [JsonProperty("emergency_calling_enabled")] - public bool? EmergencyCallingEnabled { get; private set; } - /// - /// Whether secure SIP is enabled for the domain - /// - [JsonProperty("secure")] - public bool? Secure { get; private set; } - /// - /// The SID of the BYOC Trunk resource. - /// - [JsonProperty("byoc_trunk_sid")] - public string ByocTrunkSid { get; private set; } - /// - /// Whether an emergency caller sid is configured for the domain. - /// - [JsonProperty("emergency_caller_sid")] - public string EmergencyCallerSid { get; private set; } - - private DomainResource() - { - - } - } +{ + + public class DomainResource : Resource + { + private static Request BuildReadRequest(ReadDomainOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of domains belonging to the account used to make the request + /// + /// Read Domain parameters + /// Client to make requests to Twilio + /// A single instance of Domain + public static ResourceSet Read(ReadDomainOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("domains", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of domains belonging to the account used to make the request + /// + /// Read Domain parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task> ReadAsync(ReadDomainOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("domains", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of domains belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Domain + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDomainOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of domains belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDomainOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("domains", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("domains", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("domains", response.Content); + } + + private static Request BuildCreateRequest(CreateDomainOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Domain + /// + /// Create Domain parameters + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Create(CreateDomainOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Domain + /// + /// Create Domain parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task CreateAsync(CreateDomainOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Domain + /// + /// The unique address on Twilio to route SIP traffic + /// The SID of the Account that will create the resource + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method to use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method to use with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call `voice_status_callback_url` + /// Whether SIP registration is allowed + /// Whether emergency calling is enabled for the domain. + /// Whether secure SIP is enabled for the domain + /// The SID of the BYOC Trunk resource. + /// Whether an emergency caller sid is configured for the domain. + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Create(string domainName, + string pathAccountSid = null, + string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceStatusCallbackUrl = null, + Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, + bool? sipRegistration = null, + bool? emergencyCallingEnabled = null, + bool? secure = null, + string byocTrunkSid = null, + string emergencyCallerSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDomainOptions(domainName) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, SipRegistration = sipRegistration, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Domain + /// + /// The unique address on Twilio to route SIP traffic + /// The SID of the Account that will create the resource + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method to use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method to use with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call `voice_status_callback_url` + /// Whether SIP registration is allowed + /// Whether emergency calling is enabled for the domain. + /// Whether secure SIP is enabled for the domain + /// The SID of the BYOC Trunk resource. + /// Whether an emergency caller sid is configured for the domain. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task CreateAsync(string domainName, + string pathAccountSid = null, + string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceStatusCallbackUrl = null, + Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, + bool? sipRegistration = null, + bool? emergencyCallingEnabled = null, + bool? secure = null, + string byocTrunkSid = null, + string emergencyCallerSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDomainOptions(domainName) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, SipRegistration = sipRegistration, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchDomainOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a Domain + /// + /// Fetch Domain parameters + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Fetch(FetchDomainOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a Domain + /// + /// Fetch Domain parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task FetchAsync(FetchDomainOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a Domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchDomainOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a Domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchDomainOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateDomainOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the attributes of a domain + /// + /// Update Domain parameters + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Update(UpdateDomainOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the attributes of a domain + /// + /// Update Domain parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDomainOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the attributes of a domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to update + /// A string to describe the resource + /// The HTTP method used with voice_fallback_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method we should use with voice_url + /// The HTTP method we should use to call voice_status_callback_url + /// The URL that we should call to pass status updates + /// The URL we should call when receiving a call + /// Whether SIP registration is allowed + /// The unique address on Twilio to route SIP traffic + /// Whether emergency calling is enabled for the domain. + /// Whether secure SIP is enabled for the domain + /// The SID of the BYOC Trunk resource. + /// Whether an emergency caller sid is configured for the domain. + /// Client to make requests to Twilio + /// A single instance of Domain + public static DomainResource Update(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, + Uri voiceStatusCallbackUrl = null, + Uri voiceUrl = null, + bool? sipRegistration = null, + string domainName = null, + bool? emergencyCallingEnabled = null, + bool? secure = null, + string byocTrunkSid = null, + string emergencyCallerSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateDomainOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceUrl = voiceUrl, SipRegistration = sipRegistration, DomainName = domainName, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the attributes of a domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to update + /// A string to describe the resource + /// The HTTP method used with voice_fallback_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method we should use with voice_url + /// The HTTP method we should use to call voice_status_callback_url + /// The URL that we should call to pass status updates + /// The URL we should call when receiving a call + /// Whether SIP registration is allowed + /// The unique address on Twilio to route SIP traffic + /// Whether emergency calling is enabled for the domain. + /// Whether secure SIP is enabled for the domain + /// The SID of the BYOC Trunk resource. + /// Whether an emergency caller sid is configured for the domain. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + string friendlyName = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Twilio.Http.HttpMethod voiceStatusCallbackMethod = null, + Uri voiceStatusCallbackUrl = null, + Uri voiceUrl = null, + bool? sipRegistration = null, + string domainName = null, + bool? emergencyCallingEnabled = null, + bool? secure = null, + string byocTrunkSid = null, + string emergencyCallerSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateDomainOptions(pathSid) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceStatusCallbackMethod = voiceStatusCallbackMethod, VoiceStatusCallbackUrl = voiceStatusCallbackUrl, VoiceUrl = voiceUrl, SipRegistration = sipRegistration, DomainName = domainName, EmergencyCallingEnabled = emergencyCallingEnabled, Secure = secure, ByocTrunkSid = byocTrunkSid, EmergencyCallerSid = emergencyCallerSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDomainOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/Domains/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an instance of a Domain + /// + /// Delete Domain parameters + /// Client to make requests to Twilio + /// A single instance of Domain + public static bool Delete(DeleteDomainOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an instance of a Domain + /// + /// Delete Domain parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDomainOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an instance of a Domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Domain + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteDomainOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an instance of a Domain + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Domain + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteDomainOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DomainResource object + /// + /// Raw JSON string + /// DomainResource object represented by the provided JSON + public static DomainResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to process the call + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The types of authentication mapped to the domain + /// + [JsonProperty("auth_type")] + public string AuthType { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique address on Twilio to route SIP traffic + /// + [JsonProperty("domain_name")] + public string DomainName { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method to use with voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The HTTP method we use to call voice_status_callback_url + /// + [JsonProperty("voice_status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceStatusCallbackMethod { get; private set; } + /// + /// The URL that we call with status updates + /// + [JsonProperty("voice_status_callback_url")] + public Uri VoiceStatusCallbackUrl { get; private set; } + /// + /// The URL we call when receiving a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// A list mapping resources associated with the SIP Domain resource + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// Whether SIP registration is allowed + /// + [JsonProperty("sip_registration")] + public bool? SipRegistration { get; private set; } + /// + /// Whether emergency calling is enabled for the domain. + /// + [JsonProperty("emergency_calling_enabled")] + public bool? EmergencyCallingEnabled { get; private set; } + /// + /// Whether secure SIP is enabled for the domain + /// + [JsonProperty("secure")] + public bool? Secure { get; private set; } + /// + /// The SID of the BYOC Trunk resource. + /// + [JsonProperty("byoc_trunk_sid")] + public string ByocTrunkSid { get; private set; } + /// + /// Whether an emergency caller sid is configured for the domain. + /// + [JsonProperty("emergency_caller_sid")] + public string EmergencyCallerSid { get; private set; } + + private DomainResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressOptions.cs index 5645b3f72..862306ade 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressOptions.cs @@ -9,258 +9,258 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip.IpAccessControlList -{ - +{ + + /// + /// Read multiple IpAddress resources. + /// + public class ReadIpAddressOptions : ReadOptions + { /// - /// Read multiple IpAddress resources. + /// The unique sid that identifies this account /// - public class ReadIpAddressOptions : ReadOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to read - /// - public string PathIpAccessControlListSid { get; } - - /// - /// Construct a new ReadIpAddressOptions - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// read - public ReadIpAddressOptions(string pathIpAccessControlListSid) - { - PathIpAccessControlListSid = pathIpAccessControlListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Create a new IpAddress resource. + /// The IpAccessControlList Sid that identifies the IpAddress resources to read /// - public class CreateIpAddressOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The IpAccessControlList Sid with which to associate the created IpAddress resource - /// - public string PathIpAccessControlListSid { get; } - /// - /// A human readable descriptive text for this resource, up to 64 characters long. - /// - public string FriendlyName { get; } - /// - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// - public string IpAddress { get; } - /// - /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. - /// - public int? CidrPrefixLength { get; set; } - - /// - /// Construct a new CreateIpAddressOptions - /// - /// The IpAccessControlList Sid with which to associate the created IpAddress - /// resource - /// A human readable descriptive text for this resource, up to 64 characters long. - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP - /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. - public CreateIpAddressOptions(string pathIpAccessControlListSid, string friendlyName, string ipAddress) - { - PathIpAccessControlListSid = pathIpAccessControlListSid; - FriendlyName = friendlyName; - IpAddress = ipAddress; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (IpAddress != null) - { - p.Add(new KeyValuePair("IpAddress", IpAddress)); - } - - if (CidrPrefixLength != null) - { - p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); - } - - return p; - } - } - + public string PathIpAccessControlListSid { get; } + /// - /// Read one IpAddress resource. + /// Construct a new ReadIpAddressOptions /// - public class FetchIpAddressOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to fetch - /// - public string PathIpAccessControlListSid { get; } - /// - /// A string that identifies the IpAddress resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpAddressOptions - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// fetch - /// A string that identifies the IpAddress resource to fetch - public FetchIpAddressOptions(string pathIpAccessControlListSid, string pathSid) - { - PathIpAccessControlListSid = pathIpAccessControlListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// read + public ReadIpAddressOptions(string pathIpAccessControlListSid) + { + PathIpAccessControlListSid = pathIpAccessControlListSid; + } + /// - /// Update an IpAddress resource. + /// Generate the necessary parameters /// - public class UpdateIpAddressOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to update - /// - public string PathIpAccessControlListSid { get; } - /// - /// A string that identifies the IpAddress resource to update - /// - public string PathSid { get; } - /// - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// - public string IpAddress { get; set; } - /// - /// A human readable descriptive text for this resource, up to 64 characters long. - /// - public string FriendlyName { get; set; } - /// - /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. - /// - public int? CidrPrefixLength { get; set; } - - /// - /// Construct a new UpdateIpAddressOptions - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// update - /// A string that identifies the IpAddress resource to update - public UpdateIpAddressOptions(string pathIpAccessControlListSid, string pathSid) - { - PathIpAccessControlListSid = pathIpAccessControlListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpAddress != null) - { - p.Add(new KeyValuePair("IpAddress", IpAddress)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CidrPrefixLength != null) - { - p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new IpAddress resource. + /// + public class CreateIpAddressOptions : IOptions + { /// - /// Delete an IpAddress resource. + /// The unique sid that identifies this account /// - public class DeleteIpAddressOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to delete - /// - public string PathIpAccessControlListSid { get; } - /// - /// A string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIpAddressOptions - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// delete - /// A string that identifies the resource to delete - public DeleteIpAddressOptions(string pathIpAccessControlListSid, string pathSid) - { - PathIpAccessControlListSid = pathIpAccessControlListSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The IpAccessControlList Sid with which to associate the created IpAddress resource + /// + public string PathIpAccessControlListSid { get; } + /// + /// A human readable descriptive text for this resource, up to 64 characters long. + /// + public string FriendlyName { get; } + /// + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// + public string IpAddress { get; } + /// + /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. + /// + public int? CidrPrefixLength { get; set; } + + /// + /// Construct a new CreateIpAddressOptions + /// + /// The IpAccessControlList Sid with which to associate the created IpAddress + /// resource + /// A human readable descriptive text for this resource, up to 64 characters long. + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP + /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. + public CreateIpAddressOptions(string pathIpAccessControlListSid, string friendlyName, string ipAddress) + { + PathIpAccessControlListSid = pathIpAccessControlListSid; + FriendlyName = friendlyName; + IpAddress = ipAddress; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (IpAddress != null) + { + p.Add(new KeyValuePair("IpAddress", IpAddress)); + } + + if (CidrPrefixLength != null) + { + p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); + } + + return p; + } + } + + /// + /// Read one IpAddress resource. + /// + public class FetchIpAddressOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to fetch + /// + public string PathIpAccessControlListSid { get; } + /// + /// A string that identifies the IpAddress resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchIpAddressOptions + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// fetch + /// A string that identifies the IpAddress resource to fetch + public FetchIpAddressOptions(string pathIpAccessControlListSid, string pathSid) + { + PathIpAccessControlListSid = pathIpAccessControlListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an IpAddress resource. + /// + public class UpdateIpAddressOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to update + /// + public string PathIpAccessControlListSid { get; } + /// + /// A string that identifies the IpAddress resource to update + /// + public string PathSid { get; } + /// + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// + public string IpAddress { get; set; } + /// + /// A human readable descriptive text for this resource, up to 64 characters long. + /// + public string FriendlyName { get; set; } + /// + /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. + /// + public int? CidrPrefixLength { get; set; } + + /// + /// Construct a new UpdateIpAddressOptions + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// update + /// A string that identifies the IpAddress resource to update + public UpdateIpAddressOptions(string pathIpAccessControlListSid, string pathSid) + { + PathIpAccessControlListSid = pathIpAccessControlListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IpAddress != null) + { + p.Add(new KeyValuePair("IpAddress", IpAddress)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CidrPrefixLength != null) + { + p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); + } + + return p; + } + } + + /// + /// Delete an IpAddress resource. + /// + public class DeleteIpAddressOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to delete + /// + public string PathIpAccessControlListSid { get; } + /// + /// A string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIpAddressOptions + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// delete + /// A string that identifies the resource to delete + public DeleteIpAddressOptions(string pathIpAccessControlListSid, string pathSid) + { + PathIpAccessControlListSid = pathIpAccessControlListSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressResource.cs index e0a8ef08a..cec391ae1 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlList/IpAddressResource.cs @@ -16,557 +16,557 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip.IpAccessControlList -{ - - public class IpAddressResource : Resource - { - private static Request BuildReadRequest(ReadIpAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Read multiple IpAddress resources. - /// - /// Read IpAddress parameters - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static ResourceSet Read(ReadIpAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_addresses", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Read multiple IpAddress resources. - /// - /// Read IpAddress parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_addresses", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Read multiple IpAddress resources. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// read - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static ResourceSet Read(string pathIpAccessControlListSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAddressOptions(pathIpAccessControlListSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Read multiple IpAddress resources. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// read - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task> ReadAsync(string pathIpAccessControlListSid, - string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAddressOptions(pathIpAccessControlListSid){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_addresses", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_addresses", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_addresses", response.Content); - } - - private static Request BuildCreateRequest(CreateIpAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new IpAddress resource. - /// - /// Create IpAddress parameters - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Create(CreateIpAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new IpAddress resource. - /// - /// Create IpAddress parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task CreateAsync(CreateIpAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new IpAddress resource. - /// - /// The IpAccessControlList Sid with which to associate the created IpAddress - /// resource - /// A human readable descriptive text for this resource, up to 64 characters long. - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP - /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// The unique sid that identifies this account - /// An integer representing the length of the CIDR prefix to use with this IP address - /// when accepting traffic. By default the entire IP address is used. - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Create(string pathIpAccessControlListSid, - string friendlyName, - string ipAddress, - string pathAccountSid = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAddressOptions(pathIpAccessControlListSid, friendlyName, ipAddress){PathAccountSid = pathAccountSid, CidrPrefixLength = cidrPrefixLength}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new IpAddress resource. - /// - /// The IpAccessControlList Sid with which to associate the created IpAddress - /// resource - /// A human readable descriptive text for this resource, up to 64 characters long. - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP - /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// The unique sid that identifies this account - /// An integer representing the length of the CIDR prefix to use with this IP address - /// when accepting traffic. By default the entire IP address is used. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task CreateAsync(string pathIpAccessControlListSid, - string friendlyName, - string ipAddress, - string pathAccountSid = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAddressOptions(pathIpAccessControlListSid, friendlyName, ipAddress){PathAccountSid = pathAccountSid, CidrPrefixLength = cidrPrefixLength}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchIpAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Read one IpAddress resource. - /// - /// Fetch IpAddress parameters - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Fetch(FetchIpAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Read one IpAddress resource. - /// - /// Fetch IpAddress parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task FetchAsync(FetchIpAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Read one IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// fetch - /// A string that identifies the IpAddress resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Fetch(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Read one IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// fetch - /// A string that identifies the IpAddress resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task FetchAsync(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateIpAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an IpAddress resource. - /// - /// Update IpAddress parameters - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Update(UpdateIpAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an IpAddress resource. - /// - /// Update IpAddress parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// update - /// A string that identifies the IpAddress resource to update - /// The unique sid that identifies this account - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP - /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// A human readable descriptive text for this resource, up to 64 characters long. - /// An integer representing the length of the CIDR prefix to use with this IP address - /// when accepting traffic. By default the entire IP address is used. - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static IpAddressResource Update(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - string ipAddress = null, - string friendlyName = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new UpdateIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid, IpAddress = ipAddress, FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// update - /// A string that identifies the IpAddress resource to update - /// The unique sid that identifies this account - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP - /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// A human readable descriptive text for this resource, up to 64 characters long. - /// An integer representing the length of the CIDR prefix to use with this IP address - /// when accepting traffic. By default the entire IP address is used. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task UpdateAsync(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - string ipAddress = null, - string friendlyName = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new UpdateIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid, IpAddress = ipAddress, FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteIpAddressOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an IpAddress resource. - /// - /// Delete IpAddress parameters - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static bool Delete(DeleteIpAddressOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an IpAddress resource. - /// - /// Delete IpAddress parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAddressOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// delete - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAddress - public static bool Delete(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an IpAddress resource. - /// - /// The IpAccessControlList Sid that identifies the IpAddress resources to - /// delete - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAddress - public static async System.Threading.Tasks.Task DeleteAsync(string pathIpAccessControlListSid, - string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIpAddressOptions(pathIpAccessControlListSid, pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a IpAddressResource object - /// - /// Raw JSON string - /// IpAddressResource object represented by the provided JSON - public static IpAddressResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique id of the Account that is responsible for this resource. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A human readable descriptive text for this resource, up to 64 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. - /// - [JsonProperty("ip_address")] - public string IpAddress { get; private set; } - /// - /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. - /// - [JsonProperty("cidr_prefix_length")] - public int? CidrPrefixLength { get; private set; } - /// - /// The unique id of the IpAccessControlList resource that includes this resource. - /// - [JsonProperty("ip_access_control_list_sid")] - public string IpAccessControlListSid { get; private set; } - /// - /// The date that this resource was created, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated, given as GMT in RFC 2822 format. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URI for this resource, relative to https://api.twilio.com - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private IpAddressResource() - { - - } - } +{ + + public class IpAddressResource : Resource + { + private static Request BuildReadRequest(ReadIpAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Read multiple IpAddress resources. + /// + /// Read IpAddress parameters + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static ResourceSet Read(ReadIpAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_addresses", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Read multiple IpAddress resources. + /// + /// Read IpAddress parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_addresses", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Read multiple IpAddress resources. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// read + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static ResourceSet Read(string pathIpAccessControlListSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAddressOptions(pathIpAccessControlListSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Read multiple IpAddress resources. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// read + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task> ReadAsync(string pathIpAccessControlListSid, + string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAddressOptions(pathIpAccessControlListSid) { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_addresses", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_addresses", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_addresses", response.Content); + } + + private static Request BuildCreateRequest(CreateIpAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new IpAddress resource. + /// + /// Create IpAddress parameters + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Create(CreateIpAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new IpAddress resource. + /// + /// Create IpAddress parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task CreateAsync(CreateIpAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new IpAddress resource. + /// + /// The IpAccessControlList Sid with which to associate the created IpAddress + /// resource + /// A human readable descriptive text for this resource, up to 64 characters long. + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP + /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// The unique sid that identifies this account + /// An integer representing the length of the CIDR prefix to use with this IP address + /// when accepting traffic. By default the entire IP address is used. + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Create(string pathIpAccessControlListSid, + string friendlyName, + string ipAddress, + string pathAccountSid = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAddressOptions(pathIpAccessControlListSid, friendlyName, ipAddress) { PathAccountSid = pathAccountSid, CidrPrefixLength = cidrPrefixLength }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new IpAddress resource. + /// + /// The IpAccessControlList Sid with which to associate the created IpAddress + /// resource + /// A human readable descriptive text for this resource, up to 64 characters long. + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP + /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// The unique sid that identifies this account + /// An integer representing the length of the CIDR prefix to use with this IP address + /// when accepting traffic. By default the entire IP address is used. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task CreateAsync(string pathIpAccessControlListSid, + string friendlyName, + string ipAddress, + string pathAccountSid = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAddressOptions(pathIpAccessControlListSid, friendlyName, ipAddress) { PathAccountSid = pathAccountSid, CidrPrefixLength = cidrPrefixLength }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchIpAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Read one IpAddress resource. + /// + /// Fetch IpAddress parameters + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Fetch(FetchIpAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Read one IpAddress resource. + /// + /// Fetch IpAddress parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task FetchAsync(FetchIpAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Read one IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// fetch + /// A string that identifies the IpAddress resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Fetch(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Read one IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// fetch + /// A string that identifies the IpAddress resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task FetchAsync(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateIpAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an IpAddress resource. + /// + /// Update IpAddress parameters + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Update(UpdateIpAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an IpAddress resource. + /// + /// Update IpAddress parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// update + /// A string that identifies the IpAddress resource to update + /// The unique sid that identifies this account + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP + /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// A human readable descriptive text for this resource, up to 64 characters long. + /// An integer representing the length of the CIDR prefix to use with this IP address + /// when accepting traffic. By default the entire IP address is used. + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static IpAddressResource Update(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + string ipAddress = null, + string friendlyName = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new UpdateIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid, IpAddress = ipAddress, FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// update + /// A string that identifies the IpAddress resource to update + /// The unique sid that identifies this account + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP + /// requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// A human readable descriptive text for this resource, up to 64 characters long. + /// An integer representing the length of the CIDR prefix to use with this IP address + /// when accepting traffic. By default the entire IP address is used. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task UpdateAsync(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + string ipAddress = null, + string friendlyName = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new UpdateIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid, IpAddress = ipAddress, FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteIpAddressOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathIpAccessControlListSid + "/IpAddresses/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an IpAddress resource. + /// + /// Delete IpAddress parameters + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static bool Delete(DeleteIpAddressOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an IpAddress resource. + /// + /// Delete IpAddress parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAddressOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// delete + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAddress + public static bool Delete(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an IpAddress resource. + /// + /// The IpAccessControlList Sid that identifies the IpAddress resources to + /// delete + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAddress + public static async System.Threading.Tasks.Task DeleteAsync(string pathIpAccessControlListSid, + string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIpAddressOptions(pathIpAccessControlListSid, pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a IpAddressResource object + /// + /// Raw JSON string + /// IpAddressResource object represented by the provided JSON + public static IpAddressResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique id of the Account that is responsible for this resource. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A human readable descriptive text for this resource, up to 64 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. + /// + [JsonProperty("ip_address")] + public string IpAddress { get; private set; } + /// + /// An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. + /// + [JsonProperty("cidr_prefix_length")] + public int? CidrPrefixLength { get; private set; } + /// + /// The unique id of the IpAccessControlList resource that includes this resource. + /// + [JsonProperty("ip_access_control_list_sid")] + public string IpAccessControlListSid { get; private set; } + /// + /// The date that this resource was created, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated, given as GMT in RFC 2822 format. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URI for this resource, relative to https://api.twilio.com + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private IpAddressResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListOptions.cs index 255fff9eb..8fe944d6e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListOptions.cs @@ -9,179 +9,179 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - +{ + + /// + /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// + public class ReadIpAccessControlListOptions : ReadOptions + { /// - /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// The unique sid that identifies this account /// - public class ReadIpAccessControlListOptions : ReadOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathAccountSid { get; set; } + /// - /// Create a new IpAccessControlList resource - /// - public class CreateIpAccessControlListOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A human readable description of this resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateIpAccessControlListOptions - /// - /// A human readable description of this resource - public CreateIpAccessControlListOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Create a new IpAccessControlList resource + /// + public class CreateIpAccessControlListOptions : IOptions + { /// - /// Fetch a specific instance of an IpAccessControlList - /// - public class FetchIpAccessControlListOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpAccessControlListOptions - /// - /// A string that identifies the resource to fetch - public FetchIpAccessControlListOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } /// - /// Rename an IpAccessControlList - /// - public class UpdateIpAccessControlListOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the resource to update - /// - public string PathSid { get; } - /// - /// A human readable description of this resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new UpdateIpAccessControlListOptions - /// - /// A string that identifies the resource to update - /// A human readable description of this resource - public UpdateIpAccessControlListOptions(string pathSid, string friendlyName) - { - PathSid = pathSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// A human readable description of this resource + /// + public string FriendlyName { get; } + /// - /// Delete an IpAccessControlList from the requested account - /// - public class DeleteIpAccessControlListOptions : IOptions - { - /// - /// The unique sid that identifies this account - /// - public string PathAccountSid { get; set; } - /// - /// A string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIpAccessControlListOptions - /// - /// A string that identifies the resource to delete - public DeleteIpAccessControlListOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateIpAccessControlListOptions + /// + /// A human readable description of this resource + public CreateIpAccessControlListOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Fetch a specific instance of an IpAccessControlList + /// + public class FetchIpAccessControlListOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchIpAccessControlListOptions + /// + /// A string that identifies the resource to fetch + public FetchIpAccessControlListOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Rename an IpAccessControlList + /// + public class UpdateIpAccessControlListOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the resource to update + /// + public string PathSid { get; } + /// + /// A human readable description of this resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new UpdateIpAccessControlListOptions + /// + /// A string that identifies the resource to update + /// A human readable description of this resource + public UpdateIpAccessControlListOptions(string pathSid, string friendlyName) + { + PathSid = pathSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Delete an IpAccessControlList from the requested account + /// + public class DeleteIpAccessControlListOptions : IOptions + { + /// + /// The unique sid that identifies this account + /// + public string PathAccountSid { get; set; } + /// + /// A string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIpAccessControlListOptions + /// + /// A string that identifies the resource to delete + public DeleteIpAccessControlListOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListResource.cs b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListResource.cs index 48414c10b..fb6bfd90f 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Sip/IpAccessControlListResource.cs @@ -16,497 +16,497 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account.Sip -{ - - public class IpAccessControlListResource : Resource - { - private static Request BuildReadRequest(ReadIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request - /// - /// Read IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static ResourceSet Read(ReadIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request - /// - /// Read IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request - /// - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request - /// - /// The unique sid that identifies this account - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - private static Request BuildCreateRequest(CreateIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new IpAccessControlList resource - /// - /// Create IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Create(CreateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new IpAccessControlList resource - /// - /// Create IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new IpAccessControlList resource - /// - /// A human readable description of this resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Create(string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListOptions(friendlyName){PathAccountSid = pathAccountSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new IpAccessControlList resource - /// - /// A human readable description of this resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListOptions(friendlyName){PathAccountSid = pathAccountSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific instance of an IpAccessControlList - /// - /// Fetch IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Fetch(FetchIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific instance of an IpAccessControlList - /// - /// Fetch IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific instance of an IpAccessControlList - /// - /// A string that identifies the resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific instance of an IpAccessControlList - /// - /// A string that identifies the resource to fetch - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Rename an IpAccessControlList - /// - /// Update IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Update(UpdateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Rename an IpAccessControlList - /// - /// Update IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Rename an IpAccessControlList - /// - /// A string that identifies the resource to update - /// A human readable description of this resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Update(string pathSid, - string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateIpAccessControlListOptions(pathSid, friendlyName){PathAccountSid = pathAccountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Rename an IpAccessControlList - /// - /// A string that identifies the resource to update - /// A human readable description of this resource - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateIpAccessControlListOptions(pathSid, friendlyName){PathAccountSid = pathAccountSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an IpAccessControlList from the requested account - /// - /// Delete IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static bool Delete(DeleteIpAccessControlListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an IpAccessControlList from the requested account - /// - /// Delete IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an IpAccessControlList from the requested account - /// - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an IpAccessControlList from the requested account - /// - /// A string that identifies the resource to delete - /// The unique sid that identifies this account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a IpAccessControlListResource object - /// - /// Raw JSON string - /// IpAccessControlListResource object represented by the provided JSON - public static IpAccessControlListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique sid that identifies this account - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A human readable description of this resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The IP addresses associated with this resource. - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI for this resource - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private IpAccessControlListResource() - { - - } - } +{ + + public class IpAccessControlListResource : Resource + { + private static Request BuildReadRequest(ReadIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// + /// Read IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static ResourceSet Read(ReadIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// + /// Read IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IpAccessControlLists that belong to the account used to make the request + /// + /// The unique sid that identifies this account + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + private static Request BuildCreateRequest(CreateIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new IpAccessControlList resource + /// + /// Create IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Create(CreateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new IpAccessControlList resource + /// + /// Create IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new IpAccessControlList resource + /// + /// A human readable description of this resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Create(string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListOptions(friendlyName) { PathAccountSid = pathAccountSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new IpAccessControlList resource + /// + /// A human readable description of this resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListOptions(friendlyName) { PathAccountSid = pathAccountSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific instance of an IpAccessControlList + /// + /// Fetch IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Fetch(FetchIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific instance of an IpAccessControlList + /// + /// Fetch IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific instance of an IpAccessControlList + /// + /// A string that identifies the resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific instance of an IpAccessControlList + /// + /// A string that identifies the resource to fetch + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Rename an IpAccessControlList + /// + /// Update IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Update(UpdateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Rename an IpAccessControlList + /// + /// Update IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Rename an IpAccessControlList + /// + /// A string that identifies the resource to update + /// A human readable description of this resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Update(string pathSid, + string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateIpAccessControlListOptions(pathSid, friendlyName) { PathAccountSid = pathAccountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Rename an IpAccessControlList + /// + /// A string that identifies the resource to update + /// A human readable description of this resource + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateIpAccessControlListOptions(pathSid, friendlyName) { PathAccountSid = pathAccountSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/SIP/IpAccessControlLists/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an IpAccessControlList from the requested account + /// + /// Delete IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static bool Delete(DeleteIpAccessControlListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an IpAccessControlList from the requested account + /// + /// Delete IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an IpAccessControlList from the requested account + /// + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an IpAccessControlList from the requested account + /// + /// A string that identifies the resource to delete + /// The unique sid that identifies this account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a IpAccessControlListResource object + /// + /// Raw JSON string + /// IpAccessControlListResource object represented by the provided JSON + public static IpAccessControlListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique sid that identifies this account + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A human readable description of this resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The IP addresses associated with this resource. + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI for this resource + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private IpAccessControlListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/TokenOptions.cs b/src/Twilio/Rest/Api/V2010/Account/TokenOptions.cs index 892291085..dc1dc3be6 100644 --- a/src/Twilio/Rest/Api/V2010/Account/TokenOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/TokenOptions.cs @@ -9,35 +9,35 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Create a new token for ICE servers + /// + public class CreateTokenOptions : IOptions + { /// - /// Create a new token for ICE servers + /// The SID of the Account that will create the resource /// - public class CreateTokenOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The duration in seconds the credentials are valid - /// - public int? Ttl { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The duration in seconds the credentials are valid + /// + public int? Ttl { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/TokenResource.cs b/src/Twilio/Rest/Api/V2010/Account/TokenResource.cs index 28cf66dfe..c7c1e90eb 100644 --- a/src/Twilio/Rest/Api/V2010/Account/TokenResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/TokenResource.cs @@ -17,138 +17,138 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class TokenResource : Resource - { - private static Request BuildCreateRequest(CreateTokenOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Tokens.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new token for ICE servers - /// - /// Create Token parameters - /// Client to make requests to Twilio - /// A single instance of Token - public static TokenResource Create(CreateTokenOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new token for ICE servers - /// - /// Create Token parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Token - public static async System.Threading.Tasks.Task CreateAsync(CreateTokenOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new token for ICE servers - /// - /// The SID of the Account that will create the resource - /// The duration in seconds the credentials are valid - /// Client to make requests to Twilio - /// A single instance of Token - public static TokenResource Create(string pathAccountSid = null, int? ttl = null, ITwilioRestClient client = null) - { - var options = new CreateTokenOptions(){PathAccountSid = pathAccountSid, Ttl = ttl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new token for ICE servers - /// - /// The SID of the Account that will create the resource - /// The duration in seconds the credentials are valid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Token - public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateTokenOptions(){PathAccountSid = pathAccountSid, Ttl = ttl}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TokenResource object - /// - /// Raw JSON string - /// TokenResource object represented by the provided JSON - public static TokenResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An array representing the ephemeral credentials - /// - [JsonProperty("ice_servers")] - public List IceServers { get; private set; } - /// - /// The temporary password used for authenticating - /// - [JsonProperty("password")] - public string Password { get; private set; } - /// - /// The duration in seconds the credentials are valid - /// - [JsonProperty("ttl")] - public string Ttl { get; private set; } - /// - /// The temporary username that uniquely identifies a Token - /// - [JsonProperty("username")] - public string Username { get; private set; } - - private TokenResource() - { - - } - } +{ + + public class TokenResource : Resource + { + private static Request BuildCreateRequest(CreateTokenOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Tokens.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new token for ICE servers + /// + /// Create Token parameters + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create(CreateTokenOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new token for ICE servers + /// + /// Create Token parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync(CreateTokenOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new token for ICE servers + /// + /// The SID of the Account that will create the resource + /// The duration in seconds the credentials are valid + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create(string pathAccountSid = null, int? ttl = null, ITwilioRestClient client = null) + { + var options = new CreateTokenOptions() { PathAccountSid = pathAccountSid, Ttl = ttl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new token for ICE servers + /// + /// The SID of the Account that will create the resource + /// The duration in seconds the credentials are valid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync(string pathAccountSid = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateTokenOptions() { PathAccountSid = pathAccountSid, Ttl = ttl }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TokenResource object + /// + /// Raw JSON string + /// TokenResource object represented by the provided JSON + public static TokenResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An array representing the ephemeral credentials + /// + [JsonProperty("ice_servers")] + public List IceServers { get; private set; } + /// + /// The temporary password used for authenticating + /// + [JsonProperty("password")] + public string Password { get; private set; } + /// + /// The duration in seconds the credentials are valid + /// + [JsonProperty("ttl")] + public string Ttl { get; private set; } + /// + /// The temporary username that uniquely identifies a Token + /// + [JsonProperty("username")] + public string Username { get; private set; } + + private TokenResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/TranscriptionOptions.cs b/src/Twilio/Rest/Api/V2010/Account/TranscriptionOptions.cs index 0770365b0..e2bb650f7 100644 --- a/src/Twilio/Rest/Api/V2010/Account/TranscriptionOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/TranscriptionOptions.cs @@ -9,97 +9,97 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// Fetch an instance of a Transcription + /// + public class FetchTranscriptionOptions : IOptions + { /// - /// Fetch an instance of a Transcription + /// The SID of the Account that created the resource to fetch /// - public class FetchTranscriptionOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTranscriptionOptions - /// - /// The unique string that identifies the resource - public FetchTranscriptionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Delete a transcription from the account used to make the request + /// The unique string that identifies the resource /// - public class DeleteTranscriptionOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTranscriptionOptions - /// - /// The unique string that identifies the resource - public DeleteTranscriptionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a list of transcriptions belonging to the account used to make the request + /// Construct a new FetchTranscriptionOptions /// - public class ReadTranscriptionOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The unique string that identifies the resource + public FetchTranscriptionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a transcription from the account used to make the request + /// + public class DeleteTranscriptionOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTranscriptionOptions + /// + /// The unique string that identifies the resource + public DeleteTranscriptionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of transcriptions belonging to the account used to make the request + /// + public class ReadTranscriptionOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/TranscriptionResource.cs b/src/Twilio/Rest/Api/V2010/Account/TranscriptionResource.cs index f1d8d0a4f..84be033fa 100644 --- a/src/Twilio/Rest/Api/V2010/Account/TranscriptionResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/TranscriptionResource.cs @@ -17,389 +17,389 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account -{ - - public class TranscriptionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - private static Request BuildFetchRequest(FetchTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of a Transcription - /// - /// Fetch Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static TranscriptionResource Fetch(FetchTranscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of a Transcription - /// - /// Fetch Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task FetchAsync(FetchTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of a Transcription - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Transcription - public static TranscriptionResource Fetch(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchTranscriptionOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of a Transcription - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchTranscriptionOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a transcription from the account used to make the request - /// - /// Delete Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static bool Delete(DeleteTranscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a transcription from the account used to make the request - /// - /// Delete Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a transcription from the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Transcription - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteTranscriptionOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a transcription from the account used to make the request - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteTranscriptionOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTranscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of transcriptions belonging to the account used to make the request - /// - /// Read Transcription parameters - /// Client to make requests to Twilio - /// A single instance of Transcription - public static ResourceSet Read(ReadTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("transcriptions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of transcriptions belonging to the account used to make the request - /// - /// Read Transcription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task> ReadAsync(ReadTranscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("transcriptions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of transcriptions belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Transcription - public static ResourceSet Read(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTranscriptionOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of transcriptions belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Transcription - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTranscriptionOptions(){PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("transcriptions", response.Content); - } - - /// - /// Converts a JSON string into a TranscriptionResource object - /// - /// Raw JSON string - /// TranscriptionResource object represented by the provided JSON - public static TranscriptionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the transcription - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The duration of the transcribed audio in seconds. - /// - [JsonProperty("duration")] - public string Duration { get; private set; } - /// - /// The charge for the transcription - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which price is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The SID that identifies the transcription's recording - /// - [JsonProperty("recording_sid")] - public string RecordingSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the transcription - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public TranscriptionResource.StatusEnum Status { get; private set; } - /// - /// The text content of the transcription. - /// - [JsonProperty("transcription_text")] - public string TranscriptionText { get; private set; } - /// - /// The transcription type - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private TranscriptionResource() - { - - } - } +{ + + public class TranscriptionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + private static Request BuildFetchRequest(FetchTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of a Transcription + /// + /// Fetch Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static TranscriptionResource Fetch(FetchTranscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of a Transcription + /// + /// Fetch Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task FetchAsync(FetchTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of a Transcription + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Transcription + public static TranscriptionResource Fetch(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchTranscriptionOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of a Transcription + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchTranscriptionOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a transcription from the account used to make the request + /// + /// Delete Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static bool Delete(DeleteTranscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a transcription from the account used to make the request + /// + /// Delete Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a transcription from the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Transcription + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteTranscriptionOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a transcription from the account used to make the request + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteTranscriptionOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTranscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Transcriptions.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of transcriptions belonging to the account used to make the request + /// + /// Read Transcription parameters + /// Client to make requests to Twilio + /// A single instance of Transcription + public static ResourceSet Read(ReadTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("transcriptions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of transcriptions belonging to the account used to make the request + /// + /// Read Transcription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task> ReadAsync(ReadTranscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("transcriptions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of transcriptions belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Transcription + public static ResourceSet Read(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTranscriptionOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of transcriptions belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Transcription + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTranscriptionOptions() { PathAccountSid = pathAccountSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("transcriptions", response.Content); + } + + /// + /// Converts a JSON string into a TranscriptionResource object + /// + /// Raw JSON string + /// TranscriptionResource object represented by the provided JSON + public static TranscriptionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the transcription + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The duration of the transcribed audio in seconds. + /// + [JsonProperty("duration")] + public string Duration { get; private set; } + /// + /// The charge for the transcription + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which price is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The SID that identifies the transcription's recording + /// + [JsonProperty("recording_sid")] + public string RecordingSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the transcription + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public TranscriptionResource.StatusEnum Status { get; private set; } + /// + /// The text content of the transcription. + /// + [JsonProperty("transcription_text")] + public string TranscriptionText { get; private set; } + /// + /// The transcription type + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private TranscriptionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeOptions.cs index 1d90802db..7b958772e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadAllTimeOptions + /// + public class ReadAllTimeOptions : ReadOptions + { /// - /// ReadAllTimeOptions + /// The SID of the Account that created the resources to read /// - public class ReadAllTimeOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public AllTimeResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public AllTimeResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeResource.cs index ef29d3f4e..be4829156 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/AllTimeResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class AllTimeResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadAllTimeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/AllTime.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read AllTime parameters - /// Client to make requests to Twilio - /// A single instance of AllTime - public static ResourceSet Read(ReadAllTimeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read AllTime parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AllTime - public static async System.Threading.Tasks.Task> ReadAsync(ReadAllTimeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AllTime - public static ResourceSet Read(string pathAccountSid = null, - AllTimeResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAllTimeOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AllTime - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - AllTimeResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAllTimeOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a AllTimeResource object - /// - /// Raw JSON string - /// AllTimeResource object represented by the provided JSON - public static AllTimeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public AllTimeResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private AllTimeResource() - { - - } - } +{ + + public class AllTimeResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadAllTimeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/AllTime.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read AllTime parameters + /// Client to make requests to Twilio + /// A single instance of AllTime + public static ResourceSet Read(ReadAllTimeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read AllTime parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AllTime + public static async System.Threading.Tasks.Task> ReadAsync(ReadAllTimeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AllTime + public static ResourceSet Read(string pathAccountSid = null, + AllTimeResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAllTimeOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AllTime + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + AllTimeResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAllTimeOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a AllTimeResource object + /// + /// Raw JSON string + /// AllTimeResource object represented by the provided JSON + public static AllTimeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public AllTimeResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private AllTimeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyOptions.cs index 0bbbdc3ec..7bebfd8c0 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadDailyOptions + /// + public class ReadDailyOptions : ReadOptions + { /// - /// ReadDailyOptions + /// The SID of the Account that created the resources to read /// - public class ReadDailyOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public DailyResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public DailyResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyResource.cs index f73376cad..e1e9395dc 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/DailyResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class DailyResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadDailyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Daily.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Daily parameters - /// Client to make requests to Twilio - /// A single instance of Daily - public static ResourceSet Read(ReadDailyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Daily parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Daily - public static async System.Threading.Tasks.Task> ReadAsync(ReadDailyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Daily - public static ResourceSet Read(string pathAccountSid = null, - DailyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDailyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Daily - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - DailyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDailyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a DailyResource object - /// - /// Raw JSON string - /// DailyResource object represented by the provided JSON - public static DailyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public DailyResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private DailyResource() - { - - } - } +{ + + public class DailyResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadDailyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Daily.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Daily parameters + /// Client to make requests to Twilio + /// A single instance of Daily + public static ResourceSet Read(ReadDailyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Daily parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Daily + public static async System.Threading.Tasks.Task> ReadAsync(ReadDailyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Daily + public static ResourceSet Read(string pathAccountSid = null, + DailyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDailyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Daily + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + DailyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDailyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a DailyResource object + /// + /// Raw JSON string + /// DailyResource object represented by the provided JSON + public static DailyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public DailyResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private DailyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthOptions.cs index acdf15e7a..112169f86 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadLastMonthOptions + /// + public class ReadLastMonthOptions : ReadOptions + { /// - /// ReadLastMonthOptions + /// The SID of the Account that created the resources to read /// - public class ReadLastMonthOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public LastMonthResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public LastMonthResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthResource.cs index e1723a3fb..c54ca22d3 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/LastMonthResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class LastMonthResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadLastMonthOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/LastMonth.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read LastMonth parameters - /// Client to make requests to Twilio - /// A single instance of LastMonth - public static ResourceSet Read(ReadLastMonthOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read LastMonth parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of LastMonth - public static async System.Threading.Tasks.Task> ReadAsync(ReadLastMonthOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of LastMonth - public static ResourceSet Read(string pathAccountSid = null, - LastMonthResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLastMonthOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of LastMonth - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - LastMonthResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLastMonthOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a LastMonthResource object - /// - /// Raw JSON string - /// LastMonthResource object represented by the provided JSON - public static LastMonthResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public LastMonthResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private LastMonthResource() - { - - } - } +{ + + public class LastMonthResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadLastMonthOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/LastMonth.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read LastMonth parameters + /// Client to make requests to Twilio + /// A single instance of LastMonth + public static ResourceSet Read(ReadLastMonthOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read LastMonth parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of LastMonth + public static async System.Threading.Tasks.Task> ReadAsync(ReadLastMonthOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of LastMonth + public static ResourceSet Read(string pathAccountSid = null, + LastMonthResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLastMonthOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of LastMonth + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + LastMonthResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLastMonthOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a LastMonthResource object + /// + /// Raw JSON string + /// LastMonthResource object represented by the provided JSON + public static LastMonthResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public LastMonthResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private LastMonthResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyOptions.cs index d4f798a59..a09c2d825 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadMonthlyOptions + /// + public class ReadMonthlyOptions : ReadOptions + { /// - /// ReadMonthlyOptions + /// The SID of the Account that created the resources to read /// - public class ReadMonthlyOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public MonthlyResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public MonthlyResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyResource.cs index 97a49f4e7..1202881f9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/MonthlyResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class MonthlyResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadMonthlyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Monthly.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Monthly parameters - /// Client to make requests to Twilio - /// A single instance of Monthly - public static ResourceSet Read(ReadMonthlyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Monthly parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Monthly - public static async System.Threading.Tasks.Task> ReadAsync(ReadMonthlyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Monthly - public static ResourceSet Read(string pathAccountSid = null, - MonthlyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMonthlyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Monthly - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - MonthlyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMonthlyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a MonthlyResource object - /// - /// Raw JSON string - /// MonthlyResource object represented by the provided JSON - public static MonthlyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public MonthlyResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private MonthlyResource() - { - - } - } +{ + + public class MonthlyResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadMonthlyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Monthly.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Monthly parameters + /// Client to make requests to Twilio + /// A single instance of Monthly + public static ResourceSet Read(ReadMonthlyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Monthly parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Monthly + public static async System.Threading.Tasks.Task> ReadAsync(ReadMonthlyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Monthly + public static ResourceSet Read(string pathAccountSid = null, + MonthlyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMonthlyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Monthly + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + MonthlyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMonthlyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a MonthlyResource object + /// + /// Raw JSON string + /// MonthlyResource object represented by the provided JSON + public static MonthlyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public MonthlyResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private MonthlyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthOptions.cs index ce847686f..b39e99c4b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadThisMonthOptions + /// + public class ReadThisMonthOptions : ReadOptions + { /// - /// ReadThisMonthOptions + /// The SID of the Account that created the resources to read /// - public class ReadThisMonthOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public ThisMonthResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public ThisMonthResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthResource.cs index 1b8d6e2ad..ba7eca793 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/ThisMonthResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class ThisMonthResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadThisMonthOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/ThisMonth.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ThisMonth parameters - /// Client to make requests to Twilio - /// A single instance of ThisMonth - public static ResourceSet Read(ReadThisMonthOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ThisMonth parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ThisMonth - public static async System.Threading.Tasks.Task> ReadAsync(ReadThisMonthOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ThisMonth - public static ResourceSet Read(string pathAccountSid = null, - ThisMonthResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadThisMonthOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ThisMonth - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - ThisMonthResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadThisMonthOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a ThisMonthResource object - /// - /// Raw JSON string - /// ThisMonthResource object represented by the provided JSON - public static ThisMonthResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public ThisMonthResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private ThisMonthResource() - { - - } - } +{ + + public class ThisMonthResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadThisMonthOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/ThisMonth.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ThisMonth parameters + /// Client to make requests to Twilio + /// A single instance of ThisMonth + public static ResourceSet Read(ReadThisMonthOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ThisMonth parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ThisMonth + public static async System.Threading.Tasks.Task> ReadAsync(ReadThisMonthOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ThisMonth + public static ResourceSet Read(string pathAccountSid = null, + ThisMonthResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadThisMonthOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ThisMonth + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + ThisMonthResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadThisMonthOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a ThisMonthResource object + /// + /// Raw JSON string + /// ThisMonthResource object represented by the provided JSON + public static ThisMonthResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public ThisMonthResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private ThisMonthResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayOptions.cs index c4b880ea7..ec2b575aa 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadTodayOptions + /// + public class ReadTodayOptions : ReadOptions + { /// - /// ReadTodayOptions + /// The SID of the Account that created the resources to read /// - public class ReadTodayOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public TodayResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public TodayResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayResource.cs index f37b79eb4..a6e64ebf8 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/TodayResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class TodayResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadTodayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Today.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Today parameters - /// Client to make requests to Twilio - /// A single instance of Today - public static ResourceSet Read(ReadTodayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Today parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Today - public static async System.Threading.Tasks.Task> ReadAsync(ReadTodayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Today - public static ResourceSet Read(string pathAccountSid = null, - TodayResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTodayOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Today - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - TodayResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTodayOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a TodayResource object - /// - /// Raw JSON string - /// TodayResource object represented by the provided JSON - public static TodayResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public TodayResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private TodayResource() - { - - } - } +{ + + public class TodayResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadTodayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Today.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Today parameters + /// Client to make requests to Twilio + /// A single instance of Today + public static ResourceSet Read(ReadTodayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Today parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Today + public static async System.Threading.Tasks.Task> ReadAsync(ReadTodayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Today + public static ResourceSet Read(string pathAccountSid = null, + TodayResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTodayOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Today + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + TodayResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTodayOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a TodayResource object + /// + /// Raw JSON string + /// TodayResource object represented by the provided JSON + public static TodayResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public TodayResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private TodayResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyOptions.cs index 431d2b63d..a3d0c6036 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadYearlyOptions + /// + public class ReadYearlyOptions : ReadOptions + { /// - /// ReadYearlyOptions + /// The SID of the Account that created the resources to read /// - public class ReadYearlyOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public YearlyResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public YearlyResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyResource.cs index f0a72ccf0..39b35362e 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YearlyResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class YearlyResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadYearlyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Yearly.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Yearly parameters - /// Client to make requests to Twilio - /// A single instance of Yearly - public static ResourceSet Read(ReadYearlyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Yearly parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Yearly - public static async System.Threading.Tasks.Task> ReadAsync(ReadYearlyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Yearly - public static ResourceSet Read(string pathAccountSid = null, - YearlyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadYearlyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Yearly - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - YearlyResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadYearlyOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a YearlyResource object - /// - /// Raw JSON string - /// YearlyResource object represented by the provided JSON - public static YearlyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public YearlyResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private YearlyResource() - { - - } - } +{ + + public class YearlyResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadYearlyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Yearly.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Yearly parameters + /// Client to make requests to Twilio + /// A single instance of Yearly + public static ResourceSet Read(ReadYearlyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Yearly parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Yearly + public static async System.Threading.Tasks.Task> ReadAsync(ReadYearlyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Yearly + public static ResourceSet Read(string pathAccountSid = null, + YearlyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadYearlyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Yearly + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + YearlyResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadYearlyOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a YearlyResource object + /// + /// Raw JSON string + /// YearlyResource object represented by the provided JSON + public static YearlyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public YearlyResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private YearlyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayOptions.cs index 8b06d87a6..fafa518f3 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - +{ + + /// + /// ReadYesterdayOptions + /// + public class ReadYesterdayOptions : ReadOptions + { /// - /// ReadYesterdayOptions + /// The SID of the Account that created the resources to read /// - public class ReadYesterdayOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public YesterdayResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public YesterdayResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayResource.cs index 1d6a20e45..be5456bc6 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/Record/YesterdayResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage.Record -{ - - public class YesterdayResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadYesterdayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Yesterday.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Yesterday parameters - /// Client to make requests to Twilio - /// A single instance of Yesterday - public static ResourceSet Read(ReadYesterdayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Yesterday parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Yesterday - public static async System.Threading.Tasks.Task> ReadAsync(ReadYesterdayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Yesterday - public static ResourceSet Read(string pathAccountSid = null, - YesterdayResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadYesterdayOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Yesterday - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - YesterdayResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadYesterdayOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a YesterdayResource object - /// - /// Raw JSON string - /// YesterdayResource object represented by the provided JSON - public static YesterdayResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public YesterdayResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private YesterdayResource() - { - - } - } +{ + + public class YesterdayResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadYesterdayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records/Yesterday.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Yesterday parameters + /// Client to make requests to Twilio + /// A single instance of Yesterday + public static ResourceSet Read(ReadYesterdayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Yesterday parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Yesterday + public static async System.Threading.Tasks.Task> ReadAsync(ReadYesterdayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Yesterday + public static ResourceSet Read(string pathAccountSid = null, + YesterdayResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadYesterdayOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Yesterday + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + YesterdayResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadYesterdayOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a YesterdayResource object + /// + /// Raw JSON string + /// YesterdayResource object represented by the provided JSON + public static YesterdayResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public YesterdayResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private YesterdayResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/RecordOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/RecordOptions.cs index 8ef24a971..fdc05cb1b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/RecordOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/RecordOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage -{ - +{ + + /// + /// Retrieve a list of usage-records belonging to the account used to make the request + /// + public class ReadRecordOptions : ReadOptions + { /// - /// Retrieve a list of usage-records belonging to the account used to make the request + /// The SID of the Account that created the resources to read /// - public class ReadRecordOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The usage category of the UsageRecord resources to read - /// - public RecordResource.CategoryEnum Category { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Whether to include usage from the master account and all its subaccounts - /// - public bool? IncludeSubaccounts { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Category != null) - { - p.Add(new KeyValuePair("Category", Category.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (IncludeSubaccounts != null) - { - p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The usage category of the UsageRecord resources to read + /// + public RecordResource.CategoryEnum Category { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Whether to include usage from the master account and all its subaccounts + /// + public bool? IncludeSubaccounts { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Category != null) + { + p.Add(new KeyValuePair("Category", Category.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (IncludeSubaccounts != null) + { + p.Add(new KeyValuePair("IncludeSubaccounts", IncludeSubaccounts.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/RecordResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/RecordResource.cs index 9a3a7b4ad..30e90dde9 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/RecordResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/RecordResource.cs @@ -17,509 +17,509 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage -{ - - public class RecordResource : Resource - { - public sealed class CategoryEnum : StringEnum - { - private CategoryEnum(string value) : base(value) {} - public CategoryEnum() {} - public static implicit operator CategoryEnum(string value) - { - return new CategoryEnum(value); - } - - public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); - public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); - public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); - public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); - public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); - public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); - public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); - public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); - public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); - public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); - public static readonly CategoryEnum Calls = new CategoryEnum("calls"); - public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); - public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); - public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); - public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); - public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); - public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); - public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); - public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); - public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); - public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); - public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); - public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); - public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); - public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); - public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); - public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); - public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); - public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); - public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); - public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); - public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); - public static readonly CategoryEnum Cps = new CategoryEnum("cps"); - public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); - public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); - public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); - public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); - public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); - public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); - public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); - public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); - public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); - public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); - public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); - public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); - public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); - public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); - public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); - public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); - public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); - public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); - public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); - public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); - public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); - public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); - public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); - public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); - public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); - public static readonly CategoryEnum Mms = new CategoryEnum("mms"); - public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); - public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); - public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); - public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); - public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); - public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); - public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); - public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); - public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); - public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); - public static readonly CategoryEnum Notify = new CategoryEnum("notify"); - public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); - public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); - public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); - public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); - public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); - public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); - public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); - public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); - public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); - public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); - public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); - public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); - public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); - public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); - public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); - public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); - public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); - public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); - public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); - public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); - public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); - public static readonly CategoryEnum Pv = new CategoryEnum("pv"); - public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); - public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); - public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); - public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); - public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); - public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); - public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); - public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); - public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); - public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); - public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); - public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); - public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); - public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); - public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); - public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); - public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); - public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); - public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); - public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); - public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); - public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); - public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); - public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); - public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); - public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); - public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); - public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); - public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); - public static readonly CategoryEnum Sms = new CategoryEnum("sms"); - public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); - public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); - public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); - public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); - public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); - public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); - public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); - public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); - public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); - public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); - public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); - public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); - public static readonly CategoryEnum Sync = new CategoryEnum("sync"); - public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); - public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); - public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); - public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); - public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); - public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); - public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); - public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); - public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); - public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); - public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); - public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); - public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); - public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); - public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); - public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); - public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); - public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); - public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); - public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); - public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); - public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); - public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); - public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); - public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); - public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); - public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); - public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); - public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); - public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); - public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); - public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); - public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); - public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); - public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); - public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); - public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); - public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); - public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); - public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); - public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); - public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); - public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); - public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); - public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); - public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); - public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); - public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); - public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); - public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); - public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); - public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); - public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); - public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); - public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); - public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); - public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); - } - - private static Request BuildReadRequest(ReadRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of usage-records belonging to the account used to make the request - /// - /// Read Record parameters - /// Client to make requests to Twilio - /// A single instance of Record - public static ResourceSet Read(ReadRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of usage-records belonging to the account used to make the request - /// - /// Read Record parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Record - public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of usage-records belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Record - public static ResourceSet Read(string pathAccountSid = null, - RecordResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of usage-records belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The usage category of the UsageRecord resources to read - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// Whether to include usage from the master account and all its subaccounts - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Record - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - RecordResource.CategoryEnum category = null, - DateTime? startDate = null, - DateTime? endDate = null, - bool? includeSubaccounts = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordOptions(){PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a RecordResource object - /// - /// Raw JSON string - /// RecordResource object represented by the provided JSON - public static RecordResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account accrued the usage - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Usage records up to date as of this timestamp - /// - [JsonProperty("as_of")] - public string AsOf { get; private set; } - /// - /// The category of usage - /// - [JsonProperty("category")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordResource.CategoryEnum Category { get; private set; } - /// - /// The number of usage events - /// - [JsonProperty("count")] - public string Count { get; private set; } - /// - /// The units in which count is measured - /// - [JsonProperty("count_unit")] - public string CountUnit { get; private set; } - /// - /// A plain-language description of the usage category - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The last date for which usage is included in the UsageRecord - /// - [JsonProperty("end_date")] - public DateTime? EndDate { get; private set; } - /// - /// The total price of the usage - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The currency in which `price` is measured - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The first date for which usage is included in this UsageRecord - /// - [JsonProperty("start_date")] - public DateTime? StartDate { get; private set; } - /// - /// A list of related resources identified by their relative URIs - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The amount of usage - /// - [JsonProperty("usage")] - public string Usage { get; private set; } - /// - /// The units in which usage is measured - /// - [JsonProperty("usage_unit")] - public string UsageUnit { get; private set; } - - private RecordResource() - { - - } - } +{ + + public class RecordResource : Resource + { + public sealed class CategoryEnum : StringEnum + { + private CategoryEnum(string value) : base(value) { } + public CategoryEnum() { } + public static implicit operator CategoryEnum(string value) + { + return new CategoryEnum(value); + } + + public static readonly CategoryEnum AgentConference = new CategoryEnum("agent-conference"); + public static readonly CategoryEnum AnsweringMachineDetection = new CategoryEnum("answering-machine-detection"); + public static readonly CategoryEnum AuthyAuthentications = new CategoryEnum("authy-authentications"); + public static readonly CategoryEnum AuthyCallsOutbound = new CategoryEnum("authy-calls-outbound"); + public static readonly CategoryEnum AuthyMonthlyFees = new CategoryEnum("authy-monthly-fees"); + public static readonly CategoryEnum AuthyPhoneIntelligence = new CategoryEnum("authy-phone-intelligence"); + public static readonly CategoryEnum AuthyPhoneVerifications = new CategoryEnum("authy-phone-verifications"); + public static readonly CategoryEnum AuthySmsOutbound = new CategoryEnum("authy-sms-outbound"); + public static readonly CategoryEnum CallProgessEvents = new CategoryEnum("call-progess-events"); + public static readonly CategoryEnum Calleridlookups = new CategoryEnum("calleridlookups"); + public static readonly CategoryEnum Calls = new CategoryEnum("calls"); + public static readonly CategoryEnum CallsClient = new CategoryEnum("calls-client"); + public static readonly CategoryEnum CallsGlobalconference = new CategoryEnum("calls-globalconference"); + public static readonly CategoryEnum CallsInbound = new CategoryEnum("calls-inbound"); + public static readonly CategoryEnum CallsInboundLocal = new CategoryEnum("calls-inbound-local"); + public static readonly CategoryEnum CallsInboundMobile = new CategoryEnum("calls-inbound-mobile"); + public static readonly CategoryEnum CallsInboundTollfree = new CategoryEnum("calls-inbound-tollfree"); + public static readonly CategoryEnum CallsOutbound = new CategoryEnum("calls-outbound"); + public static readonly CategoryEnum CallsPayVerbTransactions = new CategoryEnum("calls-pay-verb-transactions"); + public static readonly CategoryEnum CallsRecordings = new CategoryEnum("calls-recordings"); + public static readonly CategoryEnum CallsSip = new CategoryEnum("calls-sip"); + public static readonly CategoryEnum CallsSipInbound = new CategoryEnum("calls-sip-inbound"); + public static readonly CategoryEnum CallsSipOutbound = new CategoryEnum("calls-sip-outbound"); + public static readonly CategoryEnum CallsTransfers = new CategoryEnum("calls-transfers"); + public static readonly CategoryEnum CarrierLookups = new CategoryEnum("carrier-lookups"); + public static readonly CategoryEnum Conversations = new CategoryEnum("conversations"); + public static readonly CategoryEnum ConversationsApiRequests = new CategoryEnum("conversations-api-requests"); + public static readonly CategoryEnum ConversationsConversationEvents = new CategoryEnum("conversations-conversation-events"); + public static readonly CategoryEnum ConversationsEndpointConnectivity = new CategoryEnum("conversations-endpoint-connectivity"); + public static readonly CategoryEnum ConversationsEvents = new CategoryEnum("conversations-events"); + public static readonly CategoryEnum ConversationsParticipantEvents = new CategoryEnum("conversations-participant-events"); + public static readonly CategoryEnum ConversationsParticipants = new CategoryEnum("conversations-participants"); + public static readonly CategoryEnum Cps = new CategoryEnum("cps"); + public static readonly CategoryEnum FlexUsage = new CategoryEnum("flex-usage"); + public static readonly CategoryEnum FraudLookups = new CategoryEnum("fraud-lookups"); + public static readonly CategoryEnum GroupRooms = new CategoryEnum("group-rooms"); + public static readonly CategoryEnum GroupRoomsDataTrack = new CategoryEnum("group-rooms-data-track"); + public static readonly CategoryEnum GroupRoomsEncryptedMediaRecorded = new CategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaDownloaded = new CategoryEnum("group-rooms-media-downloaded"); + public static readonly CategoryEnum GroupRoomsMediaRecorded = new CategoryEnum("group-rooms-media-recorded"); + public static readonly CategoryEnum GroupRoomsMediaRouted = new CategoryEnum("group-rooms-media-routed"); + public static readonly CategoryEnum GroupRoomsMediaStored = new CategoryEnum("group-rooms-media-stored"); + public static readonly CategoryEnum GroupRoomsParticipantMinutes = new CategoryEnum("group-rooms-participant-minutes"); + public static readonly CategoryEnum GroupRoomsRecordedMinutes = new CategoryEnum("group-rooms-recorded-minutes"); + public static readonly CategoryEnum ImpV1Usage = new CategoryEnum("imp-v1-usage"); + public static readonly CategoryEnum Lookups = new CategoryEnum("lookups"); + public static readonly CategoryEnum Marketplace = new CategoryEnum("marketplace"); + public static readonly CategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new CategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly CategoryEnum MarketplaceCadenceTranscription = new CategoryEnum("marketplace-cadence-transcription"); + public static readonly CategoryEnum MarketplaceCadenceTranslation = new CategoryEnum("marketplace-cadence-translation"); + public static readonly CategoryEnum MarketplaceCapioSpeechToText = new CategoryEnum("marketplace-capio-speech-to-text"); + public static readonly CategoryEnum MarketplaceConvrizaAbaba = new CategoryEnum("marketplace-convriza-ababa"); + public static readonly CategoryEnum MarketplaceDeepgramPhraseDetector = new CategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly CategoryEnum MarketplaceDigitalSegmentBusinessInfo = new CategoryEnum("marketplace-digital-segment-business-info"); + public static readonly CategoryEnum MarketplaceFacebookOfflineConversions = new CategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly CategoryEnum MarketplaceGoogleSpeechToText = new CategoryEnum("marketplace-google-speech-to-text"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageInsights = new CategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly CategoryEnum MarketplaceIbmWatsonMessageSentiment = new CategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly CategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new CategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly CategoryEnum MarketplaceIbmWatsonToneAnalyzer = new CategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly CategoryEnum MarketplaceIcehookSystemsScout = new CategoryEnum("marketplace-icehook-systems-scout"); + public static readonly CategoryEnum MarketplaceInfogroupDataaxleBizinfo = new CategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly CategoryEnum MarketplaceKeenIoContactCenterAnalytics = new CategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly CategoryEnum MarketplaceMarchexCleancall = new CategoryEnum("marketplace-marchex-cleancall"); + public static readonly CategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new CategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly CategoryEnum MarketplaceMarketplaceNextcallerSocialId = new CategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly CategoryEnum MarketplaceMobileCommonsOptOutClassifier = new CategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly CategoryEnum MarketplaceNexiwaveVoicemailToText = new CategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly CategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new CategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly CategoryEnum MarketplaceNomoroboSpamScore = new CategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly CategoryEnum MarketplacePayfoneTcpaCompliance = new CategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly CategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new CategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly CategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new CategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly CategoryEnum MarketplaceTeloOpencnam = new CategoryEnum("marketplace-telo-opencnam"); + public static readonly CategoryEnum MarketplaceTruecnamTrueSpam = new CategoryEnum("marketplace-truecnam-true-spam"); + public static readonly CategoryEnum MarketplaceTwilioCallerNameLookupUs = new CategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly CategoryEnum MarketplaceTwilioCarrierInformationLookup = new CategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly CategoryEnum MarketplaceVoicebasePci = new CategoryEnum("marketplace-voicebase-pci"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscription = new CategoryEnum("marketplace-voicebase-transcription"); + public static readonly CategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new CategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly CategoryEnum MarketplaceWhitepagesProCallerIdentification = new CategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new CategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly CategoryEnum MarketplaceWhitepagesProPhoneReputation = new CategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly CategoryEnum MarketplaceWolfarmSpokenResults = new CategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly CategoryEnum MarketplaceWolframShortAnswer = new CategoryEnum("marketplace-wolfram-short-answer"); + public static readonly CategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new CategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly CategoryEnum Mediastorage = new CategoryEnum("mediastorage"); + public static readonly CategoryEnum Mms = new CategoryEnum("mms"); + public static readonly CategoryEnum MmsInbound = new CategoryEnum("mms-inbound"); + public static readonly CategoryEnum MmsInboundLongcode = new CategoryEnum("mms-inbound-longcode"); + public static readonly CategoryEnum MmsInboundShortcode = new CategoryEnum("mms-inbound-shortcode"); + public static readonly CategoryEnum MmsMessagesCarrierfees = new CategoryEnum("mms-messages-carrierfees"); + public static readonly CategoryEnum MmsOutbound = new CategoryEnum("mms-outbound"); + public static readonly CategoryEnum MmsOutboundLongcode = new CategoryEnum("mms-outbound-longcode"); + public static readonly CategoryEnum MmsOutboundShortcode = new CategoryEnum("mms-outbound-shortcode"); + public static readonly CategoryEnum MonitorReads = new CategoryEnum("monitor-reads"); + public static readonly CategoryEnum MonitorStorage = new CategoryEnum("monitor-storage"); + public static readonly CategoryEnum MonitorWrites = new CategoryEnum("monitor-writes"); + public static readonly CategoryEnum Notify = new CategoryEnum("notify"); + public static readonly CategoryEnum NotifyActionsAttempts = new CategoryEnum("notify-actions-attempts"); + public static readonly CategoryEnum NotifyChannels = new CategoryEnum("notify-channels"); + public static readonly CategoryEnum NumberFormatLookups = new CategoryEnum("number-format-lookups"); + public static readonly CategoryEnum Pchat = new CategoryEnum("pchat"); + public static readonly CategoryEnum PchatUsers = new CategoryEnum("pchat-users"); + public static readonly CategoryEnum PeerToPeerRoomsParticipantMinutes = new CategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly CategoryEnum Pfax = new CategoryEnum("pfax"); + public static readonly CategoryEnum PfaxMinutes = new CategoryEnum("pfax-minutes"); + public static readonly CategoryEnum PfaxMinutesInbound = new CategoryEnum("pfax-minutes-inbound"); + public static readonly CategoryEnum PfaxMinutesOutbound = new CategoryEnum("pfax-minutes-outbound"); + public static readonly CategoryEnum PfaxPages = new CategoryEnum("pfax-pages"); + public static readonly CategoryEnum Phonenumbers = new CategoryEnum("phonenumbers"); + public static readonly CategoryEnum PhonenumbersCps = new CategoryEnum("phonenumbers-cps"); + public static readonly CategoryEnum PhonenumbersEmergency = new CategoryEnum("phonenumbers-emergency"); + public static readonly CategoryEnum PhonenumbersLocal = new CategoryEnum("phonenumbers-local"); + public static readonly CategoryEnum PhonenumbersMobile = new CategoryEnum("phonenumbers-mobile"); + public static readonly CategoryEnum PhonenumbersSetups = new CategoryEnum("phonenumbers-setups"); + public static readonly CategoryEnum PhonenumbersTollfree = new CategoryEnum("phonenumbers-tollfree"); + public static readonly CategoryEnum Premiumsupport = new CategoryEnum("premiumsupport"); + public static readonly CategoryEnum Proxy = new CategoryEnum("proxy"); + public static readonly CategoryEnum ProxyActiveSessions = new CategoryEnum("proxy-active-sessions"); + public static readonly CategoryEnum Pstnconnectivity = new CategoryEnum("pstnconnectivity"); + public static readonly CategoryEnum Pv = new CategoryEnum("pv"); + public static readonly CategoryEnum PvCompositionMediaDownloaded = new CategoryEnum("pv-composition-media-downloaded"); + public static readonly CategoryEnum PvCompositionMediaEncrypted = new CategoryEnum("pv-composition-media-encrypted"); + public static readonly CategoryEnum PvCompositionMediaStored = new CategoryEnum("pv-composition-media-stored"); + public static readonly CategoryEnum PvCompositionMinutes = new CategoryEnum("pv-composition-minutes"); + public static readonly CategoryEnum PvRecordingCompositions = new CategoryEnum("pv-recording-compositions"); + public static readonly CategoryEnum PvRoomParticipants = new CategoryEnum("pv-room-participants"); + public static readonly CategoryEnum PvRoomParticipantsAu1 = new CategoryEnum("pv-room-participants-au1"); + public static readonly CategoryEnum PvRoomParticipantsBr1 = new CategoryEnum("pv-room-participants-br1"); + public static readonly CategoryEnum PvRoomParticipantsIe1 = new CategoryEnum("pv-room-participants-ie1"); + public static readonly CategoryEnum PvRoomParticipantsJp1 = new CategoryEnum("pv-room-participants-jp1"); + public static readonly CategoryEnum PvRoomParticipantsSg1 = new CategoryEnum("pv-room-participants-sg1"); + public static readonly CategoryEnum PvRoomParticipantsUs1 = new CategoryEnum("pv-room-participants-us1"); + public static readonly CategoryEnum PvRoomParticipantsUs2 = new CategoryEnum("pv-room-participants-us2"); + public static readonly CategoryEnum PvRooms = new CategoryEnum("pv-rooms"); + public static readonly CategoryEnum PvSipEndpointRegistrations = new CategoryEnum("pv-sip-endpoint-registrations"); + public static readonly CategoryEnum Recordings = new CategoryEnum("recordings"); + public static readonly CategoryEnum Recordingstorage = new CategoryEnum("recordingstorage"); + public static readonly CategoryEnum RoomsGroupBandwidth = new CategoryEnum("rooms-group-bandwidth"); + public static readonly CategoryEnum RoomsGroupMinutes = new CategoryEnum("rooms-group-minutes"); + public static readonly CategoryEnum RoomsPeerToPeerMinutes = new CategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly CategoryEnum Shortcodes = new CategoryEnum("shortcodes"); + public static readonly CategoryEnum ShortcodesCustomerowned = new CategoryEnum("shortcodes-customerowned"); + public static readonly CategoryEnum ShortcodesMmsEnablement = new CategoryEnum("shortcodes-mms-enablement"); + public static readonly CategoryEnum ShortcodesMps = new CategoryEnum("shortcodes-mps"); + public static readonly CategoryEnum ShortcodesRandom = new CategoryEnum("shortcodes-random"); + public static readonly CategoryEnum ShortcodesUk = new CategoryEnum("shortcodes-uk"); + public static readonly CategoryEnum ShortcodesVanity = new CategoryEnum("shortcodes-vanity"); + public static readonly CategoryEnum SmallGroupRooms = new CategoryEnum("small-group-rooms"); + public static readonly CategoryEnum SmallGroupRoomsDataTrack = new CategoryEnum("small-group-rooms-data-track"); + public static readonly CategoryEnum SmallGroupRoomsParticipantMinutes = new CategoryEnum("small-group-rooms-participant-minutes"); + public static readonly CategoryEnum Sms = new CategoryEnum("sms"); + public static readonly CategoryEnum SmsInbound = new CategoryEnum("sms-inbound"); + public static readonly CategoryEnum SmsInboundLongcode = new CategoryEnum("sms-inbound-longcode"); + public static readonly CategoryEnum SmsInboundShortcode = new CategoryEnum("sms-inbound-shortcode"); + public static readonly CategoryEnum SmsMessagesCarrierfees = new CategoryEnum("sms-messages-carrierfees"); + public static readonly CategoryEnum SmsMessagesFeatures = new CategoryEnum("sms-messages-features"); + public static readonly CategoryEnum SmsMessagesFeaturesSenderid = new CategoryEnum("sms-messages-features-senderid"); + public static readonly CategoryEnum SmsOutbound = new CategoryEnum("sms-outbound"); + public static readonly CategoryEnum SmsOutboundContentInspection = new CategoryEnum("sms-outbound-content-inspection"); + public static readonly CategoryEnum SmsOutboundLongcode = new CategoryEnum("sms-outbound-longcode"); + public static readonly CategoryEnum SmsOutboundShortcode = new CategoryEnum("sms-outbound-shortcode"); + public static readonly CategoryEnum SpeechRecognition = new CategoryEnum("speech-recognition"); + public static readonly CategoryEnum StudioEngagements = new CategoryEnum("studio-engagements"); + public static readonly CategoryEnum Sync = new CategoryEnum("sync"); + public static readonly CategoryEnum SyncActions = new CategoryEnum("sync-actions"); + public static readonly CategoryEnum SyncEndpointHours = new CategoryEnum("sync-endpoint-hours"); + public static readonly CategoryEnum SyncEndpointHoursAboveDailyCap = new CategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly CategoryEnum TaskrouterTasks = new CategoryEnum("taskrouter-tasks"); + public static readonly CategoryEnum Totalprice = new CategoryEnum("totalprice"); + public static readonly CategoryEnum Transcriptions = new CategoryEnum("transcriptions"); + public static readonly CategoryEnum TrunkingCps = new CategoryEnum("trunking-cps"); + public static readonly CategoryEnum TrunkingEmergencyCalls = new CategoryEnum("trunking-emergency-calls"); + public static readonly CategoryEnum TrunkingOrigination = new CategoryEnum("trunking-origination"); + public static readonly CategoryEnum TrunkingOriginationLocal = new CategoryEnum("trunking-origination-local"); + public static readonly CategoryEnum TrunkingOriginationMobile = new CategoryEnum("trunking-origination-mobile"); + public static readonly CategoryEnum TrunkingOriginationTollfree = new CategoryEnum("trunking-origination-tollfree"); + public static readonly CategoryEnum TrunkingRecordings = new CategoryEnum("trunking-recordings"); + public static readonly CategoryEnum TrunkingSecure = new CategoryEnum("trunking-secure"); + public static readonly CategoryEnum TrunkingTermination = new CategoryEnum("trunking-termination"); + public static readonly CategoryEnum Turnmegabytes = new CategoryEnum("turnmegabytes"); + public static readonly CategoryEnum TurnmegabytesAustralia = new CategoryEnum("turnmegabytes-australia"); + public static readonly CategoryEnum TurnmegabytesBrasil = new CategoryEnum("turnmegabytes-brasil"); + public static readonly CategoryEnum TurnmegabytesGermany = new CategoryEnum("turnmegabytes-germany"); + public static readonly CategoryEnum TurnmegabytesIndia = new CategoryEnum("turnmegabytes-india"); + public static readonly CategoryEnum TurnmegabytesIreland = new CategoryEnum("turnmegabytes-ireland"); + public static readonly CategoryEnum TurnmegabytesJapan = new CategoryEnum("turnmegabytes-japan"); + public static readonly CategoryEnum TurnmegabytesSingapore = new CategoryEnum("turnmegabytes-singapore"); + public static readonly CategoryEnum TurnmegabytesUseast = new CategoryEnum("turnmegabytes-useast"); + public static readonly CategoryEnum TurnmegabytesUswest = new CategoryEnum("turnmegabytes-uswest"); + public static readonly CategoryEnum TwilioInterconnect = new CategoryEnum("twilio-interconnect"); + public static readonly CategoryEnum VerifyPush = new CategoryEnum("verify-push"); + public static readonly CategoryEnum VideoRecordings = new CategoryEnum("video-recordings"); + public static readonly CategoryEnum VoiceInsights = new CategoryEnum("voice-insights"); + public static readonly CategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new CategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new CategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly CategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new CategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly CategoryEnum Wireless = new CategoryEnum("wireless"); + public static readonly CategoryEnum WirelessOrders = new CategoryEnum("wireless-orders"); + public static readonly CategoryEnum WirelessOrdersArtwork = new CategoryEnum("wireless-orders-artwork"); + public static readonly CategoryEnum WirelessOrdersBulk = new CategoryEnum("wireless-orders-bulk"); + public static readonly CategoryEnum WirelessOrdersEsim = new CategoryEnum("wireless-orders-esim"); + public static readonly CategoryEnum WirelessOrdersStarter = new CategoryEnum("wireless-orders-starter"); + public static readonly CategoryEnum WirelessUsage = new CategoryEnum("wireless-usage"); + public static readonly CategoryEnum WirelessUsageCommands = new CategoryEnum("wireless-usage-commands"); + public static readonly CategoryEnum WirelessUsageCommandsAfrica = new CategoryEnum("wireless-usage-commands-africa"); + public static readonly CategoryEnum WirelessUsageCommandsAsia = new CategoryEnum("wireless-usage-commands-asia"); + public static readonly CategoryEnum WirelessUsageCommandsCentralandsouthamerica = new CategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageCommandsEurope = new CategoryEnum("wireless-usage-commands-europe"); + public static readonly CategoryEnum WirelessUsageCommandsHome = new CategoryEnum("wireless-usage-commands-home"); + public static readonly CategoryEnum WirelessUsageCommandsNorthamerica = new CategoryEnum("wireless-usage-commands-northamerica"); + public static readonly CategoryEnum WirelessUsageCommandsOceania = new CategoryEnum("wireless-usage-commands-oceania"); + public static readonly CategoryEnum WirelessUsageCommandsRoaming = new CategoryEnum("wireless-usage-commands-roaming"); + public static readonly CategoryEnum WirelessUsageData = new CategoryEnum("wireless-usage-data"); + public static readonly CategoryEnum WirelessUsageDataAfrica = new CategoryEnum("wireless-usage-data-africa"); + public static readonly CategoryEnum WirelessUsageDataAsia = new CategoryEnum("wireless-usage-data-asia"); + public static readonly CategoryEnum WirelessUsageDataCentralandsouthamerica = new CategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly CategoryEnum WirelessUsageDataCustomAdditionalmb = new CategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly CategoryEnum WirelessUsageDataCustomFirst5Mb = new CategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly CategoryEnum WirelessUsageDataDomesticRoaming = new CategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly CategoryEnum WirelessUsageDataEurope = new CategoryEnum("wireless-usage-data-europe"); + public static readonly CategoryEnum WirelessUsageDataIndividualAdditionalgb = new CategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly CategoryEnum WirelessUsageDataIndividualFirstgb = new CategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingCanada = new CategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingIndia = new CategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly CategoryEnum WirelessUsageDataInternationalRoamingMexico = new CategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly CategoryEnum WirelessUsageDataNorthamerica = new CategoryEnum("wireless-usage-data-northamerica"); + public static readonly CategoryEnum WirelessUsageDataOceania = new CategoryEnum("wireless-usage-data-oceania"); + public static readonly CategoryEnum WirelessUsageDataPooled = new CategoryEnum("wireless-usage-data-pooled"); + public static readonly CategoryEnum WirelessUsageDataPooledDownlink = new CategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly CategoryEnum WirelessUsageDataPooledUplink = new CategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly CategoryEnum WirelessUsageMrc = new CategoryEnum("wireless-usage-mrc"); + public static readonly CategoryEnum WirelessUsageMrcCustom = new CategoryEnum("wireless-usage-mrc-custom"); + public static readonly CategoryEnum WirelessUsageMrcIndividual = new CategoryEnum("wireless-usage-mrc-individual"); + public static readonly CategoryEnum WirelessUsageMrcPooled = new CategoryEnum("wireless-usage-mrc-pooled"); + public static readonly CategoryEnum WirelessUsageMrcSuspended = new CategoryEnum("wireless-usage-mrc-suspended"); + public static readonly CategoryEnum WirelessUsageSms = new CategoryEnum("wireless-usage-sms"); + public static readonly CategoryEnum WirelessUsageVoice = new CategoryEnum("wireless-usage-voice"); + } + + private static Request BuildReadRequest(ReadRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Records.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of usage-records belonging to the account used to make the request + /// + /// Read Record parameters + /// Client to make requests to Twilio + /// A single instance of Record + public static ResourceSet Read(ReadRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of usage-records belonging to the account used to make the request + /// + /// Read Record parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Record + public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of usage-records belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Record + public static ResourceSet Read(string pathAccountSid = null, + RecordResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of usage-records belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The usage category of the UsageRecord resources to read + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// Whether to include usage from the master account and all its subaccounts + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Record + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + RecordResource.CategoryEnum category = null, + DateTime? startDate = null, + DateTime? endDate = null, + bool? includeSubaccounts = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordOptions() { PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, IncludeSubaccounts = includeSubaccounts, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a RecordResource object + /// + /// Raw JSON string + /// RecordResource object represented by the provided JSON + public static RecordResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account accrued the usage + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Usage records up to date as of this timestamp + /// + [JsonProperty("as_of")] + public string AsOf { get; private set; } + /// + /// The category of usage + /// + [JsonProperty("category")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordResource.CategoryEnum Category { get; private set; } + /// + /// The number of usage events + /// + [JsonProperty("count")] + public string Count { get; private set; } + /// + /// The units in which count is measured + /// + [JsonProperty("count_unit")] + public string CountUnit { get; private set; } + /// + /// A plain-language description of the usage category + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The last date for which usage is included in the UsageRecord + /// + [JsonProperty("end_date")] + public DateTime? EndDate { get; private set; } + /// + /// The total price of the usage + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The currency in which `price` is measured + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The first date for which usage is included in this UsageRecord + /// + [JsonProperty("start_date")] + public DateTime? StartDate { get; private set; } + /// + /// A list of related resources identified by their relative URIs + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The amount of usage + /// + [JsonProperty("usage")] + public string Usage { get; private set; } + /// + /// The units in which usage is measured + /// + [JsonProperty("usage_unit")] + public string UsageUnit { get; private set; } + + private RecordResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerOptions.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerOptions.cs index d4de729ce..53653c7dd 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerOptions.cs @@ -9,280 +9,280 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account.Usage -{ - +{ + + /// + /// Fetch and instance of a usage-trigger + /// + public class FetchTriggerOptions : IOptions + { /// - /// Fetch and instance of a usage-trigger + /// The SID of the Account that created the resource to fetch /// - public class FetchTriggerOptions : IOptions - { - /// - /// The SID of the Account that created the resource to fetch - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTriggerOptions - /// - /// The unique string that identifies the resource - public FetchTriggerOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAccountSid { get; set; } /// - /// Update an instance of a usage trigger + /// The unique string that identifies the resource /// - public class UpdateTriggerOptions : IOptions - { - /// - /// The SID of the Account that created the resources to update - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The HTTP method to use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// The URL we call when the trigger fires - /// - public Uri CallbackUrl { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateTriggerOptions - /// - /// The unique string that identifies the resource - public UpdateTriggerOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteTriggerOptions + /// Construct a new FetchTriggerOptions /// - public class DeleteTriggerOptions : IOptions - { - /// - /// The SID of the Account that created the resources to delete - /// - public string PathAccountSid { get; set; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTriggerOptions - /// - /// The unique string that identifies the resource - public DeleteTriggerOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + public FetchTriggerOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Create a new UsageTrigger + /// Generate the necessary parameters /// - public class CreateTriggerOptions : IOptions - { - /// - /// The SID of the Account that will create the resource - /// - public string PathAccountSid { get; set; } - /// - /// The URL we call when the trigger fires - /// - public Uri CallbackUrl { get; } - /// - /// The usage value at which the trigger should fire - /// - public string TriggerValue { get; } - /// - /// The usage category the trigger watches - /// - public TriggerResource.UsageCategoryEnum UsageCategory { get; } - /// - /// The HTTP method to use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The frequency of a recurring UsageTrigger - /// - public TriggerResource.RecurringEnum Recurring { get; set; } - /// - /// The field in the UsageRecord resource that fires the trigger - /// - public TriggerResource.TriggerFieldEnum TriggerBy { get; set; } - - /// - /// Construct a new CreateTriggerOptions - /// - /// The URL we call when the trigger fires - /// The usage value at which the trigger should fire - /// The usage category the trigger watches - public CreateTriggerOptions(Uri callbackUrl, string triggerValue, TriggerResource.UsageCategoryEnum usageCategory) - { - CallbackUrl = callbackUrl; - TriggerValue = triggerValue; - UsageCategory = usageCategory; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (TriggerValue != null) - { - p.Add(new KeyValuePair("TriggerValue", TriggerValue)); - } - - if (UsageCategory != null) - { - p.Add(new KeyValuePair("UsageCategory", UsageCategory.ToString())); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Recurring != null) - { - p.Add(new KeyValuePair("Recurring", Recurring.ToString())); - } - - if (TriggerBy != null) - { - p.Add(new KeyValuePair("TriggerBy", TriggerBy.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an instance of a usage trigger + /// + public class UpdateTriggerOptions : IOptions + { /// - /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// The SID of the Account that created the resources to update /// - public class ReadTriggerOptions : ReadOptions - { - /// - /// The SID of the Account that created the resources to read - /// - public string PathAccountSid { get; set; } - /// - /// The frequency of recurring UsageTriggers to read - /// - public TriggerResource.RecurringEnum Recurring { get; set; } - /// - /// The trigger field of the UsageTriggers to read - /// - public TriggerResource.TriggerFieldEnum TriggerBy { get; set; } - /// - /// The usage category of the UsageTriggers to read - /// - public TriggerResource.UsageCategoryEnum UsageCategory { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Recurring != null) - { - p.Add(new KeyValuePair("Recurring", Recurring.ToString())); - } - - if (TriggerBy != null) - { - p.Add(new KeyValuePair("TriggerBy", TriggerBy.ToString())); - } - - if (UsageCategory != null) - { - p.Add(new KeyValuePair("UsageCategory", UsageCategory.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The HTTP method to use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// The URL we call when the trigger fires + /// + public Uri CallbackUrl { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateTriggerOptions + /// + /// The unique string that identifies the resource + public UpdateTriggerOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteTriggerOptions + /// + public class DeleteTriggerOptions : IOptions + { + /// + /// The SID of the Account that created the resources to delete + /// + public string PathAccountSid { get; set; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTriggerOptions + /// + /// The unique string that identifies the resource + public DeleteTriggerOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Create a new UsageTrigger + /// + public class CreateTriggerOptions : IOptions + { + /// + /// The SID of the Account that will create the resource + /// + public string PathAccountSid { get; set; } + /// + /// The URL we call when the trigger fires + /// + public Uri CallbackUrl { get; } + /// + /// The usage value at which the trigger should fire + /// + public string TriggerValue { get; } + /// + /// The usage category the trigger watches + /// + public TriggerResource.UsageCategoryEnum UsageCategory { get; } + /// + /// The HTTP method to use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The frequency of a recurring UsageTrigger + /// + public TriggerResource.RecurringEnum Recurring { get; set; } + /// + /// The field in the UsageRecord resource that fires the trigger + /// + public TriggerResource.TriggerFieldEnum TriggerBy { get; set; } + + /// + /// Construct a new CreateTriggerOptions + /// + /// The URL we call when the trigger fires + /// The usage value at which the trigger should fire + /// The usage category the trigger watches + public CreateTriggerOptions(Uri callbackUrl, string triggerValue, TriggerResource.UsageCategoryEnum usageCategory) + { + CallbackUrl = callbackUrl; + TriggerValue = triggerValue; + UsageCategory = usageCategory; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (TriggerValue != null) + { + p.Add(new KeyValuePair("TriggerValue", TriggerValue)); + } + + if (UsageCategory != null) + { + p.Add(new KeyValuePair("UsageCategory", UsageCategory.ToString())); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Recurring != null) + { + p.Add(new KeyValuePair("Recurring", Recurring.ToString())); + } + + if (TriggerBy != null) + { + p.Add(new KeyValuePair("TriggerBy", TriggerBy.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// + public class ReadTriggerOptions : ReadOptions + { + /// + /// The SID of the Account that created the resources to read + /// + public string PathAccountSid { get; set; } + /// + /// The frequency of recurring UsageTriggers to read + /// + public TriggerResource.RecurringEnum Recurring { get; set; } + /// + /// The trigger field of the UsageTriggers to read + /// + public TriggerResource.TriggerFieldEnum TriggerBy { get; set; } + /// + /// The usage category of the UsageTriggers to read + /// + public TriggerResource.UsageCategoryEnum UsageCategory { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Recurring != null) + { + p.Add(new KeyValuePair("Recurring", Recurring.ToString())); + } + + if (TriggerBy != null) + { + p.Add(new KeyValuePair("TriggerBy", TriggerBy.ToString())); + } + + if (UsageCategory != null) + { + p.Add(new KeyValuePair("UsageCategory", UsageCategory.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerResource.cs b/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerResource.cs index 728e5d096..678379fb0 100644 --- a/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/Usage/TriggerResource.cs @@ -17,862 +17,862 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010.Account.Usage -{ - - public class TriggerResource : Resource - { - public sealed class UsageCategoryEnum : StringEnum - { - private UsageCategoryEnum(string value) : base(value) {} - public UsageCategoryEnum() {} - public static implicit operator UsageCategoryEnum(string value) - { - return new UsageCategoryEnum(value); - } - - public static readonly UsageCategoryEnum AgentConference = new UsageCategoryEnum("agent-conference"); - public static readonly UsageCategoryEnum AnsweringMachineDetection = new UsageCategoryEnum("answering-machine-detection"); - public static readonly UsageCategoryEnum AuthyAuthentications = new UsageCategoryEnum("authy-authentications"); - public static readonly UsageCategoryEnum AuthyCallsOutbound = new UsageCategoryEnum("authy-calls-outbound"); - public static readonly UsageCategoryEnum AuthyMonthlyFees = new UsageCategoryEnum("authy-monthly-fees"); - public static readonly UsageCategoryEnum AuthyPhoneIntelligence = new UsageCategoryEnum("authy-phone-intelligence"); - public static readonly UsageCategoryEnum AuthyPhoneVerifications = new UsageCategoryEnum("authy-phone-verifications"); - public static readonly UsageCategoryEnum AuthySmsOutbound = new UsageCategoryEnum("authy-sms-outbound"); - public static readonly UsageCategoryEnum CallProgessEvents = new UsageCategoryEnum("call-progess-events"); - public static readonly UsageCategoryEnum Calleridlookups = new UsageCategoryEnum("calleridlookups"); - public static readonly UsageCategoryEnum Calls = new UsageCategoryEnum("calls"); - public static readonly UsageCategoryEnum CallsClient = new UsageCategoryEnum("calls-client"); - public static readonly UsageCategoryEnum CallsGlobalconference = new UsageCategoryEnum("calls-globalconference"); - public static readonly UsageCategoryEnum CallsInbound = new UsageCategoryEnum("calls-inbound"); - public static readonly UsageCategoryEnum CallsInboundLocal = new UsageCategoryEnum("calls-inbound-local"); - public static readonly UsageCategoryEnum CallsInboundMobile = new UsageCategoryEnum("calls-inbound-mobile"); - public static readonly UsageCategoryEnum CallsInboundTollfree = new UsageCategoryEnum("calls-inbound-tollfree"); - public static readonly UsageCategoryEnum CallsOutbound = new UsageCategoryEnum("calls-outbound"); - public static readonly UsageCategoryEnum CallsPayVerbTransactions = new UsageCategoryEnum("calls-pay-verb-transactions"); - public static readonly UsageCategoryEnum CallsRecordings = new UsageCategoryEnum("calls-recordings"); - public static readonly UsageCategoryEnum CallsSip = new UsageCategoryEnum("calls-sip"); - public static readonly UsageCategoryEnum CallsSipInbound = new UsageCategoryEnum("calls-sip-inbound"); - public static readonly UsageCategoryEnum CallsSipOutbound = new UsageCategoryEnum("calls-sip-outbound"); - public static readonly UsageCategoryEnum CallsTransfers = new UsageCategoryEnum("calls-transfers"); - public static readonly UsageCategoryEnum CarrierLookups = new UsageCategoryEnum("carrier-lookups"); - public static readonly UsageCategoryEnum Conversations = new UsageCategoryEnum("conversations"); - public static readonly UsageCategoryEnum ConversationsApiRequests = new UsageCategoryEnum("conversations-api-requests"); - public static readonly UsageCategoryEnum ConversationsConversationEvents = new UsageCategoryEnum("conversations-conversation-events"); - public static readonly UsageCategoryEnum ConversationsEndpointConnectivity = new UsageCategoryEnum("conversations-endpoint-connectivity"); - public static readonly UsageCategoryEnum ConversationsEvents = new UsageCategoryEnum("conversations-events"); - public static readonly UsageCategoryEnum ConversationsParticipantEvents = new UsageCategoryEnum("conversations-participant-events"); - public static readonly UsageCategoryEnum ConversationsParticipants = new UsageCategoryEnum("conversations-participants"); - public static readonly UsageCategoryEnum Cps = new UsageCategoryEnum("cps"); - public static readonly UsageCategoryEnum FlexUsage = new UsageCategoryEnum("flex-usage"); - public static readonly UsageCategoryEnum FraudLookups = new UsageCategoryEnum("fraud-lookups"); - public static readonly UsageCategoryEnum GroupRooms = new UsageCategoryEnum("group-rooms"); - public static readonly UsageCategoryEnum GroupRoomsDataTrack = new UsageCategoryEnum("group-rooms-data-track"); - public static readonly UsageCategoryEnum GroupRoomsEncryptedMediaRecorded = new UsageCategoryEnum("group-rooms-encrypted-media-recorded"); - public static readonly UsageCategoryEnum GroupRoomsMediaDownloaded = new UsageCategoryEnum("group-rooms-media-downloaded"); - public static readonly UsageCategoryEnum GroupRoomsMediaRecorded = new UsageCategoryEnum("group-rooms-media-recorded"); - public static readonly UsageCategoryEnum GroupRoomsMediaRouted = new UsageCategoryEnum("group-rooms-media-routed"); - public static readonly UsageCategoryEnum GroupRoomsMediaStored = new UsageCategoryEnum("group-rooms-media-stored"); - public static readonly UsageCategoryEnum GroupRoomsParticipantMinutes = new UsageCategoryEnum("group-rooms-participant-minutes"); - public static readonly UsageCategoryEnum GroupRoomsRecordedMinutes = new UsageCategoryEnum("group-rooms-recorded-minutes"); - public static readonly UsageCategoryEnum ImpV1Usage = new UsageCategoryEnum("imp-v1-usage"); - public static readonly UsageCategoryEnum Lookups = new UsageCategoryEnum("lookups"); - public static readonly UsageCategoryEnum Marketplace = new UsageCategoryEnum("marketplace"); - public static readonly UsageCategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new UsageCategoryEnum("marketplace-algorithmia-named-entity-recognition"); - public static readonly UsageCategoryEnum MarketplaceCadenceTranscription = new UsageCategoryEnum("marketplace-cadence-transcription"); - public static readonly UsageCategoryEnum MarketplaceCadenceTranslation = new UsageCategoryEnum("marketplace-cadence-translation"); - public static readonly UsageCategoryEnum MarketplaceCapioSpeechToText = new UsageCategoryEnum("marketplace-capio-speech-to-text"); - public static readonly UsageCategoryEnum MarketplaceConvrizaAbaba = new UsageCategoryEnum("marketplace-convriza-ababa"); - public static readonly UsageCategoryEnum MarketplaceDeepgramPhraseDetector = new UsageCategoryEnum("marketplace-deepgram-phrase-detector"); - public static readonly UsageCategoryEnum MarketplaceDigitalSegmentBusinessInfo = new UsageCategoryEnum("marketplace-digital-segment-business-info"); - public static readonly UsageCategoryEnum MarketplaceFacebookOfflineConversions = new UsageCategoryEnum("marketplace-facebook-offline-conversions"); - public static readonly UsageCategoryEnum MarketplaceGoogleSpeechToText = new UsageCategoryEnum("marketplace-google-speech-to-text"); - public static readonly UsageCategoryEnum MarketplaceIbmWatsonMessageInsights = new UsageCategoryEnum("marketplace-ibm-watson-message-insights"); - public static readonly UsageCategoryEnum MarketplaceIbmWatsonMessageSentiment = new UsageCategoryEnum("marketplace-ibm-watson-message-sentiment"); - public static readonly UsageCategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new UsageCategoryEnum("marketplace-ibm-watson-recording-analysis"); - public static readonly UsageCategoryEnum MarketplaceIbmWatsonToneAnalyzer = new UsageCategoryEnum("marketplace-ibm-watson-tone-analyzer"); - public static readonly UsageCategoryEnum MarketplaceIcehookSystemsScout = new UsageCategoryEnum("marketplace-icehook-systems-scout"); - public static readonly UsageCategoryEnum MarketplaceInfogroupDataaxleBizinfo = new UsageCategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); - public static readonly UsageCategoryEnum MarketplaceKeenIoContactCenterAnalytics = new UsageCategoryEnum("marketplace-keen-io-contact-center-analytics"); - public static readonly UsageCategoryEnum MarketplaceMarchexCleancall = new UsageCategoryEnum("marketplace-marchex-cleancall"); - public static readonly UsageCategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new UsageCategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); - public static readonly UsageCategoryEnum MarketplaceMarketplaceNextcallerSocialId = new UsageCategoryEnum("marketplace-marketplace-nextcaller-social-id"); - public static readonly UsageCategoryEnum MarketplaceMobileCommonsOptOutClassifier = new UsageCategoryEnum("marketplace-mobile-commons-opt-out-classifier"); - public static readonly UsageCategoryEnum MarketplaceNexiwaveVoicemailToText = new UsageCategoryEnum("marketplace-nexiwave-voicemail-to-text"); - public static readonly UsageCategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new UsageCategoryEnum("marketplace-nextcaller-advanced-caller-identification"); - public static readonly UsageCategoryEnum MarketplaceNomoroboSpamScore = new UsageCategoryEnum("marketplace-nomorobo-spam-score"); - public static readonly UsageCategoryEnum MarketplacePayfoneTcpaCompliance = new UsageCategoryEnum("marketplace-payfone-tcpa-compliance"); - public static readonly UsageCategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new UsageCategoryEnum("marketplace-remeeting-automatic-speech-recognition"); - public static readonly UsageCategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new UsageCategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); - public static readonly UsageCategoryEnum MarketplaceTeloOpencnam = new UsageCategoryEnum("marketplace-telo-opencnam"); - public static readonly UsageCategoryEnum MarketplaceTruecnamTrueSpam = new UsageCategoryEnum("marketplace-truecnam-true-spam"); - public static readonly UsageCategoryEnum MarketplaceTwilioCallerNameLookupUs = new UsageCategoryEnum("marketplace-twilio-caller-name-lookup-us"); - public static readonly UsageCategoryEnum MarketplaceTwilioCarrierInformationLookup = new UsageCategoryEnum("marketplace-twilio-carrier-information-lookup"); - public static readonly UsageCategoryEnum MarketplaceVoicebasePci = new UsageCategoryEnum("marketplace-voicebase-pci"); - public static readonly UsageCategoryEnum MarketplaceVoicebaseTranscription = new UsageCategoryEnum("marketplace-voicebase-transcription"); - public static readonly UsageCategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new UsageCategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); - public static readonly UsageCategoryEnum MarketplaceWhitepagesProCallerIdentification = new UsageCategoryEnum("marketplace-whitepages-pro-caller-identification"); - public static readonly UsageCategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new UsageCategoryEnum("marketplace-whitepages-pro-phone-intelligence"); - public static readonly UsageCategoryEnum MarketplaceWhitepagesProPhoneReputation = new UsageCategoryEnum("marketplace-whitepages-pro-phone-reputation"); - public static readonly UsageCategoryEnum MarketplaceWolfarmSpokenResults = new UsageCategoryEnum("marketplace-wolfarm-spoken-results"); - public static readonly UsageCategoryEnum MarketplaceWolframShortAnswer = new UsageCategoryEnum("marketplace-wolfram-short-answer"); - public static readonly UsageCategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new UsageCategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); - public static readonly UsageCategoryEnum Mediastorage = new UsageCategoryEnum("mediastorage"); - public static readonly UsageCategoryEnum Mms = new UsageCategoryEnum("mms"); - public static readonly UsageCategoryEnum MmsInbound = new UsageCategoryEnum("mms-inbound"); - public static readonly UsageCategoryEnum MmsInboundLongcode = new UsageCategoryEnum("mms-inbound-longcode"); - public static readonly UsageCategoryEnum MmsInboundShortcode = new UsageCategoryEnum("mms-inbound-shortcode"); - public static readonly UsageCategoryEnum MmsMessagesCarrierfees = new UsageCategoryEnum("mms-messages-carrierfees"); - public static readonly UsageCategoryEnum MmsOutbound = new UsageCategoryEnum("mms-outbound"); - public static readonly UsageCategoryEnum MmsOutboundLongcode = new UsageCategoryEnum("mms-outbound-longcode"); - public static readonly UsageCategoryEnum MmsOutboundShortcode = new UsageCategoryEnum("mms-outbound-shortcode"); - public static readonly UsageCategoryEnum MonitorReads = new UsageCategoryEnum("monitor-reads"); - public static readonly UsageCategoryEnum MonitorStorage = new UsageCategoryEnum("monitor-storage"); - public static readonly UsageCategoryEnum MonitorWrites = new UsageCategoryEnum("monitor-writes"); - public static readonly UsageCategoryEnum Notify = new UsageCategoryEnum("notify"); - public static readonly UsageCategoryEnum NotifyActionsAttempts = new UsageCategoryEnum("notify-actions-attempts"); - public static readonly UsageCategoryEnum NotifyChannels = new UsageCategoryEnum("notify-channels"); - public static readonly UsageCategoryEnum NumberFormatLookups = new UsageCategoryEnum("number-format-lookups"); - public static readonly UsageCategoryEnum Pchat = new UsageCategoryEnum("pchat"); - public static readonly UsageCategoryEnum PchatUsers = new UsageCategoryEnum("pchat-users"); - public static readonly UsageCategoryEnum PeerToPeerRoomsParticipantMinutes = new UsageCategoryEnum("peer-to-peer-rooms-participant-minutes"); - public static readonly UsageCategoryEnum Pfax = new UsageCategoryEnum("pfax"); - public static readonly UsageCategoryEnum PfaxMinutes = new UsageCategoryEnum("pfax-minutes"); - public static readonly UsageCategoryEnum PfaxMinutesInbound = new UsageCategoryEnum("pfax-minutes-inbound"); - public static readonly UsageCategoryEnum PfaxMinutesOutbound = new UsageCategoryEnum("pfax-minutes-outbound"); - public static readonly UsageCategoryEnum PfaxPages = new UsageCategoryEnum("pfax-pages"); - public static readonly UsageCategoryEnum Phonenumbers = new UsageCategoryEnum("phonenumbers"); - public static readonly UsageCategoryEnum PhonenumbersCps = new UsageCategoryEnum("phonenumbers-cps"); - public static readonly UsageCategoryEnum PhonenumbersEmergency = new UsageCategoryEnum("phonenumbers-emergency"); - public static readonly UsageCategoryEnum PhonenumbersLocal = new UsageCategoryEnum("phonenumbers-local"); - public static readonly UsageCategoryEnum PhonenumbersMobile = new UsageCategoryEnum("phonenumbers-mobile"); - public static readonly UsageCategoryEnum PhonenumbersSetups = new UsageCategoryEnum("phonenumbers-setups"); - public static readonly UsageCategoryEnum PhonenumbersTollfree = new UsageCategoryEnum("phonenumbers-tollfree"); - public static readonly UsageCategoryEnum Premiumsupport = new UsageCategoryEnum("premiumsupport"); - public static readonly UsageCategoryEnum Proxy = new UsageCategoryEnum("proxy"); - public static readonly UsageCategoryEnum ProxyActiveSessions = new UsageCategoryEnum("proxy-active-sessions"); - public static readonly UsageCategoryEnum Pstnconnectivity = new UsageCategoryEnum("pstnconnectivity"); - public static readonly UsageCategoryEnum Pv = new UsageCategoryEnum("pv"); - public static readonly UsageCategoryEnum PvCompositionMediaDownloaded = new UsageCategoryEnum("pv-composition-media-downloaded"); - public static readonly UsageCategoryEnum PvCompositionMediaEncrypted = new UsageCategoryEnum("pv-composition-media-encrypted"); - public static readonly UsageCategoryEnum PvCompositionMediaStored = new UsageCategoryEnum("pv-composition-media-stored"); - public static readonly UsageCategoryEnum PvCompositionMinutes = new UsageCategoryEnum("pv-composition-minutes"); - public static readonly UsageCategoryEnum PvRecordingCompositions = new UsageCategoryEnum("pv-recording-compositions"); - public static readonly UsageCategoryEnum PvRoomParticipants = new UsageCategoryEnum("pv-room-participants"); - public static readonly UsageCategoryEnum PvRoomParticipantsAu1 = new UsageCategoryEnum("pv-room-participants-au1"); - public static readonly UsageCategoryEnum PvRoomParticipantsBr1 = new UsageCategoryEnum("pv-room-participants-br1"); - public static readonly UsageCategoryEnum PvRoomParticipantsIe1 = new UsageCategoryEnum("pv-room-participants-ie1"); - public static readonly UsageCategoryEnum PvRoomParticipantsJp1 = new UsageCategoryEnum("pv-room-participants-jp1"); - public static readonly UsageCategoryEnum PvRoomParticipantsSg1 = new UsageCategoryEnum("pv-room-participants-sg1"); - public static readonly UsageCategoryEnum PvRoomParticipantsUs1 = new UsageCategoryEnum("pv-room-participants-us1"); - public static readonly UsageCategoryEnum PvRoomParticipantsUs2 = new UsageCategoryEnum("pv-room-participants-us2"); - public static readonly UsageCategoryEnum PvRooms = new UsageCategoryEnum("pv-rooms"); - public static readonly UsageCategoryEnum PvSipEndpointRegistrations = new UsageCategoryEnum("pv-sip-endpoint-registrations"); - public static readonly UsageCategoryEnum Recordings = new UsageCategoryEnum("recordings"); - public static readonly UsageCategoryEnum Recordingstorage = new UsageCategoryEnum("recordingstorage"); - public static readonly UsageCategoryEnum RoomsGroupBandwidth = new UsageCategoryEnum("rooms-group-bandwidth"); - public static readonly UsageCategoryEnum RoomsGroupMinutes = new UsageCategoryEnum("rooms-group-minutes"); - public static readonly UsageCategoryEnum RoomsPeerToPeerMinutes = new UsageCategoryEnum("rooms-peer-to-peer-minutes"); - public static readonly UsageCategoryEnum Shortcodes = new UsageCategoryEnum("shortcodes"); - public static readonly UsageCategoryEnum ShortcodesCustomerowned = new UsageCategoryEnum("shortcodes-customerowned"); - public static readonly UsageCategoryEnum ShortcodesMmsEnablement = new UsageCategoryEnum("shortcodes-mms-enablement"); - public static readonly UsageCategoryEnum ShortcodesMps = new UsageCategoryEnum("shortcodes-mps"); - public static readonly UsageCategoryEnum ShortcodesRandom = new UsageCategoryEnum("shortcodes-random"); - public static readonly UsageCategoryEnum ShortcodesUk = new UsageCategoryEnum("shortcodes-uk"); - public static readonly UsageCategoryEnum ShortcodesVanity = new UsageCategoryEnum("shortcodes-vanity"); - public static readonly UsageCategoryEnum SmallGroupRooms = new UsageCategoryEnum("small-group-rooms"); - public static readonly UsageCategoryEnum SmallGroupRoomsDataTrack = new UsageCategoryEnum("small-group-rooms-data-track"); - public static readonly UsageCategoryEnum SmallGroupRoomsParticipantMinutes = new UsageCategoryEnum("small-group-rooms-participant-minutes"); - public static readonly UsageCategoryEnum Sms = new UsageCategoryEnum("sms"); - public static readonly UsageCategoryEnum SmsInbound = new UsageCategoryEnum("sms-inbound"); - public static readonly UsageCategoryEnum SmsInboundLongcode = new UsageCategoryEnum("sms-inbound-longcode"); - public static readonly UsageCategoryEnum SmsInboundShortcode = new UsageCategoryEnum("sms-inbound-shortcode"); - public static readonly UsageCategoryEnum SmsMessagesCarrierfees = new UsageCategoryEnum("sms-messages-carrierfees"); - public static readonly UsageCategoryEnum SmsMessagesFeatures = new UsageCategoryEnum("sms-messages-features"); - public static readonly UsageCategoryEnum SmsMessagesFeaturesSenderid = new UsageCategoryEnum("sms-messages-features-senderid"); - public static readonly UsageCategoryEnum SmsOutbound = new UsageCategoryEnum("sms-outbound"); - public static readonly UsageCategoryEnum SmsOutboundContentInspection = new UsageCategoryEnum("sms-outbound-content-inspection"); - public static readonly UsageCategoryEnum SmsOutboundLongcode = new UsageCategoryEnum("sms-outbound-longcode"); - public static readonly UsageCategoryEnum SmsOutboundShortcode = new UsageCategoryEnum("sms-outbound-shortcode"); - public static readonly UsageCategoryEnum SpeechRecognition = new UsageCategoryEnum("speech-recognition"); - public static readonly UsageCategoryEnum StudioEngagements = new UsageCategoryEnum("studio-engagements"); - public static readonly UsageCategoryEnum Sync = new UsageCategoryEnum("sync"); - public static readonly UsageCategoryEnum SyncActions = new UsageCategoryEnum("sync-actions"); - public static readonly UsageCategoryEnum SyncEndpointHours = new UsageCategoryEnum("sync-endpoint-hours"); - public static readonly UsageCategoryEnum SyncEndpointHoursAboveDailyCap = new UsageCategoryEnum("sync-endpoint-hours-above-daily-cap"); - public static readonly UsageCategoryEnum TaskrouterTasks = new UsageCategoryEnum("taskrouter-tasks"); - public static readonly UsageCategoryEnum Totalprice = new UsageCategoryEnum("totalprice"); - public static readonly UsageCategoryEnum Transcriptions = new UsageCategoryEnum("transcriptions"); - public static readonly UsageCategoryEnum TrunkingCps = new UsageCategoryEnum("trunking-cps"); - public static readonly UsageCategoryEnum TrunkingEmergencyCalls = new UsageCategoryEnum("trunking-emergency-calls"); - public static readonly UsageCategoryEnum TrunkingOrigination = new UsageCategoryEnum("trunking-origination"); - public static readonly UsageCategoryEnum TrunkingOriginationLocal = new UsageCategoryEnum("trunking-origination-local"); - public static readonly UsageCategoryEnum TrunkingOriginationMobile = new UsageCategoryEnum("trunking-origination-mobile"); - public static readonly UsageCategoryEnum TrunkingOriginationTollfree = new UsageCategoryEnum("trunking-origination-tollfree"); - public static readonly UsageCategoryEnum TrunkingRecordings = new UsageCategoryEnum("trunking-recordings"); - public static readonly UsageCategoryEnum TrunkingSecure = new UsageCategoryEnum("trunking-secure"); - public static readonly UsageCategoryEnum TrunkingTermination = new UsageCategoryEnum("trunking-termination"); - public static readonly UsageCategoryEnum Turnmegabytes = new UsageCategoryEnum("turnmegabytes"); - public static readonly UsageCategoryEnum TurnmegabytesAustralia = new UsageCategoryEnum("turnmegabytes-australia"); - public static readonly UsageCategoryEnum TurnmegabytesBrasil = new UsageCategoryEnum("turnmegabytes-brasil"); - public static readonly UsageCategoryEnum TurnmegabytesGermany = new UsageCategoryEnum("turnmegabytes-germany"); - public static readonly UsageCategoryEnum TurnmegabytesIndia = new UsageCategoryEnum("turnmegabytes-india"); - public static readonly UsageCategoryEnum TurnmegabytesIreland = new UsageCategoryEnum("turnmegabytes-ireland"); - public static readonly UsageCategoryEnum TurnmegabytesJapan = new UsageCategoryEnum("turnmegabytes-japan"); - public static readonly UsageCategoryEnum TurnmegabytesSingapore = new UsageCategoryEnum("turnmegabytes-singapore"); - public static readonly UsageCategoryEnum TurnmegabytesUseast = new UsageCategoryEnum("turnmegabytes-useast"); - public static readonly UsageCategoryEnum TurnmegabytesUswest = new UsageCategoryEnum("turnmegabytes-uswest"); - public static readonly UsageCategoryEnum TwilioInterconnect = new UsageCategoryEnum("twilio-interconnect"); - public static readonly UsageCategoryEnum VerifyPush = new UsageCategoryEnum("verify-push"); - public static readonly UsageCategoryEnum VideoRecordings = new UsageCategoryEnum("video-recordings"); - public static readonly UsageCategoryEnum VoiceInsights = new UsageCategoryEnum("voice-insights"); - public static readonly UsageCategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-client-insights-on-demand-minute"); - public static readonly UsageCategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); - public static readonly UsageCategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); - public static readonly UsageCategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); - public static readonly UsageCategoryEnum Wireless = new UsageCategoryEnum("wireless"); - public static readonly UsageCategoryEnum WirelessOrders = new UsageCategoryEnum("wireless-orders"); - public static readonly UsageCategoryEnum WirelessOrdersArtwork = new UsageCategoryEnum("wireless-orders-artwork"); - public static readonly UsageCategoryEnum WirelessOrdersBulk = new UsageCategoryEnum("wireless-orders-bulk"); - public static readonly UsageCategoryEnum WirelessOrdersEsim = new UsageCategoryEnum("wireless-orders-esim"); - public static readonly UsageCategoryEnum WirelessOrdersStarter = new UsageCategoryEnum("wireless-orders-starter"); - public static readonly UsageCategoryEnum WirelessUsage = new UsageCategoryEnum("wireless-usage"); - public static readonly UsageCategoryEnum WirelessUsageCommands = new UsageCategoryEnum("wireless-usage-commands"); - public static readonly UsageCategoryEnum WirelessUsageCommandsAfrica = new UsageCategoryEnum("wireless-usage-commands-africa"); - public static readonly UsageCategoryEnum WirelessUsageCommandsAsia = new UsageCategoryEnum("wireless-usage-commands-asia"); - public static readonly UsageCategoryEnum WirelessUsageCommandsCentralandsouthamerica = new UsageCategoryEnum("wireless-usage-commands-centralandsouthamerica"); - public static readonly UsageCategoryEnum WirelessUsageCommandsEurope = new UsageCategoryEnum("wireless-usage-commands-europe"); - public static readonly UsageCategoryEnum WirelessUsageCommandsHome = new UsageCategoryEnum("wireless-usage-commands-home"); - public static readonly UsageCategoryEnum WirelessUsageCommandsNorthamerica = new UsageCategoryEnum("wireless-usage-commands-northamerica"); - public static readonly UsageCategoryEnum WirelessUsageCommandsOceania = new UsageCategoryEnum("wireless-usage-commands-oceania"); - public static readonly UsageCategoryEnum WirelessUsageCommandsRoaming = new UsageCategoryEnum("wireless-usage-commands-roaming"); - public static readonly UsageCategoryEnum WirelessUsageData = new UsageCategoryEnum("wireless-usage-data"); - public static readonly UsageCategoryEnum WirelessUsageDataAfrica = new UsageCategoryEnum("wireless-usage-data-africa"); - public static readonly UsageCategoryEnum WirelessUsageDataAsia = new UsageCategoryEnum("wireless-usage-data-asia"); - public static readonly UsageCategoryEnum WirelessUsageDataCentralandsouthamerica = new UsageCategoryEnum("wireless-usage-data-centralandsouthamerica"); - public static readonly UsageCategoryEnum WirelessUsageDataCustomAdditionalmb = new UsageCategoryEnum("wireless-usage-data-custom-additionalmb"); - public static readonly UsageCategoryEnum WirelessUsageDataCustomFirst5Mb = new UsageCategoryEnum("wireless-usage-data-custom-first5mb"); - public static readonly UsageCategoryEnum WirelessUsageDataDomesticRoaming = new UsageCategoryEnum("wireless-usage-data-domestic-roaming"); - public static readonly UsageCategoryEnum WirelessUsageDataEurope = new UsageCategoryEnum("wireless-usage-data-europe"); - public static readonly UsageCategoryEnum WirelessUsageDataIndividualAdditionalgb = new UsageCategoryEnum("wireless-usage-data-individual-additionalgb"); - public static readonly UsageCategoryEnum WirelessUsageDataIndividualFirstgb = new UsageCategoryEnum("wireless-usage-data-individual-firstgb"); - public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingCanada = new UsageCategoryEnum("wireless-usage-data-international-roaming-canada"); - public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingIndia = new UsageCategoryEnum("wireless-usage-data-international-roaming-india"); - public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingMexico = new UsageCategoryEnum("wireless-usage-data-international-roaming-mexico"); - public static readonly UsageCategoryEnum WirelessUsageDataNorthamerica = new UsageCategoryEnum("wireless-usage-data-northamerica"); - public static readonly UsageCategoryEnum WirelessUsageDataOceania = new UsageCategoryEnum("wireless-usage-data-oceania"); - public static readonly UsageCategoryEnum WirelessUsageDataPooled = new UsageCategoryEnum("wireless-usage-data-pooled"); - public static readonly UsageCategoryEnum WirelessUsageDataPooledDownlink = new UsageCategoryEnum("wireless-usage-data-pooled-downlink"); - public static readonly UsageCategoryEnum WirelessUsageDataPooledUplink = new UsageCategoryEnum("wireless-usage-data-pooled-uplink"); - public static readonly UsageCategoryEnum WirelessUsageMrc = new UsageCategoryEnum("wireless-usage-mrc"); - public static readonly UsageCategoryEnum WirelessUsageMrcCustom = new UsageCategoryEnum("wireless-usage-mrc-custom"); - public static readonly UsageCategoryEnum WirelessUsageMrcIndividual = new UsageCategoryEnum("wireless-usage-mrc-individual"); - public static readonly UsageCategoryEnum WirelessUsageMrcPooled = new UsageCategoryEnum("wireless-usage-mrc-pooled"); - public static readonly UsageCategoryEnum WirelessUsageMrcSuspended = new UsageCategoryEnum("wireless-usage-mrc-suspended"); - public static readonly UsageCategoryEnum WirelessUsageSms = new UsageCategoryEnum("wireless-usage-sms"); - public static readonly UsageCategoryEnum WirelessUsageVoice = new UsageCategoryEnum("wireless-usage-voice"); - } - - public sealed class RecurringEnum : StringEnum - { - private RecurringEnum(string value) : base(value) {} - public RecurringEnum() {} - public static implicit operator RecurringEnum(string value) - { - return new RecurringEnum(value); - } - - public static readonly RecurringEnum Daily = new RecurringEnum("daily"); - public static readonly RecurringEnum Monthly = new RecurringEnum("monthly"); - public static readonly RecurringEnum Yearly = new RecurringEnum("yearly"); - public static readonly RecurringEnum Alltime = new RecurringEnum("alltime"); - } - - public sealed class TriggerFieldEnum : StringEnum - { - private TriggerFieldEnum(string value) : base(value) {} - public TriggerFieldEnum() {} - public static implicit operator TriggerFieldEnum(string value) - { - return new TriggerFieldEnum(value); - } - - public static readonly TriggerFieldEnum Count = new TriggerFieldEnum("count"); - public static readonly TriggerFieldEnum Usage = new TriggerFieldEnum("usage"); - public static readonly TriggerFieldEnum Price = new TriggerFieldEnum("price"); - } - - private static Request BuildFetchRequest(FetchTriggerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch and instance of a usage-trigger - /// - /// Fetch Trigger parameters - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Fetch(FetchTriggerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch and instance of a usage-trigger - /// - /// Fetch Trigger parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task FetchAsync(FetchTriggerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch and instance of a usage-trigger - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchTriggerOptions(pathSid){PathAccountSid = pathAccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch and instance of a usage-trigger - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchTriggerOptions(pathSid){PathAccountSid = pathAccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTriggerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an instance of a usage trigger - /// - /// Update Trigger parameters - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Update(UpdateTriggerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an instance of a usage trigger - /// - /// Update Trigger parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTriggerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an instance of a usage trigger - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The HTTP method to use to call callback_url - /// The URL we call when the trigger fires - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Update(string pathSid, - string pathAccountSid = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateTriggerOptions(pathSid){PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an instance of a usage trigger - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to update - /// The HTTP method to use to call callback_url - /// The URL we call when the trigger fires - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string pathAccountSid = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateTriggerOptions(pathSid){PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTriggerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Trigger parameters - /// Client to make requests to Twilio - /// A single instance of Trigger - public static bool Delete(DeleteTriggerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Trigger parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTriggerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// A single instance of Trigger - public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) - { - var options = new DeleteTriggerOptions(pathSid){PathAccountSid = pathAccountSid}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// The SID of the Account that created the resources to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - string pathAccountSid = null, - ITwilioRestClient client = null) - { - var options = new DeleteTriggerOptions(pathSid){PathAccountSid = pathAccountSid}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateTriggerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new UsageTrigger - /// - /// Create Trigger parameters - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Create(CreateTriggerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new UsageTrigger - /// - /// Create Trigger parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task CreateAsync(CreateTriggerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new UsageTrigger - /// - /// The URL we call when the trigger fires - /// The usage value at which the trigger should fire - /// The usage category the trigger watches - /// The SID of the Account that will create the resource - /// The HTTP method to use to call callback_url - /// A string to describe the resource - /// The frequency of a recurring UsageTrigger - /// The field in the UsageRecord resource that fires the trigger - /// Client to make requests to Twilio - /// A single instance of Trigger - public static TriggerResource Create(Uri callbackUrl, - string triggerValue, - TriggerResource.UsageCategoryEnum usageCategory, - string pathAccountSid = null, - Twilio.Http.HttpMethod callbackMethod = null, - string friendlyName = null, - TriggerResource.RecurringEnum recurring = null, - TriggerResource.TriggerFieldEnum triggerBy = null, - ITwilioRestClient client = null) - { - var options = new CreateTriggerOptions(callbackUrl, triggerValue, usageCategory){PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, FriendlyName = friendlyName, Recurring = recurring, TriggerBy = triggerBy}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new UsageTrigger - /// - /// The URL we call when the trigger fires - /// The usage value at which the trigger should fire - /// The usage category the trigger watches - /// The SID of the Account that will create the resource - /// The HTTP method to use to call callback_url - /// A string to describe the resource - /// The frequency of a recurring UsageTrigger - /// The field in the UsageRecord resource that fires the trigger - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task CreateAsync(Uri callbackUrl, - string triggerValue, - TriggerResource.UsageCategoryEnum usageCategory, - string pathAccountSid = null, - Twilio.Http.HttpMethod callbackMethod = null, - string friendlyName = null, - TriggerResource.RecurringEnum recurring = null, - TriggerResource.TriggerFieldEnum triggerBy = null, - ITwilioRestClient client = null) - { - var options = new CreateTriggerOptions(callbackUrl, triggerValue, usageCategory){PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, FriendlyName = friendlyName, Recurring = recurring, TriggerBy = triggerBy}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTriggerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of usage-triggers belonging to the account used to make the request - /// - /// Read Trigger parameters - /// Client to make requests to Twilio - /// A single instance of Trigger - public static ResourceSet Read(ReadTriggerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_triggers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of usage-triggers belonging to the account used to make the request - /// - /// Read Trigger parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task> ReadAsync(ReadTriggerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_triggers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of usage-triggers belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The frequency of recurring UsageTriggers to read - /// The trigger field of the UsageTriggers to read - /// The usage category of the UsageTriggers to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Trigger - public static ResourceSet Read(string pathAccountSid = null, - TriggerResource.RecurringEnum recurring = null, - TriggerResource.TriggerFieldEnum triggerBy = null, - TriggerResource.UsageCategoryEnum usageCategory = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTriggerOptions(){PathAccountSid = pathAccountSid, Recurring = recurring, TriggerBy = triggerBy, UsageCategory = usageCategory, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of usage-triggers belonging to the account used to make the request - /// - /// The SID of the Account that created the resources to read - /// The frequency of recurring UsageTriggers to read - /// The trigger field of the UsageTriggers to read - /// The usage category of the UsageTriggers to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trigger - public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, - TriggerResource.RecurringEnum recurring = null, - TriggerResource.TriggerFieldEnum triggerBy = null, - TriggerResource.UsageCategoryEnum usageCategory = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTriggerOptions(){PathAccountSid = pathAccountSid, Recurring = recurring, TriggerBy = triggerBy, UsageCategory = usageCategory, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_triggers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_triggers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("usage_triggers", response.Content); - } - - /// - /// Converts a JSON string into a TriggerResource object - /// - /// Raw JSON string - /// TriggerResource object represented by the provided JSON - public static TriggerResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that this trigger monitors - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The API version used to create the resource - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The HTTP method we use to call callback_url - /// - [JsonProperty("callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod CallbackMethod { get; private set; } - /// - /// he URL we call when the trigger fires - /// - [JsonProperty("callback_url")] - public Uri CallbackUrl { get; private set; } - /// - /// The current value of the field the trigger is watching - /// - [JsonProperty("current_value")] - public string CurrentValue { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the trigger was last fired - /// - [JsonProperty("date_fired")] - public DateTime? DateFired { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the trigger - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The frequency of a recurring UsageTrigger - /// - [JsonProperty("recurring")] - [JsonConverter(typeof(StringEnumConverter))] - public TriggerResource.RecurringEnum Recurring { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The field in the UsageRecord resource that fires the trigger - /// - [JsonProperty("trigger_by")] - [JsonConverter(typeof(StringEnumConverter))] - public TriggerResource.TriggerFieldEnum TriggerBy { get; private set; } - /// - /// The value at which the trigger will fire - /// - [JsonProperty("trigger_value")] - public string TriggerValue { get; private set; } - /// - /// The URI of the resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - /// - /// The usage category the trigger watches - /// - [JsonProperty("usage_category")] - [JsonConverter(typeof(StringEnumConverter))] - public TriggerResource.UsageCategoryEnum UsageCategory { get; private set; } - /// - /// The URI of the UsageRecord resource this trigger watches - /// - [JsonProperty("usage_record_uri")] - public string UsageRecordUri { get; private set; } - - private TriggerResource() - { - - } - } +{ + + public class TriggerResource : Resource + { + public sealed class UsageCategoryEnum : StringEnum + { + private UsageCategoryEnum(string value) : base(value) { } + public UsageCategoryEnum() { } + public static implicit operator UsageCategoryEnum(string value) + { + return new UsageCategoryEnum(value); + } + + public static readonly UsageCategoryEnum AgentConference = new UsageCategoryEnum("agent-conference"); + public static readonly UsageCategoryEnum AnsweringMachineDetection = new UsageCategoryEnum("answering-machine-detection"); + public static readonly UsageCategoryEnum AuthyAuthentications = new UsageCategoryEnum("authy-authentications"); + public static readonly UsageCategoryEnum AuthyCallsOutbound = new UsageCategoryEnum("authy-calls-outbound"); + public static readonly UsageCategoryEnum AuthyMonthlyFees = new UsageCategoryEnum("authy-monthly-fees"); + public static readonly UsageCategoryEnum AuthyPhoneIntelligence = new UsageCategoryEnum("authy-phone-intelligence"); + public static readonly UsageCategoryEnum AuthyPhoneVerifications = new UsageCategoryEnum("authy-phone-verifications"); + public static readonly UsageCategoryEnum AuthySmsOutbound = new UsageCategoryEnum("authy-sms-outbound"); + public static readonly UsageCategoryEnum CallProgessEvents = new UsageCategoryEnum("call-progess-events"); + public static readonly UsageCategoryEnum Calleridlookups = new UsageCategoryEnum("calleridlookups"); + public static readonly UsageCategoryEnum Calls = new UsageCategoryEnum("calls"); + public static readonly UsageCategoryEnum CallsClient = new UsageCategoryEnum("calls-client"); + public static readonly UsageCategoryEnum CallsGlobalconference = new UsageCategoryEnum("calls-globalconference"); + public static readonly UsageCategoryEnum CallsInbound = new UsageCategoryEnum("calls-inbound"); + public static readonly UsageCategoryEnum CallsInboundLocal = new UsageCategoryEnum("calls-inbound-local"); + public static readonly UsageCategoryEnum CallsInboundMobile = new UsageCategoryEnum("calls-inbound-mobile"); + public static readonly UsageCategoryEnum CallsInboundTollfree = new UsageCategoryEnum("calls-inbound-tollfree"); + public static readonly UsageCategoryEnum CallsOutbound = new UsageCategoryEnum("calls-outbound"); + public static readonly UsageCategoryEnum CallsPayVerbTransactions = new UsageCategoryEnum("calls-pay-verb-transactions"); + public static readonly UsageCategoryEnum CallsRecordings = new UsageCategoryEnum("calls-recordings"); + public static readonly UsageCategoryEnum CallsSip = new UsageCategoryEnum("calls-sip"); + public static readonly UsageCategoryEnum CallsSipInbound = new UsageCategoryEnum("calls-sip-inbound"); + public static readonly UsageCategoryEnum CallsSipOutbound = new UsageCategoryEnum("calls-sip-outbound"); + public static readonly UsageCategoryEnum CallsTransfers = new UsageCategoryEnum("calls-transfers"); + public static readonly UsageCategoryEnum CarrierLookups = new UsageCategoryEnum("carrier-lookups"); + public static readonly UsageCategoryEnum Conversations = new UsageCategoryEnum("conversations"); + public static readonly UsageCategoryEnum ConversationsApiRequests = new UsageCategoryEnum("conversations-api-requests"); + public static readonly UsageCategoryEnum ConversationsConversationEvents = new UsageCategoryEnum("conversations-conversation-events"); + public static readonly UsageCategoryEnum ConversationsEndpointConnectivity = new UsageCategoryEnum("conversations-endpoint-connectivity"); + public static readonly UsageCategoryEnum ConversationsEvents = new UsageCategoryEnum("conversations-events"); + public static readonly UsageCategoryEnum ConversationsParticipantEvents = new UsageCategoryEnum("conversations-participant-events"); + public static readonly UsageCategoryEnum ConversationsParticipants = new UsageCategoryEnum("conversations-participants"); + public static readonly UsageCategoryEnum Cps = new UsageCategoryEnum("cps"); + public static readonly UsageCategoryEnum FlexUsage = new UsageCategoryEnum("flex-usage"); + public static readonly UsageCategoryEnum FraudLookups = new UsageCategoryEnum("fraud-lookups"); + public static readonly UsageCategoryEnum GroupRooms = new UsageCategoryEnum("group-rooms"); + public static readonly UsageCategoryEnum GroupRoomsDataTrack = new UsageCategoryEnum("group-rooms-data-track"); + public static readonly UsageCategoryEnum GroupRoomsEncryptedMediaRecorded = new UsageCategoryEnum("group-rooms-encrypted-media-recorded"); + public static readonly UsageCategoryEnum GroupRoomsMediaDownloaded = new UsageCategoryEnum("group-rooms-media-downloaded"); + public static readonly UsageCategoryEnum GroupRoomsMediaRecorded = new UsageCategoryEnum("group-rooms-media-recorded"); + public static readonly UsageCategoryEnum GroupRoomsMediaRouted = new UsageCategoryEnum("group-rooms-media-routed"); + public static readonly UsageCategoryEnum GroupRoomsMediaStored = new UsageCategoryEnum("group-rooms-media-stored"); + public static readonly UsageCategoryEnum GroupRoomsParticipantMinutes = new UsageCategoryEnum("group-rooms-participant-minutes"); + public static readonly UsageCategoryEnum GroupRoomsRecordedMinutes = new UsageCategoryEnum("group-rooms-recorded-minutes"); + public static readonly UsageCategoryEnum ImpV1Usage = new UsageCategoryEnum("imp-v1-usage"); + public static readonly UsageCategoryEnum Lookups = new UsageCategoryEnum("lookups"); + public static readonly UsageCategoryEnum Marketplace = new UsageCategoryEnum("marketplace"); + public static readonly UsageCategoryEnum MarketplaceAlgorithmiaNamedEntityRecognition = new UsageCategoryEnum("marketplace-algorithmia-named-entity-recognition"); + public static readonly UsageCategoryEnum MarketplaceCadenceTranscription = new UsageCategoryEnum("marketplace-cadence-transcription"); + public static readonly UsageCategoryEnum MarketplaceCadenceTranslation = new UsageCategoryEnum("marketplace-cadence-translation"); + public static readonly UsageCategoryEnum MarketplaceCapioSpeechToText = new UsageCategoryEnum("marketplace-capio-speech-to-text"); + public static readonly UsageCategoryEnum MarketplaceConvrizaAbaba = new UsageCategoryEnum("marketplace-convriza-ababa"); + public static readonly UsageCategoryEnum MarketplaceDeepgramPhraseDetector = new UsageCategoryEnum("marketplace-deepgram-phrase-detector"); + public static readonly UsageCategoryEnum MarketplaceDigitalSegmentBusinessInfo = new UsageCategoryEnum("marketplace-digital-segment-business-info"); + public static readonly UsageCategoryEnum MarketplaceFacebookOfflineConversions = new UsageCategoryEnum("marketplace-facebook-offline-conversions"); + public static readonly UsageCategoryEnum MarketplaceGoogleSpeechToText = new UsageCategoryEnum("marketplace-google-speech-to-text"); + public static readonly UsageCategoryEnum MarketplaceIbmWatsonMessageInsights = new UsageCategoryEnum("marketplace-ibm-watson-message-insights"); + public static readonly UsageCategoryEnum MarketplaceIbmWatsonMessageSentiment = new UsageCategoryEnum("marketplace-ibm-watson-message-sentiment"); + public static readonly UsageCategoryEnum MarketplaceIbmWatsonRecordingAnalysis = new UsageCategoryEnum("marketplace-ibm-watson-recording-analysis"); + public static readonly UsageCategoryEnum MarketplaceIbmWatsonToneAnalyzer = new UsageCategoryEnum("marketplace-ibm-watson-tone-analyzer"); + public static readonly UsageCategoryEnum MarketplaceIcehookSystemsScout = new UsageCategoryEnum("marketplace-icehook-systems-scout"); + public static readonly UsageCategoryEnum MarketplaceInfogroupDataaxleBizinfo = new UsageCategoryEnum("marketplace-infogroup-dataaxle-bizinfo"); + public static readonly UsageCategoryEnum MarketplaceKeenIoContactCenterAnalytics = new UsageCategoryEnum("marketplace-keen-io-contact-center-analytics"); + public static readonly UsageCategoryEnum MarketplaceMarchexCleancall = new UsageCategoryEnum("marketplace-marchex-cleancall"); + public static readonly UsageCategoryEnum MarketplaceMarchexSentimentAnalysisForSms = new UsageCategoryEnum("marketplace-marchex-sentiment-analysis-for-sms"); + public static readonly UsageCategoryEnum MarketplaceMarketplaceNextcallerSocialId = new UsageCategoryEnum("marketplace-marketplace-nextcaller-social-id"); + public static readonly UsageCategoryEnum MarketplaceMobileCommonsOptOutClassifier = new UsageCategoryEnum("marketplace-mobile-commons-opt-out-classifier"); + public static readonly UsageCategoryEnum MarketplaceNexiwaveVoicemailToText = new UsageCategoryEnum("marketplace-nexiwave-voicemail-to-text"); + public static readonly UsageCategoryEnum MarketplaceNextcallerAdvancedCallerIdentification = new UsageCategoryEnum("marketplace-nextcaller-advanced-caller-identification"); + public static readonly UsageCategoryEnum MarketplaceNomoroboSpamScore = new UsageCategoryEnum("marketplace-nomorobo-spam-score"); + public static readonly UsageCategoryEnum MarketplacePayfoneTcpaCompliance = new UsageCategoryEnum("marketplace-payfone-tcpa-compliance"); + public static readonly UsageCategoryEnum MarketplaceRemeetingAutomaticSpeechRecognition = new UsageCategoryEnum("marketplace-remeeting-automatic-speech-recognition"); + public static readonly UsageCategoryEnum MarketplaceTcpaDefenseSolutionsBlacklistFeed = new UsageCategoryEnum("marketplace-tcpa-defense-solutions-blacklist-feed"); + public static readonly UsageCategoryEnum MarketplaceTeloOpencnam = new UsageCategoryEnum("marketplace-telo-opencnam"); + public static readonly UsageCategoryEnum MarketplaceTruecnamTrueSpam = new UsageCategoryEnum("marketplace-truecnam-true-spam"); + public static readonly UsageCategoryEnum MarketplaceTwilioCallerNameLookupUs = new UsageCategoryEnum("marketplace-twilio-caller-name-lookup-us"); + public static readonly UsageCategoryEnum MarketplaceTwilioCarrierInformationLookup = new UsageCategoryEnum("marketplace-twilio-carrier-information-lookup"); + public static readonly UsageCategoryEnum MarketplaceVoicebasePci = new UsageCategoryEnum("marketplace-voicebase-pci"); + public static readonly UsageCategoryEnum MarketplaceVoicebaseTranscription = new UsageCategoryEnum("marketplace-voicebase-transcription"); + public static readonly UsageCategoryEnum MarketplaceVoicebaseTranscriptionCustomVocabulary = new UsageCategoryEnum("marketplace-voicebase-transcription-custom-vocabulary"); + public static readonly UsageCategoryEnum MarketplaceWhitepagesProCallerIdentification = new UsageCategoryEnum("marketplace-whitepages-pro-caller-identification"); + public static readonly UsageCategoryEnum MarketplaceWhitepagesProPhoneIntelligence = new UsageCategoryEnum("marketplace-whitepages-pro-phone-intelligence"); + public static readonly UsageCategoryEnum MarketplaceWhitepagesProPhoneReputation = new UsageCategoryEnum("marketplace-whitepages-pro-phone-reputation"); + public static readonly UsageCategoryEnum MarketplaceWolfarmSpokenResults = new UsageCategoryEnum("marketplace-wolfarm-spoken-results"); + public static readonly UsageCategoryEnum MarketplaceWolframShortAnswer = new UsageCategoryEnum("marketplace-wolfram-short-answer"); + public static readonly UsageCategoryEnum MarketplaceYticaContactCenterReportingAnalytics = new UsageCategoryEnum("marketplace-ytica-contact-center-reporting-analytics"); + public static readonly UsageCategoryEnum Mediastorage = new UsageCategoryEnum("mediastorage"); + public static readonly UsageCategoryEnum Mms = new UsageCategoryEnum("mms"); + public static readonly UsageCategoryEnum MmsInbound = new UsageCategoryEnum("mms-inbound"); + public static readonly UsageCategoryEnum MmsInboundLongcode = new UsageCategoryEnum("mms-inbound-longcode"); + public static readonly UsageCategoryEnum MmsInboundShortcode = new UsageCategoryEnum("mms-inbound-shortcode"); + public static readonly UsageCategoryEnum MmsMessagesCarrierfees = new UsageCategoryEnum("mms-messages-carrierfees"); + public static readonly UsageCategoryEnum MmsOutbound = new UsageCategoryEnum("mms-outbound"); + public static readonly UsageCategoryEnum MmsOutboundLongcode = new UsageCategoryEnum("mms-outbound-longcode"); + public static readonly UsageCategoryEnum MmsOutboundShortcode = new UsageCategoryEnum("mms-outbound-shortcode"); + public static readonly UsageCategoryEnum MonitorReads = new UsageCategoryEnum("monitor-reads"); + public static readonly UsageCategoryEnum MonitorStorage = new UsageCategoryEnum("monitor-storage"); + public static readonly UsageCategoryEnum MonitorWrites = new UsageCategoryEnum("monitor-writes"); + public static readonly UsageCategoryEnum Notify = new UsageCategoryEnum("notify"); + public static readonly UsageCategoryEnum NotifyActionsAttempts = new UsageCategoryEnum("notify-actions-attempts"); + public static readonly UsageCategoryEnum NotifyChannels = new UsageCategoryEnum("notify-channels"); + public static readonly UsageCategoryEnum NumberFormatLookups = new UsageCategoryEnum("number-format-lookups"); + public static readonly UsageCategoryEnum Pchat = new UsageCategoryEnum("pchat"); + public static readonly UsageCategoryEnum PchatUsers = new UsageCategoryEnum("pchat-users"); + public static readonly UsageCategoryEnum PeerToPeerRoomsParticipantMinutes = new UsageCategoryEnum("peer-to-peer-rooms-participant-minutes"); + public static readonly UsageCategoryEnum Pfax = new UsageCategoryEnum("pfax"); + public static readonly UsageCategoryEnum PfaxMinutes = new UsageCategoryEnum("pfax-minutes"); + public static readonly UsageCategoryEnum PfaxMinutesInbound = new UsageCategoryEnum("pfax-minutes-inbound"); + public static readonly UsageCategoryEnum PfaxMinutesOutbound = new UsageCategoryEnum("pfax-minutes-outbound"); + public static readonly UsageCategoryEnum PfaxPages = new UsageCategoryEnum("pfax-pages"); + public static readonly UsageCategoryEnum Phonenumbers = new UsageCategoryEnum("phonenumbers"); + public static readonly UsageCategoryEnum PhonenumbersCps = new UsageCategoryEnum("phonenumbers-cps"); + public static readonly UsageCategoryEnum PhonenumbersEmergency = new UsageCategoryEnum("phonenumbers-emergency"); + public static readonly UsageCategoryEnum PhonenumbersLocal = new UsageCategoryEnum("phonenumbers-local"); + public static readonly UsageCategoryEnum PhonenumbersMobile = new UsageCategoryEnum("phonenumbers-mobile"); + public static readonly UsageCategoryEnum PhonenumbersSetups = new UsageCategoryEnum("phonenumbers-setups"); + public static readonly UsageCategoryEnum PhonenumbersTollfree = new UsageCategoryEnum("phonenumbers-tollfree"); + public static readonly UsageCategoryEnum Premiumsupport = new UsageCategoryEnum("premiumsupport"); + public static readonly UsageCategoryEnum Proxy = new UsageCategoryEnum("proxy"); + public static readonly UsageCategoryEnum ProxyActiveSessions = new UsageCategoryEnum("proxy-active-sessions"); + public static readonly UsageCategoryEnum Pstnconnectivity = new UsageCategoryEnum("pstnconnectivity"); + public static readonly UsageCategoryEnum Pv = new UsageCategoryEnum("pv"); + public static readonly UsageCategoryEnum PvCompositionMediaDownloaded = new UsageCategoryEnum("pv-composition-media-downloaded"); + public static readonly UsageCategoryEnum PvCompositionMediaEncrypted = new UsageCategoryEnum("pv-composition-media-encrypted"); + public static readonly UsageCategoryEnum PvCompositionMediaStored = new UsageCategoryEnum("pv-composition-media-stored"); + public static readonly UsageCategoryEnum PvCompositionMinutes = new UsageCategoryEnum("pv-composition-minutes"); + public static readonly UsageCategoryEnum PvRecordingCompositions = new UsageCategoryEnum("pv-recording-compositions"); + public static readonly UsageCategoryEnum PvRoomParticipants = new UsageCategoryEnum("pv-room-participants"); + public static readonly UsageCategoryEnum PvRoomParticipantsAu1 = new UsageCategoryEnum("pv-room-participants-au1"); + public static readonly UsageCategoryEnum PvRoomParticipantsBr1 = new UsageCategoryEnum("pv-room-participants-br1"); + public static readonly UsageCategoryEnum PvRoomParticipantsIe1 = new UsageCategoryEnum("pv-room-participants-ie1"); + public static readonly UsageCategoryEnum PvRoomParticipantsJp1 = new UsageCategoryEnum("pv-room-participants-jp1"); + public static readonly UsageCategoryEnum PvRoomParticipantsSg1 = new UsageCategoryEnum("pv-room-participants-sg1"); + public static readonly UsageCategoryEnum PvRoomParticipantsUs1 = new UsageCategoryEnum("pv-room-participants-us1"); + public static readonly UsageCategoryEnum PvRoomParticipantsUs2 = new UsageCategoryEnum("pv-room-participants-us2"); + public static readonly UsageCategoryEnum PvRooms = new UsageCategoryEnum("pv-rooms"); + public static readonly UsageCategoryEnum PvSipEndpointRegistrations = new UsageCategoryEnum("pv-sip-endpoint-registrations"); + public static readonly UsageCategoryEnum Recordings = new UsageCategoryEnum("recordings"); + public static readonly UsageCategoryEnum Recordingstorage = new UsageCategoryEnum("recordingstorage"); + public static readonly UsageCategoryEnum RoomsGroupBandwidth = new UsageCategoryEnum("rooms-group-bandwidth"); + public static readonly UsageCategoryEnum RoomsGroupMinutes = new UsageCategoryEnum("rooms-group-minutes"); + public static readonly UsageCategoryEnum RoomsPeerToPeerMinutes = new UsageCategoryEnum("rooms-peer-to-peer-minutes"); + public static readonly UsageCategoryEnum Shortcodes = new UsageCategoryEnum("shortcodes"); + public static readonly UsageCategoryEnum ShortcodesCustomerowned = new UsageCategoryEnum("shortcodes-customerowned"); + public static readonly UsageCategoryEnum ShortcodesMmsEnablement = new UsageCategoryEnum("shortcodes-mms-enablement"); + public static readonly UsageCategoryEnum ShortcodesMps = new UsageCategoryEnum("shortcodes-mps"); + public static readonly UsageCategoryEnum ShortcodesRandom = new UsageCategoryEnum("shortcodes-random"); + public static readonly UsageCategoryEnum ShortcodesUk = new UsageCategoryEnum("shortcodes-uk"); + public static readonly UsageCategoryEnum ShortcodesVanity = new UsageCategoryEnum("shortcodes-vanity"); + public static readonly UsageCategoryEnum SmallGroupRooms = new UsageCategoryEnum("small-group-rooms"); + public static readonly UsageCategoryEnum SmallGroupRoomsDataTrack = new UsageCategoryEnum("small-group-rooms-data-track"); + public static readonly UsageCategoryEnum SmallGroupRoomsParticipantMinutes = new UsageCategoryEnum("small-group-rooms-participant-minutes"); + public static readonly UsageCategoryEnum Sms = new UsageCategoryEnum("sms"); + public static readonly UsageCategoryEnum SmsInbound = new UsageCategoryEnum("sms-inbound"); + public static readonly UsageCategoryEnum SmsInboundLongcode = new UsageCategoryEnum("sms-inbound-longcode"); + public static readonly UsageCategoryEnum SmsInboundShortcode = new UsageCategoryEnum("sms-inbound-shortcode"); + public static readonly UsageCategoryEnum SmsMessagesCarrierfees = new UsageCategoryEnum("sms-messages-carrierfees"); + public static readonly UsageCategoryEnum SmsMessagesFeatures = new UsageCategoryEnum("sms-messages-features"); + public static readonly UsageCategoryEnum SmsMessagesFeaturesSenderid = new UsageCategoryEnum("sms-messages-features-senderid"); + public static readonly UsageCategoryEnum SmsOutbound = new UsageCategoryEnum("sms-outbound"); + public static readonly UsageCategoryEnum SmsOutboundContentInspection = new UsageCategoryEnum("sms-outbound-content-inspection"); + public static readonly UsageCategoryEnum SmsOutboundLongcode = new UsageCategoryEnum("sms-outbound-longcode"); + public static readonly UsageCategoryEnum SmsOutboundShortcode = new UsageCategoryEnum("sms-outbound-shortcode"); + public static readonly UsageCategoryEnum SpeechRecognition = new UsageCategoryEnum("speech-recognition"); + public static readonly UsageCategoryEnum StudioEngagements = new UsageCategoryEnum("studio-engagements"); + public static readonly UsageCategoryEnum Sync = new UsageCategoryEnum("sync"); + public static readonly UsageCategoryEnum SyncActions = new UsageCategoryEnum("sync-actions"); + public static readonly UsageCategoryEnum SyncEndpointHours = new UsageCategoryEnum("sync-endpoint-hours"); + public static readonly UsageCategoryEnum SyncEndpointHoursAboveDailyCap = new UsageCategoryEnum("sync-endpoint-hours-above-daily-cap"); + public static readonly UsageCategoryEnum TaskrouterTasks = new UsageCategoryEnum("taskrouter-tasks"); + public static readonly UsageCategoryEnum Totalprice = new UsageCategoryEnum("totalprice"); + public static readonly UsageCategoryEnum Transcriptions = new UsageCategoryEnum("transcriptions"); + public static readonly UsageCategoryEnum TrunkingCps = new UsageCategoryEnum("trunking-cps"); + public static readonly UsageCategoryEnum TrunkingEmergencyCalls = new UsageCategoryEnum("trunking-emergency-calls"); + public static readonly UsageCategoryEnum TrunkingOrigination = new UsageCategoryEnum("trunking-origination"); + public static readonly UsageCategoryEnum TrunkingOriginationLocal = new UsageCategoryEnum("trunking-origination-local"); + public static readonly UsageCategoryEnum TrunkingOriginationMobile = new UsageCategoryEnum("trunking-origination-mobile"); + public static readonly UsageCategoryEnum TrunkingOriginationTollfree = new UsageCategoryEnum("trunking-origination-tollfree"); + public static readonly UsageCategoryEnum TrunkingRecordings = new UsageCategoryEnum("trunking-recordings"); + public static readonly UsageCategoryEnum TrunkingSecure = new UsageCategoryEnum("trunking-secure"); + public static readonly UsageCategoryEnum TrunkingTermination = new UsageCategoryEnum("trunking-termination"); + public static readonly UsageCategoryEnum Turnmegabytes = new UsageCategoryEnum("turnmegabytes"); + public static readonly UsageCategoryEnum TurnmegabytesAustralia = new UsageCategoryEnum("turnmegabytes-australia"); + public static readonly UsageCategoryEnum TurnmegabytesBrasil = new UsageCategoryEnum("turnmegabytes-brasil"); + public static readonly UsageCategoryEnum TurnmegabytesGermany = new UsageCategoryEnum("turnmegabytes-germany"); + public static readonly UsageCategoryEnum TurnmegabytesIndia = new UsageCategoryEnum("turnmegabytes-india"); + public static readonly UsageCategoryEnum TurnmegabytesIreland = new UsageCategoryEnum("turnmegabytes-ireland"); + public static readonly UsageCategoryEnum TurnmegabytesJapan = new UsageCategoryEnum("turnmegabytes-japan"); + public static readonly UsageCategoryEnum TurnmegabytesSingapore = new UsageCategoryEnum("turnmegabytes-singapore"); + public static readonly UsageCategoryEnum TurnmegabytesUseast = new UsageCategoryEnum("turnmegabytes-useast"); + public static readonly UsageCategoryEnum TurnmegabytesUswest = new UsageCategoryEnum("turnmegabytes-uswest"); + public static readonly UsageCategoryEnum TwilioInterconnect = new UsageCategoryEnum("twilio-interconnect"); + public static readonly UsageCategoryEnum VerifyPush = new UsageCategoryEnum("verify-push"); + public static readonly UsageCategoryEnum VideoRecordings = new UsageCategoryEnum("video-recordings"); + public static readonly UsageCategoryEnum VoiceInsights = new UsageCategoryEnum("voice-insights"); + public static readonly UsageCategoryEnum VoiceInsightsClientInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-client-insights-on-demand-minute"); + public static readonly UsageCategoryEnum VoiceInsightsPtsnInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-ptsn-insights-on-demand-minute"); + public static readonly UsageCategoryEnum VoiceInsightsSipInterfaceInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-sip-interface-insights-on-demand-minute"); + public static readonly UsageCategoryEnum VoiceInsightsSipTrunkingInsightsOnDemandMinute = new UsageCategoryEnum("voice-insights-sip-trunking-insights-on-demand-minute"); + public static readonly UsageCategoryEnum Wireless = new UsageCategoryEnum("wireless"); + public static readonly UsageCategoryEnum WirelessOrders = new UsageCategoryEnum("wireless-orders"); + public static readonly UsageCategoryEnum WirelessOrdersArtwork = new UsageCategoryEnum("wireless-orders-artwork"); + public static readonly UsageCategoryEnum WirelessOrdersBulk = new UsageCategoryEnum("wireless-orders-bulk"); + public static readonly UsageCategoryEnum WirelessOrdersEsim = new UsageCategoryEnum("wireless-orders-esim"); + public static readonly UsageCategoryEnum WirelessOrdersStarter = new UsageCategoryEnum("wireless-orders-starter"); + public static readonly UsageCategoryEnum WirelessUsage = new UsageCategoryEnum("wireless-usage"); + public static readonly UsageCategoryEnum WirelessUsageCommands = new UsageCategoryEnum("wireless-usage-commands"); + public static readonly UsageCategoryEnum WirelessUsageCommandsAfrica = new UsageCategoryEnum("wireless-usage-commands-africa"); + public static readonly UsageCategoryEnum WirelessUsageCommandsAsia = new UsageCategoryEnum("wireless-usage-commands-asia"); + public static readonly UsageCategoryEnum WirelessUsageCommandsCentralandsouthamerica = new UsageCategoryEnum("wireless-usage-commands-centralandsouthamerica"); + public static readonly UsageCategoryEnum WirelessUsageCommandsEurope = new UsageCategoryEnum("wireless-usage-commands-europe"); + public static readonly UsageCategoryEnum WirelessUsageCommandsHome = new UsageCategoryEnum("wireless-usage-commands-home"); + public static readonly UsageCategoryEnum WirelessUsageCommandsNorthamerica = new UsageCategoryEnum("wireless-usage-commands-northamerica"); + public static readonly UsageCategoryEnum WirelessUsageCommandsOceania = new UsageCategoryEnum("wireless-usage-commands-oceania"); + public static readonly UsageCategoryEnum WirelessUsageCommandsRoaming = new UsageCategoryEnum("wireless-usage-commands-roaming"); + public static readonly UsageCategoryEnum WirelessUsageData = new UsageCategoryEnum("wireless-usage-data"); + public static readonly UsageCategoryEnum WirelessUsageDataAfrica = new UsageCategoryEnum("wireless-usage-data-africa"); + public static readonly UsageCategoryEnum WirelessUsageDataAsia = new UsageCategoryEnum("wireless-usage-data-asia"); + public static readonly UsageCategoryEnum WirelessUsageDataCentralandsouthamerica = new UsageCategoryEnum("wireless-usage-data-centralandsouthamerica"); + public static readonly UsageCategoryEnum WirelessUsageDataCustomAdditionalmb = new UsageCategoryEnum("wireless-usage-data-custom-additionalmb"); + public static readonly UsageCategoryEnum WirelessUsageDataCustomFirst5Mb = new UsageCategoryEnum("wireless-usage-data-custom-first5mb"); + public static readonly UsageCategoryEnum WirelessUsageDataDomesticRoaming = new UsageCategoryEnum("wireless-usage-data-domestic-roaming"); + public static readonly UsageCategoryEnum WirelessUsageDataEurope = new UsageCategoryEnum("wireless-usage-data-europe"); + public static readonly UsageCategoryEnum WirelessUsageDataIndividualAdditionalgb = new UsageCategoryEnum("wireless-usage-data-individual-additionalgb"); + public static readonly UsageCategoryEnum WirelessUsageDataIndividualFirstgb = new UsageCategoryEnum("wireless-usage-data-individual-firstgb"); + public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingCanada = new UsageCategoryEnum("wireless-usage-data-international-roaming-canada"); + public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingIndia = new UsageCategoryEnum("wireless-usage-data-international-roaming-india"); + public static readonly UsageCategoryEnum WirelessUsageDataInternationalRoamingMexico = new UsageCategoryEnum("wireless-usage-data-international-roaming-mexico"); + public static readonly UsageCategoryEnum WirelessUsageDataNorthamerica = new UsageCategoryEnum("wireless-usage-data-northamerica"); + public static readonly UsageCategoryEnum WirelessUsageDataOceania = new UsageCategoryEnum("wireless-usage-data-oceania"); + public static readonly UsageCategoryEnum WirelessUsageDataPooled = new UsageCategoryEnum("wireless-usage-data-pooled"); + public static readonly UsageCategoryEnum WirelessUsageDataPooledDownlink = new UsageCategoryEnum("wireless-usage-data-pooled-downlink"); + public static readonly UsageCategoryEnum WirelessUsageDataPooledUplink = new UsageCategoryEnum("wireless-usage-data-pooled-uplink"); + public static readonly UsageCategoryEnum WirelessUsageMrc = new UsageCategoryEnum("wireless-usage-mrc"); + public static readonly UsageCategoryEnum WirelessUsageMrcCustom = new UsageCategoryEnum("wireless-usage-mrc-custom"); + public static readonly UsageCategoryEnum WirelessUsageMrcIndividual = new UsageCategoryEnum("wireless-usage-mrc-individual"); + public static readonly UsageCategoryEnum WirelessUsageMrcPooled = new UsageCategoryEnum("wireless-usage-mrc-pooled"); + public static readonly UsageCategoryEnum WirelessUsageMrcSuspended = new UsageCategoryEnum("wireless-usage-mrc-suspended"); + public static readonly UsageCategoryEnum WirelessUsageSms = new UsageCategoryEnum("wireless-usage-sms"); + public static readonly UsageCategoryEnum WirelessUsageVoice = new UsageCategoryEnum("wireless-usage-voice"); + } + + public sealed class RecurringEnum : StringEnum + { + private RecurringEnum(string value) : base(value) { } + public RecurringEnum() { } + public static implicit operator RecurringEnum(string value) + { + return new RecurringEnum(value); + } + + public static readonly RecurringEnum Daily = new RecurringEnum("daily"); + public static readonly RecurringEnum Monthly = new RecurringEnum("monthly"); + public static readonly RecurringEnum Yearly = new RecurringEnum("yearly"); + public static readonly RecurringEnum Alltime = new RecurringEnum("alltime"); + } + + public sealed class TriggerFieldEnum : StringEnum + { + private TriggerFieldEnum(string value) : base(value) { } + public TriggerFieldEnum() { } + public static implicit operator TriggerFieldEnum(string value) + { + return new TriggerFieldEnum(value); + } + + public static readonly TriggerFieldEnum Count = new TriggerFieldEnum("count"); + public static readonly TriggerFieldEnum Usage = new TriggerFieldEnum("usage"); + public static readonly TriggerFieldEnum Price = new TriggerFieldEnum("price"); + } + + private static Request BuildFetchRequest(FetchTriggerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch and instance of a usage-trigger + /// + /// Fetch Trigger parameters + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Fetch(FetchTriggerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch and instance of a usage-trigger + /// + /// Fetch Trigger parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task FetchAsync(FetchTriggerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch and instance of a usage-trigger + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchTriggerOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch and instance of a usage-trigger + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchTriggerOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTriggerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an instance of a usage trigger + /// + /// Update Trigger parameters + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Update(UpdateTriggerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an instance of a usage trigger + /// + /// Update Trigger parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTriggerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an instance of a usage trigger + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The HTTP method to use to call callback_url + /// The URL we call when the trigger fires + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Update(string pathSid, + string pathAccountSid = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateTriggerOptions(pathSid) { PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an instance of a usage trigger + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to update + /// The HTTP method to use to call callback_url + /// The URL we call when the trigger fires + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string pathAccountSid = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateTriggerOptions(pathSid) { PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTriggerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers/" + options.PathSid + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Trigger parameters + /// Client to make requests to Twilio + /// A single instance of Trigger + public static bool Delete(DeleteTriggerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Trigger parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTriggerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// A single instance of Trigger + public static bool Delete(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null) + { + var options = new DeleteTriggerOptions(pathSid) { PathAccountSid = pathAccountSid }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// The SID of the Account that created the resources to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + string pathAccountSid = null, + ITwilioRestClient client = null) + { + var options = new DeleteTriggerOptions(pathSid) { PathAccountSid = pathAccountSid }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateTriggerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new UsageTrigger + /// + /// Create Trigger parameters + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Create(CreateTriggerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new UsageTrigger + /// + /// Create Trigger parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task CreateAsync(CreateTriggerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new UsageTrigger + /// + /// The URL we call when the trigger fires + /// The usage value at which the trigger should fire + /// The usage category the trigger watches + /// The SID of the Account that will create the resource + /// The HTTP method to use to call callback_url + /// A string to describe the resource + /// The frequency of a recurring UsageTrigger + /// The field in the UsageRecord resource that fires the trigger + /// Client to make requests to Twilio + /// A single instance of Trigger + public static TriggerResource Create(Uri callbackUrl, + string triggerValue, + TriggerResource.UsageCategoryEnum usageCategory, + string pathAccountSid = null, + Twilio.Http.HttpMethod callbackMethod = null, + string friendlyName = null, + TriggerResource.RecurringEnum recurring = null, + TriggerResource.TriggerFieldEnum triggerBy = null, + ITwilioRestClient client = null) + { + var options = new CreateTriggerOptions(callbackUrl, triggerValue, usageCategory) { PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, FriendlyName = friendlyName, Recurring = recurring, TriggerBy = triggerBy }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new UsageTrigger + /// + /// The URL we call when the trigger fires + /// The usage value at which the trigger should fire + /// The usage category the trigger watches + /// The SID of the Account that will create the resource + /// The HTTP method to use to call callback_url + /// A string to describe the resource + /// The frequency of a recurring UsageTrigger + /// The field in the UsageRecord resource that fires the trigger + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task CreateAsync(Uri callbackUrl, + string triggerValue, + TriggerResource.UsageCategoryEnum usageCategory, + string pathAccountSid = null, + Twilio.Http.HttpMethod callbackMethod = null, + string friendlyName = null, + TriggerResource.RecurringEnum recurring = null, + TriggerResource.TriggerFieldEnum triggerBy = null, + ITwilioRestClient client = null) + { + var options = new CreateTriggerOptions(callbackUrl, triggerValue, usageCategory) { PathAccountSid = pathAccountSid, CallbackMethod = callbackMethod, FriendlyName = friendlyName, Recurring = recurring, TriggerBy = triggerBy }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTriggerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/Usage/Triggers.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// + /// Read Trigger parameters + /// Client to make requests to Twilio + /// A single instance of Trigger + public static ResourceSet Read(ReadTriggerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_triggers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// + /// Read Trigger parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task> ReadAsync(ReadTriggerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_triggers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The frequency of recurring UsageTriggers to read + /// The trigger field of the UsageTriggers to read + /// The usage category of the UsageTriggers to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Trigger + public static ResourceSet Read(string pathAccountSid = null, + TriggerResource.RecurringEnum recurring = null, + TriggerResource.TriggerFieldEnum triggerBy = null, + TriggerResource.UsageCategoryEnum usageCategory = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTriggerOptions() { PathAccountSid = pathAccountSid, Recurring = recurring, TriggerBy = triggerBy, UsageCategory = usageCategory, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of usage-triggers belonging to the account used to make the request + /// + /// The SID of the Account that created the resources to read + /// The frequency of recurring UsageTriggers to read + /// The trigger field of the UsageTriggers to read + /// The usage category of the UsageTriggers to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trigger + public static async System.Threading.Tasks.Task> ReadAsync(string pathAccountSid = null, + TriggerResource.RecurringEnum recurring = null, + TriggerResource.TriggerFieldEnum triggerBy = null, + TriggerResource.UsageCategoryEnum usageCategory = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTriggerOptions() { PathAccountSid = pathAccountSid, Recurring = recurring, TriggerBy = triggerBy, UsageCategory = usageCategory, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_triggers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_triggers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("usage_triggers", response.Content); + } + + /// + /// Converts a JSON string into a TriggerResource object + /// + /// Raw JSON string + /// TriggerResource object represented by the provided JSON + public static TriggerResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that this trigger monitors + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The API version used to create the resource + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The HTTP method we use to call callback_url + /// + [JsonProperty("callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod CallbackMethod { get; private set; } + /// + /// he URL we call when the trigger fires + /// + [JsonProperty("callback_url")] + public Uri CallbackUrl { get; private set; } + /// + /// The current value of the field the trigger is watching + /// + [JsonProperty("current_value")] + public string CurrentValue { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the trigger was last fired + /// + [JsonProperty("date_fired")] + public DateTime? DateFired { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the trigger + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The frequency of a recurring UsageTrigger + /// + [JsonProperty("recurring")] + [JsonConverter(typeof(StringEnumConverter))] + public TriggerResource.RecurringEnum Recurring { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The field in the UsageRecord resource that fires the trigger + /// + [JsonProperty("trigger_by")] + [JsonConverter(typeof(StringEnumConverter))] + public TriggerResource.TriggerFieldEnum TriggerBy { get; private set; } + /// + /// The value at which the trigger will fire + /// + [JsonProperty("trigger_value")] + public string TriggerValue { get; private set; } + /// + /// The URI of the resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + /// + /// The usage category the trigger watches + /// + [JsonProperty("usage_category")] + [JsonConverter(typeof(StringEnumConverter))] + public TriggerResource.UsageCategoryEnum UsageCategory { get; private set; } + /// + /// The URI of the UsageRecord resource this trigger watches + /// + [JsonProperty("usage_record_uri")] + public string UsageRecordUri { get; private set; } + + private TriggerResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ValidationRequestOptions.cs b/src/Twilio/Rest/Api/V2010/Account/ValidationRequestOptions.cs index c5d9661d2..0ed86048b 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ValidationRequestOptions.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ValidationRequestOptions.cs @@ -9,89 +9,89 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010.Account -{ - +{ + + /// + /// CreateValidationRequestOptions + /// + public class CreateValidationRequestOptions : IOptions + { /// - /// CreateValidationRequestOptions + /// The SID of the Account responsible for the new Caller ID /// - public class CreateValidationRequestOptions : IOptions - { - /// - /// The SID of the Account responsible for the new Caller ID - /// - public string PathAccountSid { get; set; } - /// - /// The phone number to verify in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The number of seconds to delay before initiating the verification call - /// - public int? CallDelay { get; set; } - /// - /// The digits to dial after connecting the verification call - /// - public string Extension { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Construct a new CreateValidationRequestOptions - /// - /// The phone number to verify in E.164 format - public CreateValidationRequestOptions(Types.PhoneNumber phoneNumber) - { - PhoneNumber = phoneNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CallDelay != null) - { - p.Add(new KeyValuePair("CallDelay", CallDelay.ToString())); - } - - if (Extension != null) - { - p.Add(new KeyValuePair("Extension", Extension)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - return p; - } - } + public string PathAccountSid { get; set; } + /// + /// The phone number to verify in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The number of seconds to delay before initiating the verification call + /// + public int? CallDelay { get; set; } + /// + /// The digits to dial after connecting the verification call + /// + public string Extension { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Construct a new CreateValidationRequestOptions + /// + /// The phone number to verify in E.164 format + public CreateValidationRequestOptions(Types.PhoneNumber phoneNumber) + { + PhoneNumber = phoneNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CallDelay != null) + { + p.Add(new KeyValuePair("CallDelay", CallDelay.ToString())); + } + + if (Extension != null) + { + p.Add(new KeyValuePair("Extension", Extension)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/Account/ValidationRequestResource.cs b/src/Twilio/Rest/Api/V2010/Account/ValidationRequestResource.cs index 8e1738282..62c0529b7 100644 --- a/src/Twilio/Rest/Api/V2010/Account/ValidationRequestResource.cs +++ b/src/Twilio/Rest/Api/V2010/Account/ValidationRequestResource.cs @@ -16,152 +16,152 @@ using Twilio.Http; namespace Twilio.Rest.Api.V2010.Account -{ - - public class ValidationRequestResource : Resource - { - private static Request BuildCreateRequest(CreateValidationRequestOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ValidationRequest parameters - /// Client to make requests to Twilio - /// A single instance of ValidationRequest - public static ValidationRequestResource Create(CreateValidationRequestOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ValidationRequest parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ValidationRequest - public static async System.Threading.Tasks.Task CreateAsync(CreateValidationRequestOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The phone number to verify in E.164 format - /// The SID of the Account responsible for the new Caller ID - /// A string to describe the resource - /// The number of seconds to delay before initiating the verification call - /// The digits to dial after connecting the verification call - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Client to make requests to Twilio - /// A single instance of ValidationRequest - public static ValidationRequestResource Create(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string friendlyName = null, - int? callDelay = null, - string extension = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateValidationRequestOptions(phoneNumber){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CallDelay = callDelay, Extension = extension, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The phone number to verify in E.164 format - /// The SID of the Account responsible for the new Caller ID - /// A string to describe the resource - /// The number of seconds to delay before initiating the verification call - /// The digits to dial after connecting the verification call - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ValidationRequest - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, - string pathAccountSid = null, - string friendlyName = null, - int? callDelay = null, - string extension = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateValidationRequestOptions(phoneNumber){PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CallDelay = callDelay, Extension = extension, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ValidationRequestResource object - /// - /// Raw JSON string - /// ValidationRequestResource object represented by the provided JSON - public static ValidationRequestResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Call the resource is associated with - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The phone number to verify in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The 6 digit validation code that someone must enter to validate the Caller ID when `phone_number` is called - /// - [JsonProperty("validation_code")] - public string ValidationCode { get; private set; } - - private ValidationRequestResource() - { - - } - } +{ + + public class ValidationRequestResource : Resource + { + private static Request BuildCreateRequest(CreateValidationRequestOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/OutgoingCallerIds.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ValidationRequest parameters + /// Client to make requests to Twilio + /// A single instance of ValidationRequest + public static ValidationRequestResource Create(CreateValidationRequestOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ValidationRequest parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ValidationRequest + public static async System.Threading.Tasks.Task CreateAsync(CreateValidationRequestOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The phone number to verify in E.164 format + /// The SID of the Account responsible for the new Caller ID + /// A string to describe the resource + /// The number of seconds to delay before initiating the verification call + /// The digits to dial after connecting the verification call + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Client to make requests to Twilio + /// A single instance of ValidationRequest + public static ValidationRequestResource Create(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string friendlyName = null, + int? callDelay = null, + string extension = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateValidationRequestOptions(phoneNumber) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CallDelay = callDelay, Extension = extension, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The phone number to verify in E.164 format + /// The SID of the Account responsible for the new Caller ID + /// A string to describe the resource + /// The number of seconds to delay before initiating the verification call + /// The digits to dial after connecting the verification call + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ValidationRequest + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, + string pathAccountSid = null, + string friendlyName = null, + int? callDelay = null, + string extension = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateValidationRequestOptions(phoneNumber) { PathAccountSid = pathAccountSid, FriendlyName = friendlyName, CallDelay = callDelay, Extension = extension, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ValidationRequestResource object + /// + /// Raw JSON string + /// ValidationRequestResource object represented by the provided JSON + public static ValidationRequestResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Call the resource is associated with + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The phone number to verify in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The 6 digit validation code that someone must enter to validate the Caller ID when `phone_number` is called + /// + [JsonProperty("validation_code")] + public string ValidationCode { get; private set; } + + private ValidationRequestResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/AccountOptions.cs b/src/Twilio/Rest/Api/V2010/AccountOptions.cs index 02d70abb7..db8bc7400 100644 --- a/src/Twilio/Rest/Api/V2010/AccountOptions.cs +++ b/src/Twilio/Rest/Api/V2010/AccountOptions.cs @@ -9,128 +9,128 @@ using Twilio.Converters; namespace Twilio.Rest.Api.V2010 -{ - +{ + + /// + /// Create a new Twilio Subaccount from the account making the request + /// + public class CreateAccountOptions : IOptions + { /// - /// Create a new Twilio Subaccount from the account making the request + /// A human readable description of the account /// - public class CreateAccountOptions : IOptions - { - /// - /// A human readable description of the account - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string FriendlyName { get; set; } + /// - /// Fetch the account specified by the provided Account Sid + /// Generate the necessary parameters /// - public class FetchAccountOptions : IOptions - { - /// - /// Fetch by unique Account Sid - /// - public string PathSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Fetch the account specified by the provided Account Sid + /// + public class FetchAccountOptions : IOptions + { /// - /// Retrieves a collection of Accounts belonging to the account used to make the request + /// Fetch by unique Account Sid /// - public class ReadAccountOptions : ReadOptions - { - /// - /// FriendlyName to filter on - /// - public string FriendlyName { get; set; } - /// - /// Status to filter on - /// - public AccountResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; set; } + /// - /// Modify the properties of a given Account + /// Generate the necessary parameters /// - public class UpdateAccountOptions : IOptions - { - /// - /// Update by unique Account Sid - /// - public string PathSid { get; set; } - /// - /// FriendlyName to update - /// - public string FriendlyName { get; set; } - /// - /// Status to update the Account with - /// - public AccountResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieves a collection of Accounts belonging to the account used to make the request + /// + public class ReadAccountOptions : ReadOptions + { + /// + /// FriendlyName to filter on + /// + public string FriendlyName { get; set; } + /// + /// Status to filter on + /// + public AccountResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Modify the properties of a given Account + /// + public class UpdateAccountOptions : IOptions + { + /// + /// Update by unique Account Sid + /// + public string PathSid { get; set; } + /// + /// FriendlyName to update + /// + public string FriendlyName { get; set; } + /// + /// Status to update the Account with + /// + public AccountResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Api/V2010/AccountResource.cs b/src/Twilio/Rest/Api/V2010/AccountResource.cs index 647865d65..7db18d79d 100644 --- a/src/Twilio/Rest/Api/V2010/AccountResource.cs +++ b/src/Twilio/Rest/Api/V2010/AccountResource.cs @@ -17,459 +17,459 @@ using Twilio.Types; namespace Twilio.Rest.Api.V2010 -{ - - public class AccountResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Suspended = new StatusEnum("suspended"); - public static readonly StatusEnum Closed = new StatusEnum("closed"); - } - - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Trial = new TypeEnum("Trial"); - public static readonly TypeEnum Full = new TypeEnum("Full"); - } - - private static Request BuildCreateRequest(CreateAccountOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts.json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Twilio Subaccount from the account making the request - /// - /// Create Account parameters - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Create(CreateAccountOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Twilio Subaccount from the account making the request - /// - /// Create Account parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Twilio Subaccount from the account making the request - /// - /// A human readable description of the account - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Create(string friendlyName = null, ITwilioRestClient client = null) - { - var options = new CreateAccountOptions(){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Twilio Subaccount from the account making the request - /// - /// A human readable description of the account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateAccountOptions(){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchAccountOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathSid ?? client.AccountSid) + ".json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the account specified by the provided Account Sid - /// - /// Fetch Account parameters - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Fetch(FetchAccountOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the account specified by the provided Account Sid - /// - /// Fetch Account parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the account specified by the provided Account Sid - /// - /// Fetch by unique Account Sid - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Fetch(string pathSid = null, ITwilioRestClient client = null) - { - var options = new FetchAccountOptions(){PathSid = pathSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the account specified by the provided Account Sid - /// - /// Fetch by unique Account Sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task FetchAsync(string pathSid = null, - ITwilioRestClient client = null) - { - var options = new FetchAccountOptions(){PathSid = pathSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAccountOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Api, - "/2010-04-01/Accounts.json", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieves a collection of Accounts belonging to the account used to make the request - /// - /// Read Account parameters - /// Client to make requests to Twilio - /// A single instance of Account - public static ResourceSet Read(ReadAccountOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("accounts", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of Accounts belonging to the account used to make the request - /// - /// Read Account parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("accounts", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieves a collection of Accounts belonging to the account used to make the request - /// - /// FriendlyName to filter on - /// Status to filter on - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Account - public static ResourceSet Read(string friendlyName = null, - AccountResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAccountOptions(){FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieves a collection of Accounts belonging to the account used to make the request - /// - /// FriendlyName to filter on - /// Status to filter on - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, - AccountResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAccountOptions(){FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("accounts", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("accounts", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Api) - ); - - var response = client.Request(request); - return Page.FromJson("accounts", response.Content); - } - - private static Request BuildUpdateRequest(UpdateAccountOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Api, - "/2010-04-01/Accounts/" + (options.PathSid ?? client.AccountSid) + ".json", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Modify the properties of a given Account - /// - /// Update Account parameters - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Update(UpdateAccountOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// Update Account parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAccountOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Modify the properties of a given Account - /// - /// Update by unique Account Sid - /// FriendlyName to update - /// Status to update the Account with - /// Client to make requests to Twilio - /// A single instance of Account - public static AccountResource Update(string pathSid = null, - string friendlyName = null, - AccountResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateAccountOptions(){PathSid = pathSid, FriendlyName = friendlyName, Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// Modify the properties of a given Account - /// - /// Update by unique Account Sid - /// FriendlyName to update - /// Status to update the Account with - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid = null, - string friendlyName = null, - AccountResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateAccountOptions(){PathSid = pathSid, FriendlyName = friendlyName, Status = status}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AccountResource object - /// - /// Raw JSON string - /// AccountResource object represented by the provided JSON - public static AccountResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The authorization token for this account - /// - [JsonProperty("auth_token")] - public string AuthToken { get; private set; } - /// - /// The date this account was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this account was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A human readable description of this account - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique 34 character id representing the parent of this account - /// - [JsonProperty("owner_account_sid")] - public string OwnerAccountSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of this account - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public AccountResource.StatusEnum Status { get; private set; } - /// - /// Account Instance Subresources - /// - [JsonProperty("subresource_uris")] - public Dictionary SubresourceUris { get; private set; } - /// - /// The type of this account - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public AccountResource.TypeEnum Type { get; private set; } - /// - /// The URI for this resource, relative to `https://api.twilio.com` - /// - [JsonProperty("uri")] - public string Uri { get; private set; } - - private AccountResource() - { - - } - } +{ + + public class AccountResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Suspended = new StatusEnum("suspended"); + public static readonly StatusEnum Closed = new StatusEnum("closed"); + } + + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Trial = new TypeEnum("Trial"); + public static readonly TypeEnum Full = new TypeEnum("Full"); + } + + private static Request BuildCreateRequest(CreateAccountOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts.json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Twilio Subaccount from the account making the request + /// + /// Create Account parameters + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Create(CreateAccountOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Twilio Subaccount from the account making the request + /// + /// Create Account parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Twilio Subaccount from the account making the request + /// + /// A human readable description of the account + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Create(string friendlyName = null, ITwilioRestClient client = null) + { + var options = new CreateAccountOptions() { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Twilio Subaccount from the account making the request + /// + /// A human readable description of the account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateAccountOptions() { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchAccountOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathSid ?? client.AccountSid) + ".json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the account specified by the provided Account Sid + /// + /// Fetch Account parameters + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Fetch(FetchAccountOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the account specified by the provided Account Sid + /// + /// Fetch Account parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the account specified by the provided Account Sid + /// + /// Fetch by unique Account Sid + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Fetch(string pathSid = null, ITwilioRestClient client = null) + { + var options = new FetchAccountOptions() { PathSid = pathSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the account specified by the provided Account Sid + /// + /// Fetch by unique Account Sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task FetchAsync(string pathSid = null, + ITwilioRestClient client = null) + { + var options = new FetchAccountOptions() { PathSid = pathSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAccountOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Api, + "/2010-04-01/Accounts.json", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieves a collection of Accounts belonging to the account used to make the request + /// + /// Read Account parameters + /// Client to make requests to Twilio + /// A single instance of Account + public static ResourceSet Read(ReadAccountOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("accounts", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of Accounts belonging to the account used to make the request + /// + /// Read Account parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("accounts", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieves a collection of Accounts belonging to the account used to make the request + /// + /// FriendlyName to filter on + /// Status to filter on + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Account + public static ResourceSet Read(string friendlyName = null, + AccountResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAccountOptions() { FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieves a collection of Accounts belonging to the account used to make the request + /// + /// FriendlyName to filter on + /// Status to filter on + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, + AccountResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAccountOptions() { FriendlyName = friendlyName, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("accounts", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("accounts", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("accounts", response.Content); + } + + private static Request BuildUpdateRequest(UpdateAccountOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Api, + "/2010-04-01/Accounts/" + (options.PathSid ?? client.AccountSid) + ".json", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Modify the properties of a given Account + /// + /// Update Account parameters + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Update(UpdateAccountOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// Update Account parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAccountOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Modify the properties of a given Account + /// + /// Update by unique Account Sid + /// FriendlyName to update + /// Status to update the Account with + /// Client to make requests to Twilio + /// A single instance of Account + public static AccountResource Update(string pathSid = null, + string friendlyName = null, + AccountResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateAccountOptions() { PathSid = pathSid, FriendlyName = friendlyName, Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// Modify the properties of a given Account + /// + /// Update by unique Account Sid + /// FriendlyName to update + /// Status to update the Account with + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Account + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid = null, + string friendlyName = null, + AccountResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateAccountOptions() { PathSid = pathSid, FriendlyName = friendlyName, Status = status }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AccountResource object + /// + /// Raw JSON string + /// AccountResource object represented by the provided JSON + public static AccountResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The authorization token for this account + /// + [JsonProperty("auth_token")] + public string AuthToken { get; private set; } + /// + /// The date this account was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this account was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A human readable description of this account + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique 34 character id representing the parent of this account + /// + [JsonProperty("owner_account_sid")] + public string OwnerAccountSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of this account + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public AccountResource.StatusEnum Status { get; private set; } + /// + /// Account Instance Subresources + /// + [JsonProperty("subresource_uris")] + public Dictionary SubresourceUris { get; private set; } + /// + /// The type of this account + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public AccountResource.TypeEnum Type { get; private set; } + /// + /// The URI for this resource, relative to `https://api.twilio.com` + /// + [JsonProperty("uri")] + public string Uri { get; private set; } + + private AccountResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsOptions.cs index b352ba3ac..7fee9a2c2 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchDefaultsOptions + /// + public class FetchDefaultsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchDefaultsOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchDefaultsOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new FetchDefaultsOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - public FetchDefaultsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateDefaultsOptions + /// Construct a new FetchDefaultsOptions /// - public class UpdateDefaultsOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to update - /// - public string PathAssistantSid { get; } - /// - /// A JSON string that describes the default task links. - /// - public object Defaults { get; set; } - - /// - /// Construct a new UpdateDefaultsOptions - /// - /// The SID of the Assistant that is the parent of the resource to update - public UpdateDefaultsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Defaults != null) - { - p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); - } - - return p; - } - } + /// The SID of the Assistant that is the parent of the resource to fetch + public FetchDefaultsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateDefaultsOptions + /// + public class UpdateDefaultsOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resource to update + /// + public string PathAssistantSid { get; } + /// + /// A JSON string that describes the default task links. + /// + public object Defaults { get; set; } + + /// + /// Construct a new UpdateDefaultsOptions + /// + /// The SID of the Assistant that is the parent of the resource to update + public UpdateDefaultsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Defaults != null) + { + p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsResource.cs index 74d411111..3a7428acc 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/DefaultsResource.cs @@ -19,192 +19,192 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class DefaultsResource : Resource - { - private static Request BuildFetchRequest(FetchDefaultsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Defaults", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Defaults parameters - /// Client to make requests to Twilio - /// A single instance of Defaults - public static DefaultsResource Fetch(FetchDefaultsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Defaults parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Defaults - public static async System.Threading.Tasks.Task FetchAsync(FetchDefaultsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Defaults - public static DefaultsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) - { - var options = new FetchDefaultsOptions(pathAssistantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Defaults - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - ITwilioRestClient client = null) - { - var options = new FetchDefaultsOptions(pathAssistantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateDefaultsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Defaults", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Defaults parameters - /// Client to make requests to Twilio - /// A single instance of Defaults - public static DefaultsResource Update(UpdateDefaultsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Defaults parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Defaults - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDefaultsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// A JSON string that describes the default task links. - /// Client to make requests to Twilio - /// A single instance of Defaults - public static DefaultsResource Update(string pathAssistantSid, - object defaults = null, - ITwilioRestClient client = null) - { - var options = new UpdateDefaultsOptions(pathAssistantSid){Defaults = defaults}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// A JSON string that describes the default task links. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Defaults - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - object defaults = null, - ITwilioRestClient client = null) - { - var options = new UpdateDefaultsOptions(pathAssistantSid){Defaults = defaults}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DefaultsResource object - /// - /// Raw JSON string - /// DefaultsResource object represented by the provided JSON - public static DefaultsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The absolute URL of the Defaults resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON string that describes the default task links - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private DefaultsResource() - { - - } - } +{ + + public class DefaultsResource : Resource + { + private static Request BuildFetchRequest(FetchDefaultsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Defaults", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Defaults parameters + /// Client to make requests to Twilio + /// A single instance of Defaults + public static DefaultsResource Fetch(FetchDefaultsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Defaults parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Defaults + public static async System.Threading.Tasks.Task FetchAsync(FetchDefaultsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Defaults + public static DefaultsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) + { + var options = new FetchDefaultsOptions(pathAssistantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Defaults + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + ITwilioRestClient client = null) + { + var options = new FetchDefaultsOptions(pathAssistantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateDefaultsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Defaults", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Defaults parameters + /// Client to make requests to Twilio + /// A single instance of Defaults + public static DefaultsResource Update(UpdateDefaultsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Defaults parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Defaults + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDefaultsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// A JSON string that describes the default task links. + /// Client to make requests to Twilio + /// A single instance of Defaults + public static DefaultsResource Update(string pathAssistantSid, + object defaults = null, + ITwilioRestClient client = null) + { + var options = new UpdateDefaultsOptions(pathAssistantSid) { Defaults = defaults }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// A JSON string that describes the default task links. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Defaults + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + object defaults = null, + ITwilioRestClient client = null) + { + var options = new UpdateDefaultsOptions(pathAssistantSid) { Defaults = defaults }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DefaultsResource object + /// + /// Raw JSON string + /// DefaultsResource object represented by the provided JSON + public static DefaultsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The absolute URL of the Defaults resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON string that describes the default task links + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private DefaultsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueOptions.cs index 8e36f4b58..5039f4349 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchDialogueOptions + /// + public class FetchDialogueOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchDialogueOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchDialogueOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDialogueOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - public FetchDialogueOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDialogueOptions + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + public FetchDialogueOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueResource.cs index 7d8055752..3b93c0cab 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/DialogueResource.cs @@ -19,128 +19,128 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class DialogueResource : Resource - { - private static Request BuildFetchRequest(FetchDialogueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Dialogues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Dialogue parameters - /// Client to make requests to Twilio - /// A single instance of Dialogue - public static DialogueResource Fetch(FetchDialogueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Dialogue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Dialogue - public static async System.Threading.Tasks.Task FetchAsync(FetchDialogueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Dialogue - public static DialogueResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDialogueOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Dialogue - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDialogueOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DialogueResource object - /// - /// Raw JSON string - /// DialogueResource object represented by the provided JSON - public static DialogueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The JSON string that describes the dialogue session object - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The absolute URL of the Dialogue resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DialogueResource() - { - - } - } +{ + + public class DialogueResource : Resource + { + private static Request BuildFetchRequest(FetchDialogueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Dialogues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Dialogue parameters + /// Client to make requests to Twilio + /// A single instance of Dialogue + public static DialogueResource Fetch(FetchDialogueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Dialogue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Dialogue + public static async System.Threading.Tasks.Task FetchAsync(FetchDialogueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Dialogue + public static DialogueResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDialogueOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Dialogue + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDialogueOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DialogueResource object + /// + /// Raw JSON string + /// DialogueResource object represented by the provided JSON + public static DialogueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The JSON string that describes the dialogue session object + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The absolute URL of the Dialogue resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DialogueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueOptions.cs index 597e227c6..63f37695b 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant.FieldType -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldValueOptions + /// + public class FetchFieldValueOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldValueOptions - /// - public class FetchFieldValueOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Field Type associated with the Field Value to fetch - /// - public string PathFieldTypeSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldValueOptions - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resource to fetch - /// The SID of the Field Type associated with the Field Value to fetch - /// The unique string that identifies the resource - public FetchFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Assistant that is the parent of the FieldType associated with the resource to fetch + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldValueOptions - /// - public class ReadFieldValueOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the resources to read - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Field Type associated with the Field Value to read - /// - public string PathFieldTypeSid { get; } - /// - /// The ISO language-country tag that identifies the language of the value - /// - public string Language { get; set; } - - /// - /// Construct a new ReadFieldValueOptions - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to read - /// The SID of the Field Type associated with the Field Value to read - public ReadFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Field Type associated with the Field Value to fetch + /// + public string PathFieldTypeSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldValueOptions - /// - public class CreateFieldValueOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the new resource - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Field Type associated with the Field Value - /// - public string PathFieldTypeSid { get; } - /// - /// The ISO language-country tag that identifies the language of the value - /// - public string Language { get; } - /// - /// The Field Value data - /// - public string Value { get; } - /// - /// The string value that indicates which word the field value is a synonym of - /// - public string SynonymOf { get; set; } - - /// - /// Construct a new CreateFieldValueOptions - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// new resource - /// The SID of the Field Type associated with the Field Value - /// The ISO language-country tag that identifies the language of the value - /// The Field Value data - public CreateFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string language, string value) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - Language = language; - Value = value; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (Value != null) - { - p.Add(new KeyValuePair("Value", Value)); - } - - if (SynonymOf != null) - { - p.Add(new KeyValuePair("SynonymOf", SynonymOf.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldValueOptions - /// - public class DeleteFieldValueOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Field Type associated with the Field Value to delete - /// - public string PathFieldTypeSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldValueOptions - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to delete - /// The SID of the Field Type associated with the Field Value to delete - /// The unique string that identifies the resource - public DeleteFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchFieldValueOptions + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resource to fetch + /// The SID of the Field Type associated with the Field Value to fetch + /// The unique string that identifies the resource + public FetchFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldValueOptions + /// + public class ReadFieldValueOptions : ReadOptions + { + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the resources to read + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Field Type associated with the Field Value to read + /// + public string PathFieldTypeSid { get; } + /// + /// The ISO language-country tag that identifies the language of the value + /// + public string Language { get; set; } + + /// + /// Construct a new ReadFieldValueOptions + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to read + /// The SID of the Field Type associated with the Field Value to read + public ReadFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldValueOptions + /// + public class CreateFieldValueOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the new resource + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Field Type associated with the Field Value + /// + public string PathFieldTypeSid { get; } + /// + /// The ISO language-country tag that identifies the language of the value + /// + public string Language { get; } + /// + /// The Field Value data + /// + public string Value { get; } + /// + /// The string value that indicates which word the field value is a synonym of + /// + public string SynonymOf { get; set; } + + /// + /// Construct a new CreateFieldValueOptions + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// new resource + /// The SID of the Field Type associated with the Field Value + /// The ISO language-country tag that identifies the language of the value + /// The Field Value data + public CreateFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string language, string value) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + Language = language; + Value = value; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (Value != null) + { + p.Add(new KeyValuePair("Value", Value)); + } + + if (SynonymOf != null) + { + p.Add(new KeyValuePair("SynonymOf", SynonymOf.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldValueOptions + /// + public class DeleteFieldValueOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Field Type associated with the Field Value to delete + /// + public string PathFieldTypeSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldValueOptions + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to delete + /// The SID of the Field Type associated with the Field Value to delete + /// The unique string that identifies the resource + public DeleteFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueResource.cs index 92d3c0873..9d376d33a 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldType/FieldValueResource.cs @@ -19,468 +19,468 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant.FieldType -{ - - public class FieldValueResource : Resource - { - private static Request BuildFetchRequest(FetchFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Fetch(FetchFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resource to fetch - /// The SID of the Field Type associated with the Field Value to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Fetch(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resource to fetch - /// The SID of the Field Type associated with the Field Value to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static ResourceSet Read(ReadFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_values", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_values", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to read - /// The SID of the Field Type associated with the Field Value to read - /// The ISO language-country tag that identifies the language of the value - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static ResourceSet Read(string pathAssistantSid, - string pathFieldTypeSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid){Language = language, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to read - /// The SID of the Field Type associated with the Field Value to read - /// The ISO language-country tag that identifies the language of the value - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathFieldTypeSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid){Language = language, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Create(CreateFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// new resource - /// The SID of the Field Type associated with the Field Value - /// The ISO language-country tag that identifies the language of the value - /// The Field Value data - /// The string value that indicates which word the field value is a synonym of - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Create(string pathAssistantSid, - string pathFieldTypeSid, - string language, - string value, - string synonymOf = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value){SynonymOf = synonymOf}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// new resource - /// The SID of the Field Type associated with the Field Value - /// The ISO language-country tag that identifies the language of the value - /// The Field Value data - /// The string value that indicates which word the field value is a synonym of - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathFieldTypeSid, - string language, - string value, - string synonymOf = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value){SynonymOf = synonymOf}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static bool Delete(DeleteFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to delete - /// The SID of the Field Type associated with the Field Value to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static bool Delete(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the - /// resources to delete - /// The SID of the Field Type associated with the Field Value to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldValueResource object - /// - /// Raw JSON string - /// FieldValueResource object represented by the provided JSON - public static FieldValueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Field Type associated with the Field Value - /// - [JsonProperty("field_type_sid")] - public string FieldTypeSid { get; private set; } - /// - /// The ISO language-country tag that identifies the language of the value - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The SID of the Assistant that is the parent of the FieldType associated with the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The Field Value data - /// - [JsonProperty("value")] - public string Value { get; private set; } - /// - /// The absolute URL of the FieldValue resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The word for which the field value is a synonym of - /// - [JsonProperty("synonym_of")] - public string SynonymOf { get; private set; } - - private FieldValueResource() - { - - } - } +{ + + public class FieldValueResource : Resource + { + private static Request BuildFetchRequest(FetchFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Fetch(FetchFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resource to fetch + /// The SID of the Field Type associated with the Field Value to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Fetch(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resource to fetch + /// The SID of the Field Type associated with the Field Value to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static ResourceSet Read(ReadFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_values", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_values", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to read + /// The SID of the Field Type associated with the Field Value to read + /// The ISO language-country tag that identifies the language of the value + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static ResourceSet Read(string pathAssistantSid, + string pathFieldTypeSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid) { Language = language, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to read + /// The SID of the Field Type associated with the Field Value to read + /// The ISO language-country tag that identifies the language of the value + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathFieldTypeSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid) { Language = language, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Create(CreateFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// new resource + /// The SID of the Field Type associated with the Field Value + /// The ISO language-country tag that identifies the language of the value + /// The Field Value data + /// The string value that indicates which word the field value is a synonym of + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Create(string pathAssistantSid, + string pathFieldTypeSid, + string language, + string value, + string synonymOf = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value) { SynonymOf = synonymOf }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// new resource + /// The SID of the Field Type associated with the Field Value + /// The ISO language-country tag that identifies the language of the value + /// The Field Value data + /// The string value that indicates which word the field value is a synonym of + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathFieldTypeSid, + string language, + string value, + string synonymOf = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value) { SynonymOf = synonymOf }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static bool Delete(DeleteFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to delete + /// The SID of the Field Type associated with the Field Value to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static bool Delete(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the + /// resources to delete + /// The SID of the Field Type associated with the Field Value to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldValueResource object + /// + /// Raw JSON string + /// FieldValueResource object represented by the provided JSON + public static FieldValueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Field Type associated with the Field Value + /// + [JsonProperty("field_type_sid")] + public string FieldTypeSid { get; private set; } + /// + /// The ISO language-country tag that identifies the language of the value + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The SID of the Assistant that is the parent of the FieldType associated with the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The Field Value data + /// + [JsonProperty("value")] + public string Value { get; private set; } + /// + /// The absolute URL of the FieldValue resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The word for which the field value is a synonym of + /// + [JsonProperty("synonym_of")] + public string SynonymOf { get; private set; } + + private FieldValueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeOptions.cs index 98bf67e68..1c7b7aec0 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeOptions.cs @@ -9,227 +9,227 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldTypeOptions + /// + public class FetchFieldTypeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldTypeOptions - /// - public class FetchFieldTypeOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldTypeOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - public FetchFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Assistant that is the parent of the resource to fetch + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldTypeOptions - /// - public class ReadFieldTypeOptions : ReadOptions - { - /// - /// The SID of the Assistant with the FieldType resources to read - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadFieldTypeOptions - /// - /// The SID of the Assistant with the FieldType resources to read - public ReadFieldTypeOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldTypeOptions - /// - public class CreateFieldTypeOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the new resource - /// - public string PathAssistantSid { get; } - /// - /// An application-defined string that uniquely identifies the new resource - /// - public string UniqueName { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new CreateFieldTypeOptions - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the new resource - public CreateFieldTypeOptions(string pathAssistantSid, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Construct a new FetchFieldTypeOptions + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + public FetchFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateFieldTypeOptions - /// - public class UpdateFieldTypeOptions : IOptions - { - /// - /// The SID of the Assistant with the FieldType resource to update - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateFieldTypeOptions - /// - /// The SID of the Assistant with the FieldType resource to update - /// The unique string that identifies the resource - public UpdateFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldTypeOptions + /// + public class ReadFieldTypeOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldTypeOptions - /// - public class DeleteFieldTypeOptions : IOptions - { - /// - /// The SID of the Assistant with the FieldType resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldTypeOptions - /// - /// The SID of the Assistant with the FieldType resources to delete - /// The unique string that identifies the resource - public DeleteFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Assistant with the FieldType resources to read + /// + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadFieldTypeOptions + /// + /// The SID of the Assistant with the FieldType resources to read + public ReadFieldTypeOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldTypeOptions + /// + public class CreateFieldTypeOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the new resource + /// + public string PathAssistantSid { get; } + /// + /// An application-defined string that uniquely identifies the new resource + /// + public string UniqueName { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new CreateFieldTypeOptions + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the new resource + public CreateFieldTypeOptions(string pathAssistantSid, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateFieldTypeOptions + /// + public class UpdateFieldTypeOptions : IOptions + { + /// + /// The SID of the Assistant with the FieldType resource to update + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateFieldTypeOptions + /// + /// The SID of the Assistant with the FieldType resource to update + /// The unique string that identifies the resource + public UpdateFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldTypeOptions + /// + public class DeleteFieldTypeOptions : IOptions + { + /// + /// The SID of the Assistant with the FieldType resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldTypeOptions + /// + /// The SID of the Assistant with the FieldType resources to delete + /// The unique string that identifies the resource + public DeleteFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeResource.cs index 6e1bc57a7..70e4d92c2 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeResource.cs @@ -19,507 +19,507 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class FieldTypeResource : Resource - { - private static Request BuildFetchRequest(FetchFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Fetch(FetchFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static ResourceSet Read(ReadFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant with the FieldType resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FieldType - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldTypeOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant with the FieldType resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldTypeOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Create(CreateFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the new resource - /// A string to describe the new resource - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Create(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the new resource - /// A string to describe the new resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Update(UpdateFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant with the FieldType resource to update - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Update(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant with the FieldType resource to update - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static bool Delete(DeleteFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant with the FieldType resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of FieldType - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant with the FieldType resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldTypeResource object - /// - /// Raw JSON string - /// FieldTypeResource object represented by the provided JSON - public static FieldTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A list of the URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The absolute URL of the FieldType resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FieldTypeResource() - { - - } - } +{ + + public class FieldTypeResource : Resource + { + private static Request BuildFetchRequest(FetchFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Fetch(FetchFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static ResourceSet Read(ReadFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant with the FieldType resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FieldType + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldTypeOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant with the FieldType resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldTypeOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Create(CreateFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the new resource + /// A string to describe the new resource + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Create(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the new resource + /// A string to describe the new resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Update(UpdateFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant with the FieldType resource to update + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Update(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant with the FieldType resource to update + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static bool Delete(DeleteFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant with the FieldType resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of FieldType + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant with the FieldType resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldTypeResource object + /// + /// Raw JSON string + /// FieldTypeResource object represented by the provided JSON + public static FieldTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A list of the URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The absolute URL of the FieldType resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FieldTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildOptions.cs index 93083a37e..e3f4dc3d7 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildOptions.cs @@ -9,216 +9,216 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchModelBuildOptions + /// + public class FetchModelBuildOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchModelBuildOptions - /// - public class FetchModelBuildOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchModelBuildOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - public FetchModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Assistant that is the parent of the resource to fetch + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadModelBuildOptions - /// - public class ReadModelBuildOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to read - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadModelBuildOptions - /// - /// The SID of the Assistant that is the parent of the resources to read - public ReadModelBuildOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateModelBuildOptions - /// - public class CreateModelBuildOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the new resource - /// - public string PathAssistantSid { get; } - /// - /// The URL we should call using a POST method to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// An application-defined string that uniquely identifies the new resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new CreateModelBuildOptions - /// - /// The SID of the Assistant that is the parent of the new resource - public CreateModelBuildOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Construct a new FetchModelBuildOptions + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + public FetchModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateModelBuildOptions - /// - public class UpdateModelBuildOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to update - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to update - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateModelBuildOptions - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - public UpdateModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadModelBuildOptions + /// + public class ReadModelBuildOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteModelBuildOptions - /// - public class DeleteModelBuildOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteModelBuildOptions - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - public DeleteModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Assistant that is the parent of the resources to read + /// + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadModelBuildOptions + /// + /// The SID of the Assistant that is the parent of the resources to read + public ReadModelBuildOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateModelBuildOptions + /// + public class CreateModelBuildOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the new resource + /// + public string PathAssistantSid { get; } + /// + /// The URL we should call using a POST method to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// An application-defined string that uniquely identifies the new resource + /// + public string UniqueName { get; set; } + + /// + /// Construct a new CreateModelBuildOptions + /// + /// The SID of the Assistant that is the parent of the new resource + public CreateModelBuildOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateModelBuildOptions + /// + public class UpdateModelBuildOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resource to update + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource to update + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateModelBuildOptions + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + public UpdateModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteModelBuildOptions + /// + public class DeleteModelBuildOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteModelBuildOptions + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + public DeleteModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildResource.cs index 5bf66d442..8b174625c 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/ModelBuildResource.cs @@ -20,527 +20,527 @@ using Twilio.Types; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class ModelBuildResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); - public static readonly StatusEnum Building = new StatusEnum("building"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - } - - private static Request BuildFetchRequest(FetchModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Fetch(FetchModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task FetchAsync(FetchModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ResourceSet Read(ReadModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("model_builds", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task> ReadAsync(ReadModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("model_builds", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadModelBuildOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadModelBuildOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - private static Request BuildCreateRequest(CreateModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Create(CreateModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task CreateAsync(CreateModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// The URL we should call using a POST method to send status information to your - /// application - /// An application-defined string that uniquely identifies the new resource - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Create(string pathAssistantSid, - Uri statusCallback = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateModelBuildOptions(pathAssistantSid){StatusCallback = statusCallback, UniqueName = uniqueName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// The URL we should call using a POST method to send status information to your - /// application - /// An application-defined string that uniquely identifies the new resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - Uri statusCallback = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateModelBuildOptions(pathAssistantSid){StatusCallback = statusCallback, UniqueName = uniqueName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Update(UpdateModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task UpdateAsync(UpdateModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Update(string pathAssistantSid, - string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid){UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid){UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static bool Delete(DeleteModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task DeleteAsync(DeleteModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ModelBuildResource object - /// - /// Raw JSON string - /// ModelBuildResource object represented by the provided JSON - public static ModelBuildResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the model build process - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ModelBuildResource.StatusEnum Status { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The absolute URL of the ModelBuild resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The time in seconds it took to build the model - /// - [JsonProperty("build_duration")] - public int? BuildDuration { get; private set; } - /// - /// More information about why the model build failed, if `status` is `failed` - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - - private ModelBuildResource() - { - - } - } +{ + + public class ModelBuildResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); + public static readonly StatusEnum Building = new StatusEnum("building"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + } + + private static Request BuildFetchRequest(FetchModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Fetch(FetchModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task FetchAsync(FetchModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ResourceSet Read(ReadModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("model_builds", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task> ReadAsync(ReadModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("model_builds", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadModelBuildOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadModelBuildOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + private static Request BuildCreateRequest(CreateModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Create(CreateModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task CreateAsync(CreateModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// The URL we should call using a POST method to send status information to your + /// application + /// An application-defined string that uniquely identifies the new resource + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Create(string pathAssistantSid, + Uri statusCallback = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateModelBuildOptions(pathAssistantSid) { StatusCallback = statusCallback, UniqueName = uniqueName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// The URL we should call using a POST method to send status information to your + /// application + /// An application-defined string that uniquely identifies the new resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + Uri statusCallback = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateModelBuildOptions(pathAssistantSid) { StatusCallback = statusCallback, UniqueName = uniqueName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Update(UpdateModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task UpdateAsync(UpdateModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Update(string pathAssistantSid, + string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static bool Delete(DeleteModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task DeleteAsync(DeleteModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ModelBuildResource object + /// + /// Raw JSON string + /// ModelBuildResource object represented by the provided JSON + public static ModelBuildResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the model build process + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ModelBuildResource.StatusEnum Status { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The absolute URL of the ModelBuild resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The time in seconds it took to build the model + /// + [JsonProperty("build_duration")] + public int? BuildDuration { get; private set; } + /// + /// More information about why the model build failed, if `status` is `failed` + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + + private ModelBuildResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/QueryOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/QueryOptions.cs index ab1438045..3a9a8320a 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/QueryOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/QueryOptions.cs @@ -9,283 +9,283 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchQueryOptions + /// + public class FetchQueryOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchQueryOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchQueryOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchQueryOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - public FetchQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadQueryOptions + /// The unique string that identifies the resource /// - public class ReadQueryOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to read - /// - public string PathAssistantSid { get; } - /// - /// The ISO language-country string that specifies the language used by the Query resources to read - /// - public string Language { get; set; } - /// - /// The SID or unique name of the Model Build to be queried - /// - public string ModelBuild { get; set; } - /// - /// The status of the resources to read - /// - public string Status { get; set; } - /// - /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - /// - public string DialogueSid { get; set; } - - /// - /// Construct a new ReadQueryOptions - /// - /// The SID of the Assistant that is the parent of the resources to read - public ReadQueryOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (ModelBuild != null) - { - p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (DialogueSid != null) - { - p.Add(new KeyValuePair("DialogueSid", DialogueSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateQueryOptions + /// Construct a new FetchQueryOptions /// - public class CreateQueryOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the new resource - /// - public string PathAssistantSid { get; } - /// - /// The ISO language-country string that specifies the language used for the new query - /// - public string Language { get; } - /// - /// The end-user's natural language input - /// - public string Query { get; } - /// - /// The list of tasks to limit the new query to - /// - public string Tasks { get; set; } - /// - /// The SID or unique name of the Model Build to be queried - /// - public string ModelBuild { get; set; } - - /// - /// Construct a new CreateQueryOptions - /// - /// The SID of the Assistant that is the parent of the new resource - /// The ISO language-country string that specifies the language used for the new query - /// The end-user's natural language input - public CreateQueryOptions(string pathAssistantSid, string language, string query) - { - PathAssistantSid = pathAssistantSid; - Language = language; - Query = query; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (Query != null) - { - p.Add(new KeyValuePair("Query", Query)); - } - - if (Tasks != null) - { - p.Add(new KeyValuePair("Tasks", Tasks)); - } - - if (ModelBuild != null) - { - p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); - } - - return p; - } - } - + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + public FetchQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateQueryOptions + /// Generate the necessary parameters /// - public class UpdateQueryOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to update - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The SID of an optional reference to the Sample created from the query - /// - public string SampleSid { get; set; } - /// - /// The new status of the resource - /// - public string Status { get; set; } - - /// - /// Construct a new UpdateQueryOptions - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - public UpdateQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (SampleSid != null) - { - p.Add(new KeyValuePair("SampleSid", SampleSid.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadQueryOptions + /// + public class ReadQueryOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteQueryOptions + /// The SID of the Assistant that is the parent of the resources to read /// - public class DeleteQueryOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteQueryOptions - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - public DeleteQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// The ISO language-country string that specifies the language used by the Query resources to read + /// + public string Language { get; set; } + /// + /// The SID or unique name of the Model Build to be queried + /// + public string ModelBuild { get; set; } + /// + /// The status of the resources to read + /// + public string Status { get; set; } + /// + /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). + /// + public string DialogueSid { get; set; } + + /// + /// Construct a new ReadQueryOptions + /// + /// The SID of the Assistant that is the parent of the resources to read + public ReadQueryOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (ModelBuild != null) + { + p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (DialogueSid != null) + { + p.Add(new KeyValuePair("DialogueSid", DialogueSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateQueryOptions + /// + public class CreateQueryOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the new resource + /// + public string PathAssistantSid { get; } + /// + /// The ISO language-country string that specifies the language used for the new query + /// + public string Language { get; } + /// + /// The end-user's natural language input + /// + public string Query { get; } + /// + /// The list of tasks to limit the new query to + /// + public string Tasks { get; set; } + /// + /// The SID or unique name of the Model Build to be queried + /// + public string ModelBuild { get; set; } + + /// + /// Construct a new CreateQueryOptions + /// + /// The SID of the Assistant that is the parent of the new resource + /// The ISO language-country string that specifies the language used for the new query + /// The end-user's natural language input + public CreateQueryOptions(string pathAssistantSid, string language, string query) + { + PathAssistantSid = pathAssistantSid; + Language = language; + Query = query; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (Query != null) + { + p.Add(new KeyValuePair("Query", Query)); + } + + if (Tasks != null) + { + p.Add(new KeyValuePair("Tasks", Tasks)); + } + + if (ModelBuild != null) + { + p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateQueryOptions + /// + public class UpdateQueryOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resource to update + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The SID of an optional reference to the Sample created from the query + /// + public string SampleSid { get; set; } + /// + /// The new status of the resource + /// + public string Status { get; set; } + + /// + /// Construct a new UpdateQueryOptions + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + public UpdateQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (SampleSid != null) + { + p.Add(new KeyValuePair("SampleSid", SampleSid.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteQueryOptions + /// + public class DeleteQueryOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteQueryOptions + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + public DeleteQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/QueryResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/QueryResource.cs index 8150de73f..b7f1dc293 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/QueryResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/QueryResource.cs @@ -19,558 +19,558 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class QueryResource : Resource - { - private static Request BuildFetchRequest(FetchQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Fetch(FetchQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task FetchAsync(FetchQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchQueryOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchQueryOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Queries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static ResourceSet Read(ReadQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("queries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task> ReadAsync(ReadQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("queries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// The ISO language-country string that specifies the language used by the Query resources to - /// read - /// The SID or unique name of the Model Build to be queried - /// The status of the resources to read - /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Query - public static ResourceSet Read(string pathAssistantSid, - string language = null, - string modelBuild = null, - string status = null, - string dialogueSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueryOptions(pathAssistantSid){Language = language, ModelBuild = modelBuild, Status = status, DialogueSid = dialogueSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// The ISO language-country string that specifies the language used by the Query resources to - /// read - /// The SID or unique name of the Model Build to be queried - /// The status of the resources to read - /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string language = null, - string modelBuild = null, - string status = null, - string dialogueSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueryOptions(pathAssistantSid){Language = language, ModelBuild = modelBuild, Status = status, DialogueSid = dialogueSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - private static Request BuildCreateRequest(CreateQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Queries", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Create(CreateQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task CreateAsync(CreateQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// The ISO language-country string that specifies the language used for the new query - /// The end-user's natural language input - /// The list of tasks to limit the new query to - /// The SID or unique name of the Model Build to be queried - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Create(string pathAssistantSid, - string language, - string query, - string tasks = null, - string modelBuild = null, - ITwilioRestClient client = null) - { - var options = new CreateQueryOptions(pathAssistantSid, language, query){Tasks = tasks, ModelBuild = modelBuild}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// The ISO language-country string that specifies the language used for the new query - /// The end-user's natural language input - /// The list of tasks to limit the new query to - /// The SID or unique name of the Model Build to be queried - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string language, - string query, - string tasks = null, - string modelBuild = null, - ITwilioRestClient client = null) - { - var options = new CreateQueryOptions(pathAssistantSid, language, query){Tasks = tasks, ModelBuild = modelBuild}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Update(UpdateQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - /// The SID of an optional reference to the Sample created from the query - /// The new status of the resource - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Update(string pathAssistantSid, - string pathSid, - string sampleSid = null, - string status = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueryOptions(pathAssistantSid, pathSid){SampleSid = sampleSid, Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource to update - /// The SID of an optional reference to the Sample created from the query - /// The new status of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string sampleSid = null, - string status = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueryOptions(pathAssistantSid, pathSid){SampleSid = sampleSid, Status = status}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static bool Delete(DeleteQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Query - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteQueryOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteQueryOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a QueryResource object - /// - /// Raw JSON string - /// QueryResource object represented by the provided JSON - public static QueryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The natural language analysis results that include the Task recognized and a list of identified Fields - /// - [JsonProperty("results")] - public object Results { get; private set; } - /// - /// The ISO language-country string that specifies the language used by the Query - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The SID of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) queried - /// - [JsonProperty("model_build_sid")] - public string ModelBuildSid { get; private set; } - /// - /// The end-user's natural language input - /// - [JsonProperty("query")] - public string Query { get; private set; } - /// - /// The SID of an optional reference to the Sample created from the query - /// - [JsonProperty("sample_sid")] - public string SampleSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the Query - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// The absolute URL of the Query resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The communication channel from where the end-user input came - /// - [JsonProperty("source_channel")] - public string SourceChannel { get; private set; } - /// - /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - /// - [JsonProperty("dialogue_sid")] - public string DialogueSid { get; private set; } - - private QueryResource() - { - - } - } +{ + + public class QueryResource : Resource + { + private static Request BuildFetchRequest(FetchQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Fetch(FetchQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task FetchAsync(FetchQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchQueryOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchQueryOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Queries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static ResourceSet Read(ReadQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("queries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task> ReadAsync(ReadQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("queries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// The ISO language-country string that specifies the language used by the Query resources to + /// read + /// The SID or unique name of the Model Build to be queried + /// The status of the resources to read + /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Query + public static ResourceSet Read(string pathAssistantSid, + string language = null, + string modelBuild = null, + string status = null, + string dialogueSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueryOptions(pathAssistantSid) { Language = language, ModelBuild = modelBuild, Status = status, DialogueSid = dialogueSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// The ISO language-country string that specifies the language used by the Query resources to + /// read + /// The SID or unique name of the Model Build to be queried + /// The status of the resources to read + /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string language = null, + string modelBuild = null, + string status = null, + string dialogueSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueryOptions(pathAssistantSid) { Language = language, ModelBuild = modelBuild, Status = status, DialogueSid = dialogueSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + private static Request BuildCreateRequest(CreateQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Queries", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Create(CreateQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task CreateAsync(CreateQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// The ISO language-country string that specifies the language used for the new query + /// The end-user's natural language input + /// The list of tasks to limit the new query to + /// The SID or unique name of the Model Build to be queried + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Create(string pathAssistantSid, + string language, + string query, + string tasks = null, + string modelBuild = null, + ITwilioRestClient client = null) + { + var options = new CreateQueryOptions(pathAssistantSid, language, query) { Tasks = tasks, ModelBuild = modelBuild }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// The ISO language-country string that specifies the language used for the new query + /// The end-user's natural language input + /// The list of tasks to limit the new query to + /// The SID or unique name of the Model Build to be queried + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string language, + string query, + string tasks = null, + string modelBuild = null, + ITwilioRestClient client = null) + { + var options = new CreateQueryOptions(pathAssistantSid, language, query) { Tasks = tasks, ModelBuild = modelBuild }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Update(UpdateQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + /// The SID of an optional reference to the Sample created from the query + /// The new status of the resource + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Update(string pathAssistantSid, + string pathSid, + string sampleSid = null, + string status = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueryOptions(pathAssistantSid, pathSid) { SampleSid = sampleSid, Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource to update + /// The SID of an optional reference to the Sample created from the query + /// The new status of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string sampleSid = null, + string status = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueryOptions(pathAssistantSid, pathSid) { SampleSid = sampleSid, Status = status }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static bool Delete(DeleteQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Query + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteQueryOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteQueryOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a QueryResource object + /// + /// Raw JSON string + /// QueryResource object represented by the provided JSON + public static QueryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The natural language analysis results that include the Task recognized and a list of identified Fields + /// + [JsonProperty("results")] + public object Results { get; private set; } + /// + /// The ISO language-country string that specifies the language used by the Query + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The SID of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) queried + /// + [JsonProperty("model_build_sid")] + public string ModelBuildSid { get; private set; } + /// + /// The end-user's natural language input + /// + [JsonProperty("query")] + public string Query { get; private set; } + /// + /// The SID of an optional reference to the Sample created from the query + /// + [JsonProperty("sample_sid")] + public string SampleSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the Query + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// The absolute URL of the Query resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The communication channel from where the end-user input came + /// + [JsonProperty("source_channel")] + public string SourceChannel { get; private set; } + /// + /// The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). + /// + [JsonProperty("dialogue_sid")] + public string DialogueSid { get; private set; } + + private QueryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetOptions.cs index 80a5fa59a..cda0f364b 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Returns Style sheet JSON object for the Assistant + /// + public class FetchStyleSheetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Returns Style sheet JSON object for the Assistant + /// The SID of the Assistant with the StyleSheet resource to fetch /// - public class FetchStyleSheetOptions : IOptions - { - /// - /// The SID of the Assistant with the StyleSheet resource to fetch - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new FetchStyleSheetOptions - /// - /// The SID of the Assistant with the StyleSheet resource to fetch - public FetchStyleSheetOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// Construct a new FetchStyleSheetOptions /// - public class UpdateStyleSheetOptions : IOptions - { - /// - /// The SID of the Assistant with the StyleSheet resource to update - /// - public string PathAssistantSid { get; } - /// - /// The JSON string that describes the style sheet object - /// - public object StyleSheet { get; set; } - - /// - /// Construct a new UpdateStyleSheetOptions - /// - /// The SID of the Assistant with the StyleSheet resource to update - public UpdateStyleSheetOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - return p; - } - } + /// The SID of the Assistant with the StyleSheet resource to fetch + public FetchStyleSheetOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// + public class UpdateStyleSheetOptions : IOptions + { + /// + /// The SID of the Assistant with the StyleSheet resource to update + /// + public string PathAssistantSid { get; } + /// + /// The JSON string that describes the style sheet object + /// + public object StyleSheet { get; set; } + + /// + /// Construct a new UpdateStyleSheetOptions + /// + /// The SID of the Assistant with the StyleSheet resource to update + public UpdateStyleSheetOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetResource.cs index 83b37526e..841075e57 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/StyleSheetResource.cs @@ -19,192 +19,192 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class StyleSheetResource : Resource - { - private static Request BuildFetchRequest(FetchStyleSheetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/StyleSheet", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns Style sheet JSON object for the Assistant - /// - /// Fetch StyleSheet parameters - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Fetch(FetchStyleSheetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns Style sheet JSON object for the Assistant - /// - /// Fetch StyleSheet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task FetchAsync(FetchStyleSheetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns Style sheet JSON object for the Assistant - /// - /// The SID of the Assistant with the StyleSheet resource to fetch - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) - { - var options = new FetchStyleSheetOptions(pathAssistantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns Style sheet JSON object for the Assistant - /// - /// The SID of the Assistant with the StyleSheet resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - ITwilioRestClient client = null) - { - var options = new FetchStyleSheetOptions(pathAssistantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateStyleSheetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/StyleSheet", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the style sheet for an Assistant identified by `assistant_sid`. - /// - /// Update StyleSheet parameters - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Update(UpdateStyleSheetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the style sheet for an Assistant identified by `assistant_sid`. - /// - /// Update StyleSheet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task UpdateAsync(UpdateStyleSheetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the style sheet for an Assistant identified by `assistant_sid`. - /// - /// The SID of the Assistant with the StyleSheet resource to update - /// The JSON string that describes the style sheet object - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Update(string pathAssistantSid, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateStyleSheetOptions(pathAssistantSid){StyleSheet = styleSheet}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the style sheet for an Assistant identified by `assistant_sid`. - /// - /// The SID of the Assistant with the StyleSheet resource to update - /// The JSON string that describes the style sheet object - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateStyleSheetOptions(pathAssistantSid){StyleSheet = styleSheet}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a StyleSheetResource object - /// - /// Raw JSON string - /// StyleSheetResource object represented by the provided JSON - public static StyleSheetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The absolute URL of the StyleSheet resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON string that describes the style sheet object - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private StyleSheetResource() - { - - } - } +{ + + public class StyleSheetResource : Resource + { + private static Request BuildFetchRequest(FetchStyleSheetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/StyleSheet", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns Style sheet JSON object for the Assistant + /// + /// Fetch StyleSheet parameters + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Fetch(FetchStyleSheetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns Style sheet JSON object for the Assistant + /// + /// Fetch StyleSheet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task FetchAsync(FetchStyleSheetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns Style sheet JSON object for the Assistant + /// + /// The SID of the Assistant with the StyleSheet resource to fetch + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) + { + var options = new FetchStyleSheetOptions(pathAssistantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns Style sheet JSON object for the Assistant + /// + /// The SID of the Assistant with the StyleSheet resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + ITwilioRestClient client = null) + { + var options = new FetchStyleSheetOptions(pathAssistantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateStyleSheetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/StyleSheet", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// + /// Update StyleSheet parameters + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Update(UpdateStyleSheetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// + /// Update StyleSheet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task UpdateAsync(UpdateStyleSheetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// + /// The SID of the Assistant with the StyleSheet resource to update + /// The JSON string that describes the style sheet object + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Update(string pathAssistantSid, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateStyleSheetOptions(pathAssistantSid) { StyleSheet = styleSheet }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the style sheet for an Assistant identified by `assistant_sid`. + /// + /// The SID of the Assistant with the StyleSheet resource to update + /// The JSON string that describes the style sheet object + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateStyleSheetOptions(pathAssistantSid) { StyleSheet = styleSheet }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a StyleSheetResource object + /// + /// Raw JSON string + /// StyleSheetResource object represented by the provided JSON + public static StyleSheetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The absolute URL of the StyleSheet resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON string that describes the style sheet object + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private StyleSheetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldOptions.cs index 2e8425a60..079f7e184 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldOptions.cs @@ -9,205 +9,205 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldOptions + /// + public class FetchFieldOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldOptions - /// - public class FetchFieldOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to fetch - /// - public string PathTaskSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to fetch - /// The unique string that identifies the resource - public FetchFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Assistant that is the parent of the Task associated with the resource to fetch + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldOptions - /// - public class ReadFieldOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resources to read. - /// - public string PathAssistantSid { get; } - /// - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resources to read - /// - public string PathTaskSid { get; } - - /// - /// Construct a new ReadFieldOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read. - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resources to read - public ReadFieldOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to fetch + /// + public string PathTaskSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldOptions - /// - public class CreateFieldOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the new resource - /// - public string PathAssistantSid { get; } - /// - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the new Field resource - /// - public string PathTaskSid { get; } - /// - /// The Field Type of this field - /// - public string FieldType { get; } - /// - /// An application-defined string that uniquely identifies the new resource - /// - public string UniqueName { get; } - - /// - /// Construct a new CreateFieldOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the new Field resource - /// The Field Type of this field - /// An application-defined string that uniquely identifies the new resource - public CreateFieldOptions(string pathAssistantSid, string pathTaskSid, string fieldType, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - FieldType = fieldType; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FieldType != null) - { - p.Add(new KeyValuePair("FieldType", FieldType)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldOptions - /// - public class DeleteFieldOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to delete - /// - public string PathTaskSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to delete - /// The unique string that identifies the resource - public DeleteFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchFieldOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to fetch + /// The unique string that identifies the resource + public FetchFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldOptions + /// + public class ReadFieldOptions : ReadOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the resources to read. + /// + public string PathAssistantSid { get; } + /// + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resources to read + /// + public string PathTaskSid { get; } + + /// + /// Construct a new ReadFieldOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read. + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resources to read + public ReadFieldOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldOptions + /// + public class CreateFieldOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the new resource + /// + public string PathAssistantSid { get; } + /// + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the new Field resource + /// + public string PathTaskSid { get; } + /// + /// The Field Type of this field + /// + public string FieldType { get; } + /// + /// An application-defined string that uniquely identifies the new resource + /// + public string UniqueName { get; } + + /// + /// Construct a new CreateFieldOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the new Field resource + /// The Field Type of this field + /// An application-defined string that uniquely identifies the new resource + public CreateFieldOptions(string pathAssistantSid, string pathTaskSid, string fieldType, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + FieldType = fieldType; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FieldType != null) + { + p.Add(new KeyValuePair("FieldType", FieldType)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldOptions + /// + public class DeleteFieldOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to delete + /// + public string PathTaskSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to delete + /// The unique string that identifies the resource + public DeleteFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldResource.cs index 026c26aa9..f0dd34a2b 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/FieldResource.cs @@ -19,463 +19,463 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - - public class FieldResource : Resource - { - private static Request BuildFetchRequest(FetchFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Fetch(FetchFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Fetch(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static ResourceSet Read(ReadFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("fields", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("fields", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read. - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Field - public static ResourceSet Read(string pathAssistantSid, - string pathTaskSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read. - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathTaskSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Create(CreateFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the new Field resource - /// The Field Type of this field - /// An application-defined string that uniquely identifies the new resource - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Create(string pathAssistantSid, - string pathTaskSid, - string fieldType, - string uniqueName, - ITwilioRestClient client = null) - { - var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the new Field resource - /// The Field Type of this field - /// An application-defined string that uniquely identifies the new resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathTaskSid, - string fieldType, - string uniqueName, - ITwilioRestClient client = null) - { - var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static bool Delete(DeleteFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Field - public static bool Delete(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource - /// associated with the Field resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldResource object - /// - /// Raw JSON string - /// FieldResource object represented by the provided JSON - public static FieldResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Field Type of the field - /// - [JsonProperty("field_type")] - public string FieldType { get; private set; } - /// - /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with this Field - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The absolute URL of the Field resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FieldResource() - { - - } - } +{ + + public class FieldResource : Resource + { + private static Request BuildFetchRequest(FetchFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Fetch(FetchFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Fetch(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static ResourceSet Read(ReadFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("fields", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("fields", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read. + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Field + public static ResourceSet Read(string pathAssistantSid, + string pathTaskSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read. + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathTaskSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Create(CreateFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the new Field resource + /// The Field Type of this field + /// An application-defined string that uniquely identifies the new resource + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Create(string pathAssistantSid, + string pathTaskSid, + string fieldType, + string uniqueName, + ITwilioRestClient client = null) + { + var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the new Field resource + /// The Field Type of this field + /// An application-defined string that uniquely identifies the new resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathTaskSid, + string fieldType, + string uniqueName, + ITwilioRestClient client = null) + { + var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static bool Delete(DeleteFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Field + public static bool Delete(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource + /// associated with the Field resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldResource object + /// + /// Raw JSON string + /// FieldResource object represented by the provided JSON + public static FieldResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Field Type of the field + /// + [JsonProperty("field_type")] + public string FieldType { get; private set; } + /// + /// The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with this Field + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the Task associated with the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The absolute URL of the Field resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FieldResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleOptions.cs index 1536bf012..8a64e4373 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleOptions.cs @@ -9,291 +9,291 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSampleOptions + /// + public class FetchSampleOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSampleOptions + /// The SID of the Assistant that is the parent of the Task associated with the resource to fetch /// - public class FetchSampleOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task associated with the Sample resource to create - /// - public string PathTaskSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSampleOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the Task associated with the Sample resource to create - /// The unique string that identifies the resource - public FetchSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSampleOptions + /// The SID of the Task associated with the Sample resource to create /// - public class ReadSampleOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resources to read - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task associated with the Sample resources to read - /// - public string PathTaskSid { get; } - /// - /// The ISO language-country string that specifies the language used for the sample - /// - public string Language { get; set; } - - /// - /// Construct a new ReadSampleOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read - /// The SID of the Task associated with the Sample resources to read - public ReadSampleOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathTaskSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSampleOptions + /// The unique string that identifies the resource /// - public class CreateSampleOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the new resource - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task associated with the Sample resource to create - /// - public string PathTaskSid { get; } - /// - /// The ISO language-country string that specifies the language used for the new sample - /// - public string Language { get; } - /// - /// The text example of how end users might express the task - /// - public string TaggedText { get; } - /// - /// The communication channel from which the new sample was captured - /// - public string SourceChannel { get; set; } - - /// - /// Construct a new CreateSampleOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the Task associated with the Sample resource to create - /// The ISO language-country string that specifies the language used for the new sample - /// The text example of how end users might express the task - public CreateSampleOptions(string pathAssistantSid, string pathTaskSid, string language, string taggedText) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - Language = language; - TaggedText = taggedText; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (TaggedText != null) - { - p.Add(new KeyValuePair("TaggedText", TaggedText)); - } - - if (SourceChannel != null) - { - p.Add(new KeyValuePair("SourceChannel", SourceChannel)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateSampleOptions + /// Construct a new FetchSampleOptions /// - public class UpdateSampleOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource to update - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task associated with the Sample resource to update - /// - public string PathTaskSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The ISO language-country string that specifies the language used for the sample - /// - public string Language { get; set; } - /// - /// The text example of how end users might express the task - /// - public string TaggedText { get; set; } - /// - /// The communication channel from which the sample was captured - /// - public string SourceChannel { get; set; } - - /// - /// Construct a new UpdateSampleOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to update - /// The SID of the Task associated with the Sample resource to update - /// The unique string that identifies the resource - public UpdateSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (TaggedText != null) - { - p.Add(new KeyValuePair("TaggedText", TaggedText)); - } - - if (SourceChannel != null) - { - p.Add(new KeyValuePair("SourceChannel", SourceChannel)); - } - - return p; - } - } - + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the Task associated with the Sample resource to create + /// The unique string that identifies the resource + public FetchSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSampleOptions + /// Generate the necessary parameters /// - public class DeleteSampleOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task associated with the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task associated with the Sample resource to delete - /// - public string PathTaskSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSampleOptions - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the Task associated with the Sample resource to delete - /// The unique string that identifies the resource - public DeleteSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSampleOptions + /// + public class ReadSampleOptions : ReadOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the resources to read + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Task associated with the Sample resources to read + /// + public string PathTaskSid { get; } + /// + /// The ISO language-country string that specifies the language used for the sample + /// + public string Language { get; set; } + + /// + /// Construct a new ReadSampleOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read + /// The SID of the Task associated with the Sample resources to read + public ReadSampleOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSampleOptions + /// + public class CreateSampleOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the new resource + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Task associated with the Sample resource to create + /// + public string PathTaskSid { get; } + /// + /// The ISO language-country string that specifies the language used for the new sample + /// + public string Language { get; } + /// + /// The text example of how end users might express the task + /// + public string TaggedText { get; } + /// + /// The communication channel from which the new sample was captured + /// + public string SourceChannel { get; set; } + + /// + /// Construct a new CreateSampleOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the Task associated with the Sample resource to create + /// The ISO language-country string that specifies the language used for the new sample + /// The text example of how end users might express the task + public CreateSampleOptions(string pathAssistantSid, string pathTaskSid, string language, string taggedText) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + Language = language; + TaggedText = taggedText; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (TaggedText != null) + { + p.Add(new KeyValuePair("TaggedText", TaggedText)); + } + + if (SourceChannel != null) + { + p.Add(new KeyValuePair("SourceChannel", SourceChannel)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateSampleOptions + /// + public class UpdateSampleOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the resource to update + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Task associated with the Sample resource to update + /// + public string PathTaskSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The ISO language-country string that specifies the language used for the sample + /// + public string Language { get; set; } + /// + /// The text example of how end users might express the task + /// + public string TaggedText { get; set; } + /// + /// The communication channel from which the sample was captured + /// + public string SourceChannel { get; set; } + + /// + /// Construct a new UpdateSampleOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to update + /// The SID of the Task associated with the Sample resource to update + /// The unique string that identifies the resource + public UpdateSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (TaggedText != null) + { + p.Add(new KeyValuePair("TaggedText", TaggedText)); + } + + if (SourceChannel != null) + { + p.Add(new KeyValuePair("SourceChannel", SourceChannel)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSampleOptions + /// + public class DeleteSampleOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task associated with the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Task associated with the Sample resource to delete + /// + public string PathTaskSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSampleOptions + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the Task associated with the Sample resource to delete + /// The unique string that identifies the resource + public DeleteSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleResource.cs index 9781055cf..bd7679693 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/SampleResource.cs @@ -19,558 +19,558 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - - public class SampleResource : Resource - { - private static Request BuildFetchRequest(FetchSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Fetch(FetchSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task FetchAsync(FetchSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the Task associated with the Sample resource to create - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Fetch(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to fetch - /// The SID of the Task associated with the Sample resource to create - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static ResourceSet Read(ReadSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("samples", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task> ReadAsync(ReadSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("samples", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read - /// The SID of the Task associated with the Sample resources to read - /// The ISO language-country string that specifies the language used for the sample - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sample - public static ResourceSet Read(string pathAssistantSid, - string pathTaskSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid){Language = language, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to read - /// The SID of the Task associated with the Sample resources to read - /// The ISO language-country string that specifies the language used for the sample - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathTaskSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid){Language = language, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - private static Request BuildCreateRequest(CreateSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Create(CreateSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task CreateAsync(CreateSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the Task associated with the Sample resource to create - /// The ISO language-country string that specifies the language used for the new sample - /// The text example of how end users might express the task - /// The communication channel from which the new sample was captured - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Create(string pathAssistantSid, - string pathTaskSid, - string language, - string taggedText, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText){SourceChannel = sourceChannel}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the Task associated with the new - /// resource - /// The SID of the Task associated with the Sample resource to create - /// The ISO language-country string that specifies the language used for the new sample - /// The text example of how end users might express the task - /// The communication channel from which the new sample was captured - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathTaskSid, - string language, - string taggedText, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText){SourceChannel = sourceChannel}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Update(UpdateSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to update - /// The SID of the Task associated with the Sample resource to update - /// The unique string that identifies the resource - /// The ISO language-country string that specifies the language used for the sample - /// The text example of how end users might express the task - /// The communication channel from which the sample was captured - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Update(string pathAssistantSid, - string pathTaskSid, - string pathSid, - string language = null, - string taggedText = null, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid){Language = language, TaggedText = taggedText, SourceChannel = sourceChannel}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resource to update - /// The SID of the Task associated with the Sample resource to update - /// The unique string that identifies the resource - /// The ISO language-country string that specifies the language used for the sample - /// The text example of how end users might express the task - /// The communication channel from which the sample was captured - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - string language = null, - string taggedText = null, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid){Language = language, TaggedText = taggedText, SourceChannel = sourceChannel}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static bool Delete(DeleteSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the Task associated with the Sample resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Sample - public static bool Delete(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the Task associated with the - /// resources to delete - /// The SID of the Task associated with the Sample resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SampleResource object - /// - /// Raw JSON string - /// SampleResource object represented by the provided JSON - public static SampleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Task associated with the resource - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// An ISO language-country string that specifies the language used for the sample - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The text example of how end users might express the task - /// - [JsonProperty("tagged_text")] - public string TaggedText { get; private set; } - /// - /// The absolute URL of the Sample resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The communication channel from which the sample was captured - /// - [JsonProperty("source_channel")] - public string SourceChannel { get; private set; } - - private SampleResource() - { - - } - } +{ + + public class SampleResource : Resource + { + private static Request BuildFetchRequest(FetchSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Fetch(FetchSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task FetchAsync(FetchSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the Task associated with the Sample resource to create + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Fetch(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to fetch + /// The SID of the Task associated with the Sample resource to create + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static ResourceSet Read(ReadSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("samples", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task> ReadAsync(ReadSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("samples", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read + /// The SID of the Task associated with the Sample resources to read + /// The ISO language-country string that specifies the language used for the sample + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sample + public static ResourceSet Read(string pathAssistantSid, + string pathTaskSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid) { Language = language, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to read + /// The SID of the Task associated with the Sample resources to read + /// The ISO language-country string that specifies the language used for the sample + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathTaskSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid) { Language = language, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + private static Request BuildCreateRequest(CreateSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Create(CreateSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task CreateAsync(CreateSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the Task associated with the Sample resource to create + /// The ISO language-country string that specifies the language used for the new sample + /// The text example of how end users might express the task + /// The communication channel from which the new sample was captured + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Create(string pathAssistantSid, + string pathTaskSid, + string language, + string taggedText, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText) { SourceChannel = sourceChannel }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the Task associated with the new + /// resource + /// The SID of the Task associated with the Sample resource to create + /// The ISO language-country string that specifies the language used for the new sample + /// The text example of how end users might express the task + /// The communication channel from which the new sample was captured + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathTaskSid, + string language, + string taggedText, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText) { SourceChannel = sourceChannel }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Update(UpdateSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to update + /// The SID of the Task associated with the Sample resource to update + /// The unique string that identifies the resource + /// The ISO language-country string that specifies the language used for the sample + /// The text example of how end users might express the task + /// The communication channel from which the sample was captured + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Update(string pathAssistantSid, + string pathTaskSid, + string pathSid, + string language = null, + string taggedText = null, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid) { Language = language, TaggedText = taggedText, SourceChannel = sourceChannel }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resource to update + /// The SID of the Task associated with the Sample resource to update + /// The unique string that identifies the resource + /// The ISO language-country string that specifies the language used for the sample + /// The text example of how end users might express the task + /// The communication channel from which the sample was captured + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + string language = null, + string taggedText = null, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid) { Language = language, TaggedText = taggedText, SourceChannel = sourceChannel }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static bool Delete(DeleteSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the Task associated with the Sample resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Sample + public static bool Delete(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the Task associated with the + /// resources to delete + /// The SID of the Task associated with the Sample resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SampleResource object + /// + /// Raw JSON string + /// SampleResource object represented by the provided JSON + public static SampleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Task associated with the resource + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// An ISO language-country string that specifies the language used for the sample + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The SID of the Assistant that is the parent of the Task associated with the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The text example of how end users might express the task + /// + [JsonProperty("tagged_text")] + public string TaggedText { get; private set; } + /// + /// The absolute URL of the Sample resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The communication channel from which the sample was captured + /// + [JsonProperty("source_channel")] + public string SourceChannel { get; private set; } + + private SampleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsOptions.cs index d274f97ea..ad2b52b9f 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsOptions.cs @@ -9,93 +9,93 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Returns JSON actions for the Task. + /// + public class FetchTaskActionsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Returns JSON actions for the Task. + /// The SID of the Assistant that is the parent of the Task for which the task actions to fetch were defined /// - public class FetchTaskActionsOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions to fetch were defined - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task for which the task actions to fetch were defined - /// - public string PathTaskSid { get; } - - /// - /// Construct a new FetchTaskActionsOptions - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to fetch were defined - /// The SID of the Task for which the task actions to fetch were defined - public FetchTaskActionsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// The SID of the Task for which the task actions to fetch were defined /// - public class UpdateTaskActionsOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions to update were defined - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task for which the task actions to update were defined - /// - public string PathTaskSid { get; } - /// - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task - /// - public object Actions { get; set; } - - /// - /// Construct a new UpdateTaskActionsOptions - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to update were defined - /// The SID of the Task for which the task actions to update were defined - public UpdateTaskActionsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - return p; - } - } + public string PathTaskSid { get; } + + /// + /// Construct a new FetchTaskActionsOptions + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to fetch were defined + /// The SID of the Task for which the task actions to fetch were defined + public FetchTaskActionsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + public class UpdateTaskActionsOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions to update were defined + /// + public string PathAssistantSid { get; } + /// + /// The SID of the Task for which the task actions to update were defined + /// + public string PathTaskSid { get; } + /// + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task + /// + public object Actions { get; set; } + + /// + /// Construct a new UpdateTaskActionsOptions + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to update were defined + /// The SID of the Task for which the task actions to update were defined + public UpdateTaskActionsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsResource.cs index 9ce5a598d..98d1e97dc 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskActionsResource.cs @@ -19,210 +19,210 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - - public class TaskActionsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns JSON actions for the Task. - /// - /// Fetch TaskActions parameters - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Fetch(FetchTaskActionsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns JSON actions for the Task. - /// - /// Fetch TaskActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns JSON actions for the Task. - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to fetch were defined - /// The SID of the Task for which the task actions to fetch were defined - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Fetch(string pathAssistantSid, string pathTaskSid, ITwilioRestClient client = null) - { - var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns JSON actions for the Task. - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to fetch were defined - /// The SID of the Task for which the task actions to fetch were defined - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// Update TaskActions parameters - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Update(UpdateTaskActionsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// Update TaskActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to update were defined - /// The SID of the Task for which the task actions to update were defined - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Update(string pathAssistantSid, - string pathTaskSid, - object actions = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid){Actions = actions}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// The SID of the Assistant that is the parent of the Task for which the task actions - /// to update were defined - /// The SID of the Task for which the task actions to update were defined - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathTaskSid, - object actions = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid){Actions = actions}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskActionsResource object - /// - /// Raw JSON string - /// TaskActionsResource object represented by the provided JSON - public static TaskActionsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The SID of the Task associated with the resource - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The absolute URL of the TaskActions resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private TaskActionsResource() - { - - } - } +{ + + public class TaskActionsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns JSON actions for the Task. + /// + /// Fetch TaskActions parameters + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Fetch(FetchTaskActionsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns JSON actions for the Task. + /// + /// Fetch TaskActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns JSON actions for the Task. + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to fetch were defined + /// The SID of the Task for which the task actions to fetch were defined + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Fetch(string pathAssistantSid, string pathTaskSid, ITwilioRestClient client = null) + { + var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns JSON actions for the Task. + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to fetch were defined + /// The SID of the Task for which the task actions to fetch were defined + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// Update TaskActions parameters + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Update(UpdateTaskActionsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// Update TaskActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to update were defined + /// The SID of the Task for which the task actions to update were defined + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Update(string pathAssistantSid, + string pathTaskSid, + object actions = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid) { Actions = actions }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// The SID of the Assistant that is the parent of the Task for which the task actions + /// to update were defined + /// The SID of the Task for which the task actions to update were defined + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathTaskSid, + object actions = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid) { Actions = actions }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskActionsResource object + /// + /// Raw JSON string + /// TaskActionsResource object represented by the provided JSON + public static TaskActionsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the Task associated with the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The SID of the Task associated with the resource + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The absolute URL of the TaskActions resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private TaskActionsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsOptions.cs index 73e90c82f..457702a64 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchTaskStatisticsOptions + /// + public class FetchTaskStatisticsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchTaskStatisticsOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchTaskStatisticsOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The SID of the Task that is associated with the resource to fetch - /// - public string PathTaskSid { get; } - - /// - /// Construct a new FetchTaskStatisticsOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The SID of the Task that is associated with the resource to fetch - public FetchTaskStatisticsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// The SID of the Task that is associated with the resource to fetch + /// + public string PathTaskSid { get; } + + /// + /// Construct a new FetchTaskStatisticsOptions + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The SID of the Task that is associated with the resource to fetch + public FetchTaskStatisticsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsResource.cs index bb911f98e..11d3adb54 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/Task/TaskStatisticsResource.cs @@ -19,135 +19,135 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant.Task -{ - - public class TaskStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskStatistics - public static TaskStatisticsResource Fetch(FetchTaskStatisticsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The SID of the Task that is associated with the resource to fetch - /// Client to make requests to Twilio - /// A single instance of TaskStatistics - public static TaskStatisticsResource Fetch(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The SID of the Task that is associated with the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskStatisticsResource object - /// - /// Raw JSON string - /// TaskStatisticsResource object represented by the provided JSON - public static TaskStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Assistant that is the parent of the Task associated with the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The SID of the Task for which the statistics were collected - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The total number of Samples associated with the Task - /// - [JsonProperty("samples_count")] - public int? SamplesCount { get; private set; } - /// - /// The total number of Fields associated with the Task - /// - [JsonProperty("fields_count")] - public int? FieldsCount { get; private set; } - /// - /// The absolute URL of the TaskStatistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskStatisticsResource() - { - - } - } +{ + + public class TaskStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskStatistics + public static TaskStatisticsResource Fetch(FetchTaskStatisticsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The SID of the Task that is associated with the resource to fetch + /// Client to make requests to Twilio + /// A single instance of TaskStatistics + public static TaskStatisticsResource Fetch(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The SID of the Task that is associated with the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskStatisticsResource object + /// + /// Raw JSON string + /// TaskStatisticsResource object represented by the provided JSON + public static TaskStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Assistant that is the parent of the Task associated with the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The SID of the Task for which the statistics were collected + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The total number of Samples associated with the Task + /// + [JsonProperty("samples_count")] + public int? SamplesCount { get; private set; } + /// + /// The total number of Fields associated with the Task + /// + [JsonProperty("fields_count")] + public int? FieldsCount { get; private set; } + /// + /// The absolute URL of the TaskStatistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/TaskOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/TaskOptions.cs index 814b1ff2e..d3431e6a5 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/TaskOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/TaskOptions.cs @@ -9,263 +9,263 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchTaskOptions + /// + public class FetchTaskOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchTaskOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchTaskOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTaskOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - public FetchTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadTaskOptions + /// The unique string that identifies the resource to fetch /// - public class ReadTaskOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to read - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadTaskOptions - /// - /// The SID of the Assistant that is the parent of the resources to read - public ReadTaskOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateTaskOptions + /// Construct a new FetchTaskOptions /// - public class CreateTaskOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the new resource - /// - public string PathAssistantSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; } - /// - /// descriptive string that you create to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task - /// - public object Actions { get; set; } - /// - /// The URL from which the Assistant can fetch actions - /// - public Uri ActionsUrl { get; set; } - - /// - /// Construct a new CreateTaskOptions - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - public CreateTaskOptions(string pathAssistantSid, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - if (ActionsUrl != null) - { - p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); - } - - return p; - } - } - + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + public FetchTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateTaskOptions + /// Generate the necessary parameters /// - public class UpdateTaskOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to update - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task - /// - public object Actions { get; set; } - /// - /// The URL from which the Assistant can fetch actions - /// - public Uri ActionsUrl { get; set; } - - /// - /// Construct a new UpdateTaskOptions - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - public UpdateTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - if (ActionsUrl != null) - { - p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadTaskOptions + /// + public class ReadTaskOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteTaskOptions + /// The SID of the Assistant that is the parent of the resources to read /// - public class DeleteTaskOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTaskOptions - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - public DeleteTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadTaskOptions + /// + /// The SID of the Assistant that is the parent of the resources to read + public ReadTaskOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateTaskOptions + /// + public class CreateTaskOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the new resource + /// + public string PathAssistantSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; } + /// + /// descriptive string that you create to describe the new resource + /// + public string FriendlyName { get; set; } + /// + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task + /// + public object Actions { get; set; } + /// + /// The URL from which the Assistant can fetch actions + /// + public Uri ActionsUrl { get; set; } + + /// + /// Construct a new CreateTaskOptions + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + public CreateTaskOptions(string pathAssistantSid, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + if (ActionsUrl != null) + { + p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateTaskOptions + /// + public class UpdateTaskOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resource to update + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the task + /// + public object Actions { get; set; } + /// + /// The URL from which the Assistant can fetch actions + /// + public Uri ActionsUrl { get; set; } + + /// + /// Construct a new UpdateTaskOptions + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + public UpdateTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + if (ActionsUrl != null) + { + p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteTaskOptions + /// + public class DeleteTaskOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTaskOptions + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + public DeleteTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/TaskResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/TaskResource.cs index db16c9ee1..3aead6e52 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/TaskResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/TaskResource.cs @@ -19,532 +19,532 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class TaskResource : Resource - { - private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - /// descriptive string that you create to describe the new resource - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// The URL from which the Assistant can fetch actions - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - /// descriptive string that you create to describe the new resource - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// The URL from which the Assistant can fetch actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// The URL from which the Assistant can fetch actions - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// The JSON string that specifies the actions that instruct the Assistant on how to perform the - /// task - /// The URL from which the Assistant can fetch actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskResource object - /// - /// Raw JSON string - /// TaskResource object represented by the provided JSON - public static TaskResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A list of the URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The URL from which the Assistant can fetch actions - /// - [JsonProperty("actions_url")] - public Uri ActionsUrl { get; private set; } - /// - /// The absolute URL of the Task resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskResource() - { - - } - } +{ + + public class TaskResource : Resource + { + private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + /// descriptive string that you create to describe the new resource + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// The URL from which the Assistant can fetch actions + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + /// descriptive string that you create to describe the new resource + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// The URL from which the Assistant can fetch actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// The URL from which the Assistant can fetch actions + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// The JSON string that specifies the actions that instruct the Assistant on how to perform the + /// task + /// The URL from which the Assistant can fetch actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskResource object + /// + /// Raw JSON string + /// TaskResource object represented by the provided JSON + public static TaskResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A list of the URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The URL from which the Assistant can fetch actions + /// + [JsonProperty("actions_url")] + public Uri ActionsUrl { get; private set; } + /// + /// The absolute URL of the Task resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookOptions.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookOptions.cs index 7809f806b..9bdc1176d 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookOptions.cs @@ -9,267 +9,267 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchWebhookOptions + /// + public class FetchWebhookOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchWebhookOptions + /// The SID of the Assistant that is the parent of the resource to fetch /// - public class FetchWebhookOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - public FetchWebhookOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadWebhookOptions + /// The unique string that identifies the resource to fetch /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to read - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// The SID of the Assistant that is the parent of the resources to read - public ReadWebhookOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateWebhookOptions + /// Construct a new FetchWebhookOptions /// - public class CreateWebhookOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the new resource - /// - public string PathAssistantSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; } - /// - /// The list of space-separated events that this Webhook will subscribe to. - /// - public string Events { get; } - /// - /// The URL associated with this Webhook. - /// - public Uri WebhookUrl { get; } - /// - /// The method to be used when calling the webhook's URL. - /// - public string WebhookMethod { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - /// The list of space-separated events that this Webhook will subscribe to. - /// The URL associated with this Webhook. - public CreateWebhookOptions(string pathAssistantSid, string uniqueName, string events, Uri webhookUrl) - { - PathAssistantSid = pathAssistantSid; - UniqueName = uniqueName; - Events = events; - WebhookUrl = webhookUrl; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Events != null) - { - p.Add(new KeyValuePair("Events", Events)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - return p; - } - } - + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + public FetchWebhookOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateWebhookOptions + /// Generate the necessary parameters /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resource to update - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The list of space-separated events that this Webhook will subscribe to. - /// - public string Events { get; set; } - /// - /// The URL associated with this Webhook. - /// - public Uri WebhookUrl { get; set; } - /// - /// The method to be used when calling the webhook's URL. - /// - public string WebhookMethod { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - public UpdateWebhookOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Events != null) - { - p.Add(new KeyValuePair("Events", Events)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadWebhookOptions + /// + public class ReadWebhookOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteWebhookOptions + /// The SID of the Assistant that is the parent of the resources to read /// - public class DeleteWebhookOptions : IOptions - { - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// - public string PathAssistantSid { get; } - /// - /// The unique string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - public DeleteWebhookOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadWebhookOptions + /// + /// The SID of the Assistant that is the parent of the resources to read + public ReadWebhookOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateWebhookOptions + /// + public class CreateWebhookOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the new resource + /// + public string PathAssistantSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; } + /// + /// The list of space-separated events that this Webhook will subscribe to. + /// + public string Events { get; } + /// + /// The URL associated with this Webhook. + /// + public Uri WebhookUrl { get; } + /// + /// The method to be used when calling the webhook's URL. + /// + public string WebhookMethod { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + /// The list of space-separated events that this Webhook will subscribe to. + /// The URL associated with this Webhook. + public CreateWebhookOptions(string pathAssistantSid, string uniqueName, string events, Uri webhookUrl) + { + PathAssistantSid = pathAssistantSid; + UniqueName = uniqueName; + Events = events; + WebhookUrl = webhookUrl; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Events != null) + { + p.Add(new KeyValuePair("Events", Events)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateWebhookOptions + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resource to update + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The list of space-separated events that this Webhook will subscribe to. + /// + public string Events { get; set; } + /// + /// The URL associated with this Webhook. + /// + public Uri WebhookUrl { get; set; } + /// + /// The method to be used when calling the webhook's URL. + /// + public string WebhookMethod { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + public UpdateWebhookOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Events != null) + { + p.Add(new KeyValuePair("Events", Events)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteWebhookOptions + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// + public string PathAssistantSid { get; } + /// + /// The unique string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + public DeleteWebhookOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookResource.cs b/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookResource.cs index 02815fd2a..7f12c44ac 100644 --- a/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/Assistant/WebhookResource.cs @@ -19,528 +19,528 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1.Assistant -{ - - public class WebhookResource : Resource - { - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Assistant that is the parent of the resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Assistant that is the parent of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - /// The list of space-separated events that this Webhook will subscribe to. - /// The URL associated with this Webhook. - /// The method to be used when calling the webhook's URL. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathAssistantSid, - string uniqueName, - string events, - Uri webhookUrl, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathAssistantSid, uniqueName, events, webhookUrl){WebhookMethod = webhookMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Assistant that is the parent of the new resource - /// An application-defined string that uniquely identifies the resource - /// The list of space-separated events that this Webhook will subscribe to. - /// The URL associated with this Webhook. - /// The method to be used when calling the webhook's URL. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string uniqueName, - string events, - Uri webhookUrl, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathAssistantSid, uniqueName, events, webhookUrl){WebhookMethod = webhookMethod}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - /// An application-defined string that uniquely identifies the resource - /// The list of space-separated events that this Webhook will subscribe to. - /// The URL associated with this Webhook. - /// The method to be used when calling the webhook's URL. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathAssistantSid, - string pathSid, - string uniqueName = null, - string events = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathAssistantSid, pathSid){UniqueName = uniqueName, Events = events, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Assistant that is the parent of the resource to update - /// The unique string that identifies the resource - /// An application-defined string that uniquely identifies the resource - /// The list of space-separated events that this Webhook will subscribe to. - /// The URL associated with this Webhook. - /// The method to be used when calling the webhook's URL. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string uniqueName = null, - string events = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathAssistantSid, pathSid){UniqueName = uniqueName, Events = events, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Assistant that is the parent of the resources to delete - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The absolute URL of the Webhook resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Assistant that is the parent of the resource - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The list of space-separated events that this Webhook is subscribed to. - /// - [JsonProperty("events")] - public string Events { get; private set; } - /// - /// The URL associated with this Webhook. - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// The method used when calling the webhook's URL. - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Assistant that is the parent of the resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Assistant that is the parent of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + /// The list of space-separated events that this Webhook will subscribe to. + /// The URL associated with this Webhook. + /// The method to be used when calling the webhook's URL. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathAssistantSid, + string uniqueName, + string events, + Uri webhookUrl, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathAssistantSid, uniqueName, events, webhookUrl) { WebhookMethod = webhookMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Assistant that is the parent of the new resource + /// An application-defined string that uniquely identifies the resource + /// The list of space-separated events that this Webhook will subscribe to. + /// The URL associated with this Webhook. + /// The method to be used when calling the webhook's URL. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string uniqueName, + string events, + Uri webhookUrl, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathAssistantSid, uniqueName, events, webhookUrl) { WebhookMethod = webhookMethod }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + /// An application-defined string that uniquely identifies the resource + /// The list of space-separated events that this Webhook will subscribe to. + /// The URL associated with this Webhook. + /// The method to be used when calling the webhook's URL. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathAssistantSid, + string pathSid, + string uniqueName = null, + string events = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName, Events = events, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Assistant that is the parent of the resource to update + /// The unique string that identifies the resource + /// An application-defined string that uniquely identifies the resource + /// The list of space-separated events that this Webhook will subscribe to. + /// The URL associated with this Webhook. + /// The method to be used when calling the webhook's URL. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string uniqueName = null, + string events = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName, Events = events, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathAssistantSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Assistant that is the parent of the resources to delete + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The absolute URL of the Webhook resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Assistant that is the parent of the resource + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The list of space-separated events that this Webhook is subscribed to. + /// + [JsonProperty("events")] + public string Events { get; private set; } + /// + /// The URL associated with this Webhook. + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// The method used when calling the webhook's URL. + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/AssistantOptions.cs b/src/Twilio/Rest/Autopilot/V1/AssistantOptions.cs index 77b5bcfc0..709dae5af 100644 --- a/src/Twilio/Rest/Autopilot/V1/AssistantOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/AssistantOptions.cs @@ -9,279 +9,279 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchAssistantOptions + /// + public class FetchAssistantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchAssistantOptions + /// The unique string that identifies the resource /// - public class FetchAssistantOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssistantOptions - /// - /// The unique string that identifies the resource - public FetchAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadAssistantOptions + /// Construct a new FetchAssistantOptions /// - public class ReadAssistantOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + public FetchAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateAssistantOptions + /// Generate the necessary parameters /// - public class CreateAssistantOptions : IOptions - { - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// Whether queries should be logged and kept after training - /// - public bool? LogQueries { get; set; } - /// - /// An application-defined string that uniquely identifies the new resource - /// - public string UniqueName { get; set; } - /// - /// Reserved - /// - public Uri CallbackUrl { get; set; } - /// - /// Reserved - /// - public string CallbackEvents { get; set; } - /// - /// A JSON string that defines the Assistant's style sheet - /// - public object StyleSheet { get; set; } - /// - /// A JSON object that defines the Assistant's default tasks for various scenarios - /// - public object Defaults { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (LogQueries != null) - { - p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackEvents != null) - { - p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); - } - - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - if (Defaults != null) - { - p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadAssistantOptions + /// + public class ReadAssistantOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateAssistantOptions + /// Generate the necessary parameters /// - public class UpdateAssistantOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// Whether queries should be logged and kept after training - /// - public bool? LogQueries { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// Reserved - /// - public Uri CallbackUrl { get; set; } - /// - /// Reserved - /// - public string CallbackEvents { get; set; } - /// - /// A JSON string that defines the Assistant's style sheet - /// - public object StyleSheet { get; set; } - /// - /// A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios - /// - public object Defaults { get; set; } - /// - /// A string describing the state of the assistant. - /// - public string DevelopmentStage { get; set; } - - /// - /// Construct a new UpdateAssistantOptions - /// - /// The unique string that identifies the resource - public UpdateAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (LogQueries != null) - { - p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackEvents != null) - { - p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); - } - - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - if (Defaults != null) - { - p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); - } - - if (DevelopmentStage != null) - { - p.Add(new KeyValuePair("DevelopmentStage", DevelopmentStage)); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateAssistantOptions + /// + public class CreateAssistantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteAssistantOptions + /// A string to describe the new resource /// - public class DeleteAssistantOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAssistantOptions - /// - /// The unique string that identifies the resource - public DeleteAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string FriendlyName { get; set; } + /// + /// Whether queries should be logged and kept after training + /// + public bool? LogQueries { get; set; } + /// + /// An application-defined string that uniquely identifies the new resource + /// + public string UniqueName { get; set; } + /// + /// Reserved + /// + public Uri CallbackUrl { get; set; } + /// + /// Reserved + /// + public string CallbackEvents { get; set; } + /// + /// A JSON string that defines the Assistant's style sheet + /// + public object StyleSheet { get; set; } + /// + /// A JSON object that defines the Assistant's default tasks for various scenarios + /// + public object Defaults { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (LogQueries != null) + { + p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackEvents != null) + { + p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); + } + + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + if (Defaults != null) + { + p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateAssistantOptions + /// + public class UpdateAssistantOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// Whether queries should be logged and kept after training + /// + public bool? LogQueries { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// Reserved + /// + public Uri CallbackUrl { get; set; } + /// + /// Reserved + /// + public string CallbackEvents { get; set; } + /// + /// A JSON string that defines the Assistant's style sheet + /// + public object StyleSheet { get; set; } + /// + /// A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios + /// + public object Defaults { get; set; } + /// + /// A string describing the state of the assistant. + /// + public string DevelopmentStage { get; set; } + + /// + /// Construct a new UpdateAssistantOptions + /// + /// The unique string that identifies the resource + public UpdateAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (LogQueries != null) + { + p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackEvents != null) + { + p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); + } + + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + if (Defaults != null) + { + p.Add(new KeyValuePair("Defaults", Serializers.JsonObject(Defaults))); + } + + if (DevelopmentStage != null) + { + p.Add(new KeyValuePair("DevelopmentStage", DevelopmentStage)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteAssistantOptions + /// + public class DeleteAssistantOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAssistantOptions + /// + /// The unique string that identifies the resource + public DeleteAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/AssistantResource.cs b/src/Twilio/Rest/Autopilot/V1/AssistantResource.cs index c1f01c945..2ce8a23cc 100644 --- a/src/Twilio/Rest/Autopilot/V1/AssistantResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/AssistantResource.cs @@ -19,559 +19,559 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1 -{ - - public class AssistantResource : Resource - { - private static Request BuildFetchRequest(FetchAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Fetch(FetchAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAssistantOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAssistantOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Autopilot, - "/v1/Assistants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static ResourceSet Read(ReadAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("assistants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("assistants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Assistant - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssistantOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssistantOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Autopilot) - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - private static Request BuildCreateRequest(CreateAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Create(CreateAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task CreateAsync(CreateAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the new resource - /// Whether queries should be logged and kept after training - /// An application-defined string that uniquely identifies the new resource - /// Reserved - /// Reserved - /// A JSON string that defines the Assistant's style sheet - /// A JSON object that defines the Assistant's default tasks for various scenarios - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Create(string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object styleSheet = null, - object defaults = null, - ITwilioRestClient client = null) - { - var options = new CreateAssistantOptions(){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the new resource - /// Whether queries should be logged and kept after training - /// An application-defined string that uniquely identifies the new resource - /// Reserved - /// Reserved - /// A JSON string that defines the Assistant's style sheet - /// A JSON object that defines the Assistant's default tasks for various scenarios - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object styleSheet = null, - object defaults = null, - ITwilioRestClient client = null) - { - var options = new CreateAssistantOptions(){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Update(UpdateAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Whether queries should be logged and kept after training - /// An application-defined string that uniquely identifies the resource - /// Reserved - /// Reserved - /// A JSON string that defines the Assistant's style sheet - /// A JSON object that defines the Assistant's [default - /// tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios - /// A string describing the state of the assistant. - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Update(string pathSid, - string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object styleSheet = null, - object defaults = null, - string developmentStage = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantOptions(pathSid){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults, DevelopmentStage = developmentStage}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Whether queries should be logged and kept after training - /// An application-defined string that uniquely identifies the resource - /// Reserved - /// Reserved - /// A JSON string that defines the Assistant's style sheet - /// A JSON object that defines the Assistant's [default - /// tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios - /// A string describing the state of the assistant. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object styleSheet = null, - object defaults = null, - string developmentStage = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantOptions(pathSid){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults, DevelopmentStage = developmentStage}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Autopilot, - "/v1/Assistants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static bool Delete(DeleteAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Assistant - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAssistantOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAssistantOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssistantResource object - /// - /// Raw JSON string - /// AssistantResource object represented by the provided JSON - public static AssistantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Reserved - /// - [JsonProperty("latest_model_build_sid")] - public string LatestModelBuildSid { get; private set; } - /// - /// A list of the URLs of the Assistant's related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// Whether queries should be logged and kept after training - /// - [JsonProperty("log_queries")] - public bool? LogQueries { get; private set; } - /// - /// A string describing the state of the assistant. - /// - [JsonProperty("development_stage")] - public string DevelopmentStage { get; private set; } - /// - /// Whether model needs to be rebuilt - /// - [JsonProperty("needs_model_build")] - public bool? NeedsModelBuild { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The absolute URL of the Assistant resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Reserved - /// - [JsonProperty("callback_url")] - public Uri CallbackUrl { get; private set; } - /// - /// Reserved - /// - [JsonProperty("callback_events")] - public string CallbackEvents { get; private set; } - - private AssistantResource() - { - - } - } +{ + + public class AssistantResource : Resource + { + private static Request BuildFetchRequest(FetchAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Fetch(FetchAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAssistantOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAssistantOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Autopilot, + "/v1/Assistants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static ResourceSet Read(ReadAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("assistants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("assistants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Assistant + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssistantOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssistantOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Autopilot) + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + private static Request BuildCreateRequest(CreateAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Create(CreateAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task CreateAsync(CreateAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the new resource + /// Whether queries should be logged and kept after training + /// An application-defined string that uniquely identifies the new resource + /// Reserved + /// Reserved + /// A JSON string that defines the Assistant's style sheet + /// A JSON object that defines the Assistant's default tasks for various scenarios + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Create(string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object styleSheet = null, + object defaults = null, + ITwilioRestClient client = null) + { + var options = new CreateAssistantOptions() { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the new resource + /// Whether queries should be logged and kept after training + /// An application-defined string that uniquely identifies the new resource + /// Reserved + /// Reserved + /// A JSON string that defines the Assistant's style sheet + /// A JSON object that defines the Assistant's default tasks for various scenarios + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object styleSheet = null, + object defaults = null, + ITwilioRestClient client = null) + { + var options = new CreateAssistantOptions() { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Update(UpdateAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Whether queries should be logged and kept after training + /// An application-defined string that uniquely identifies the resource + /// Reserved + /// Reserved + /// A JSON string that defines the Assistant's style sheet + /// A JSON object that defines the Assistant's [default + /// tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios + /// A string describing the state of the assistant. + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Update(string pathSid, + string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object styleSheet = null, + object defaults = null, + string developmentStage = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantOptions(pathSid) { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults, DevelopmentStage = developmentStage }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Whether queries should be logged and kept after training + /// An application-defined string that uniquely identifies the resource + /// Reserved + /// Reserved + /// A JSON string that defines the Assistant's style sheet + /// A JSON object that defines the Assistant's [default + /// tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios + /// A string describing the state of the assistant. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object styleSheet = null, + object defaults = null, + string developmentStage = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantOptions(pathSid) { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, StyleSheet = styleSheet, Defaults = defaults, DevelopmentStage = developmentStage }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Autopilot, + "/v1/Assistants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static bool Delete(DeleteAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Assistant + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAssistantOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAssistantOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssistantResource object + /// + /// Raw JSON string + /// AssistantResource object represented by the provided JSON + public static AssistantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Reserved + /// + [JsonProperty("latest_model_build_sid")] + public string LatestModelBuildSid { get; private set; } + /// + /// A list of the URLs of the Assistant's related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// Whether queries should be logged and kept after training + /// + [JsonProperty("log_queries")] + public bool? LogQueries { get; private set; } + /// + /// A string describing the state of the assistant. + /// + [JsonProperty("development_stage")] + public string DevelopmentStage { get; private set; } + /// + /// Whether model needs to be rebuilt + /// + [JsonProperty("needs_model_build")] + public bool? NeedsModelBuild { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The absolute URL of the Assistant resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Reserved + /// + [JsonProperty("callback_url")] + public Uri CallbackUrl { get; private set; } + /// + /// Reserved + /// + [JsonProperty("callback_events")] + public string CallbackEvents { get; private set; } + + private AssistantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/RestoreAssistantOptions.cs b/src/Twilio/Rest/Autopilot/V1/RestoreAssistantOptions.cs index 99b6ec970..b40f78254 100644 --- a/src/Twilio/Rest/Autopilot/V1/RestoreAssistantOptions.cs +++ b/src/Twilio/Rest/Autopilot/V1/RestoreAssistantOptions.cs @@ -9,43 +9,43 @@ using Twilio.Converters; namespace Twilio.Rest.Autopilot.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateRestoreAssistantOptions + /// + public class UpdateRestoreAssistantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateRestoreAssistantOptions + /// The unique string that identifies the resource /// - public class UpdateRestoreAssistantOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string Assistant { get; } - - /// - /// Construct a new UpdateRestoreAssistantOptions - /// - /// The unique string that identifies the resource - public UpdateRestoreAssistantOptions(string assistant) - { - Assistant = assistant; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Assistant != null) - { - p.Add(new KeyValuePair("Assistant", Assistant.ToString())); - } - - return p; - } - } + public string Assistant { get; } + + /// + /// Construct a new UpdateRestoreAssistantOptions + /// + /// The unique string that identifies the resource + public UpdateRestoreAssistantOptions(string assistant) + { + Assistant = assistant; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Assistant != null) + { + p.Add(new KeyValuePair("Assistant", Assistant.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Autopilot/V1/RestoreAssistantResource.cs b/src/Twilio/Rest/Autopilot/V1/RestoreAssistantResource.cs index 731345f82..a4addfa28 100644 --- a/src/Twilio/Rest/Autopilot/V1/RestoreAssistantResource.cs +++ b/src/Twilio/Rest/Autopilot/V1/RestoreAssistantResource.cs @@ -19,160 +19,160 @@ using Twilio.Http; namespace Twilio.Rest.Autopilot.V1 -{ - - public class RestoreAssistantResource : Resource - { - private static Request BuildUpdateRequest(UpdateRestoreAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Autopilot, - "/v1/Assistants/Restore", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update RestoreAssistant parameters - /// Client to make requests to Twilio - /// A single instance of RestoreAssistant - public static RestoreAssistantResource Update(UpdateRestoreAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update RestoreAssistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RestoreAssistant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRestoreAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of RestoreAssistant - public static RestoreAssistantResource Update(string assistant, ITwilioRestClient client = null) - { - var options = new UpdateRestoreAssistantOptions(assistant); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RestoreAssistant - public static async System.Threading.Tasks.Task UpdateAsync(string assistant, - ITwilioRestClient client = null) - { - var options = new UpdateRestoreAssistantOptions(assistant); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RestoreAssistantResource object - /// - /// Raw JSON string - /// RestoreAssistantResource object represented by the provided JSON - public static RestoreAssistantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Whether model needs to be rebuilt - /// - [JsonProperty("needs_model_build")] - public bool? NeedsModelBuild { get; private set; } - /// - /// Reserved - /// - [JsonProperty("latest_model_build_sid")] - public string LatestModelBuildSid { get; private set; } - /// - /// Whether queries should be logged and kept after training - /// - [JsonProperty("log_queries")] - public bool? LogQueries { get; private set; } - /// - /// A string describing the state of the assistant. - /// - [JsonProperty("development_stage")] - public string DevelopmentStage { get; private set; } - /// - /// Reserved - /// - [JsonProperty("callback_url")] - public Uri CallbackUrl { get; private set; } - /// - /// Reserved - /// - [JsonProperty("callback_events")] - public string CallbackEvents { get; private set; } - - private RestoreAssistantResource() - { - - } - } +{ + + public class RestoreAssistantResource : Resource + { + private static Request BuildUpdateRequest(UpdateRestoreAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Autopilot, + "/v1/Assistants/Restore", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update RestoreAssistant parameters + /// Client to make requests to Twilio + /// A single instance of RestoreAssistant + public static RestoreAssistantResource Update(UpdateRestoreAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update RestoreAssistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RestoreAssistant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRestoreAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of RestoreAssistant + public static RestoreAssistantResource Update(string assistant, ITwilioRestClient client = null) + { + var options = new UpdateRestoreAssistantOptions(assistant); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RestoreAssistant + public static async System.Threading.Tasks.Task UpdateAsync(string assistant, + ITwilioRestClient client = null) + { + var options = new UpdateRestoreAssistantOptions(assistant); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RestoreAssistantResource object + /// + /// Raw JSON string + /// RestoreAssistantResource object represented by the provided JSON + public static RestoreAssistantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Whether model needs to be rebuilt + /// + [JsonProperty("needs_model_build")] + public bool? NeedsModelBuild { get; private set; } + /// + /// Reserved + /// + [JsonProperty("latest_model_build_sid")] + public string LatestModelBuildSid { get; private set; } + /// + /// Whether queries should be logged and kept after training + /// + [JsonProperty("log_queries")] + public bool? LogQueries { get; private set; } + /// + /// A string describing the state of the assistant. + /// + [JsonProperty("development_stage")] + public string DevelopmentStage { get; private set; } + /// + /// Reserved + /// + [JsonProperty("callback_url")] + public Uri CallbackUrl { get; private set; } + /// + /// Reserved + /// + [JsonProperty("callback_events")] + public string CallbackEvents { get; private set; } + + private RestoreAssistantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/DayOptions.cs b/src/Twilio/Rest/Bulkexports/V1/Export/DayOptions.cs index e01c83880..5e169935d 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/DayOptions.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/DayOptions.cs @@ -9,75 +9,75 @@ using Twilio.Converters; namespace Twilio.Rest.Bulkexports.V1.Export -{ - +{ + + /// + /// Fetch a specific Day. + /// + public class FetchDayOptions : IOptions + { /// - /// Fetch a specific Day. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchDayOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// The date of the data in the file - /// - public string PathDay { get; } - - /// - /// Construct a new FetchDayOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - public FetchDayOptions(string pathResourceType, string pathDay) - { - PathResourceType = pathResourceType; - PathDay = pathDay; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathResourceType { get; } /// - /// Retrieve a list of all Days for a resource. + /// The date of the data in the file /// - public class ReadDayOptions : ReadOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new ReadDayOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public ReadDayOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathDay { get; } + + /// + /// Construct a new FetchDayOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + public FetchDayOptions(string pathResourceType, string pathDay) + { + PathResourceType = pathResourceType; + PathDay = pathDay; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Days for a resource. + /// + public class ReadDayOptions : ReadOptions + { + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + + /// + /// Construct a new ReadDayOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public ReadDayOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/DayResource.cs b/src/Twilio/Rest/Bulkexports/V1/Export/DayResource.cs index f67ef1328..a5c7354f1 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/DayResource.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/DayResource.cs @@ -16,266 +16,266 @@ using Twilio.Http; namespace Twilio.Rest.Bulkexports.V1.Export -{ - - public class DayResource : Resource - { - private static Request BuildFetchRequest(FetchDayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Days/" + options.PathDay + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Day. - /// - /// Fetch Day parameters - /// Client to make requests to Twilio - /// A single instance of Day - public static DayResource Fetch(FetchDayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Day. - /// - /// Fetch Day parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task FetchAsync(FetchDayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Day. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - /// Client to make requests to Twilio - /// A single instance of Day - public static DayResource Fetch(string pathResourceType, string pathDay, ITwilioRestClient client = null) - { - var options = new FetchDayOptions(pathResourceType, pathDay); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Day. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - string pathDay, - ITwilioRestClient client = null) - { - var options = new FetchDayOptions(pathResourceType, pathDay); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Days", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Days for a resource. - /// - /// Read Day parameters - /// Client to make requests to Twilio - /// A single instance of Day - public static ResourceSet Read(ReadDayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("days", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Days for a resource. - /// - /// Read Day parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task> ReadAsync(ReadDayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("days", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Days for a resource. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Day - public static ResourceSet Read(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDayOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Days for a resource. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDayOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Bulkexports) - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Bulkexports) - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Converts a JSON string into a DayResource object - /// - /// Raw JSON string - /// DayResource object represented by the provided JSON - public static DayResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The redirect_to - /// - [JsonProperty("redirect_to")] - public Uri RedirectTo { get; private set; } - /// - /// The date of the data in the file - /// - [JsonProperty("day")] - public string Day { get; private set; } - /// - /// Size of the file in bytes - /// - [JsonProperty("size")] - public int? Size { get; private set; } - /// - /// The date when resource is created - /// - [JsonProperty("create_date")] - public string CreateDate { get; private set; } - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - - private DayResource() - { - - } - } +{ + + public class DayResource : Resource + { + private static Request BuildFetchRequest(FetchDayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Days/" + options.PathDay + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Day. + /// + /// Fetch Day parameters + /// Client to make requests to Twilio + /// A single instance of Day + public static DayResource Fetch(FetchDayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Day. + /// + /// Fetch Day parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task FetchAsync(FetchDayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Day. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + /// Client to make requests to Twilio + /// A single instance of Day + public static DayResource Fetch(string pathResourceType, string pathDay, ITwilioRestClient client = null) + { + var options = new FetchDayOptions(pathResourceType, pathDay); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Day. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + string pathDay, + ITwilioRestClient client = null) + { + var options = new FetchDayOptions(pathResourceType, pathDay); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Days", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Days for a resource. + /// + /// Read Day parameters + /// Client to make requests to Twilio + /// A single instance of Day + public static ResourceSet Read(ReadDayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("days", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Days for a resource. + /// + /// Read Day parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task> ReadAsync(ReadDayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("days", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Days for a resource. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Day + public static ResourceSet Read(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDayOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Days for a resource. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDayOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Bulkexports) + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Bulkexports) + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Converts a JSON string into a DayResource object + /// + /// Raw JSON string + /// DayResource object represented by the provided JSON + public static DayResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The redirect_to + /// + [JsonProperty("redirect_to")] + public Uri RedirectTo { get; private set; } + /// + /// The date of the data in the file + /// + [JsonProperty("day")] + public string Day { get; private set; } + /// + /// Size of the file in bytes + /// + [JsonProperty("size")] + public int? Size { get; private set; } + /// + /// The date when resource is created + /// + [JsonProperty("create_date")] + public string CreateDate { get; private set; } + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + + private DayResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobOptions.cs b/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobOptions.cs index b167c877d..db09b23d2 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobOptions.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobOptions.cs @@ -9,132 +9,132 @@ using Twilio.Converters; namespace Twilio.Rest.Bulkexports.V1.Export -{ - +{ + + /// + /// ReadExportCustomJobOptions + /// + public class ReadExportCustomJobOptions : ReadOptions + { /// - /// ReadExportCustomJobOptions + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class ReadExportCustomJobOptions : ReadOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new ReadExportCustomJobOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public ReadExportCustomJobOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathResourceType { get; } + /// - /// CreateExportCustomJobOptions + /// Construct a new ReadExportCustomJobOptions /// - public class CreateExportCustomJobOptions : IOptions - { - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - public string StartDay { get; } - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. - /// - public string EndDay { get; } - /// - /// The friendly name specified when creating the job - /// - public string FriendlyName { get; } - /// - /// The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. - /// - public string WebhookUrl { get; set; } - /// - /// This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. - /// - public string WebhookMethod { get; set; } - /// - /// The optional email to send the completion notification to - /// - public string Email { get; set; } - - /// - /// Construct a new CreateExportCustomJobOptions - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - public CreateExportCustomJobOptions(string pathResourceType, string startDay, string endDay, string friendlyName) - { - PathResourceType = pathResourceType; - StartDay = startDay; - EndDay = endDay; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StartDay != null) - { - p.Add(new KeyValuePair("StartDay", StartDay)); - } - - if (EndDay != null) - { - p.Add(new KeyValuePair("EndDay", EndDay)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - return p; - } - } + /// The type of communication – Messages, Calls, Conferences, and Participants + public ReadExportCustomJobOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateExportCustomJobOptions + /// + public class CreateExportCustomJobOptions : IOptions + { + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + public string StartDay { get; } + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. + /// + public string EndDay { get; } + /// + /// The friendly name specified when creating the job + /// + public string FriendlyName { get; } + /// + /// The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. + /// + public string WebhookUrl { get; set; } + /// + /// This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. + /// + public string WebhookMethod { get; set; } + /// + /// The optional email to send the completion notification to + /// + public string Email { get; set; } + + /// + /// Construct a new CreateExportCustomJobOptions + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + public CreateExportCustomJobOptions(string pathResourceType, string startDay, string endDay, string friendlyName) + { + PathResourceType = pathResourceType; + StartDay = startDay; + EndDay = endDay; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StartDay != null) + { + p.Add(new KeyValuePair("StartDay", StartDay)); + } + + if (EndDay != null) + { + p.Add(new KeyValuePair("EndDay", EndDay)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobResource.cs b/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobResource.cs index 580c7256b..4b16c406d 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobResource.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/ExportCustomJobResource.cs @@ -17,344 +17,344 @@ using Twilio.Types; namespace Twilio.Rest.Bulkexports.V1.Export -{ - - public class ExportCustomJobResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Errorduringrun = new StatusEnum("ErrorDuringRun"); - public static readonly StatusEnum Submitted = new StatusEnum("Submitted"); - public static readonly StatusEnum Running = new StatusEnum("Running"); - public static readonly StatusEnum Completedemptyrecords = new StatusEnum("CompletedEmptyRecords"); - public static readonly StatusEnum Completed = new StatusEnum("Completed"); - public static readonly StatusEnum Failed = new StatusEnum("Failed"); - public static readonly StatusEnum Runningtobedeleted = new StatusEnum("RunningToBeDeleted"); - public static readonly StatusEnum Deletedbyuserrequest = new StatusEnum("DeletedByUserRequest"); - } - - private static Request BuildReadRequest(ReadExportCustomJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Jobs", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ExportCustomJob parameters - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ResourceSet Read(ReadExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("jobs", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ExportCustomJob parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task> ReadAsync(ReadExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("jobs", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ResourceSet Read(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExportCustomJobOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExportCustomJobOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Bulkexports) - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Bulkexports) - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - private static Request BuildCreateRequest(CreateExportCustomJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Jobs", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ExportCustomJob parameters - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ExportCustomJobResource Create(CreateExportCustomJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ExportCustomJob parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task CreateAsync(CreateExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - /// The optional webhook url called on completion of the job. If this is supplied, - /// `WebhookMethod` must also be supplied. - /// This is the method used to call the webhook on completion of the job. If this is - /// supplied, `WebhookUrl` must also be supplied. - /// The optional email to send the completion notification to - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ExportCustomJobResource Create(string pathResourceType, - string startDay, - string endDay, - string friendlyName, - string webhookUrl = null, - string webhookMethod = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName){WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - /// The optional webhook url called on completion of the job. If this is supplied, - /// `WebhookMethod` must also be supplied. - /// This is the method used to call the webhook on completion of the job. If this is - /// supplied, `WebhookUrl` must also be supplied. - /// The optional email to send the completion notification to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task CreateAsync(string pathResourceType, - string startDay, - string endDay, - string friendlyName, - string webhookUrl = null, - string webhookMethod = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName){WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportCustomJobResource object - /// - /// Raw JSON string - /// ExportCustomJobResource object represented by the provided JSON - public static ExportCustomJobResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The start day for the custom export specified as a string in the format of yyyy-MM-dd - /// - [JsonProperty("start_day")] - public string StartDay { get; private set; } - /// - /// The end day for the custom export specified as a string in the format of yyyy-MM-dd. This will be the last day exported. For instance, to export a single day, choose the same day for start and end day. To export the first 4 days of July, you would set the start date to 2020-07-01 and the end date to 2020-07-04. The end date must be the UTC day before yesterday. - /// - [JsonProperty("end_day")] - public string EndDay { get; private set; } - /// - /// The optional webhook url called on completion - /// - [JsonProperty("webhook_url")] - public string WebhookUrl { get; private set; } - /// - /// This is the method used to call the webhook - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The optional email to send the completion notification to - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The unique job_sid returned when the custom export was created. This can be used to look up the status of the job. - /// - [JsonProperty("job_sid")] - public string JobSid { get; private set; } - /// - /// The details of a job state which is an object that contains a `status` string, a day count integer, and list of days in the job - /// - [JsonProperty("details")] - public object Details { get; private set; } - /// - /// This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease - /// - [JsonProperty("job_queue_position")] - public string JobQueuePosition { get; private set; } - /// - /// this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position - /// - [JsonProperty("estimated_completion_time")] - public string EstimatedCompletionTime { get; private set; } - - private ExportCustomJobResource() - { - - } - } +{ + + public class ExportCustomJobResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Errorduringrun = new StatusEnum("ErrorDuringRun"); + public static readonly StatusEnum Submitted = new StatusEnum("Submitted"); + public static readonly StatusEnum Running = new StatusEnum("Running"); + public static readonly StatusEnum Completedemptyrecords = new StatusEnum("CompletedEmptyRecords"); + public static readonly StatusEnum Completed = new StatusEnum("Completed"); + public static readonly StatusEnum Failed = new StatusEnum("Failed"); + public static readonly StatusEnum Runningtobedeleted = new StatusEnum("RunningToBeDeleted"); + public static readonly StatusEnum Deletedbyuserrequest = new StatusEnum("DeletedByUserRequest"); + } + + private static Request BuildReadRequest(ReadExportCustomJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Jobs", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ExportCustomJob parameters + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ResourceSet Read(ReadExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("jobs", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ExportCustomJob parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task> ReadAsync(ReadExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("jobs", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ResourceSet Read(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExportCustomJobOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExportCustomJobOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Bulkexports) + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Bulkexports) + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + private static Request BuildCreateRequest(CreateExportCustomJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Jobs", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ExportCustomJob parameters + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ExportCustomJobResource Create(CreateExportCustomJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ExportCustomJob parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task CreateAsync(CreateExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + /// The optional webhook url called on completion of the job. If this is supplied, + /// `WebhookMethod` must also be supplied. + /// This is the method used to call the webhook on completion of the job. If this is + /// supplied, `WebhookUrl` must also be supplied. + /// The optional email to send the completion notification to + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ExportCustomJobResource Create(string pathResourceType, + string startDay, + string endDay, + string friendlyName, + string webhookUrl = null, + string webhookMethod = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName) { WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + /// The optional webhook url called on completion of the job. If this is supplied, + /// `WebhookMethod` must also be supplied. + /// This is the method used to call the webhook on completion of the job. If this is + /// supplied, `WebhookUrl` must also be supplied. + /// The optional email to send the completion notification to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task CreateAsync(string pathResourceType, + string startDay, + string endDay, + string friendlyName, + string webhookUrl = null, + string webhookMethod = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName) { WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportCustomJobResource object + /// + /// Raw JSON string + /// ExportCustomJobResource object represented by the provided JSON + public static ExportCustomJobResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The start day for the custom export specified as a string in the format of yyyy-MM-dd + /// + [JsonProperty("start_day")] + public string StartDay { get; private set; } + /// + /// The end day for the custom export specified as a string in the format of yyyy-MM-dd. This will be the last day exported. For instance, to export a single day, choose the same day for start and end day. To export the first 4 days of July, you would set the start date to 2020-07-01 and the end date to 2020-07-04. The end date must be the UTC day before yesterday. + /// + [JsonProperty("end_day")] + public string EndDay { get; private set; } + /// + /// The optional webhook url called on completion + /// + [JsonProperty("webhook_url")] + public string WebhookUrl { get; private set; } + /// + /// This is the method used to call the webhook + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The optional email to send the completion notification to + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The unique job_sid returned when the custom export was created. This can be used to look up the status of the job. + /// + [JsonProperty("job_sid")] + public string JobSid { get; private set; } + /// + /// The details of a job state which is an object that contains a `status` string, a day count integer, and list of days in the job + /// + [JsonProperty("details")] + public object Details { get; private set; } + /// + /// This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease + /// + [JsonProperty("job_queue_position")] + public string JobQueuePosition { get; private set; } + /// + /// this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position + /// + [JsonProperty("estimated_completion_time")] + public string EstimatedCompletionTime { get; private set; } + + private ExportCustomJobResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/JobOptions.cs b/src/Twilio/Rest/Bulkexports/V1/Export/JobOptions.cs index 101607929..5e0ee1b69 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/JobOptions.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/JobOptions.cs @@ -9,64 +9,64 @@ using Twilio.Converters; namespace Twilio.Rest.Bulkexports.V1.Export -{ - +{ + + /// + /// FetchJobOptions + /// + public class FetchJobOptions : IOptions + { /// - /// FetchJobOptions + /// The unique string that that we created to identify the Bulk Export job /// - public class FetchJobOptions : IOptions - { - /// - /// The unique string that that we created to identify the Bulk Export job - /// - public string PathJobSid { get; } - - /// - /// Construct a new FetchJobOptions - /// - /// The unique string that that we created to identify the Bulk Export job - public FetchJobOptions(string pathJobSid) - { - PathJobSid = pathJobSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathJobSid { get; } + /// - /// DeleteJobOptions + /// Construct a new FetchJobOptions /// - public class DeleteJobOptions : IOptions - { - /// - /// The unique string that that we created to identify the Bulk Export job - /// - public string PathJobSid { get; } - - /// - /// Construct a new DeleteJobOptions - /// - /// The unique string that that we created to identify the Bulk Export job - public DeleteJobOptions(string pathJobSid) - { - PathJobSid = pathJobSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique string that that we created to identify the Bulk Export job + public FetchJobOptions(string pathJobSid) + { + PathJobSid = pathJobSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteJobOptions + /// + public class DeleteJobOptions : IOptions + { + /// + /// The unique string that that we created to identify the Bulk Export job + /// + public string PathJobSid { get; } + + /// + /// Construct a new DeleteJobOptions + /// + /// The unique string that that we created to identify the Bulk Export job + public DeleteJobOptions(string pathJobSid) + { + PathJobSid = pathJobSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/Export/JobResource.cs b/src/Twilio/Rest/Bulkexports/V1/Export/JobResource.cs index 9de8518ee..caa404c1d 100644 --- a/src/Twilio/Rest/Bulkexports/V1/Export/JobResource.cs +++ b/src/Twilio/Rest/Bulkexports/V1/Export/JobResource.cs @@ -17,245 +17,245 @@ using Twilio.Types; namespace Twilio.Rest.Bulkexports.V1.Export -{ - - public class JobResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Errorduringrun = new StatusEnum("ErrorDuringRun"); - public static readonly StatusEnum Submitted = new StatusEnum("Submitted"); - public static readonly StatusEnum Running = new StatusEnum("Running"); - public static readonly StatusEnum Completedemptyrecords = new StatusEnum("CompletedEmptyRecords"); - public static readonly StatusEnum Completed = new StatusEnum("Completed"); - public static readonly StatusEnum Failed = new StatusEnum("Failed"); - public static readonly StatusEnum Runningtobedeleted = new StatusEnum("RunningToBeDeleted"); - public static readonly StatusEnum Deletedbyuserrequest = new StatusEnum("DeletedByUserRequest"); - } - - private static Request BuildFetchRequest(FetchJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/Jobs/" + options.PathJobSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Job parameters - /// Client to make requests to Twilio - /// A single instance of Job - public static JobResource Fetch(FetchJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Job parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task FetchAsync(FetchJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// A single instance of Job - public static JobResource Fetch(string pathJobSid, ITwilioRestClient client = null) - { - var options = new FetchJobOptions(pathJobSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task FetchAsync(string pathJobSid, - ITwilioRestClient client = null) - { - var options = new FetchJobOptions(pathJobSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Bulkexports, - "/v1/Exports/Jobs/" + options.PathJobSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Job parameters - /// Client to make requests to Twilio - /// A single instance of Job - public static bool Delete(DeleteJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Job parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task DeleteAsync(DeleteJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// A single instance of Job - public static bool Delete(string pathJobSid, ITwilioRestClient client = null) - { - var options = new DeleteJobOptions(pathJobSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task DeleteAsync(string pathJobSid, ITwilioRestClient client = null) - { - var options = new DeleteJobOptions(pathJobSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a JobResource object - /// - /// Raw JSON string - /// JobResource object represented by the provided JSON - public static JobResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The details of a job state which is an object that contains a `status` string, a day count integer, and list of days in the job - /// - [JsonProperty("details")] - public object Details { get; private set; } - /// - /// The start time for the export specified when creating the job - /// - [JsonProperty("start_day")] - public string StartDay { get; private set; } - /// - /// The end time for the export specified when creating the job - /// - [JsonProperty("end_day")] - public string EndDay { get; private set; } - /// - /// The job_sid returned when the export was created - /// - [JsonProperty("job_sid")] - public string JobSid { get; private set; } - /// - /// The optional webhook url called on completion - /// - [JsonProperty("webhook_url")] - public string WebhookUrl { get; private set; } - /// - /// This is the method used to call the webhook - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The optional email to send the completion notification to - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease - /// - [JsonProperty("job_queue_position")] - public string JobQueuePosition { get; private set; } - /// - /// this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position - /// - [JsonProperty("estimated_completion_time")] - public string EstimatedCompletionTime { get; private set; } - - private JobResource() - { - - } - } +{ + + public class JobResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Errorduringrun = new StatusEnum("ErrorDuringRun"); + public static readonly StatusEnum Submitted = new StatusEnum("Submitted"); + public static readonly StatusEnum Running = new StatusEnum("Running"); + public static readonly StatusEnum Completedemptyrecords = new StatusEnum("CompletedEmptyRecords"); + public static readonly StatusEnum Completed = new StatusEnum("Completed"); + public static readonly StatusEnum Failed = new StatusEnum("Failed"); + public static readonly StatusEnum Runningtobedeleted = new StatusEnum("RunningToBeDeleted"); + public static readonly StatusEnum Deletedbyuserrequest = new StatusEnum("DeletedByUserRequest"); + } + + private static Request BuildFetchRequest(FetchJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/Jobs/" + options.PathJobSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Job parameters + /// Client to make requests to Twilio + /// A single instance of Job + public static JobResource Fetch(FetchJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Job parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task FetchAsync(FetchJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// A single instance of Job + public static JobResource Fetch(string pathJobSid, ITwilioRestClient client = null) + { + var options = new FetchJobOptions(pathJobSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task FetchAsync(string pathJobSid, + ITwilioRestClient client = null) + { + var options = new FetchJobOptions(pathJobSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Bulkexports, + "/v1/Exports/Jobs/" + options.PathJobSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Job parameters + /// Client to make requests to Twilio + /// A single instance of Job + public static bool Delete(DeleteJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Job parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task DeleteAsync(DeleteJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// A single instance of Job + public static bool Delete(string pathJobSid, ITwilioRestClient client = null) + { + var options = new DeleteJobOptions(pathJobSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task DeleteAsync(string pathJobSid, ITwilioRestClient client = null) + { + var options = new DeleteJobOptions(pathJobSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a JobResource object + /// + /// Raw JSON string + /// JobResource object represented by the provided JSON + public static JobResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The details of a job state which is an object that contains a `status` string, a day count integer, and list of days in the job + /// + [JsonProperty("details")] + public object Details { get; private set; } + /// + /// The start time for the export specified when creating the job + /// + [JsonProperty("start_day")] + public string StartDay { get; private set; } + /// + /// The end time for the export specified when creating the job + /// + [JsonProperty("end_day")] + public string EndDay { get; private set; } + /// + /// The job_sid returned when the export was created + /// + [JsonProperty("job_sid")] + public string JobSid { get; private set; } + /// + /// The optional webhook url called on completion + /// + [JsonProperty("webhook_url")] + public string WebhookUrl { get; private set; } + /// + /// This is the method used to call the webhook + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The optional email to send the completion notification to + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease + /// + [JsonProperty("job_queue_position")] + public string JobQueuePosition { get; private set; } + /// + /// this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position + /// + [JsonProperty("estimated_completion_time")] + public string EstimatedCompletionTime { get; private set; } + + private JobResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationOptions.cs b/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationOptions.cs index 427b6a877..49e2774c9 100644 --- a/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationOptions.cs +++ b/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationOptions.cs @@ -9,91 +9,91 @@ using Twilio.Converters; namespace Twilio.Rest.Bulkexports.V1 -{ - +{ + + /// + /// Fetch a specific Export Configuration. + /// + public class FetchExportConfigurationOptions : IOptions + { /// - /// Fetch a specific Export Configuration. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchExportConfigurationOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new FetchExportConfigurationOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public FetchExportConfigurationOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathResourceType { get; } + /// - /// Update a specific Export Configuration. + /// Construct a new FetchExportConfigurationOptions /// - public class UpdateExportConfigurationOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// Whether files are automatically generated - /// - public bool? Enabled { get; set; } - /// - /// URL targeted at export - /// - public Uri WebhookUrl { get; set; } - /// - /// Whether to GET or POST to the webhook url - /// - public string WebhookMethod { get; set; } - - /// - /// Construct a new UpdateExportConfigurationOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public UpdateExportConfigurationOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - return p; - } - } + /// The type of communication – Messages, Calls, Conferences, and Participants + public FetchExportConfigurationOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update a specific Export Configuration. + /// + public class UpdateExportConfigurationOptions : IOptions + { + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + /// + /// Whether files are automatically generated + /// + public bool? Enabled { get; set; } + /// + /// URL targeted at export + /// + public Uri WebhookUrl { get; set; } + /// + /// Whether to GET or POST to the webhook url + /// + public string WebhookMethod { get; set; } + + /// + /// Construct a new UpdateExportConfigurationOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public UpdateExportConfigurationOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationResource.cs b/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationResource.cs index b23476db2..92239642a 100644 --- a/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationResource.cs +++ b/src/Twilio/Rest/Bulkexports/V1/ExportConfigurationResource.cs @@ -16,207 +16,207 @@ using Twilio.Http; namespace Twilio.Rest.Bulkexports.V1 -{ - - public class ExportConfigurationResource : Resource - { - private static Request BuildFetchRequest(FetchExportConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Configuration", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Export Configuration. - /// - /// Fetch ExportConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Fetch(FetchExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Export Configuration. - /// - /// Fetch ExportConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task FetchAsync(FetchExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Fetch(string pathResourceType, ITwilioRestClient client = null) - { - var options = new FetchExportConfigurationOptions(pathResourceType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - ITwilioRestClient client = null) - { - var options = new FetchExportConfigurationOptions(pathResourceType); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateExportConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Export Configuration. - /// - /// Update ExportConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Update(UpdateExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Export Configuration. - /// - /// Update ExportConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Whether files are automatically generated - /// URL targeted at export - /// Whether to GET or POST to the webhook url - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Update(string pathResourceType, - bool? enabled = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateExportConfigurationOptions(pathResourceType){Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Whether files are automatically generated - /// URL targeted at export - /// Whether to GET or POST to the webhook url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(string pathResourceType, - bool? enabled = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateExportConfigurationOptions(pathResourceType){Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportConfigurationResource object - /// - /// Raw JSON string - /// ExportConfigurationResource object represented by the provided JSON - public static ExportConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Whether files are automatically generated - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// URL targeted at export - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// Whether to GET or POST to the webhook url - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExportConfigurationResource() - { - - } - } +{ + + public class ExportConfigurationResource : Resource + { + private static Request BuildFetchRequest(FetchExportConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Configuration", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Export Configuration. + /// + /// Fetch ExportConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Fetch(FetchExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Export Configuration. + /// + /// Fetch ExportConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task FetchAsync(FetchExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Fetch(string pathResourceType, ITwilioRestClient client = null) + { + var options = new FetchExportConfigurationOptions(pathResourceType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + ITwilioRestClient client = null) + { + var options = new FetchExportConfigurationOptions(pathResourceType); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateExportConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Export Configuration. + /// + /// Update ExportConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Update(UpdateExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Export Configuration. + /// + /// Update ExportConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Whether files are automatically generated + /// URL targeted at export + /// Whether to GET or POST to the webhook url + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Update(string pathResourceType, + bool? enabled = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateExportConfigurationOptions(pathResourceType) { Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Whether files are automatically generated + /// URL targeted at export + /// Whether to GET or POST to the webhook url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(string pathResourceType, + bool? enabled = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateExportConfigurationOptions(pathResourceType) { Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportConfigurationResource object + /// + /// Raw JSON string + /// ExportConfigurationResource object represented by the provided JSON + public static ExportConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Whether files are automatically generated + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// URL targeted at export + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// Whether to GET or POST to the webhook url + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExportConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/ExportOptions.cs b/src/Twilio/Rest/Bulkexports/V1/ExportOptions.cs index 278948b81..130c5c0c2 100644 --- a/src/Twilio/Rest/Bulkexports/V1/ExportOptions.cs +++ b/src/Twilio/Rest/Bulkexports/V1/ExportOptions.cs @@ -9,35 +9,35 @@ using Twilio.Converters; namespace Twilio.Rest.Bulkexports.V1 -{ - +{ + + /// + /// Fetch a specific Export. + /// + public class FetchExportOptions : IOptions + { /// - /// Fetch a specific Export. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchExportOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new FetchExportOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public FetchExportOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathResourceType { get; } + + /// + /// Construct a new FetchExportOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public FetchExportOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Bulkexports/V1/ExportResource.cs b/src/Twilio/Rest/Bulkexports/V1/ExportResource.cs index 00a78b3ee..807b9e40c 100644 --- a/src/Twilio/Rest/Bulkexports/V1/ExportResource.cs +++ b/src/Twilio/Rest/Bulkexports/V1/ExportResource.cs @@ -16,115 +16,115 @@ using Twilio.Http; namespace Twilio.Rest.Bulkexports.V1 -{ - - public class ExportResource : Resource - { - private static Request BuildFetchRequest(FetchExportOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Bulkexports, - "/v1/Exports/" + options.PathResourceType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Export. - /// - /// Fetch Export parameters - /// Client to make requests to Twilio - /// A single instance of Export - public static ExportResource Fetch(FetchExportOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Export. - /// - /// Fetch Export parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Export - public static async System.Threading.Tasks.Task FetchAsync(FetchExportOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Export. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// A single instance of Export - public static ExportResource Fetch(string pathResourceType, ITwilioRestClient client = null) - { - var options = new FetchExportOptions(pathResourceType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Export. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Export - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - ITwilioRestClient client = null) - { - var options = new FetchExportOptions(pathResourceType); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportResource object - /// - /// Raw JSON string - /// ExportResource object represented by the provided JSON - public static ExportResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExportResource() - { - - } - } +{ + + public class ExportResource : Resource + { + private static Request BuildFetchRequest(FetchExportOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Bulkexports, + "/v1/Exports/" + options.PathResourceType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Export. + /// + /// Fetch Export parameters + /// Client to make requests to Twilio + /// A single instance of Export + public static ExportResource Fetch(FetchExportOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Export. + /// + /// Fetch Export parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Export + public static async System.Threading.Tasks.Task FetchAsync(FetchExportOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Export. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// A single instance of Export + public static ExportResource Fetch(string pathResourceType, ITwilioRestClient client = null) + { + var options = new FetchExportOptions(pathResourceType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Export. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Export + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + ITwilioRestClient client = null) + { + var options = new FetchExportOptions(pathResourceType); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportResource object + /// + /// Raw JSON string + /// ExportResource object represented by the provided JSON + public static ExportResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExportResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/CredentialOptions.cs b/src/Twilio/Rest/Chat/V1/CredentialOptions.cs index 18740807d..90ed4518d 100644 --- a/src/Twilio/Rest/Chat/V1/CredentialOptions.cs +++ b/src/Twilio/Rest/Chat/V1/CredentialOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1 -{ - +{ + + /// + /// ReadCredentialOptions + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// ReadCredentialOptions + /// Generate the necessary parameters /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateCredentialOptions + /// + public class CreateCredentialOptions : IOptions + { /// - /// CreateCredentialOptions + /// The type of push-notification service the credential is for /// - public class CreateCredentialOptions : IOptions - { - /// - /// The type of push-notification service the credential is for - /// - public CredentialResource.PushServiceEnum Type { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The type of push-notification service the credential is for - public CreateCredentialOptions(CredentialResource.PushServiceEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushServiceEnum Type { get; } /// - /// FetchCredentialOptions + /// A string to describe the resource /// - public class FetchCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The unique string that identifies the resource - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// UpdateCredentialOptions + /// [APN only] The URL encoded representation of the certificate /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The unique string that identifies the resource - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string Certificate { get; set; } /// - /// DeleteCredentialOptions + /// [APN only] The URL encoded representation of the private key /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The unique string that identifies the resource - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The type of push-notification service the credential is for + public CreateCredentialOptions(CredentialResource.PushServiceEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// FetchCredentialOptions + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The unique string that identifies the resource + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateCredentialOptions + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// [APN only] The URL encoded representation of the certificate + /// + public string Certificate { get; set; } + /// + /// [APN only] The URL encoded representation of the private key + /// + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The unique string that identifies the resource + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// DeleteCredentialOptions + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The unique string that identifies the resource + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/CredentialResource.cs b/src/Twilio/Rest/Chat/V1/CredentialResource.cs index 22182f6cd..4affbbf33 100644 --- a/src/Twilio/Rest/Chat/V1/CredentialResource.cs +++ b/src/Twilio/Rest/Chat/V1/CredentialResource.cs @@ -17,538 +17,538 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V1 -{ - - public class CredentialResource : Resource - { - public sealed class PushServiceEnum : StringEnum - { - private PushServiceEnum(string value) : base(value) {} - public PushServiceEnum() {} - public static implicit operator PushServiceEnum(string value) - { - return new PushServiceEnum(value); - } - - public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); - public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); - public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); - } - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type of push-notification service the credential is for - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type of push-notification service the credential is for - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of push-notification service the credential is for - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushServiceEnum Type { get; private set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Credential resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushServiceEnum : StringEnum + { + private PushServiceEnum(string value) : base(value) { } + public PushServiceEnum() { } + public static implicit operator PushServiceEnum(string value) + { + return new PushServiceEnum(value); + } + + public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); + public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); + public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); + } + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type of push-notification service the credential is for + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type of push-notification service the credential is for + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of push-notification service the credential is for + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushServiceEnum Type { get; private set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Credential resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/InviteOptions.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/InviteOptions.cs index 1ca126d43..f61762427 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/InviteOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/InviteOptions.cs @@ -10,193 +10,193 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - +{ + + /// + /// FetchInviteOptions + /// + public class FetchInviteOptions : IOptions + { /// - /// FetchInviteOptions - /// - public class FetchInviteOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to fetch belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInviteOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The unique string that identifies the resource - public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// CreateInviteOptions - /// - public class CreateInviteOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the new resource belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The Role assigned to the new member - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateInviteOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + /// The SID of the Channel the resource to fetch belongs to + /// + public string PathChannelSid { get; } /// - /// ReadInviteOptions - /// - public class ReadInviteOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resources to read belong to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadInviteOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - public ReadInviteOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// DeleteInviteOptions - /// - public class DeleteInviteOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInviteOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The unique string that identifies the resource - public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchInviteOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The unique string that identifies the resource + public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateInviteOptions + /// + public class CreateInviteOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the new resource belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The Role assigned to the new member + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateInviteOptions + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadInviteOptions + /// + public class ReadInviteOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resources to read belong to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value of the resources to read + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadInviteOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + public ReadInviteOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteInviteOptions + /// + public class DeleteInviteOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resource to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInviteOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The unique string that identifies the resource + public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/InviteResource.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/InviteResource.cs index d1023f784..ed5d66430 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/InviteResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/InviteResource.cs @@ -16,456 +16,456 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - - public class InviteResource : Resource - { - private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - /// The Role assigned to the new member - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - /// The Role assigned to the new member - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a InviteResource object - /// - /// Raw JSON string - /// InviteResource object represented by the provided JSON - public static InviteResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Channel the new resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Role assigned to the member - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The identity of the User that created the invite - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The absolute URL of the Invite resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InviteResource() - { - - } - } +{ + + public class InviteResource : Resource + { + private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + /// The Role assigned to the new member + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + /// The Role assigned to the new member + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a InviteResource object + /// + /// Raw JSON string + /// InviteResource object represented by the provided JSON + public static InviteResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Channel the new resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Role assigned to the member + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The identity of the User that created the invite + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The absolute URL of the Invite resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InviteResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/MemberOptions.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/MemberOptions.cs index 03cf3fd2e..4de89f4bc 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/MemberOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/MemberOptions.cs @@ -10,252 +10,252 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - +{ + + /// + /// FetchMemberOptions + /// + public class FetchMemberOptions : IOptions + { /// - /// FetchMemberOptions + /// The SID of the Service to fetch the resource from /// - public class FetchMemberOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the member belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMemberOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the channel the member belongs to - /// The unique string that identifies the resource - public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// CreateMemberOptions + /// The unique ID of the channel the member belongs to /// - public class CreateMemberOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the new member belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The SID of the Role to assign to the member - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateMemberOptions - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + public string PathChannelSid { get; } /// - /// ReadMemberOptions + /// The unique string that identifies the resource /// - public class ReadMemberOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the member belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadMemberOptions - /// - /// The SID of the Service to read the resources from - /// The unique ID of the channel the member belongs to - public ReadMemberOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteMemberOptions + /// Construct a new FetchMemberOptions /// - public class DeleteMemberOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the message to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMemberOptions - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The unique ID of the channel the member belongs to + /// The unique string that identifies the resource + public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMemberOptions + /// Generate the necessary parameters /// - public class UpdateMemberOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the member to update belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The SID of the Role to assign to the member - /// - public string RoleSid { get; set; } - /// - /// The index of the last consumed Message for the Channel for the Member - /// - public int? LastConsumedMessageIndex { get; set; } - - /// - /// Construct a new UpdateMemberOptions - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the member to update belongs to - /// The unique string that identifies the resource - public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMemberOptions + /// + public class CreateMemberOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the new member belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The SID of the Role to assign to the member + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateMemberOptions + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadMemberOptions + /// + public class ReadMemberOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the member belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value of the resources to read + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadMemberOptions + /// + /// The SID of the Service to read the resources from + /// The unique ID of the channel the member belongs to + public ReadMemberOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMemberOptions + /// + public class DeleteMemberOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the message to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMemberOptions + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateMemberOptions + /// + public class UpdateMemberOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the member to update belongs to + /// + public string PathChannelSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The SID of the Role to assign to the member + /// + public string RoleSid { get; set; } + /// + /// The index of the last consumed Message for the Channel for the Member + /// + public int? LastConsumedMessageIndex { get; set; } + + /// + /// Construct a new UpdateMemberOptions + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the member to update belongs to + /// The unique string that identifies the resource + public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/MemberResource.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/MemberResource.cs index 9050b871f..1521cabdc 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/MemberResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/MemberResource.cs @@ -16,547 +16,547 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - - public class MemberResource : Resource - { - private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the channel the member belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the channel the member belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - /// The SID of the Role to assign to the member - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - /// The SID of the Role to assign to the member - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The unique ID of the channel the member belongs to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The unique ID of the channel the member belongs to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the member to update belongs to - /// The unique string that identifies the resource - /// The SID of the Role to assign to the member - /// The index of the last consumed Message for the Channel for the Member - /// - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the member to update belongs to - /// The unique string that identifies the resource - /// The SID of the Role to assign to the member - /// The index of the last consumed Message for the Channel for the Member - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MemberResource object - /// - /// Raw JSON string - /// MemberResource object represented by the provided JSON - public static MemberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Channel for the member - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Role assigned to the member - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The index of the last Message that the Member has read within the Channel - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The ISO 8601 based timestamp string that represents the date-time of the last Message read event for the Member within the Channel - /// - [JsonProperty("last_consumption_timestamp")] - public DateTime? LastConsumptionTimestamp { get; private set; } - /// - /// The absolute URL of the Member resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MemberResource() - { - - } - } +{ + + public class MemberResource : Resource + { + private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique ID of the channel the member belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique ID of the channel the member belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + /// The SID of the Role to assign to the member + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + /// The SID of the Role to assign to the member + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The unique ID of the channel the member belongs to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The unique ID of the channel the member belongs to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the member to update belongs to + /// The unique string that identifies the resource + /// The SID of the Role to assign to the member + /// The index of the last consumed Message for the Channel for the Member + /// + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the member to update belongs to + /// The unique string that identifies the resource + /// The SID of the Role to assign to the member + /// The index of the last consumed Message for the Channel for the Member + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MemberResource object + /// + /// Raw JSON string + /// MemberResource object represented by the provided JSON + public static MemberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Channel for the member + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Role assigned to the member + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The index of the last Message that the Member has read within the Channel + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The ISO 8601 based timestamp string that represents the date-time of the last Message read event for the Member within the Channel + /// + [JsonProperty("last_consumption_timestamp")] + public DateTime? LastConsumptionTimestamp { get; private set; } + /// + /// The absolute URL of the Member resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MemberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/MessageOptions.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/MessageOptions.cs index c73f0bb4b..2c446ce02 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/MessageOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/MessageOptions.cs @@ -9,260 +9,260 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - +{ + + /// + /// FetchMessageOptions + /// + public class FetchMessageOptions : IOptions + { /// - /// FetchMessageOptions + /// The SID of the Service to fetch the resource from /// - public class FetchMessageOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the Channel the message to fetch belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the Channel the message to fetch belongs to - /// The unique string that identifies the resource - public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// CreateMessageOptions + /// The unique ID of the Channel the message to fetch belongs to /// - public class CreateMessageOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the new resource belongs to - /// - public string PathChannelSid { get; } - /// - /// The message to send to the channel - /// - public string Body { get; } - /// - /// The identity of the new message's author - /// - public string From { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new resource belongs to - /// The message to send to the channel - public CreateMessageOptions(string pathServiceSid, string pathChannelSid, string body) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Body = body; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } - + public string PathChannelSid { get; } /// - /// ReadMessageOptions + /// The unique string that identifies the resource /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the Channel the message to read belongs to - /// - public string PathChannelSid { get; } - /// - /// The sort order of the returned messages - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The SID of the Service to read the resources from - /// The unique ID of the Channel the message to read belongs to - public ReadMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteMessageOptions + /// Construct a new FetchMessageOptions /// - public class DeleteMessageOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique ID of the channel the message to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The unique ID of the Channel the message to fetch belongs to + /// The unique string that identifies the resource + public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMessageOptions + /// Generate the necessary parameters /// - public class UpdateMessageOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// he unique ID of the Channel the message belongs to - /// - public string PathChannelSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The message to send to the channel - /// - public string Body { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The SID of the Service to update the resource from - /// he unique ID of the Channel the message belongs to - /// The unique string that identifies the resource - public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMessageOptions + /// + public class CreateMessageOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the new resource belongs to + /// + public string PathChannelSid { get; } + /// + /// The message to send to the channel + /// + public string Body { get; } + /// + /// The identity of the new message's author + /// + public string From { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new resource belongs to + /// The message to send to the channel + public CreateMessageOptions(string pathServiceSid, string pathChannelSid, string body) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Body = body; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } + + /// + /// ReadMessageOptions + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the Channel the message to read belongs to + /// + public string PathChannelSid { get; } + /// + /// The sort order of the returned messages + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The SID of the Service to read the resources from + /// The unique ID of the Channel the message to read belongs to + public ReadMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMessageOptions + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique ID of the channel the message to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateMessageOptions + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// he unique ID of the Channel the message belongs to + /// + public string PathChannelSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The message to send to the channel + /// + public string Body { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The SID of the Service to update the resource from + /// he unique ID of the Channel the message belongs to + /// The unique string that identifies the resource + public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/Channel/MessageResource.cs b/src/Twilio/Rest/Chat/V1/Service/Channel/MessageResource.cs index fb23d4955..19aea068e 100644 --- a/src/Twilio/Rest/Chat/V1/Service/Channel/MessageResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/Channel/MessageResource.cs @@ -17,572 +17,572 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V1.Service.Channel -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the Channel the message to fetch belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique ID of the Channel the message to fetch belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new resource belongs to - /// The message to send to the channel - /// The identity of the new message's author - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathServiceSid, - string pathChannelSid, - string body, - string from = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body){From = from, Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The unique ID of the channel the new resource belongs to - /// The message to send to the channel - /// The identity of the new message's author - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string body, - string from = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body){From = from, Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The unique ID of the Channel the message to read belongs to - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The unique ID of the Channel the message to read belongs to - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique ID of the channel the message to delete belongs to - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// he unique ID of the Channel the message belongs to - /// The unique string that identifies the resource - /// The message to send to the channel - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// he unique ID of the Channel the message belongs to - /// The unique string that identifies the resource - /// The message to send to the channel - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Channel that the message was sent to - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The unique ID of the Channel the Message resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Whether the message has been edited since it was created - /// - [JsonProperty("was_edited")] - public bool? WasEdited { get; private set; } - /// - /// The identity of the message's author - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The content of the message - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The index of the message within the Channel - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The absolute URL of the Message resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique ID of the Channel the message to fetch belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique ID of the Channel the message to fetch belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new resource belongs to + /// The message to send to the channel + /// The identity of the new message's author + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathServiceSid, + string pathChannelSid, + string body, + string from = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body) { From = from, Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The unique ID of the channel the new resource belongs to + /// The message to send to the channel + /// The identity of the new message's author + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string body, + string from = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body) { From = from, Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The unique ID of the Channel the message to read belongs to + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The unique ID of the Channel the message to read belongs to + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique ID of the channel the message to delete belongs to + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// he unique ID of the Channel the message belongs to + /// The unique string that identifies the resource + /// The message to send to the channel + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// he unique ID of the Channel the message belongs to + /// The unique string that identifies the resource + /// The message to send to the channel + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Channel that the message was sent to + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The unique ID of the Channel the Message resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Whether the message has been edited since it was created + /// + [JsonProperty("was_edited")] + public bool? WasEdited { get; private set; } + /// + /// The identity of the message's author + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The content of the message + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The index of the message within the Channel + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The absolute URL of the Message resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/ChannelOptions.cs b/src/Twilio/Rest/Chat/V1/Service/ChannelOptions.cs index 53e3fca7c..72115deb8 100644 --- a/src/Twilio/Rest/Chat/V1/Service/ChannelOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/ChannelOptions.cs @@ -10,247 +10,247 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service -{ - +{ + + /// + /// FetchChannelOptions + /// + public class FetchChannelOptions : IOptions + { /// - /// FetchChannelOptions + /// The SID of the Service to fetch the resource from /// - public class FetchChannelOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChannelOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - public FetchChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// DeleteChannelOptions + /// The unique string that identifies the resource /// - public class DeleteChannelOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteChannelOptions - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - public DeleteChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateChannelOptions + /// Construct a new FetchChannelOptions /// - public class CreateChannelOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The visibility of the channel - /// - public ChannelResource.ChannelTypeEnum Type { get; set; } - - /// - /// Construct a new CreateChannelOptions - /// - /// The SID of the Service to create the resource under - public CreateChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + public FetchChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadChannelOptions + /// Generate the necessary parameters /// - public class ReadChannelOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The visibility of the channel to read - /// - public List Type { get; set; } - - /// - /// Construct a new ReadChannelOptions - /// - /// The SID of the Service to read the resources from - public ReadChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Type = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteChannelOptions + /// + public class DeleteChannelOptions : IOptions + { /// - /// UpdateChannelOptions + /// The SID of the Service to delete the resource from /// - public class UpdateChannelOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - - /// - /// Construct a new UpdateChannelOptions - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - public UpdateChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteChannelOptions + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + public DeleteChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateChannelOptions + /// + public class CreateChannelOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The visibility of the channel + /// + public ChannelResource.ChannelTypeEnum Type { get; set; } + + /// + /// Construct a new CreateChannelOptions + /// + /// The SID of the Service to create the resource under + public CreateChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + return p; + } + } + + /// + /// ReadChannelOptions + /// + public class ReadChannelOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The visibility of the channel to read + /// + public List Type { get; set; } + + /// + /// Construct a new ReadChannelOptions + /// + /// The SID of the Service to read the resources from + public ReadChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Type = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateChannelOptions + /// + public class UpdateChannelOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + + /// + /// Construct a new UpdateChannelOptions + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + public UpdateChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/ChannelResource.cs b/src/Twilio/Rest/Chat/V1/Service/ChannelResource.cs index 6b7ec2d22..1f1f23d77 100644 --- a/src/Twilio/Rest/Chat/V1/Service/ChannelResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/ChannelResource.cs @@ -17,562 +17,562 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V1.Service -{ - - public class ChannelResource : Resource - { - public sealed class ChannelTypeEnum : StringEnum - { - private ChannelTypeEnum(string value) : base(value) {} - public ChannelTypeEnum() {} - public static implicit operator ChannelTypeEnum(string value) - { - return new ChannelTypeEnum(value); - } - - public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); - public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); - } - - private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// The visibility of the channel - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// The visibility of the channel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The visibility of the channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The visibility of the channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The visibility of the channel. Can be: `public` or `private` - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public ChannelResource.ChannelTypeEnum Type { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the User that created the channel - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The number of Members in the Channel - /// - [JsonProperty("members_count")] - public int? MembersCount { get; private set; } - /// - /// The number of Messages in the Channel - /// - [JsonProperty("messages_count")] - public int? MessagesCount { get; private set; } - /// - /// The absolute URL of the Channel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + public sealed class ChannelTypeEnum : StringEnum + { + private ChannelTypeEnum(string value) : base(value) { } + public ChannelTypeEnum() { } + public static implicit operator ChannelTypeEnum(string value) + { + return new ChannelTypeEnum(value); + } + + public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); + public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); + } + + private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// The visibility of the channel + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// The visibility of the channel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The visibility of the channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The visibility of the channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The visibility of the channel. Can be: `public` or `private` + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public ChannelResource.ChannelTypeEnum Type { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the User that created the channel + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The number of Members in the Channel + /// + [JsonProperty("members_count")] + public int? MembersCount { get; private set; } + /// + /// The number of Messages in the Channel + /// + [JsonProperty("messages_count")] + public int? MessagesCount { get; private set; } + /// + /// The absolute URL of the Channel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/RoleOptions.cs b/src/Twilio/Rest/Chat/V1/Service/RoleOptions.cs index 206da86ba..398770e03 100644 --- a/src/Twilio/Rest/Chat/V1/Service/RoleOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/RoleOptions.cs @@ -10,221 +10,221 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service -{ - +{ + + /// + /// FetchRoleOptions + /// + public class FetchRoleOptions : IOptions + { /// - /// FetchRoleOptions - /// - public class FetchRoleOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - public FetchRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// DeleteRoleOptions - /// - public class DeleteRoleOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - public DeleteRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// CreateRoleOptions - /// - public class CreateRoleOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; } - /// - /// The type of role - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - public CreateRoleOptions(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// Construct a new FetchRoleOptions + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + public FetchRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadRoleOptions + /// Generate the necessary parameters /// - public class ReadRoleOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadRoleOptions - /// - /// The SID of the Service to read the resources from - public ReadRoleOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteRoleOptions + /// + public class DeleteRoleOptions : IOptions + { /// - /// UpdateRoleOptions - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// A permission the role should have - public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + public DeleteRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRoleOptions + /// + public class CreateRoleOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; } + /// + /// The type of role + /// + public RoleResource.RoleTypeEnum Type { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new CreateRoleOptions + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + public CreateRoleOptions(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// ReadRoleOptions + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadRoleOptions + /// + /// The SID of the Service to read the resources from + public ReadRoleOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateRoleOptions + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// A permission the role should have + public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/RoleResource.cs b/src/Twilio/Rest/Chat/V1/Service/RoleResource.cs index 1744cb3d9..459ce0aea 100644 --- a/src/Twilio/Rest/Chat/V1/Service/RoleResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/RoleResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V1.Service -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); - public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); - } - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of role - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// An array of the permissions the role has been granted - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Role resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); + public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); + } + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of role + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// An array of the permissions the role has been granted + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Role resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/User/UserChannelOptions.cs b/src/Twilio/Rest/Chat/V1/Service/User/UserChannelOptions.cs index 1cd6fcde6..0a706c1f0 100644 --- a/src/Twilio/Rest/Chat/V1/Service/User/UserChannelOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/User/UserChannelOptions.cs @@ -9,46 +9,46 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service.User -{ - +{ + + /// + /// List all Channels for a given User. + /// + public class ReadUserChannelOptions : ReadOptions + { /// - /// List all Channels for a given User. + /// The SID of the Service to read the resources from /// - public class ReadUserChannelOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User to fetch the User Channel resources from - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserChannelOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the User to fetch the User Channel resources from + /// + public string PathUserSid { get; } + + /// + /// Construct a new ReadUserChannelOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/User/UserChannelResource.cs b/src/Twilio/Rest/Chat/V1/Service/User/UserChannelResource.cs index 3885a1609..58a55e16d 100644 --- a/src/Twilio/Rest/Chat/V1/Service/User/UserChannelResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/User/UserChannelResource.cs @@ -17,225 +17,225 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V1.Service.User -{ - - public class UserChannelResource : Resource - { - public sealed class ChannelStatusEnum : StringEnum - { - private ChannelStatusEnum(string value) : base(value) {} - public ChannelStatusEnum() {} - public static implicit operator ChannelStatusEnum(string value) - { - return new ChannelStatusEnum(value); - } - - public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); - public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); - public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); - } - - private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List all Channels for a given User. - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List all Channels for a given User. - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List all Channels for a given User. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List all Channels for a given User. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Converts a JSON string into a UserChannelResource object - /// - /// Raw JSON string - /// UserChannelResource object represented by the provided JSON - public static UserChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Channel the resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the User as a Member in the Channel - /// - [JsonProperty("member_sid")] - public string MemberSid { get; private set; } - /// - /// The status of the User on the Channel - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.ChannelStatusEnum Status { get; private set; } - /// - /// The index of the last Message in the Channel the Member has read - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The number of unread Messages in the Channel for the User - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserChannelResource() - { - - } - } +{ + + public class UserChannelResource : Resource + { + public sealed class ChannelStatusEnum : StringEnum + { + private ChannelStatusEnum(string value) : base(value) { } + public ChannelStatusEnum() { } + public static implicit operator ChannelStatusEnum(string value) + { + return new ChannelStatusEnum(value); + } + + public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); + public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); + public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); + } + + private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List all Channels for a given User. + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List all Channels for a given User. + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List all Channels for a given User. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List all Channels for a given User. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Converts a JSON string into a UserChannelResource object + /// + /// Raw JSON string + /// UserChannelResource object represented by the provided JSON + public static UserChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Channel the resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the User as a Member in the Channel + /// + [JsonProperty("member_sid")] + public string MemberSid { get; private set; } + /// + /// The status of the User on the Channel + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.ChannelStatusEnum Status { get; private set; } + /// + /// The index of the last Message in the Channel the Member has read + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The number of unread Messages in the Channel for the User + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/UserOptions.cs b/src/Twilio/Rest/Chat/V1/Service/UserOptions.cs index aa3bf1d11..472d14cd1 100644 --- a/src/Twilio/Rest/Chat/V1/Service/UserOptions.cs +++ b/src/Twilio/Rest/Chat/V1/Service/UserOptions.cs @@ -9,239 +9,239 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1.Service -{ - +{ + + /// + /// FetchUserOptions + /// + public class FetchUserOptions : IOptions + { /// - /// FetchUserOptions - /// - public class FetchUserOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - public FetchUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// DeleteUserOptions - /// - public class DeleteUserOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - public DeleteUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// CreateUserOptions - /// - public class CreateUserOptions : IOptions - { - /// - /// The SID of the Service to create the new resource under - /// - public string PathServiceSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The SID of the Role assigned to this user - /// - public string RoleSid { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - public CreateUserOptions(string pathServiceSid, string identity) - { - PathServiceSid = pathServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Construct a new FetchUserOptions + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + public FetchUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadUserOptions + /// Generate the necessary parameters /// - public class ReadUserOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadUserOptions - /// - /// The SID of the Service to read the resources from - public ReadUserOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserOptions + /// + public class DeleteUserOptions : IOptions + { /// - /// UpdateUserOptions - /// - public class UpdateUserOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The SID id of the Role assigned to this user - /// - public string RoleSid { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - public UpdateUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + public DeleteUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateUserOptions + /// + public class CreateUserOptions : IOptions + { + /// + /// The SID of the Service to create the new resource under + /// + public string PathServiceSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The SID of the Role assigned to this user + /// + public string RoleSid { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + public CreateUserOptions(string pathServiceSid, string identity) + { + PathServiceSid = pathServiceSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadUserOptions + /// + public class ReadUserOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadUserOptions + /// + /// The SID of the Service to read the resources from + public ReadUserOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateUserOptions + /// + public class UpdateUserOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The SID id of the Role assigned to this user + /// + public string RoleSid { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + public UpdateUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/Service/UserResource.cs b/src/Twilio/Rest/Chat/V1/Service/UserResource.cs index 56294b012..5b52d36f1 100644 --- a/src/Twilio/Rest/Chat/V1/Service/UserResource.cs +++ b/src/Twilio/Rest/Chat/V1/Service/UserResource.cs @@ -16,544 +16,544 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V1.Service -{ - - public class UserResource : Resource - { - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - /// The SID of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the new resource - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - /// The SID of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the new resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// The SID id of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// The SID id of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the assigned to the user - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Whether the User is actively connected to the Service instance and online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// Whether the User has a potentially valid Push Notification registration for the Service instance - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The number of Channels this User is a Member of - /// - [JsonProperty("joined_channels_count")] - public int? JoinedChannelsCount { get; private set; } - /// - /// The absolute URLs of the Channel and Binding resources related to the user - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The absolute URL of the User resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + /// The SID of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the new resource + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + /// The SID of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the new resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// The SID id of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// The SID id of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the assigned to the user + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Whether the User is actively connected to the Service instance and online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// Whether the User has a potentially valid Push Notification registration for the Service instance + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The number of Channels this User is a Member of + /// + [JsonProperty("joined_channels_count")] + public int? JoinedChannelsCount { get; private set; } + /// + /// The absolute URLs of the Channel and Binding resources related to the user + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The absolute URL of the User resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/ServiceOptions.cs b/src/Twilio/Rest/Chat/V1/ServiceOptions.cs index 5642e7ae4..31e5d0d58 100644 --- a/src/Twilio/Rest/Chat/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Chat/V1/ServiceOptions.cs @@ -10,634 +10,634 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V1 -{ - +{ + + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// FetchServiceOptions + /// The unique string that identifies the resource /// - public class FetchServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The unique string that identifies the resource - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteServiceOptions + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The unique string that identifies the resource - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateServiceOptions + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateServiceOptions - /// - /// A string to describe the resource - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The service role assigned to users when they are added to the service - /// - public string DefaultServiceRoleSid { get; set; } - /// - /// The channel role assigned to users when they are added to a channel - /// - public string DefaultChannelRoleSid { get; set; } - /// - /// The channel role assigned to a channel creator when they join a new channel - /// - public string DefaultChannelCreatorRoleSid { get; set; } - /// - /// Whether to enable the Message Consumption Horizon feature - /// - public bool? ReadStatusEnabled { get; set; } - /// - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - public bool? ReachabilityEnabled { get; set; } - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - public int? TypingIndicatorTimeout { get; set; } - /// - /// DEPRECATED - /// - public int? ConsumptionReportInterval { get; set; } - /// - /// Whether to send a notification when a new message is added to a channel - /// - public bool? NotificationsNewMessageEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a new message is added to a channel - /// - public string NotificationsNewMessageTemplate { get; set; } - /// - /// Whether to send a notification when a member is added to a channel - /// - public bool? NotificationsAddedToChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a member is added to a channel - /// - public string NotificationsAddedToChannelTemplate { get; set; } - /// - /// Whether to send a notification to a user when they are removed from a channel - /// - public bool? NotificationsRemovedFromChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed to a user when they are removed - /// - public string NotificationsRemovedFromChannelTemplate { get; set; } - /// - /// Whether to send a notification when a user is invited to a channel - /// - public bool? NotificationsInvitedToChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a user is invited to a channel - /// - public string NotificationsInvitedToChannelTemplate { get; set; } - /// - /// The webhook URL for pre-event webhooks - /// - public Uri PreWebhookUrl { get; set; } - /// - /// The URL for post-event webhooks - /// - public Uri PostWebhookUrl { get; set; } - /// - /// The HTTP method to use for both PRE and POST webhooks - /// - public Twilio.Http.HttpMethod WebhookMethod { get; set; } - /// - /// The list of WebHook events that are enabled for this Service instance - /// - public List WebhookFilters { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_send event - /// - public Uri WebhooksOnMessageSendUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_message_send.url - /// - public Twilio.Http.HttpMethod WebhooksOnMessageSendMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_update event - /// - public Uri WebhooksOnMessageUpdateUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_message_update.url - /// - public Twilio.Http.HttpMethod WebhooksOnMessageUpdateMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_remove event - /// - public Uri WebhooksOnMessageRemoveUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_message_remove.url - /// - public Twilio.Http.HttpMethod WebhooksOnMessageRemoveMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_add event - /// - public Uri WebhooksOnChannelAddUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_channel_add.url - /// - public Twilio.Http.HttpMethod WebhooksOnChannelAddMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_destroy event - /// - public Uri WebhooksOnChannelDestroyUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_channel_destroy.url - /// - public Twilio.Http.HttpMethod WebhooksOnChannelDestroyMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_update event - /// - public Uri WebhooksOnChannelUpdateUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_channel_update.url - /// - public Twilio.Http.HttpMethod WebhooksOnChannelUpdateMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_member_add event - /// - public Uri WebhooksOnMemberAddUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_member_add.url - /// - public Twilio.Http.HttpMethod WebhooksOnMemberAddMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_member_remove event - /// - public Uri WebhooksOnMemberRemoveUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_member_remove.url - /// - public Twilio.Http.HttpMethod WebhooksOnMemberRemoveMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - public Uri WebhooksOnMessageSentUrl { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - public Twilio.Http.HttpMethod WebhooksOnMessageSentMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_updated event - /// - public Uri WebhooksOnMessageUpdatedUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_message_updated.url - /// - public Twilio.Http.HttpMethod WebhooksOnMessageUpdatedMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_message_removed event - /// - public Uri WebhooksOnMessageRemovedUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_message_removed.url - /// - public Twilio.Http.HttpMethod WebhooksOnMessageRemovedMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_added event - /// - public Uri WebhooksOnChannelAddedUrl { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_added event - /// - public Twilio.Http.HttpMethod WebhooksOnChannelAddedMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_added event - /// - public Uri WebhooksOnChannelDestroyedUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_channel_destroyed.url - /// - public Twilio.Http.HttpMethod WebhooksOnChannelDestroyedMethod { get; set; } - /// - /// he URL of the webhook to call in response to the on_channel_updated event - /// - public Uri WebhooksOnChannelUpdatedUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_channel_updated.url - /// - public Twilio.Http.HttpMethod WebhooksOnChannelUpdatedMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_channel_updated event - /// - public Uri WebhooksOnMemberAddedUrl { get; set; } - /// - /// he HTTP method to use when calling the webhooks.on_channel_updated.url - /// - public Twilio.Http.HttpMethod WebhooksOnMemberAddedMethod { get; set; } - /// - /// The URL of the webhook to call in response to the on_member_removed event - /// - public Uri WebhooksOnMemberRemovedUrl { get; set; } - /// - /// The HTTP method to use when calling the webhooks.on_member_removed.url - /// - public Twilio.Http.HttpMethod WebhooksOnMemberRemovedMethod { get; set; } - /// - /// The maximum number of Members that can be added to Channels within this Service - /// - public int? LimitsChannelMembers { get; set; } - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - public int? LimitsUserChannels { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The unique string that identifies the resource - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - WebhookFilters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DefaultServiceRoleSid != null) - { - p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); - } - - if (DefaultChannelRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); - } - - if (DefaultChannelCreatorRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); - } - - if (ReadStatusEnabled != null) - { - p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); - } - - if (TypingIndicatorTimeout != null) - { - p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); - } - - if (ConsumptionReportInterval != null) - { - p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); - } - - if (NotificationsNewMessageEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); - } - - if (NotificationsNewMessageTemplate != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); - } - - if (NotificationsAddedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); - } - - if (NotificationsRemovedFromChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsRemovedFromChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); - } - - if (NotificationsInvitedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsInvitedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); - } - - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); - } - - if (WebhookFilters != null) - { - p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); - } - - if (WebhooksOnMessageSendUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSend.Url", Serializers.Url(WebhooksOnMessageSendUrl))); - } - - if (WebhooksOnMessageSendMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSend.Method", WebhooksOnMessageSendMethod.ToString())); - } - - if (WebhooksOnMessageUpdateUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Url", Serializers.Url(WebhooksOnMessageUpdateUrl))); - } - - if (WebhooksOnMessageUpdateMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Method", WebhooksOnMessageUpdateMethod.ToString())); - } - - if (WebhooksOnMessageRemoveUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Url", Serializers.Url(WebhooksOnMessageRemoveUrl))); - } - - if (WebhooksOnMessageRemoveMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Method", WebhooksOnMessageRemoveMethod.ToString())); - } - - if (WebhooksOnChannelAddUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Url", Serializers.Url(WebhooksOnChannelAddUrl))); - } - - if (WebhooksOnChannelAddMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Method", WebhooksOnChannelAddMethod.ToString())); - } - - if (WebhooksOnChannelDestroyUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Url", Serializers.Url(WebhooksOnChannelDestroyUrl))); - } - - if (WebhooksOnChannelDestroyMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Method", WebhooksOnChannelDestroyMethod.ToString())); - } - - if (WebhooksOnChannelUpdateUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Url", Serializers.Url(WebhooksOnChannelUpdateUrl))); - } - - if (WebhooksOnChannelUpdateMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Method", WebhooksOnChannelUpdateMethod.ToString())); - } - - if (WebhooksOnMemberAddUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Url", Serializers.Url(WebhooksOnMemberAddUrl))); - } - - if (WebhooksOnMemberAddMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Method", WebhooksOnMemberAddMethod.ToString())); - } - - if (WebhooksOnMemberRemoveUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Url", Serializers.Url(WebhooksOnMemberRemoveUrl))); - } - - if (WebhooksOnMemberRemoveMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Method", WebhooksOnMemberRemoveMethod.ToString())); - } - - if (WebhooksOnMessageSentUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSent.Url", Serializers.Url(WebhooksOnMessageSentUrl))); - } - - if (WebhooksOnMessageSentMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSent.Method", WebhooksOnMessageSentMethod.ToString())); - } - - if (WebhooksOnMessageUpdatedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Url", Serializers.Url(WebhooksOnMessageUpdatedUrl))); - } - - if (WebhooksOnMessageUpdatedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Method", WebhooksOnMessageUpdatedMethod.ToString())); - } - - if (WebhooksOnMessageRemovedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Url", Serializers.Url(WebhooksOnMessageRemovedUrl))); - } - - if (WebhooksOnMessageRemovedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Method", WebhooksOnMessageRemovedMethod.ToString())); - } - - if (WebhooksOnChannelAddedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Url", Serializers.Url(WebhooksOnChannelAddedUrl))); - } - - if (WebhooksOnChannelAddedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Method", WebhooksOnChannelAddedMethod.ToString())); - } - - if (WebhooksOnChannelDestroyedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Url", Serializers.Url(WebhooksOnChannelDestroyedUrl))); - } - - if (WebhooksOnChannelDestroyedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Method", WebhooksOnChannelDestroyedMethod.ToString())); - } - - if (WebhooksOnChannelUpdatedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Url", Serializers.Url(WebhooksOnChannelUpdatedUrl))); - } - - if (WebhooksOnChannelUpdatedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Method", WebhooksOnChannelUpdatedMethod.ToString())); - } - - if (WebhooksOnMemberAddedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Url", Serializers.Url(WebhooksOnMemberAddedUrl))); - } - - if (WebhooksOnMemberAddedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Method", WebhooksOnMemberAddedMethod.ToString())); - } - - if (WebhooksOnMemberRemovedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Url", Serializers.Url(WebhooksOnMemberRemovedUrl))); - } - - if (WebhooksOnMemberRemovedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Method", WebhooksOnMemberRemovedMethod.ToString())); - } - - if (LimitsChannelMembers != null) - { - p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); - } - - if (LimitsUserChannels != null) - { - p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); - } - - return p; - } - } + /// Construct a new DeleteServiceOptions + /// + /// The unique string that identifies the resource + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateServiceOptions + /// + /// A string to describe the resource + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The service role assigned to users when they are added to the service + /// + public string DefaultServiceRoleSid { get; set; } + /// + /// The channel role assigned to users when they are added to a channel + /// + public string DefaultChannelRoleSid { get; set; } + /// + /// The channel role assigned to a channel creator when they join a new channel + /// + public string DefaultChannelCreatorRoleSid { get; set; } + /// + /// Whether to enable the Message Consumption Horizon feature + /// + public bool? ReadStatusEnabled { get; set; } + /// + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + public bool? ReachabilityEnabled { get; set; } + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + public int? TypingIndicatorTimeout { get; set; } + /// + /// DEPRECATED + /// + public int? ConsumptionReportInterval { get; set; } + /// + /// Whether to send a notification when a new message is added to a channel + /// + public bool? NotificationsNewMessageEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a new message is added to a channel + /// + public string NotificationsNewMessageTemplate { get; set; } + /// + /// Whether to send a notification when a member is added to a channel + /// + public bool? NotificationsAddedToChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a member is added to a channel + /// + public string NotificationsAddedToChannelTemplate { get; set; } + /// + /// Whether to send a notification to a user when they are removed from a channel + /// + public bool? NotificationsRemovedFromChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed to a user when they are removed + /// + public string NotificationsRemovedFromChannelTemplate { get; set; } + /// + /// Whether to send a notification when a user is invited to a channel + /// + public bool? NotificationsInvitedToChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a user is invited to a channel + /// + public string NotificationsInvitedToChannelTemplate { get; set; } + /// + /// The webhook URL for pre-event webhooks + /// + public Uri PreWebhookUrl { get; set; } + /// + /// The URL for post-event webhooks + /// + public Uri PostWebhookUrl { get; set; } + /// + /// The HTTP method to use for both PRE and POST webhooks + /// + public Twilio.Http.HttpMethod WebhookMethod { get; set; } + /// + /// The list of WebHook events that are enabled for this Service instance + /// + public List WebhookFilters { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_send event + /// + public Uri WebhooksOnMessageSendUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_message_send.url + /// + public Twilio.Http.HttpMethod WebhooksOnMessageSendMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_update event + /// + public Uri WebhooksOnMessageUpdateUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_message_update.url + /// + public Twilio.Http.HttpMethod WebhooksOnMessageUpdateMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_remove event + /// + public Uri WebhooksOnMessageRemoveUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_message_remove.url + /// + public Twilio.Http.HttpMethod WebhooksOnMessageRemoveMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_add event + /// + public Uri WebhooksOnChannelAddUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_channel_add.url + /// + public Twilio.Http.HttpMethod WebhooksOnChannelAddMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_destroy event + /// + public Uri WebhooksOnChannelDestroyUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_channel_destroy.url + /// + public Twilio.Http.HttpMethod WebhooksOnChannelDestroyMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_update event + /// + public Uri WebhooksOnChannelUpdateUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_channel_update.url + /// + public Twilio.Http.HttpMethod WebhooksOnChannelUpdateMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_member_add event + /// + public Uri WebhooksOnMemberAddUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_member_add.url + /// + public Twilio.Http.HttpMethod WebhooksOnMemberAddMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_member_remove event + /// + public Uri WebhooksOnMemberRemoveUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_member_remove.url + /// + public Twilio.Http.HttpMethod WebhooksOnMemberRemoveMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + public Uri WebhooksOnMessageSentUrl { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + public Twilio.Http.HttpMethod WebhooksOnMessageSentMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_updated event + /// + public Uri WebhooksOnMessageUpdatedUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_message_updated.url + /// + public Twilio.Http.HttpMethod WebhooksOnMessageUpdatedMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_message_removed event + /// + public Uri WebhooksOnMessageRemovedUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_message_removed.url + /// + public Twilio.Http.HttpMethod WebhooksOnMessageRemovedMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_added event + /// + public Uri WebhooksOnChannelAddedUrl { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_added event + /// + public Twilio.Http.HttpMethod WebhooksOnChannelAddedMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_added event + /// + public Uri WebhooksOnChannelDestroyedUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_channel_destroyed.url + /// + public Twilio.Http.HttpMethod WebhooksOnChannelDestroyedMethod { get; set; } + /// + /// he URL of the webhook to call in response to the on_channel_updated event + /// + public Uri WebhooksOnChannelUpdatedUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_channel_updated.url + /// + public Twilio.Http.HttpMethod WebhooksOnChannelUpdatedMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_channel_updated event + /// + public Uri WebhooksOnMemberAddedUrl { get; set; } + /// + /// he HTTP method to use when calling the webhooks.on_channel_updated.url + /// + public Twilio.Http.HttpMethod WebhooksOnMemberAddedMethod { get; set; } + /// + /// The URL of the webhook to call in response to the on_member_removed event + /// + public Uri WebhooksOnMemberRemovedUrl { get; set; } + /// + /// The HTTP method to use when calling the webhooks.on_member_removed.url + /// + public Twilio.Http.HttpMethod WebhooksOnMemberRemovedMethod { get; set; } + /// + /// The maximum number of Members that can be added to Channels within this Service + /// + public int? LimitsChannelMembers { get; set; } + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + public int? LimitsUserChannels { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The unique string that identifies the resource + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + WebhookFilters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DefaultServiceRoleSid != null) + { + p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); + } + + if (DefaultChannelRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); + } + + if (DefaultChannelCreatorRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); + } + + if (ReadStatusEnabled != null) + { + p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); + } + + if (TypingIndicatorTimeout != null) + { + p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); + } + + if (ConsumptionReportInterval != null) + { + p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); + } + + if (NotificationsNewMessageEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); + } + + if (NotificationsNewMessageTemplate != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); + } + + if (NotificationsAddedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); + } + + if (NotificationsRemovedFromChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsRemovedFromChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); + } + + if (NotificationsInvitedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsInvitedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); + } + + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); + } + + if (WebhookFilters != null) + { + p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); + } + + if (WebhooksOnMessageSendUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSend.Url", Serializers.Url(WebhooksOnMessageSendUrl))); + } + + if (WebhooksOnMessageSendMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSend.Method", WebhooksOnMessageSendMethod.ToString())); + } + + if (WebhooksOnMessageUpdateUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Url", Serializers.Url(WebhooksOnMessageUpdateUrl))); + } + + if (WebhooksOnMessageUpdateMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Method", WebhooksOnMessageUpdateMethod.ToString())); + } + + if (WebhooksOnMessageRemoveUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Url", Serializers.Url(WebhooksOnMessageRemoveUrl))); + } + + if (WebhooksOnMessageRemoveMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Method", WebhooksOnMessageRemoveMethod.ToString())); + } + + if (WebhooksOnChannelAddUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Url", Serializers.Url(WebhooksOnChannelAddUrl))); + } + + if (WebhooksOnChannelAddMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Method", WebhooksOnChannelAddMethod.ToString())); + } + + if (WebhooksOnChannelDestroyUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Url", Serializers.Url(WebhooksOnChannelDestroyUrl))); + } + + if (WebhooksOnChannelDestroyMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Method", WebhooksOnChannelDestroyMethod.ToString())); + } + + if (WebhooksOnChannelUpdateUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Url", Serializers.Url(WebhooksOnChannelUpdateUrl))); + } + + if (WebhooksOnChannelUpdateMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Method", WebhooksOnChannelUpdateMethod.ToString())); + } + + if (WebhooksOnMemberAddUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Url", Serializers.Url(WebhooksOnMemberAddUrl))); + } + + if (WebhooksOnMemberAddMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Method", WebhooksOnMemberAddMethod.ToString())); + } + + if (WebhooksOnMemberRemoveUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Url", Serializers.Url(WebhooksOnMemberRemoveUrl))); + } + + if (WebhooksOnMemberRemoveMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Method", WebhooksOnMemberRemoveMethod.ToString())); + } + + if (WebhooksOnMessageSentUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSent.Url", Serializers.Url(WebhooksOnMessageSentUrl))); + } + + if (WebhooksOnMessageSentMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSent.Method", WebhooksOnMessageSentMethod.ToString())); + } + + if (WebhooksOnMessageUpdatedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Url", Serializers.Url(WebhooksOnMessageUpdatedUrl))); + } + + if (WebhooksOnMessageUpdatedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Method", WebhooksOnMessageUpdatedMethod.ToString())); + } + + if (WebhooksOnMessageRemovedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Url", Serializers.Url(WebhooksOnMessageRemovedUrl))); + } + + if (WebhooksOnMessageRemovedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Method", WebhooksOnMessageRemovedMethod.ToString())); + } + + if (WebhooksOnChannelAddedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Url", Serializers.Url(WebhooksOnChannelAddedUrl))); + } + + if (WebhooksOnChannelAddedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Method", WebhooksOnChannelAddedMethod.ToString())); + } + + if (WebhooksOnChannelDestroyedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Url", Serializers.Url(WebhooksOnChannelDestroyedUrl))); + } + + if (WebhooksOnChannelDestroyedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Method", WebhooksOnChannelDestroyedMethod.ToString())); + } + + if (WebhooksOnChannelUpdatedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Url", Serializers.Url(WebhooksOnChannelUpdatedUrl))); + } + + if (WebhooksOnChannelUpdatedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Method", WebhooksOnChannelUpdatedMethod.ToString())); + } + + if (WebhooksOnMemberAddedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Url", Serializers.Url(WebhooksOnMemberAddedUrl))); + } + + if (WebhooksOnMemberAddedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Method", WebhooksOnMemberAddedMethod.ToString())); + } + + if (WebhooksOnMemberRemovedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Url", Serializers.Url(WebhooksOnMemberRemovedUrl))); + } + + if (WebhooksOnMemberRemovedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Method", WebhooksOnMemberRemovedMethod.ToString())); + } + + if (LimitsChannelMembers != null) + { + p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); + } + + if (LimitsUserChannels != null) + { + p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V1/ServiceResource.cs b/src/Twilio/Rest/Chat/V1/ServiceResource.cs index 76c02952e..b83dd3deb 100644 --- a/src/Twilio/Rest/Chat/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Chat/V1/ServiceResource.cs @@ -16,837 +16,837 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The service role assigned to users when they are added to the service - /// The channel role assigned to users when they are added to a channel - /// The channel role assigned to a channel creator when they join a new - /// channel - /// Whether to enable the Message Consumption Horizon feature - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - /// DEPRECATED - /// Whether to send a notification when a new message is added to a - /// channel - /// The template to use to create the notification text displayed when a - /// new message is added to a channel - /// Whether to send a notification when a member is added to a - /// channel - /// The template to use to create the notification text displayed - /// when a member is added to a channel - /// Whether to send a notification to a user when they are - /// removed from a channel - /// The template to use to create the notification text - /// displayed to a user when they are removed - /// Whether to send a notification when a user is invited to a - /// channel - /// The template to use to create the notification text displayed - /// when a user is invited to a channel - /// The webhook URL for pre-event webhooks - /// The URL for post-event webhooks - /// The HTTP method to use for both PRE and POST webhooks - /// The list of WebHook events that are enabled for this Service instance - /// The URL of the webhook to call in response to the on_message_send event - /// - /// The HTTP method to use when calling the webhooks.on_message_send.url - /// - /// The URL of the webhook to call in response to the on_message_update event - /// - /// The HTTP method to use when calling the webhooks.on_message_update.url - /// - /// The URL of the webhook to call in response to the on_message_remove event - /// - /// The HTTP method to use when calling the webhooks.on_message_remove.url - /// - /// The URL of the webhook to call in response to the on_channel_add event - /// - /// The HTTP method to use when calling the webhooks.on_channel_add.url - /// - /// The URL of the webhook to call in response to the on_channel_destroy - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_destroy.url - /// The URL of the webhook to call in response to the on_channel_update event - /// - /// The HTTP method to use when calling the webhooks.on_channel_update.url - /// - /// The URL of the webhook to call in response to the on_member_add event - /// The HTTP method to use when calling the webhooks.on_member_add.url - /// The URL of the webhook to call in response to the on_member_remove event - /// - /// The HTTP method to use when calling the webhooks.on_member_remove.url - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - /// The URL of the webhook to call in response to the on_message_updated - /// event - /// The HTTP method to use when calling the - /// webhooks.on_message_updated.url - /// The URL of the webhook to call in response to the on_message_removed - /// event - /// The HTTP method to use when calling the - /// webhooks.on_message_removed.url - /// The URL of the webhook to call in response to the on_channel_added event - /// - /// The URL of the webhook to call in response to the on_channel_added - /// event - /// The URL of the webhook to call in response to the on_channel_added - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_destroyed.url - /// he URL of the webhook to call in response to the on_channel_updated - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_updated.url - /// The URL of the webhook to call in response to the on_channel_updated event - /// - /// he HTTP method to use when calling the webhooks.on_channel_updated.url - /// - /// The URL of the webhook to call in response to the on_member_removed event - /// - /// The HTTP method to use when calling the webhooks.on_member_removed.url - /// - /// The maximum number of Members that can be added to Channels within this Service - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - Uri webhooksOnMessageSendUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, - Uri webhooksOnMessageUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, - Uri webhooksOnMessageRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, - Uri webhooksOnChannelAddUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, - Uri webhooksOnChannelDestroyUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, - Uri webhooksOnChannelUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, - Uri webhooksOnMemberAddUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, - Uri webhooksOnMemberRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, - Uri webhooksOnMessageSentUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, - Uri webhooksOnMessageUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, - Uri webhooksOnMessageRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, - Uri webhooksOnChannelAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, - Uri webhooksOnChannelDestroyedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, - Uri webhooksOnChannelUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, - Uri webhooksOnMemberAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, - Uri webhooksOnMemberRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The service role assigned to users when they are added to the service - /// The channel role assigned to users when they are added to a channel - /// The channel role assigned to a channel creator when they join a new - /// channel - /// Whether to enable the Message Consumption Horizon feature - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - /// DEPRECATED - /// Whether to send a notification when a new message is added to a - /// channel - /// The template to use to create the notification text displayed when a - /// new message is added to a channel - /// Whether to send a notification when a member is added to a - /// channel - /// The template to use to create the notification text displayed - /// when a member is added to a channel - /// Whether to send a notification to a user when they are - /// removed from a channel - /// The template to use to create the notification text - /// displayed to a user when they are removed - /// Whether to send a notification when a user is invited to a - /// channel - /// The template to use to create the notification text displayed - /// when a user is invited to a channel - /// The webhook URL for pre-event webhooks - /// The URL for post-event webhooks - /// The HTTP method to use for both PRE and POST webhooks - /// The list of WebHook events that are enabled for this Service instance - /// The URL of the webhook to call in response to the on_message_send event - /// - /// The HTTP method to use when calling the webhooks.on_message_send.url - /// - /// The URL of the webhook to call in response to the on_message_update event - /// - /// The HTTP method to use when calling the webhooks.on_message_update.url - /// - /// The URL of the webhook to call in response to the on_message_remove event - /// - /// The HTTP method to use when calling the webhooks.on_message_remove.url - /// - /// The URL of the webhook to call in response to the on_channel_add event - /// - /// The HTTP method to use when calling the webhooks.on_channel_add.url - /// - /// The URL of the webhook to call in response to the on_channel_destroy - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_destroy.url - /// The URL of the webhook to call in response to the on_channel_update event - /// - /// The HTTP method to use when calling the webhooks.on_channel_update.url - /// - /// The URL of the webhook to call in response to the on_member_add event - /// The HTTP method to use when calling the webhooks.on_member_add.url - /// The URL of the webhook to call in response to the on_member_remove event - /// - /// The HTTP method to use when calling the webhooks.on_member_remove.url - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - /// The URL of the webhook to call in response to the on_message_sent event - /// - /// The URL of the webhook to call in response to the on_message_updated - /// event - /// The HTTP method to use when calling the - /// webhooks.on_message_updated.url - /// The URL of the webhook to call in response to the on_message_removed - /// event - /// The HTTP method to use when calling the - /// webhooks.on_message_removed.url - /// The URL of the webhook to call in response to the on_channel_added event - /// - /// The URL of the webhook to call in response to the on_channel_added - /// event - /// The URL of the webhook to call in response to the on_channel_added - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_destroyed.url - /// he URL of the webhook to call in response to the on_channel_updated - /// event - /// The HTTP method to use when calling the - /// webhooks.on_channel_updated.url - /// The URL of the webhook to call in response to the on_channel_updated event - /// - /// he HTTP method to use when calling the webhooks.on_channel_updated.url - /// - /// The URL of the webhook to call in response to the on_member_removed event - /// - /// The HTTP method to use when calling the webhooks.on_member_removed.url - /// - /// The maximum number of Members that can be added to Channels within this Service - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - Uri webhooksOnMessageSendUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, - Uri webhooksOnMessageUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, - Uri webhooksOnMessageRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, - Uri webhooksOnChannelAddUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, - Uri webhooksOnChannelDestroyUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, - Uri webhooksOnChannelUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, - Uri webhooksOnMemberAddUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, - Uri webhooksOnMemberRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, - Uri webhooksOnMessageSentUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, - Uri webhooksOnMessageUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, - Uri webhooksOnMessageRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, - Uri webhooksOnChannelAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, - Uri webhooksOnChannelDestroyedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, - Uri webhooksOnChannelUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, - Uri webhooksOnMemberAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, - Uri webhooksOnMemberRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The service role assigned to users when they are added to the service - /// - [JsonProperty("default_service_role_sid")] - public string DefaultServiceRoleSid { get; private set; } - /// - /// The channel role assigned to users when they are added to a channel - /// - [JsonProperty("default_channel_role_sid")] - public string DefaultChannelRoleSid { get; private set; } - /// - /// The channel role assigned to a channel creator when they join a new channel - /// - [JsonProperty("default_channel_creator_role_sid")] - public string DefaultChannelCreatorRoleSid { get; private set; } - /// - /// Whether the Message Consumption Horizon feature is enabled - /// - [JsonProperty("read_status_enabled")] - public bool? ReadStatusEnabled { get; private set; } - /// - /// Whether the Reachability Indicator feature is enabled for this Service instance - /// - [JsonProperty("reachability_enabled")] - public bool? ReachabilityEnabled { get; private set; } - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - [JsonProperty("typing_indicator_timeout")] - public int? TypingIndicatorTimeout { get; private set; } - /// - /// DEPRECATED - /// - [JsonProperty("consumption_report_interval")] - public int? ConsumptionReportInterval { get; private set; } - /// - /// An object that describes the limits of the service instance - /// - [JsonProperty("limits")] - public object Limits { get; private set; } - /// - /// An object that contains information about the webhooks configured for this service - /// - [JsonProperty("webhooks")] - public object Webhooks { get; private set; } - /// - /// The webhook URL for pre-event webhooks - /// - [JsonProperty("pre_webhook_url")] - public string PreWebhookUrl { get; private set; } - /// - /// The URL for post-event webhooks - /// - [JsonProperty("post_webhook_url")] - public string PostWebhookUrl { get; private set; } - /// - /// The HTTP method to use for both PRE and POST webhooks - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The list of WebHook events that are enabled for this Service instance - /// - [JsonProperty("webhook_filters")] - public List WebhookFilters { get; private set; } - /// - /// The notification configuration for the Service instance - /// - [JsonProperty("notifications")] - public object Notifications { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The absolute URLs of the Service's Channels, Roles, and Users - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The service role assigned to users when they are added to the service + /// The channel role assigned to users when they are added to a channel + /// The channel role assigned to a channel creator when they join a new + /// channel + /// Whether to enable the Message Consumption Horizon feature + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + /// DEPRECATED + /// Whether to send a notification when a new message is added to a + /// channel + /// The template to use to create the notification text displayed when a + /// new message is added to a channel + /// Whether to send a notification when a member is added to a + /// channel + /// The template to use to create the notification text displayed + /// when a member is added to a channel + /// Whether to send a notification to a user when they are + /// removed from a channel + /// The template to use to create the notification text + /// displayed to a user when they are removed + /// Whether to send a notification when a user is invited to a + /// channel + /// The template to use to create the notification text displayed + /// when a user is invited to a channel + /// The webhook URL for pre-event webhooks + /// The URL for post-event webhooks + /// The HTTP method to use for both PRE and POST webhooks + /// The list of WebHook events that are enabled for this Service instance + /// The URL of the webhook to call in response to the on_message_send event + /// + /// The HTTP method to use when calling the webhooks.on_message_send.url + /// + /// The URL of the webhook to call in response to the on_message_update event + /// + /// The HTTP method to use when calling the webhooks.on_message_update.url + /// + /// The URL of the webhook to call in response to the on_message_remove event + /// + /// The HTTP method to use when calling the webhooks.on_message_remove.url + /// + /// The URL of the webhook to call in response to the on_channel_add event + /// + /// The HTTP method to use when calling the webhooks.on_channel_add.url + /// + /// The URL of the webhook to call in response to the on_channel_destroy + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_destroy.url + /// The URL of the webhook to call in response to the on_channel_update event + /// + /// The HTTP method to use when calling the webhooks.on_channel_update.url + /// + /// The URL of the webhook to call in response to the on_member_add event + /// The HTTP method to use when calling the webhooks.on_member_add.url + /// The URL of the webhook to call in response to the on_member_remove event + /// + /// The HTTP method to use when calling the webhooks.on_member_remove.url + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + /// The URL of the webhook to call in response to the on_message_updated + /// event + /// The HTTP method to use when calling the + /// webhooks.on_message_updated.url + /// The URL of the webhook to call in response to the on_message_removed + /// event + /// The HTTP method to use when calling the + /// webhooks.on_message_removed.url + /// The URL of the webhook to call in response to the on_channel_added event + /// + /// The URL of the webhook to call in response to the on_channel_added + /// event + /// The URL of the webhook to call in response to the on_channel_added + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_destroyed.url + /// he URL of the webhook to call in response to the on_channel_updated + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_updated.url + /// The URL of the webhook to call in response to the on_channel_updated event + /// + /// he HTTP method to use when calling the webhooks.on_channel_updated.url + /// + /// The URL of the webhook to call in response to the on_member_removed event + /// + /// The HTTP method to use when calling the webhooks.on_member_removed.url + /// + /// The maximum number of Members that can be added to Channels within this Service + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + Uri webhooksOnMessageSendUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, + Uri webhooksOnMessageUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, + Uri webhooksOnMessageRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, + Uri webhooksOnChannelAddUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, + Uri webhooksOnChannelDestroyUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, + Uri webhooksOnChannelUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, + Uri webhooksOnMemberAddUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, + Uri webhooksOnMemberRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, + Uri webhooksOnMessageSentUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, + Uri webhooksOnMessageUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, + Uri webhooksOnMessageRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, + Uri webhooksOnChannelAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, + Uri webhooksOnChannelDestroyedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, + Uri webhooksOnChannelUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, + Uri webhooksOnMemberAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, + Uri webhooksOnMemberRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The service role assigned to users when they are added to the service + /// The channel role assigned to users when they are added to a channel + /// The channel role assigned to a channel creator when they join a new + /// channel + /// Whether to enable the Message Consumption Horizon feature + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + /// DEPRECATED + /// Whether to send a notification when a new message is added to a + /// channel + /// The template to use to create the notification text displayed when a + /// new message is added to a channel + /// Whether to send a notification when a member is added to a + /// channel + /// The template to use to create the notification text displayed + /// when a member is added to a channel + /// Whether to send a notification to a user when they are + /// removed from a channel + /// The template to use to create the notification text + /// displayed to a user when they are removed + /// Whether to send a notification when a user is invited to a + /// channel + /// The template to use to create the notification text displayed + /// when a user is invited to a channel + /// The webhook URL for pre-event webhooks + /// The URL for post-event webhooks + /// The HTTP method to use for both PRE and POST webhooks + /// The list of WebHook events that are enabled for this Service instance + /// The URL of the webhook to call in response to the on_message_send event + /// + /// The HTTP method to use when calling the webhooks.on_message_send.url + /// + /// The URL of the webhook to call in response to the on_message_update event + /// + /// The HTTP method to use when calling the webhooks.on_message_update.url + /// + /// The URL of the webhook to call in response to the on_message_remove event + /// + /// The HTTP method to use when calling the webhooks.on_message_remove.url + /// + /// The URL of the webhook to call in response to the on_channel_add event + /// + /// The HTTP method to use when calling the webhooks.on_channel_add.url + /// + /// The URL of the webhook to call in response to the on_channel_destroy + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_destroy.url + /// The URL of the webhook to call in response to the on_channel_update event + /// + /// The HTTP method to use when calling the webhooks.on_channel_update.url + /// + /// The URL of the webhook to call in response to the on_member_add event + /// The HTTP method to use when calling the webhooks.on_member_add.url + /// The URL of the webhook to call in response to the on_member_remove event + /// + /// The HTTP method to use when calling the webhooks.on_member_remove.url + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + /// The URL of the webhook to call in response to the on_message_sent event + /// + /// The URL of the webhook to call in response to the on_message_updated + /// event + /// The HTTP method to use when calling the + /// webhooks.on_message_updated.url + /// The URL of the webhook to call in response to the on_message_removed + /// event + /// The HTTP method to use when calling the + /// webhooks.on_message_removed.url + /// The URL of the webhook to call in response to the on_channel_added event + /// + /// The URL of the webhook to call in response to the on_channel_added + /// event + /// The URL of the webhook to call in response to the on_channel_added + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_destroyed.url + /// he URL of the webhook to call in response to the on_channel_updated + /// event + /// The HTTP method to use when calling the + /// webhooks.on_channel_updated.url + /// The URL of the webhook to call in response to the on_channel_updated event + /// + /// he HTTP method to use when calling the webhooks.on_channel_updated.url + /// + /// The URL of the webhook to call in response to the on_member_removed event + /// + /// The HTTP method to use when calling the webhooks.on_member_removed.url + /// + /// The maximum number of Members that can be added to Channels within this Service + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + Uri webhooksOnMessageSendUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, + Uri webhooksOnMessageUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, + Uri webhooksOnMessageRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, + Uri webhooksOnChannelAddUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, + Uri webhooksOnChannelDestroyUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, + Uri webhooksOnChannelUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, + Uri webhooksOnMemberAddUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, + Uri webhooksOnMemberRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, + Uri webhooksOnMessageSentUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, + Uri webhooksOnMessageUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, + Uri webhooksOnMessageRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, + Uri webhooksOnChannelAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, + Uri webhooksOnChannelDestroyedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, + Uri webhooksOnChannelUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, + Uri webhooksOnMemberAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, + Uri webhooksOnMemberRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The service role assigned to users when they are added to the service + /// + [JsonProperty("default_service_role_sid")] + public string DefaultServiceRoleSid { get; private set; } + /// + /// The channel role assigned to users when they are added to a channel + /// + [JsonProperty("default_channel_role_sid")] + public string DefaultChannelRoleSid { get; private set; } + /// + /// The channel role assigned to a channel creator when they join a new channel + /// + [JsonProperty("default_channel_creator_role_sid")] + public string DefaultChannelCreatorRoleSid { get; private set; } + /// + /// Whether the Message Consumption Horizon feature is enabled + /// + [JsonProperty("read_status_enabled")] + public bool? ReadStatusEnabled { get; private set; } + /// + /// Whether the Reachability Indicator feature is enabled for this Service instance + /// + [JsonProperty("reachability_enabled")] + public bool? ReachabilityEnabled { get; private set; } + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + [JsonProperty("typing_indicator_timeout")] + public int? TypingIndicatorTimeout { get; private set; } + /// + /// DEPRECATED + /// + [JsonProperty("consumption_report_interval")] + public int? ConsumptionReportInterval { get; private set; } + /// + /// An object that describes the limits of the service instance + /// + [JsonProperty("limits")] + public object Limits { get; private set; } + /// + /// An object that contains information about the webhooks configured for this service + /// + [JsonProperty("webhooks")] + public object Webhooks { get; private set; } + /// + /// The webhook URL for pre-event webhooks + /// + [JsonProperty("pre_webhook_url")] + public string PreWebhookUrl { get; private set; } + /// + /// The URL for post-event webhooks + /// + [JsonProperty("post_webhook_url")] + public string PostWebhookUrl { get; private set; } + /// + /// The HTTP method to use for both PRE and POST webhooks + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The list of WebHook events that are enabled for this Service instance + /// + [JsonProperty("webhook_filters")] + public List WebhookFilters { get; private set; } + /// + /// The notification configuration for the Service instance + /// + [JsonProperty("notifications")] + public object Notifications { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The absolute URLs of the Service's Channels, Roles, and Users + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/CredentialOptions.cs b/src/Twilio/Rest/Chat/V2/CredentialOptions.cs index 0b14f16f6..e3f8963e9 100644 --- a/src/Twilio/Rest/Chat/V2/CredentialOptions.cs +++ b/src/Twilio/Rest/Chat/V2/CredentialOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2 -{ - +{ + + /// + /// ReadCredentialOptions + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// ReadCredentialOptions + /// Generate the necessary parameters /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateCredentialOptions + /// + public class CreateCredentialOptions : IOptions + { /// - /// CreateCredentialOptions + /// The type of push-notification service the credential is for /// - public class CreateCredentialOptions : IOptions - { - /// - /// The type of push-notification service the credential is for - /// - public CredentialResource.PushServiceEnum Type { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The type of push-notification service the credential is for - public CreateCredentialOptions(CredentialResource.PushServiceEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushServiceEnum Type { get; } /// - /// FetchCredentialOptions + /// A string to describe the resource /// - public class FetchCredentialOptions : IOptions - { - /// - /// The SID of the Credential resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The SID of the Credential resource to fetch - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// UpdateCredentialOptions + /// [APN only] The URL encoded representation of the certificate /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The SID of the Credential resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The SID of the Credential resource to update - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string Certificate { get; set; } /// - /// DeleteCredentialOptions + /// [APN only] The URL encoded representation of the private key /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The SID of the Credential resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The SID of the Credential resource to delete - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The type of push-notification service the credential is for + public CreateCredentialOptions(CredentialResource.PushServiceEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// FetchCredentialOptions + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The SID of the Credential resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The SID of the Credential resource to fetch + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateCredentialOptions + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The SID of the Credential resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// [APN only] The URL encoded representation of the certificate + /// + public string Certificate { get; set; } + /// + /// [APN only] The URL encoded representation of the private key + /// + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The SID of the Credential resource to update + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// DeleteCredentialOptions + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The SID of the Credential resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The SID of the Credential resource to delete + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/CredentialResource.cs b/src/Twilio/Rest/Chat/V2/CredentialResource.cs index 9a335ba70..ce57eb4b1 100644 --- a/src/Twilio/Rest/Chat/V2/CredentialResource.cs +++ b/src/Twilio/Rest/Chat/V2/CredentialResource.cs @@ -17,538 +17,538 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2 -{ - - public class CredentialResource : Resource - { - public sealed class PushServiceEnum : StringEnum - { - private PushServiceEnum(string value) : base(value) {} - public PushServiceEnum() {} - public static implicit operator PushServiceEnum(string value) - { - return new PushServiceEnum(value); - } - - public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); - public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); - public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); - } - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type of push-notification service the credential is for - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type of push-notification service the credential is for - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Credential resource to fetch - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Credential resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Credential resource to update - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Credential resource to update - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate - /// [APN only] The URL encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential - /// [FCM only] The Server key of your project from Firebase console - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Credential resource to delete - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Credential resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of push-notification service the credential is for - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushServiceEnum Type { get; private set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Credential resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushServiceEnum : StringEnum + { + private PushServiceEnum(string value) : base(value) { } + public PushServiceEnum() { } + public static implicit operator PushServiceEnum(string value) + { + return new PushServiceEnum(value); + } + + public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); + public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); + public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); + } + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type of push-notification service the credential is for + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type of push-notification service the credential is for + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Credential resource to fetch + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Credential resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Credential resource to update + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Credential resource to update + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate + /// [APN only] The URL encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential + /// [FCM only] The Server key of your project from Firebase console + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Credential resource to delete + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Credential resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of push-notification service the credential is for + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushServiceEnum Type { get; private set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Credential resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/BindingOptions.cs b/src/Twilio/Rest/Chat/V2/Service/BindingOptions.cs index daf21cc8f..9f56d2cc8 100644 --- a/src/Twilio/Rest/Chat/V2/Service/BindingOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/BindingOptions.cs @@ -10,130 +10,130 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service -{ - +{ + + /// + /// ReadBindingOptions + /// + public class ReadBindingOptions : ReadOptions + { /// - /// ReadBindingOptions + /// The SID of the Service to read the resources from /// - public class ReadBindingOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The push technology used by the Binding resources to read - /// - public List BindingType { get; set; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadBindingOptions - /// - /// The SID of the Service to read the resources from - public ReadBindingOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - BindingType = new List(); - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (BindingType != null) - { - p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); - } - - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// FetchBindingOptions + /// The push technology used by the Binding resources to read /// - public class FetchBindingOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBindingOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource to fetch - public FetchBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List BindingType { get; set; } /// - /// DeleteBindingOptions + /// The `identity` value of the resources to read /// - public class DeleteBindingOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBindingOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the resource to delete - public DeleteBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List Identity { get; set; } + + /// + /// Construct a new ReadBindingOptions + /// + /// The SID of the Service to read the resources from + public ReadBindingOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + BindingType = new List(); + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (BindingType != null) + { + p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); + } + + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchBindingOptions + /// + public class FetchBindingOptions : IOptions + { + /// + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBindingOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource to fetch + public FetchBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteBindingOptions + /// + public class DeleteBindingOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBindingOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the resource to delete + public DeleteBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/BindingResource.cs b/src/Twilio/Rest/Chat/V2/Service/BindingResource.cs index 707165bb5..72a276375 100644 --- a/src/Twilio/Rest/Chat/V2/Service/BindingResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/BindingResource.cs @@ -17,389 +17,389 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service -{ - - public class BindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - } - - private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The push technology used by the Binding resources to read - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(string pathServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The push technology used by the Binding resources to read - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BindingResource object - /// - /// Raw JSON string - /// BindingResource object represented by the provided JSON - public static BindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Binding resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique endpoint identifier for the Binding - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The SID of the Credential for the binding - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The push technology to use for the binding - /// - [JsonProperty("binding_type")] - [JsonConverter(typeof(StringEnumConverter))] - public BindingResource.BindingTypeEnum BindingType { get; private set; } - /// - /// The Programmable Chat message types the binding is subscribed to - /// - [JsonProperty("message_types")] - public List MessageTypes { get; private set; } - /// - /// The absolute URL of the Binding resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The absolute URLs of the Binding's User - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BindingResource() - { - - } - } +{ + + public class BindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + } + + private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The push technology used by the Binding resources to read + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(string pathServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The push technology used by the Binding resources to read + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BindingResource object + /// + /// Raw JSON string + /// BindingResource object represented by the provided JSON + public static BindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Binding resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique endpoint identifier for the Binding + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The SID of the Credential for the binding + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The push technology to use for the binding + /// + [JsonProperty("binding_type")] + [JsonConverter(typeof(StringEnumConverter))] + public BindingResource.BindingTypeEnum BindingType { get; private set; } + /// + /// The Programmable Chat message types the binding is subscribed to + /// + [JsonProperty("message_types")] + public List MessageTypes { get; private set; } + /// + /// The absolute URL of the Binding resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The absolute URLs of the Binding's User + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/InviteOptions.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/InviteOptions.cs index e3c09f4be..92468a65e 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/InviteOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/InviteOptions.cs @@ -10,193 +10,193 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - +{ + + /// + /// FetchInviteOptions + /// + public class FetchInviteOptions : IOptions + { /// - /// FetchInviteOptions - /// - public class FetchInviteOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to fetch belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Invite resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInviteOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Invite resource to fetch - public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// CreateInviteOptions - /// - public class CreateInviteOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the new resource belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The Role assigned to the new member - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateInviteOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + /// The SID of the Channel the resource to fetch belongs to + /// + public string PathChannelSid { get; } /// - /// ReadInviteOptions - /// - public class ReadInviteOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resources to read belong to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadInviteOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - public ReadInviteOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Invite resource to fetch + /// + public string PathSid { get; } + /// - /// DeleteInviteOptions - /// - public class DeleteInviteOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Invite resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInviteOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The SID of the Invite resource to delete - public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchInviteOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Invite resource to fetch + public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateInviteOptions + /// + public class CreateInviteOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the new resource belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The Role assigned to the new member + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateInviteOptions + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadInviteOptions + /// + public class ReadInviteOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resources to read belong to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value of the resources to read + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadInviteOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + public ReadInviteOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteInviteOptions + /// + public class DeleteInviteOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resource to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Invite resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInviteOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The SID of the Invite resource to delete + public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/InviteResource.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/InviteResource.cs index 5edb375b2..893f155ce 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/InviteResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/InviteResource.cs @@ -16,456 +16,456 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - - public class InviteResource : Resource - { - private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Invite resource to fetch - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Invite resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - /// The Role assigned to the new member - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The `identity` value that identifies the new resource's User - /// The Role assigned to the new member - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The SID of the Invite resource to delete - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the resource to delete belongs to - /// The SID of the Invite resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a InviteResource object - /// - /// Raw JSON string - /// InviteResource object represented by the provided JSON - public static InviteResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Channel the new resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Role assigned to the member - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The identity of the User that created the invite - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The absolute URL of the Invite resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InviteResource() - { - - } - } +{ + + public class InviteResource : Resource + { + private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Invite resource to fetch + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Invite resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + /// The Role assigned to the new member + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The `identity` value that identifies the new resource's User + /// The Role assigned to the new member + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The SID of the Invite resource to delete + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the resource to delete belongs to + /// The SID of the Invite resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a InviteResource object + /// + /// Raw JSON string + /// InviteResource object represented by the provided JSON + public static InviteResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Channel the new resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Role assigned to the member + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The identity of the User that created the invite + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The absolute URL of the Invite resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InviteResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/MemberOptions.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/MemberOptions.cs index a14791341..9869bdbee 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/MemberOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/MemberOptions.cs @@ -10,387 +10,387 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - +{ + + /// + /// FetchMemberOptions + /// + public class FetchMemberOptions : IOptions + { /// - /// FetchMemberOptions - /// - public class FetchMemberOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the member belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Member resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMemberOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the channel the member belongs to - /// The SID of the Member resource to fetch - public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// CreateMemberOptions - /// - public class CreateMemberOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the new member belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The SID of the Role to assign to the member - /// - public string RoleSid { get; set; } - /// - /// The index of the last Message in the Channel the Member has read - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The ISO 8601 based timestamp string representing the datetime of the last Message read event for the member within the Channel - /// - public DateTime? LastConsumptionTimestamp { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMemberOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the channel the member belongs to + /// + public string PathChannelSid { get; } /// - /// ReadMemberOptions - /// - public class ReadMemberOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the member belongs to - /// - public string PathChannelSid { get; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadMemberOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the channel the member belongs to - public ReadMemberOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Member resource to fetch + /// + public string PathSid { get; } + /// - /// DeleteMemberOptions - /// - public class DeleteMemberOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the Member resource to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Member resource to delete - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMemberOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the channel the Member resource to delete belongs to - /// The SID of the Member resource to delete - public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchMemberOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the channel the member belongs to + /// The SID of the Member resource to fetch + public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMemberOptions - /// - public class UpdateMemberOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the member to update belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Member resource to update - /// - public string PathSid { get; } - /// - /// The SID of the Role to assign to the member - /// - public string RoleSid { get; set; } - /// - /// The index of the last consumed Message for the Channel for the Member - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The ISO 8601 based timestamp string representing the datetime of the last Message read event for the Member within the Channel - /// - public DateTime? LastConsumptionTimestamp { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMemberOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the member to update belongs to - /// The SID of the Member resource to update - public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMemberOptions + /// + public class CreateMemberOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the channel the new member belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The SID of the Role to assign to the member + /// + public string RoleSid { get; set; } + /// + /// The index of the last Message in the Channel the Member has read + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The ISO 8601 based timestamp string representing the datetime of the last Message read event for the member within the Channel + /// + public DateTime? LastConsumptionTimestamp { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMemberOptions + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadMemberOptions + /// + public class ReadMemberOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The SID of the channel the member belongs to + /// + public string PathChannelSid { get; } + /// + /// The `identity` value of the resources to read + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadMemberOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the channel the member belongs to + public ReadMemberOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMemberOptions + /// + public class DeleteMemberOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the channel the Member resource to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Member resource to delete + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMemberOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the channel the Member resource to delete belongs to + /// The SID of the Member resource to delete + public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// UpdateMemberOptions + /// + public class UpdateMemberOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the channel the member to update belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Member resource to update + /// + public string PathSid { get; } + /// + /// The SID of the Role to assign to the member + /// + public string RoleSid { get; set; } + /// + /// The index of the last consumed Message for the Channel for the Member + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The ISO 8601 based timestamp string representing the datetime of the last Message read event for the Member within the Channel + /// + public DateTime? LastConsumptionTimestamp { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMemberOptions + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the member to update belongs to + /// The SID of the Member resource to update + public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/MemberResource.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/MemberResource.cs index 8f06610e9..7895bfd7f 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/MemberResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/MemberResource.cs @@ -17,617 +17,617 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - - public class MemberResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the channel the member belongs to - /// The SID of the Member resource to fetch - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the channel the member belongs to - /// The SID of the Member resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - /// The SID of the Role to assign to the member - /// The index of the last Message in the Channel the Member has read - /// The ISO 8601 based timestamp string representing the datetime of the last - /// Message read event for the member within the Channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// A valid JSON string that contains application-specific data - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the new member belongs to - /// The `identity` value that identifies the new resource's User - /// The SID of the Role to assign to the member - /// The index of the last Message in the Channel the Member has read - /// The ISO 8601 based timestamp string representing the datetime of the last - /// Message read event for the member within the Channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// A valid JSON string that contains application-specific data - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the channel the member belongs to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the channel the member belongs to - /// The `identity` value of the resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the channel the Member resource to delete belongs to - /// The SID of the Member resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the channel the Member resource to delete belongs to - /// The SID of the Member resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the member to update belongs to - /// The SID of the Member resource to update - /// The SID of the Role to assign to the member - /// The index of the last consumed Message for the Channel for the Member - /// - /// The ISO 8601 based timestamp string representing the datetime of the last - /// Message read event for the Member within the Channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// A valid JSON string that contains application-specific data - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to create the resource under - /// The SID of the channel the member to update belongs to - /// The SID of the Member resource to update - /// The SID of the Role to assign to the member - /// The index of the last consumed Message for the Channel for the Member - /// - /// The ISO 8601 based timestamp string representing the datetime of the last - /// Message read event for the Member within the Channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// A valid JSON string that contains application-specific data - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MemberResource object - /// - /// Raw JSON string - /// MemberResource object represented by the provided JSON - public static MemberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Channel for the member - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Role assigned to the member - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The index of the last Message that the Member has read within the Channel - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The ISO 8601 based timestamp string that represents the datetime of the last Message read event for the Member within the Channel - /// - [JsonProperty("last_consumption_timestamp")] - public DateTime? LastConsumptionTimestamp { get; private set; } - /// - /// The absolute URL of the Member resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - - private MemberResource() - { - - } - } +{ + + public class MemberResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the channel the member belongs to + /// The SID of the Member resource to fetch + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the channel the member belongs to + /// The SID of the Member resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + /// The SID of the Role to assign to the member + /// The index of the last Message in the Channel the Member has read + /// The ISO 8601 based timestamp string representing the datetime of the last + /// Message read event for the member within the Channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// A valid JSON string that contains application-specific data + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the new member belongs to + /// The `identity` value that identifies the new resource's User + /// The SID of the Role to assign to the member + /// The index of the last Message in the Channel the Member has read + /// The ISO 8601 based timestamp string representing the datetime of the last + /// Message read event for the member within the Channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// A valid JSON string that contains application-specific data + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the channel the member belongs to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the channel the member belongs to + /// The `identity` value of the resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the channel the Member resource to delete belongs to + /// The SID of the Member resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the channel the Member resource to delete belongs to + /// The SID of the Member resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the member to update belongs to + /// The SID of the Member resource to update + /// The SID of the Role to assign to the member + /// The index of the last consumed Message for the Channel for the Member + /// + /// The ISO 8601 based timestamp string representing the datetime of the last + /// Message read event for the Member within the Channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// A valid JSON string that contains application-specific data + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to create the resource under + /// The SID of the channel the member to update belongs to + /// The SID of the Member resource to update + /// The SID of the Role to assign to the member + /// The index of the last consumed Message for the Channel for the Member + /// + /// The ISO 8601 based timestamp string representing the datetime of the last + /// Message read event for the Member within the Channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// A valid JSON string that contains application-specific data + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MemberResource object + /// + /// Raw JSON string + /// MemberResource object represented by the provided JSON + public static MemberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Channel for the member + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Role assigned to the member + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The index of the last Message that the Member has read within the Channel + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The ISO 8601 based timestamp string that represents the datetime of the last Message read event for the Member within the Channel + /// + [JsonProperty("last_consumption_timestamp")] + public DateTime? LastConsumptionTimestamp { get; private set; } + /// + /// The absolute URL of the Member resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + + private MemberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/MessageOptions.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/MessageOptions.cs index 65f595845..aff6ee399 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/MessageOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/MessageOptions.cs @@ -9,384 +9,384 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - +{ + + /// + /// FetchMessageOptions + /// + public class FetchMessageOptions : IOptions + { /// - /// FetchMessageOptions - /// - public class FetchMessageOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the message to fetch belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Message resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the message to fetch belongs to - /// The SID of the Message resource to fetch - public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// CreateMessageOptions - /// - public class CreateMessageOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the new resource belongs to - /// - public string PathChannelSid { get; } - /// - /// The Identity of the new message's author - /// - public string From { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The Identity of the User who last updated the Message - /// - public string LastUpdatedBy { get; set; } - /// - /// The message to send to the channel - /// - public string Body { get; set; } - /// - /// The Media Sid to be attached to the new Message - /// - public string MediaSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - public CreateMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (LastUpdatedBy != null) - { - p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (MediaSid != null) - { - p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the Channel the message to fetch belongs to + /// + public string PathChannelSid { get; } /// - /// ReadMessageOptions - /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the message to read belongs to - /// - public string PathChannelSid { get; } - /// - /// The sort order of the returned messages - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the message to read belongs to - public ReadMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Message resource to fetch + /// + public string PathSid { get; } + /// - /// DeleteMessageOptions - /// - public class DeleteMessageOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the message to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Message resource to delete - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the message to delete belongs to - /// The SID of the Message resource to delete - public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchMessageOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the message to fetch belongs to + /// The SID of the Message resource to fetch + public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMessageOptions - /// - public class UpdateMessageOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the message belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Message resource to update - /// - public string PathSid { get; } - /// - /// The message to send to the channel - /// - public string Body { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The Identity of the User who last updated the Message, if applicable - /// - public string LastUpdatedBy { get; set; } - /// - /// The Identity of the message's author - /// - public string From { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel the message belongs to - /// The SID of the Message resource to update - public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (LastUpdatedBy != null) - { - p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMessageOptions + /// + public class CreateMessageOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the new resource belongs to + /// + public string PathChannelSid { get; } + /// + /// The Identity of the new message's author + /// + public string From { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The Identity of the User who last updated the Message + /// + public string LastUpdatedBy { get; set; } + /// + /// The message to send to the channel + /// + public string Body { get; set; } + /// + /// The Media Sid to be attached to the new Message + /// + public string MediaSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + public CreateMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (LastUpdatedBy != null) + { + p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (MediaSid != null) + { + p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadMessageOptions + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the message to read belongs to + /// + public string PathChannelSid { get; } + /// + /// The sort order of the returned messages + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the message to read belongs to + public ReadMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMessageOptions + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the message to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Message resource to delete + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the message to delete belongs to + /// The SID of the Message resource to delete + public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// UpdateMessageOptions + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the message belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Message resource to update + /// + public string PathSid { get; } + /// + /// The message to send to the channel + /// + public string Body { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The Identity of the User who last updated the Message, if applicable + /// + public string LastUpdatedBy { get; set; } + /// + /// The Identity of the message's author + /// + public string From { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel the message belongs to + /// The SID of the Message resource to update + public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (LastUpdatedBy != null) + { + p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/MessageResource.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/MessageResource.cs index 7482c5c1c..9cdabefdb 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/MessageResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/MessageResource.cs @@ -17,644 +17,644 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the message to fetch belongs to - /// The SID of the Message resource to fetch - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Channel the message to fetch belongs to - /// The SID of the Message resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The Identity of the new message's author - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The Identity of the User who last updated the Message - /// The message to send to the channel - /// The Media Sid to be attached to the new Message - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathServiceSid, - string pathChannelSid, - string from = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string body = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid){From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Channel the new resource belongs to - /// The Identity of the new message's author - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The Identity of the User who last updated the Message - /// The message to send to the channel - /// The Media Sid to be attached to the new Message - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string from = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string body = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid){From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the message to read belongs to - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the message to read belongs to - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the message to delete belongs to - /// The SID of the Message resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel the message to delete belongs to - /// The SID of the Message resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel the message belongs to - /// The SID of the Message resource to update - /// The message to send to the channel - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The Identity of the User who last updated the Message, if applicable - /// The Identity of the message's author - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string from = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel the message belongs to - /// The SID of the Message resource to update - /// The message to send to the channel - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The Identity of the User who last updated the Message, if applicable - /// The Identity of the message's author - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string from = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Channel that the message was sent to - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The SID of the Channel the Message resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Identity of the User who last updated the Message - /// - [JsonProperty("last_updated_by")] - public string LastUpdatedBy { get; private set; } - /// - /// Whether the message has been edited since it was created - /// - [JsonProperty("was_edited")] - public bool? WasEdited { get; private set; } - /// - /// The Identity of the message's author - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The content of the message - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The index of the message within the Channel - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The Message type - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// A Media object that describes the Message's media if attached; otherwise, null - /// - [JsonProperty("media")] - public object Media { get; private set; } - /// - /// The absolute URL of the Message resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the message to fetch belongs to + /// The SID of the Message resource to fetch + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Channel the message to fetch belongs to + /// The SID of the Message resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The Identity of the new message's author + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The Identity of the User who last updated the Message + /// The message to send to the channel + /// The Media Sid to be attached to the new Message + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathServiceSid, + string pathChannelSid, + string from = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string body = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid) { From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Channel the new resource belongs to + /// The Identity of the new message's author + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The Identity of the User who last updated the Message + /// The message to send to the channel + /// The Media Sid to be attached to the new Message + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string from = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string body = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid) { From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the message to read belongs to + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the message to read belongs to + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the message to delete belongs to + /// The SID of the Message resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel the message to delete belongs to + /// The SID of the Message resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel the message belongs to + /// The SID of the Message resource to update + /// The message to send to the channel + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The Identity of the User who last updated the Message, if applicable + /// The Identity of the message's author + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string from = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel the message belongs to + /// The SID of the Message resource to update + /// The message to send to the channel + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The Identity of the User who last updated the Message, if applicable + /// The Identity of the message's author + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string from = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Channel that the message was sent to + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The SID of the Channel the Message resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Identity of the User who last updated the Message + /// + [JsonProperty("last_updated_by")] + public string LastUpdatedBy { get; private set; } + /// + /// Whether the message has been edited since it was created + /// + [JsonProperty("was_edited")] + public bool? WasEdited { get; private set; } + /// + /// The Identity of the message's author + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The content of the message + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The index of the message within the Channel + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The Message type + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// A Media object that describes the Message's media if attached; otherwise, null + /// + [JsonProperty("media")] + public object Media { get; private set; } + /// + /// The absolute URL of the Message resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookOptions.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookOptions.cs index 789885491..86abbba9c 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookOptions.cs @@ -10,328 +10,328 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - +{ + + /// + /// ReadWebhookOptions + /// + public class ReadWebhookOptions : ReadOptions + { /// - /// ReadWebhookOptions - /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resources to read belong to - /// - public string PathChannelSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - public ReadWebhookOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } /// - /// FetchWebhookOptions - /// - public class FetchWebhookOptions : IOptions - { - /// - /// The SID of the Service with the Channel to fetch the Webhook resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to fetch belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Channel Webhook resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The SID of the Service with the Channel to fetch the Webhook resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Channel Webhook resource to fetch - public FetchWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Channel the resources to read belong to + /// + public string PathChannelSid { get; } + /// - /// CreateWebhookOptions - /// - public class CreateWebhookOptions : IOptions - { - /// - /// The SID of the Service with the Channel to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the new resource belongs to - /// - public string PathChannelSid { get; } - /// - /// The type of webhook - /// - public WebhookResource.TypeEnum Type { get; } - /// - /// The URL of the webhook to call - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method used to call `configuration.url` - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The events that cause us to call the Channel Webhook - /// - public List ConfigurationFilters { get; set; } - /// - /// A string that will cause us to call the webhook when it is found in a message body - /// - public List ConfigurationTriggers { get; set; } - /// - /// The SID of the Studio Flow to call when an event occurs - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The number of times to retry the webhook if the first attempt fails - /// - public int? ConfigurationRetryCount { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// The SID of the Service with the Channel to create the resource under - /// The SID of the Channel the new resource belongs to - /// The type of webhook - public CreateWebhookOptions(string pathServiceSid, string pathChannelSid, WebhookResource.TypeEnum type) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Type = type; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationRetryCount != null) - { - p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); - } - - return p; - } - } - + /// Construct a new ReadWebhookOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + public ReadWebhookOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + /// - /// UpdateWebhookOptions - /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The SID of the Service with the Channel that has the Webhook resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel the resource to update belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the resource - /// - public string PathSid { get; } - /// - /// The URL of the webhook to call - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method used to call `configuration.url` - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The events that cause us to call the Channel Webhook - /// - public List ConfigurationFilters { get; set; } - /// - /// A string that will cause us to call the webhook when it is found in a message body - /// - public List ConfigurationTriggers { get; set; } - /// - /// The SID of the Studio Flow to call when an event occurs - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The number of times to retry the webhook if the first attempt fails - /// - public int? ConfigurationRetryCount { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The SID of the Service with the Channel that has the Webhook resource to update - /// - /// The SID of the Channel the resource to update belongs to - /// The SID of the resource - public UpdateWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationRetryCount != null) - { - p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchWebhookOptions + /// + public class FetchWebhookOptions : IOptions + { /// - /// DeleteWebhookOptions - /// - public class DeleteWebhookOptions : IOptions - { - /// - /// The SID of the Service with the Channel to delete the Webhook resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the channel the resource to delete belongs to - /// - public string PathChannelSid { get; } - /// - /// The SID of the Channel Webhook resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// The SID of the Service with the Channel to delete the Webhook resource from - /// The SID of the channel the resource to delete belongs to - /// The SID of the Channel Webhook resource to delete - public DeleteWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Service with the Channel to fetch the Webhook resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resource to fetch belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Channel Webhook resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// The SID of the Service with the Channel to fetch the Webhook resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Channel Webhook resource to fetch + public FetchWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateWebhookOptions + /// + public class CreateWebhookOptions : IOptions + { + /// + /// The SID of the Service with the Channel to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the new resource belongs to + /// + public string PathChannelSid { get; } + /// + /// The type of webhook + /// + public WebhookResource.TypeEnum Type { get; } + /// + /// The URL of the webhook to call + /// + public string ConfigurationUrl { get; set; } + /// + /// The HTTP method used to call `configuration.url` + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The events that cause us to call the Channel Webhook + /// + public List ConfigurationFilters { get; set; } + /// + /// A string that will cause us to call the webhook when it is found in a message body + /// + public List ConfigurationTriggers { get; set; } + /// + /// The SID of the Studio Flow to call when an event occurs + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The number of times to retry the webhook if the first attempt fails + /// + public int? ConfigurationRetryCount { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// The SID of the Service with the Channel to create the resource under + /// The SID of the Channel the new resource belongs to + /// The type of webhook + public CreateWebhookOptions(string pathServiceSid, string pathChannelSid, WebhookResource.TypeEnum type) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Type = type; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationRetryCount != null) + { + p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// UpdateWebhookOptions + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// The SID of the Service with the Channel that has the Webhook resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel the resource to update belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the resource + /// + public string PathSid { get; } + /// + /// The URL of the webhook to call + /// + public string ConfigurationUrl { get; set; } + /// + /// The HTTP method used to call `configuration.url` + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The events that cause us to call the Channel Webhook + /// + public List ConfigurationFilters { get; set; } + /// + /// A string that will cause us to call the webhook when it is found in a message body + /// + public List ConfigurationTriggers { get; set; } + /// + /// The SID of the Studio Flow to call when an event occurs + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The number of times to retry the webhook if the first attempt fails + /// + public int? ConfigurationRetryCount { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The SID of the Service with the Channel that has the Webhook resource to update + /// + /// The SID of the Channel the resource to update belongs to + /// The SID of the resource + public UpdateWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationRetryCount != null) + { + p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// DeleteWebhookOptions + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// The SID of the Service with the Channel to delete the Webhook resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the channel the resource to delete belongs to + /// + public string PathChannelSid { get; } + /// + /// The SID of the Channel Webhook resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// The SID of the Service with the Channel to delete the Webhook resource from + /// The SID of the channel the resource to delete belongs to + /// The SID of the Channel Webhook resource to delete + public DeleteWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookResource.cs b/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookResource.cs index f06c6cae1..23b4dbb24 100644 --- a/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/Channel/WebhookResource.cs @@ -17,600 +17,600 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service.Channel -{ - - public class WebhookResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Webhook = new TypeEnum("webhook"); - public static readonly TypeEnum Trigger = new TypeEnum("trigger"); - public static readonly TypeEnum Studio = new TypeEnum("studio"); - } - - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The SID of the Channel the resources to read belong to - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service with the Channel to fetch the Webhook resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Channel Webhook resource to fetch - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service with the Channel to fetch the Webhook resource from - /// The SID of the Channel the resource to fetch belongs to - /// The SID of the Channel Webhook resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service with the Channel to create the resource under - /// The SID of the Channel the new resource belongs to - /// The type of webhook - /// The URL of the webhook to call - /// The HTTP method used to call `configuration.url` - /// The events that cause us to call the Channel Webhook - /// A string that will cause us to call the webhook when it is found in a message - /// body - /// The SID of the Studio Flow to call when an event occurs - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathServiceSid, - string pathChannelSid, - WebhookResource.TypeEnum type, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service with the Channel to create the resource under - /// The SID of the Channel the new resource belongs to - /// The type of webhook - /// The URL of the webhook to call - /// The HTTP method used to call `configuration.url` - /// The events that cause us to call the Channel Webhook - /// A string that will cause us to call the webhook when it is found in a message - /// body - /// The SID of the Studio Flow to call when an event occurs - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - WebhookResource.TypeEnum type, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service with the Channel that has the Webhook resource to update - /// - /// The SID of the Channel the resource to update belongs to - /// The SID of the resource - /// The URL of the webhook to call - /// The HTTP method used to call `configuration.url` - /// The events that cause us to call the Channel Webhook - /// A string that will cause us to call the webhook when it is found in a message - /// body - /// The SID of the Studio Flow to call when an event occurs - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service with the Channel that has the Webhook resource to update - /// - /// The SID of the Channel the resource to update belongs to - /// The SID of the resource - /// The URL of the webhook to call - /// The HTTP method used to call `configuration.url` - /// The events that cause us to call the Channel Webhook - /// A string that will cause us to call the webhook when it is found in a message - /// body - /// The SID of the Studio Flow to call when an event occurs - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service with the Channel to delete the Webhook resource from - /// The SID of the channel the resource to delete belongs to - /// The SID of the Channel Webhook resource to delete - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service with the Channel to delete the Webhook resource from - /// The SID of the channel the resource to delete belongs to - /// The SID of the Channel Webhook resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Channel Webhook resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Channel the Channel Webhook resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The type of webhook - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The absolute URL of the Channel Webhook resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON string that describes the configuration object for the channel webhook - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Webhook = new TypeEnum("webhook"); + public static readonly TypeEnum Trigger = new TypeEnum("trigger"); + public static readonly TypeEnum Studio = new TypeEnum("studio"); + } + + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The SID of the Channel the resources to read belong to + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service with the Channel to fetch the Webhook resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Channel Webhook resource to fetch + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service with the Channel to fetch the Webhook resource from + /// The SID of the Channel the resource to fetch belongs to + /// The SID of the Channel Webhook resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service with the Channel to create the resource under + /// The SID of the Channel the new resource belongs to + /// The type of webhook + /// The URL of the webhook to call + /// The HTTP method used to call `configuration.url` + /// The events that cause us to call the Channel Webhook + /// A string that will cause us to call the webhook when it is found in a message + /// body + /// The SID of the Studio Flow to call when an event occurs + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathServiceSid, + string pathChannelSid, + WebhookResource.TypeEnum type, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service with the Channel to create the resource under + /// The SID of the Channel the new resource belongs to + /// The type of webhook + /// The URL of the webhook to call + /// The HTTP method used to call `configuration.url` + /// The events that cause us to call the Channel Webhook + /// A string that will cause us to call the webhook when it is found in a message + /// body + /// The SID of the Studio Flow to call when an event occurs + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + WebhookResource.TypeEnum type, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service with the Channel that has the Webhook resource to update + /// + /// The SID of the Channel the resource to update belongs to + /// The SID of the resource + /// The URL of the webhook to call + /// The HTTP method used to call `configuration.url` + /// The events that cause us to call the Channel Webhook + /// A string that will cause us to call the webhook when it is found in a message + /// body + /// The SID of the Studio Flow to call when an event occurs + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service with the Channel that has the Webhook resource to update + /// + /// The SID of the Channel the resource to update belongs to + /// The SID of the resource + /// The URL of the webhook to call + /// The HTTP method used to call `configuration.url` + /// The events that cause us to call the Channel Webhook + /// A string that will cause us to call the webhook when it is found in a message + /// body + /// The SID of the Studio Flow to call when an event occurs + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service with the Channel to delete the Webhook resource from + /// The SID of the channel the resource to delete belongs to + /// The SID of the Channel Webhook resource to delete + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service with the Channel to delete the Webhook resource from + /// The SID of the channel the resource to delete belongs to + /// The SID of the Channel Webhook resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Channel Webhook resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Channel the Channel Webhook resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The type of webhook + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The absolute URL of the Channel Webhook resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON string that describes the configuration object for the channel webhook + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/ChannelOptions.cs b/src/Twilio/Rest/Chat/V2/Service/ChannelOptions.cs index aa2628154..9e5388e7b 100644 --- a/src/Twilio/Rest/Chat/V2/Service/ChannelOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/ChannelOptions.cs @@ -10,355 +10,355 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service -{ - +{ + + /// + /// FetchChannelOptions + /// + public class FetchChannelOptions : IOptions + { /// - /// FetchChannelOptions - /// - public class FetchChannelOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChannelOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource - public FetchChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// DeleteChannelOptions - /// - public class DeleteChannelOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel resource to delete - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteChannelOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel resource to delete - public DeleteChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the resource + /// + public string PathSid { get; } + /// - /// CreateChannelOptions - /// - public class CreateChannelOptions : IOptions - { - /// - /// The SID of the Service to create the Channel resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the Channel resource - /// - public string UniqueName { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The visibility of the channel - /// - public ChannelResource.ChannelTypeEnum Type { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The identity of the User that created the Channel - /// - public string CreatedBy { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateChannelOptions - /// - /// The SID of the Service to create the Channel resource under - public CreateChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (CreatedBy != null) - { - p.Add(new KeyValuePair("CreatedBy", CreatedBy)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchChannelOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource + public FetchChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadChannelOptions - /// - public class ReadChannelOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The visibility of the channel to read - /// - public List Type { get; set; } - - /// - /// Construct a new ReadChannelOptions - /// - /// The SID of the Service to read the resources from - public ReadChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Type = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteChannelOptions + /// + public class DeleteChannelOptions : IOptions + { /// - /// UpdateChannelOptions - /// - public class UpdateChannelOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Channel resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - public DateTime? DateCreated { get; set; } - /// - /// The ISO 8601 date and time in GMT when the resource was updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The identity of the User that created the Channel - /// - public string CreatedBy { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateChannelOptions - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel resource to update - public UpdateChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (CreatedBy != null) - { - p.Add(new KeyValuePair("CreatedBy", CreatedBy)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel resource to delete + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteChannelOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel resource to delete + public DeleteChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// CreateChannelOptions + /// + public class CreateChannelOptions : IOptions + { + /// + /// The SID of the Service to create the Channel resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the Channel resource + /// + public string UniqueName { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The visibility of the channel + /// + public ChannelResource.ChannelTypeEnum Type { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The identity of the User that created the Channel + /// + public string CreatedBy { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateChannelOptions + /// + /// The SID of the Service to create the Channel resource under + public CreateChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (CreatedBy != null) + { + p.Add(new KeyValuePair("CreatedBy", CreatedBy)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadChannelOptions + /// + public class ReadChannelOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The visibility of the channel to read + /// + public List Type { get; set; } + + /// + /// Construct a new ReadChannelOptions + /// + /// The SID of the Service to read the resources from + public ReadChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Type = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateChannelOptions + /// + public class UpdateChannelOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Channel resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + public DateTime? DateCreated { get; set; } + /// + /// The ISO 8601 date and time in GMT when the resource was updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The identity of the User that created the Channel + /// + public string CreatedBy { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateChannelOptions + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel resource to update + public UpdateChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (CreatedBy != null) + { + p.Add(new KeyValuePair("CreatedBy", CreatedBy)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/ChannelResource.cs b/src/Twilio/Rest/Chat/V2/Service/ChannelResource.cs index 1612006b9..3e80767d9 100644 --- a/src/Twilio/Rest/Chat/V2/Service/ChannelResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/ChannelResource.cs @@ -17,613 +17,613 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service -{ - - public class ChannelResource : Resource - { - public sealed class ChannelTypeEnum : StringEnum - { - private ChannelTypeEnum(string value) : base(value) {} - public ChannelTypeEnum() {} - public static implicit operator ChannelTypeEnum(string value) - { - return new ChannelTypeEnum(value); - } - - public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); - public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(string pathServiceSid, - string pathSid, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Channel resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the Channel resource under - /// A string to describe the new resource - /// An application-defined string that uniquely identifies the Channel resource - /// A valid JSON string that contains application-specific data - /// The visibility of the channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The identity of the User that created the Channel - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the Channel resource under - /// A string to describe the new resource - /// An application-defined string that uniquely identifies the Channel resource - /// A valid JSON string that contains application-specific data - /// The visibility of the channel - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The identity of the User that created the Channel - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The visibility of the channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// The visibility of the channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel resource to update - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The identity of the User that created the Channel - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Channel resource to update - /// A string to describe the resource - /// An application-defined string that uniquely identifies the resource - /// A valid JSON string that contains application-specific data - /// The ISO 8601 date and time in GMT when the resource was created - /// The ISO 8601 date and time in GMT when the resource was updated - /// The identity of the User that created the Channel - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The visibility of the channel. Can be: `public` or `private` - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public ChannelResource.ChannelTypeEnum Type { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the User that created the channel - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The number of Members in the Channel - /// - [JsonProperty("members_count")] - public int? MembersCount { get; private set; } - /// - /// The number of Messages that have been passed in the Channel - /// - [JsonProperty("messages_count")] - public int? MessagesCount { get; private set; } - /// - /// The absolute URL of the Channel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + public sealed class ChannelTypeEnum : StringEnum + { + private ChannelTypeEnum(string value) : base(value) { } + public ChannelTypeEnum() { } + public static implicit operator ChannelTypeEnum(string value) + { + return new ChannelTypeEnum(value); + } + + public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); + public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(string pathServiceSid, + string pathSid, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Channel resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the Channel resource under + /// A string to describe the new resource + /// An application-defined string that uniquely identifies the Channel resource + /// A valid JSON string that contains application-specific data + /// The visibility of the channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The identity of the User that created the Channel + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the Channel resource under + /// A string to describe the new resource + /// An application-defined string that uniquely identifies the Channel resource + /// A valid JSON string that contains application-specific data + /// The visibility of the channel + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The identity of the User that created the Channel + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The visibility of the channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// The visibility of the channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel resource to update + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The identity of the User that created the Channel + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Channel resource to update + /// A string to describe the resource + /// An application-defined string that uniquely identifies the resource + /// A valid JSON string that contains application-specific data + /// The ISO 8601 date and time in GMT when the resource was created + /// The ISO 8601 date and time in GMT when the resource was updated + /// The identity of the User that created the Channel + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The visibility of the channel. Can be: `public` or `private` + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public ChannelResource.ChannelTypeEnum Type { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the User that created the channel + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The number of Members in the Channel + /// + [JsonProperty("members_count")] + public int? MembersCount { get; private set; } + /// + /// The number of Messages that have been passed in the Channel + /// + [JsonProperty("messages_count")] + public int? MessagesCount { get; private set; } + /// + /// The absolute URL of the Channel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/RoleOptions.cs b/src/Twilio/Rest/Chat/V2/Service/RoleOptions.cs index 855ae99c1..bccb66ac1 100644 --- a/src/Twilio/Rest/Chat/V2/Service/RoleOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/RoleOptions.cs @@ -10,221 +10,221 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service -{ - +{ + + /// + /// FetchRoleOptions + /// + public class FetchRoleOptions : IOptions + { /// - /// FetchRoleOptions - /// - public class FetchRoleOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Role resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Role resource to fetch - public FetchRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } /// - /// DeleteRoleOptions - /// - public class DeleteRoleOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Role resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the Role resource to delete - public DeleteRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Role resource to fetch + /// + public string PathSid { get; } + /// - /// CreateRoleOptions - /// - public class CreateRoleOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; } - /// - /// The type of role - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - public CreateRoleOptions(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// Construct a new FetchRoleOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Role resource to fetch + public FetchRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadRoleOptions + /// Generate the necessary parameters /// - public class ReadRoleOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadRoleOptions - /// - /// The SID of the Service to read the resources from - public ReadRoleOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteRoleOptions + /// + public class DeleteRoleOptions : IOptions + { /// - /// UpdateRoleOptions - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Role resource to update - /// - public string PathSid { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The SID of the Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Role resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the Role resource to delete + public DeleteRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRoleOptions + /// + public class CreateRoleOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; } + /// + /// The type of role + /// + public RoleResource.RoleTypeEnum Type { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new CreateRoleOptions + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + public CreateRoleOptions(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// ReadRoleOptions + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadRoleOptions + /// + /// The SID of the Service to read the resources from + public ReadRoleOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateRoleOptions + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Role resource to update + /// + public string PathSid { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The SID of the Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/RoleResource.cs b/src/Twilio/Rest/Chat/V2/Service/RoleResource.cs index bea207ef3..0a1208744 100644 --- a/src/Twilio/Rest/Chat/V2/Service/RoleResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/RoleResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); - public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); - } - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of role - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// An array of the permissions the role has been granted - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Role resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); + public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); + } + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of role + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// An array of the permissions the role has been granted + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Role resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/User/UserBindingOptions.cs b/src/Twilio/Rest/Chat/V2/Service/User/UserBindingOptions.cs index 53ae10bca..96d20be6b 100644 --- a/src/Twilio/Rest/Chat/V2/Service/User/UserBindingOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/User/UserBindingOptions.cs @@ -10,138 +10,138 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.User -{ - +{ + + /// + /// ReadUserBindingOptions + /// + public class ReadUserBindingOptions : ReadOptions + { /// - /// ReadUserBindingOptions + /// The SID of the Service to read the resource from /// - public class ReadUserBindingOptions : ReadOptions - { - /// - /// The SID of the Service to read the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User with the User Bindings to read - /// - public string PathUserSid { get; } - /// - /// The push technology used by the User Binding resources to read - /// - public List BindingType { get; set; } - - /// - /// Construct a new ReadUserBindingOptions - /// - /// The SID of the Service to read the resource from - /// The SID of the User with the User Bindings to read - public ReadUserBindingOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - BindingType = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (BindingType != null) - { - p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// FetchUserBindingOptions + /// The SID of the User with the User Bindings to read /// - public class FetchUserBindingOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User with the binding - /// - public string PathUserSid { get; } - /// - /// The SID of the User Binding resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserBindingOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User with the binding - /// The SID of the User Binding resource to fetch - public FetchUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathUserSid { get; } /// - /// DeleteUserBindingOptions + /// The push technology used by the User Binding resources to read /// - public class DeleteUserBindingOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User of the User Bindings to delete - /// - public string PathUserSid { get; } - /// - /// The SID of the User Binding resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserBindingOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the User of the User Bindings to delete - /// The SID of the User Binding resource to delete - public DeleteUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List BindingType { get; set; } + + /// + /// Construct a new ReadUserBindingOptions + /// + /// The SID of the Service to read the resource from + /// The SID of the User with the User Bindings to read + public ReadUserBindingOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + BindingType = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (BindingType != null) + { + p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchUserBindingOptions + /// + public class FetchUserBindingOptions : IOptions + { + /// + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User with the binding + /// + public string PathUserSid { get; } + /// + /// The SID of the User Binding resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchUserBindingOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the User with the binding + /// The SID of the User Binding resource to fetch + public FetchUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserBindingOptions + /// + public class DeleteUserBindingOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User of the User Bindings to delete + /// + public string PathUserSid { get; } + /// + /// The SID of the User Binding resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserBindingOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the User of the User Bindings to delete + /// The SID of the User Binding resource to delete + public DeleteUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/User/UserBindingResource.cs b/src/Twilio/Rest/Chat/V2/Service/User/UserBindingResource.cs index 2519b4f6f..a9f59066e 100644 --- a/src/Twilio/Rest/Chat/V2/Service/User/UserBindingResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/User/UserBindingResource.cs @@ -17,398 +17,398 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service.User -{ - - public class UserBindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - } - - private static Request BuildReadRequest(ReadUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static ResourceSet Read(ReadUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resource from - /// The SID of the User with the User Bindings to read - /// The push technology used by the User Binding resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - List bindingType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid){BindingType = bindingType, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resource from - /// The SID of the User with the User Bindings to read - /// The push technology used by the User Binding resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - List bindingType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid){BindingType = bindingType, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - private static Request BuildFetchRequest(FetchUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static UserBindingResource Fetch(FetchUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task FetchAsync(FetchUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User with the binding - /// The SID of the User Binding resource to fetch - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static UserBindingResource Fetch(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User with the binding - /// The SID of the User Binding resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static bool Delete(DeleteUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the User of the User Bindings to delete - /// The SID of the User Binding resource to delete - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static bool Delete(string pathServiceSid, string pathUserSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the User of the User Bindings to delete - /// The SID of the User Binding resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserBindingResource object - /// - /// Raw JSON string - /// UserBindingResource object represented by the provided JSON - public static UserBindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique endpoint identifier for the User Binding - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The SID of the User with the binding - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The SID of the Credential for the binding - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The push technology to use for the binding - /// - [JsonProperty("binding_type")] - [JsonConverter(typeof(StringEnumConverter))] - public UserBindingResource.BindingTypeEnum BindingType { get; private set; } - /// - /// The Programmable Chat message types the binding is subscribed to - /// - [JsonProperty("message_types")] - public List MessageTypes { get; private set; } - /// - /// The absolute URL of the User Binding resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserBindingResource() - { - - } - } +{ + + public class UserBindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + } + + private static Request BuildReadRequest(ReadUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static ResourceSet Read(ReadUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resource from + /// The SID of the User with the User Bindings to read + /// The push technology used by the User Binding resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + List bindingType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid) { BindingType = bindingType, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resource from + /// The SID of the User with the User Bindings to read + /// The push technology used by the User Binding resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + List bindingType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid) { BindingType = bindingType, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + private static Request BuildFetchRequest(FetchUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static UserBindingResource Fetch(FetchUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task FetchAsync(FetchUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the User with the binding + /// The SID of the User Binding resource to fetch + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static UserBindingResource Fetch(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the User with the binding + /// The SID of the User Binding resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static bool Delete(DeleteUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the User of the User Bindings to delete + /// The SID of the User Binding resource to delete + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static bool Delete(string pathServiceSid, string pathUserSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the User of the User Bindings to delete + /// The SID of the User Binding resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserBindingResource object + /// + /// Raw JSON string + /// UserBindingResource object represented by the provided JSON + public static UserBindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique endpoint identifier for the User Binding + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The SID of the User with the binding + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The SID of the Credential for the binding + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The push technology to use for the binding + /// + [JsonProperty("binding_type")] + [JsonConverter(typeof(StringEnumConverter))] + public UserBindingResource.BindingTypeEnum BindingType { get; private set; } + /// + /// The Programmable Chat message types the binding is subscribed to + /// + [JsonProperty("message_types")] + public List MessageTypes { get; private set; } + /// + /// The absolute URL of the User Binding resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserBindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/User/UserChannelOptions.cs b/src/Twilio/Rest/Chat/V2/Service/User/UserChannelOptions.cs index 11ba58102..280327515 100644 --- a/src/Twilio/Rest/Chat/V2/Service/User/UserChannelOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/User/UserChannelOptions.cs @@ -9,196 +9,196 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service.User -{ - +{ + + /// + /// List all Channels for a given User. + /// + public class ReadUserChannelOptions : ReadOptions + { /// - /// List all Channels for a given User. - /// - public class ReadUserChannelOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User to fetch the User Channel resources from - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserChannelOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } /// - /// FetchUserChannelOptions - /// - public class FetchUserChannelOptions : IOptions - { - /// - /// The SID of the Service to fetch the User Channel resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User to fetch the User Channel resource from - /// - public string PathUserSid { get; } - /// - /// The SID of the Channel that has the User Channel to fetch - /// - public string PathChannelSid { get; } - - /// - /// Construct a new FetchUserChannelOptions - /// - /// The SID of the Service to fetch the User Channel resource from - /// The SID of the User to fetch the User Channel resource from - /// The SID of the Channel that has the User Channel to fetch - public FetchUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the User to fetch the User Channel resources from + /// + public string PathUserSid { get; } + /// - /// Removes User from selected Channel. - /// - public class DeleteUserChannelOptions : IOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User to fetch the User Channel resources from - /// - public string PathUserSid { get; } - /// - /// The SID of the Channel the resource belongs to - /// - public string PathChannelSid { get; } - - /// - /// Construct a new DeleteUserChannelOptions - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// The SID of the Channel the resource belongs to - public DeleteUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadUserChannelOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + } + /// - /// UpdateUserChannelOptions - /// - public class UpdateUserChannelOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User to update the User Channel resource from - /// - public string PathUserSid { get; } - /// - /// The SID of the Channel with the User Channel resource to update - /// - public string PathChannelSid { get; } - /// - /// The push notification level to assign to the User Channel - /// - public UserChannelResource.NotificationLevelEnum NotificationLevel { get; set; } - /// - /// The index of the last Message that the Member has read within the Channel - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The ISO 8601 based timestamp string that represents the datetime of the last Message read event for the Member within the Channel - /// - public DateTime? LastConsumptionTimestamp { get; set; } - - /// - /// Construct a new UpdateUserChannelOptions - /// - /// The SID of the Service to update the resource from - /// The SID of the User to update the User Channel resource from - /// The SID of the Channel with the User Channel resource to update - public UpdateUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (NotificationLevel != null) - { - p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchUserChannelOptions + /// + public class FetchUserChannelOptions : IOptions + { + /// + /// The SID of the Service to fetch the User Channel resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User to fetch the User Channel resource from + /// + public string PathUserSid { get; } + /// + /// The SID of the Channel that has the User Channel to fetch + /// + public string PathChannelSid { get; } + + /// + /// Construct a new FetchUserChannelOptions + /// + /// The SID of the Service to fetch the User Channel resource from + /// The SID of the User to fetch the User Channel resource from + /// The SID of the Channel that has the User Channel to fetch + public FetchUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Removes User from selected Channel. + /// + public class DeleteUserChannelOptions : IOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User to fetch the User Channel resources from + /// + public string PathUserSid { get; } + /// + /// The SID of the Channel the resource belongs to + /// + public string PathChannelSid { get; } + + /// + /// Construct a new DeleteUserChannelOptions + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// The SID of the Channel the resource belongs to + public DeleteUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateUserChannelOptions + /// + public class UpdateUserChannelOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User to update the User Channel resource from + /// + public string PathUserSid { get; } + /// + /// The SID of the Channel with the User Channel resource to update + /// + public string PathChannelSid { get; } + /// + /// The push notification level to assign to the User Channel + /// + public UserChannelResource.NotificationLevelEnum NotificationLevel { get; set; } + /// + /// The index of the last Message that the Member has read within the Channel + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The ISO 8601 based timestamp string that represents the datetime of the last Message read event for the Member within the Channel + /// + public DateTime? LastConsumptionTimestamp { get; set; } + + /// + /// Construct a new UpdateUserChannelOptions + /// + /// The SID of the Service to update the resource from + /// The SID of the User to update the User Channel resource from + /// The SID of the Channel with the User Channel resource to update + public UpdateUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (NotificationLevel != null) + { + p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/User/UserChannelResource.cs b/src/Twilio/Rest/Chat/V2/Service/User/UserChannelResource.cs index 1f0d279e3..27d289514 100644 --- a/src/Twilio/Rest/Chat/V2/Service/User/UserChannelResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/User/UserChannelResource.cs @@ -17,498 +17,498 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service.User -{ - - public class UserChannelResource : Resource - { - public sealed class ChannelStatusEnum : StringEnum - { - private ChannelStatusEnum(string value) : base(value) {} - public ChannelStatusEnum() {} - public static implicit operator ChannelStatusEnum(string value) - { - return new ChannelStatusEnum(value); - } - - public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); - public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); - public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); - } - - public sealed class NotificationLevelEnum : StringEnum - { - private NotificationLevelEnum(string value) : base(value) {} - public NotificationLevelEnum() {} - public static implicit operator NotificationLevelEnum(string value) - { - return new NotificationLevelEnum(value); - } - - public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); - public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); - } - - private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List all Channels for a given User. - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List all Channels for a given User. - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List all Channels for a given User. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List all Channels for a given User. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildFetchRequest(FetchUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Fetch(FetchUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the User Channel resource from - /// The SID of the User to fetch the User Channel resource from - /// The SID of the Channel that has the User Channel to fetch - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Fetch(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the User Channel resource from - /// The SID of the User to fetch the User Channel resource from - /// The SID of the Channel that has the User Channel to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Removes User from selected Channel. - /// - /// Delete UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static bool Delete(DeleteUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Removes User from selected Channel. - /// - /// Delete UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Removes User from selected Channel. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// The SID of the Channel the resource belongs to - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static bool Delete(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Removes User from selected Channel. - /// - /// The SID of the Service to read the resources from - /// The SID of the User to fetch the User Channel resources from - /// The SID of the Channel the resource belongs to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Update(UpdateUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the User to update the User Channel resource from - /// The SID of the Channel with the User Channel resource to update - /// The push notification level to assign to the User Channel - /// The index of the last Message that the Member has read within the Channel - /// - /// The ISO 8601 based timestamp string that represents the datetime of the - /// last Message read event for the Member within the Channel - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Update(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - UserChannelResource.NotificationLevelEnum notificationLevel = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid){NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the User to update the User Channel resource from - /// The SID of the Channel with the User Channel resource to update - /// The push notification level to assign to the User Channel - /// The index of the last Message that the Member has read within the Channel - /// - /// The ISO 8601 based timestamp string that represents the datetime of the - /// last Message read event for the Member within the Channel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - UserChannelResource.NotificationLevelEnum notificationLevel = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid){NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserChannelResource object - /// - /// Raw JSON string - /// UserChannelResource object represented by the provided JSON - public static UserChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Channel the resource belongs to - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The SID of the User the User Channel belongs to - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The SID of the User as a Member in the Channel - /// - [JsonProperty("member_sid")] - public string MemberSid { get; private set; } - /// - /// The status of the User on the Channel - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.ChannelStatusEnum Status { get; private set; } - /// - /// The index of the last Message in the Channel the Member has read - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The number of unread Messages in the Channel for the User - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The push notification level of the User for the Channel - /// - [JsonProperty("notification_level")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.NotificationLevelEnum NotificationLevel { get; private set; } - - private UserChannelResource() - { - - } - } +{ + + public class UserChannelResource : Resource + { + public sealed class ChannelStatusEnum : StringEnum + { + private ChannelStatusEnum(string value) : base(value) { } + public ChannelStatusEnum() { } + public static implicit operator ChannelStatusEnum(string value) + { + return new ChannelStatusEnum(value); + } + + public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); + public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); + public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); + } + + public sealed class NotificationLevelEnum : StringEnum + { + private NotificationLevelEnum(string value) : base(value) { } + public NotificationLevelEnum() { } + public static implicit operator NotificationLevelEnum(string value) + { + return new NotificationLevelEnum(value); + } + + public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); + public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); + } + + private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List all Channels for a given User. + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List all Channels for a given User. + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List all Channels for a given User. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List all Channels for a given User. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildFetchRequest(FetchUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Fetch(FetchUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the User Channel resource from + /// The SID of the User to fetch the User Channel resource from + /// The SID of the Channel that has the User Channel to fetch + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Fetch(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the User Channel resource from + /// The SID of the User to fetch the User Channel resource from + /// The SID of the Channel that has the User Channel to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Removes User from selected Channel. + /// + /// Delete UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static bool Delete(DeleteUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Removes User from selected Channel. + /// + /// Delete UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Removes User from selected Channel. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// The SID of the Channel the resource belongs to + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static bool Delete(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Removes User from selected Channel. + /// + /// The SID of the Service to read the resources from + /// The SID of the User to fetch the User Channel resources from + /// The SID of the Channel the resource belongs to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Update(UpdateUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the User to update the User Channel resource from + /// The SID of the Channel with the User Channel resource to update + /// The push notification level to assign to the User Channel + /// The index of the last Message that the Member has read within the Channel + /// + /// The ISO 8601 based timestamp string that represents the datetime of the + /// last Message read event for the Member within the Channel + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Update(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + UserChannelResource.NotificationLevelEnum notificationLevel = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid) { NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the User to update the User Channel resource from + /// The SID of the Channel with the User Channel resource to update + /// The push notification level to assign to the User Channel + /// The index of the last Message that the Member has read within the Channel + /// + /// The ISO 8601 based timestamp string that represents the datetime of the + /// last Message read event for the Member within the Channel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + UserChannelResource.NotificationLevelEnum notificationLevel = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid) { NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserChannelResource object + /// + /// Raw JSON string + /// UserChannelResource object represented by the provided JSON + public static UserChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Channel the resource belongs to + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The SID of the User the User Channel belongs to + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The SID of the User as a Member in the Channel + /// + [JsonProperty("member_sid")] + public string MemberSid { get; private set; } + /// + /// The status of the User on the Channel + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.ChannelStatusEnum Status { get; private set; } + /// + /// The index of the last Message in the Channel the Member has read + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The number of unread Messages in the Channel for the User + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The push notification level of the User for the Channel + /// + [JsonProperty("notification_level")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.NotificationLevelEnum NotificationLevel { get; private set; } + + private UserChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/UserOptions.cs b/src/Twilio/Rest/Chat/V2/Service/UserOptions.cs index d23e856c9..26483cbd9 100644 --- a/src/Twilio/Rest/Chat/V2/Service/UserOptions.cs +++ b/src/Twilio/Rest/Chat/V2/Service/UserOptions.cs @@ -9,275 +9,275 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2.Service -{ - +{ + + /// + /// FetchUserOptions + /// + public class FetchUserOptions : IOptions + { /// - /// FetchUserOptions + /// The SID of the Service to fetch the resource from /// - public class FetchUserOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User resource to fetch - public FetchUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// DeleteUserOptions + /// The SID of the User resource to fetch /// - public class DeleteUserOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The SID of the Service to delete the resource from - /// The SID of the User resource to delete - public DeleteUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateUserOptions + /// Construct a new FetchUserOptions /// - public class CreateUserOptions : IOptions - { - /// - /// The SID of the Service to create the new resource under - /// - public string PathServiceSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The SID of the Role assigned to this user - /// - public string RoleSid { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - public CreateUserOptions(string pathServiceSid, string identity) - { - PathServiceSid = pathServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The SID of the User resource to fetch + public FetchUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadUserOptions + /// Generate the necessary parameters /// - public class ReadUserOptions : ReadOptions - { - /// - /// The SID of the Service to read the User resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadUserOptions - /// - /// The SID of the Service to read the User resources from - public ReadUserOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserOptions + /// + public class DeleteUserOptions : IOptions + { /// - /// UpdateUserOptions + /// The SID of the Service to delete the resource from /// - public class UpdateUserOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the User resource to update - /// - public string PathSid { get; } - /// - /// The SID id of the Role assigned to this user - /// - public string RoleSid { get; set; } - /// - /// A valid JSON string that contains application-specific data - /// - public string Attributes { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The SID of the Service to update the resource from - /// The SID of the User resource to update - public UpdateUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the User resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The SID of the Service to delete the resource from + /// The SID of the User resource to delete + public DeleteUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateUserOptions + /// + public class CreateUserOptions : IOptions + { + /// + /// The SID of the Service to create the new resource under + /// + public string PathServiceSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The SID of the Role assigned to this user + /// + public string RoleSid { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// A string to describe the new resource + /// + public string FriendlyName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + public CreateUserOptions(string pathServiceSid, string identity) + { + PathServiceSid = pathServiceSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadUserOptions + /// + public class ReadUserOptions : ReadOptions + { + /// + /// The SID of the Service to read the User resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadUserOptions + /// + /// The SID of the Service to read the User resources from + public ReadUserOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateUserOptions + /// + public class UpdateUserOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the User resource to update + /// + public string PathSid { get; } + /// + /// The SID id of the Role assigned to this user + /// + public string RoleSid { get; set; } + /// + /// A valid JSON string that contains application-specific data + /// + public string Attributes { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The SID of the Service to update the resource from + /// The SID of the User resource to update + public UpdateUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/Service/UserResource.cs b/src/Twilio/Rest/Chat/V2/Service/UserResource.cs index d3802e33e..2a4f4d8b4 100644 --- a/src/Twilio/Rest/Chat/V2/Service/UserResource.cs +++ b/src/Twilio/Rest/Chat/V2/Service/UserResource.cs @@ -17,565 +17,565 @@ using Twilio.Types; namespace Twilio.Rest.Chat.V2.Service -{ - - public class UserResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the User resource to delete - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID of the User resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - /// The SID of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the new resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the new resource under - /// The `identity` value that identifies the new resource's User - /// The SID of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the new resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the User resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the User resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the User resource to update - /// The SID id of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service to update the resource from - /// The SID of the User resource to update - /// The SID id of the Role assigned to this user - /// A valid JSON string that contains application-specific data - /// A string to describe the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The JSON string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the Role assigned to the user - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Whether the User is actively connected to the Service instance and online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// Whether the User has a potentially valid Push Notification registration for the Service instance - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The number of Channels the User is a Member of - /// - [JsonProperty("joined_channels_count")] - public int? JoinedChannelsCount { get; private set; } - /// - /// The absolute URLs of the Channel and Binding resources related to the user - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The absolute URL of the User resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the User resource to delete + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID of the User resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + /// The SID of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the new resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the new resource under + /// The `identity` value that identifies the new resource's User + /// The SID of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the new resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the User resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the User resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the User resource to update + /// The SID id of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service to update the resource from + /// The SID of the User resource to update + /// The SID id of the Role assigned to this user + /// A valid JSON string that contains application-specific data + /// A string to describe the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The JSON string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the Role assigned to the user + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Whether the User is actively connected to the Service instance and online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// Whether the User has a potentially valid Push Notification registration for the Service instance + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The number of Channels the User is a Member of + /// + [JsonProperty("joined_channels_count")] + public int? JoinedChannelsCount { get; private set; } + /// + /// The absolute URLs of the Channel and Binding resources related to the user + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The absolute URL of the User resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/ServiceOptions.cs b/src/Twilio/Rest/Chat/V2/ServiceOptions.cs index e977ec2cc..752261a7c 100644 --- a/src/Twilio/Rest/Chat/V2/ServiceOptions.cs +++ b/src/Twilio/Rest/Chat/V2/ServiceOptions.cs @@ -10,427 +10,427 @@ using Twilio.Converters; namespace Twilio.Rest.Chat.V2 -{ - +{ + + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// FetchServiceOptions + /// The SID of the Service resource to fetch /// - public class FetchServiceOptions : IOptions - { - /// - /// The SID of the Service resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The SID of the Service resource to fetch - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteServiceOptions + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The SID of the Service resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The SID of the Service resource to delete - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service resource to fetch + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateServiceOptions + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateServiceOptions - /// - /// A string to describe the resource - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service resource to delete + /// + public string PathSid { get; } + /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The SID of the Service resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The service role assigned to users when they are added to the service - /// - public string DefaultServiceRoleSid { get; set; } - /// - /// The channel role assigned to users when they are added to a channel - /// - public string DefaultChannelRoleSid { get; set; } - /// - /// The channel role assigned to a channel creator when they join a new channel - /// - public string DefaultChannelCreatorRoleSid { get; set; } - /// - /// Whether to enable the Message Consumption Horizon feature - /// - public bool? ReadStatusEnabled { get; set; } - /// - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - public bool? ReachabilityEnabled { get; set; } - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - public int? TypingIndicatorTimeout { get; set; } - /// - /// DEPRECATED - /// - public int? ConsumptionReportInterval { get; set; } - /// - /// Whether to send a notification when a new message is added to a channel - /// - public bool? NotificationsNewMessageEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a new message is added to a channel - /// - public string NotificationsNewMessageTemplate { get; set; } - /// - /// The name of the sound to play when a new message is added to a channel - /// - public string NotificationsNewMessageSound { get; set; } - /// - /// Whether the new message badge is enabled - /// - public bool? NotificationsNewMessageBadgeCountEnabled { get; set; } - /// - /// Whether to send a notification when a member is added to a channel - /// - public bool? NotificationsAddedToChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a member is added to a channel - /// - public string NotificationsAddedToChannelTemplate { get; set; } - /// - /// The name of the sound to play when a member is added to a channel - /// - public string NotificationsAddedToChannelSound { get; set; } - /// - /// Whether to send a notification to a user when they are removed from a channel - /// - public bool? NotificationsRemovedFromChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed to a user when they are removed - /// - public string NotificationsRemovedFromChannelTemplate { get; set; } - /// - /// The name of the sound to play to a user when they are removed from a channel - /// - public string NotificationsRemovedFromChannelSound { get; set; } - /// - /// Whether to send a notification when a user is invited to a channel - /// - public bool? NotificationsInvitedToChannelEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a user is invited to a channel - /// - public string NotificationsInvitedToChannelTemplate { get; set; } - /// - /// The name of the sound to play when a user is invited to a channel - /// - public string NotificationsInvitedToChannelSound { get; set; } - /// - /// The webhook URL for pre-event webhooks - /// - public Uri PreWebhookUrl { get; set; } - /// - /// The URL for post-event webhooks - /// - public Uri PostWebhookUrl { get; set; } - /// - /// The HTTP method to use for both PRE and POST webhooks - /// - public Twilio.Http.HttpMethod WebhookMethod { get; set; } - /// - /// The list of webhook events that are enabled for this Service instance - /// - public List WebhookFilters { get; set; } - /// - /// The maximum number of Members that can be added to Channels within this Service - /// - public int? LimitsChannelMembers { get; set; } - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - public int? LimitsUserChannels { get; set; } - /// - /// The message to send when a media message has no text - /// - public string MediaCompatibilityMessage { get; set; } - /// - /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses - /// - public int? PreWebhookRetryCount { get; set; } - /// - /// The number of times calls to the `post_webhook_url` will be retried - /// - public int? PostWebhookRetryCount { get; set; } - /// - /// Whether to log notifications - /// - public bool? NotificationsLogEnabled { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The SID of the Service resource to update - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - WebhookFilters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DefaultServiceRoleSid != null) - { - p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); - } - - if (DefaultChannelRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); - } - - if (DefaultChannelCreatorRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); - } - - if (ReadStatusEnabled != null) - { - p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); - } - - if (TypingIndicatorTimeout != null) - { - p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); - } - - if (ConsumptionReportInterval != null) - { - p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); - } - - if (NotificationsNewMessageEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); - } - - if (NotificationsNewMessageTemplate != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); - } - - if (NotificationsNewMessageSound != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Sound", NotificationsNewMessageSound)); - } - - if (NotificationsNewMessageBadgeCountEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.BadgeCountEnabled", NotificationsNewMessageBadgeCountEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); - } - - if (NotificationsAddedToChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Sound", NotificationsAddedToChannelSound)); - } - - if (NotificationsRemovedFromChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsRemovedFromChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); - } - - if (NotificationsRemovedFromChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Sound", NotificationsRemovedFromChannelSound)); - } - - if (NotificationsInvitedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsInvitedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); - } - - if (NotificationsInvitedToChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Sound", NotificationsInvitedToChannelSound)); - } - - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); - } - - if (WebhookFilters != null) - { - p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); - } - - if (LimitsChannelMembers != null) - { - p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); - } - - if (LimitsUserChannels != null) - { - p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); - } - - if (MediaCompatibilityMessage != null) - { - p.Add(new KeyValuePair("Media.CompatibilityMessage", MediaCompatibilityMessage)); - } - - if (PreWebhookRetryCount != null) - { - p.Add(new KeyValuePair("PreWebhookRetryCount", PreWebhookRetryCount.ToString())); - } - - if (PostWebhookRetryCount != null) - { - p.Add(new KeyValuePair("PostWebhookRetryCount", PostWebhookRetryCount.ToString())); - } - - if (NotificationsLogEnabled != null) - { - p.Add(new KeyValuePair("Notifications.LogEnabled", NotificationsLogEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new DeleteServiceOptions + /// + /// The SID of the Service resource to delete + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateServiceOptions + /// + /// A string to describe the resource + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The SID of the Service resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The service role assigned to users when they are added to the service + /// + public string DefaultServiceRoleSid { get; set; } + /// + /// The channel role assigned to users when they are added to a channel + /// + public string DefaultChannelRoleSid { get; set; } + /// + /// The channel role assigned to a channel creator when they join a new channel + /// + public string DefaultChannelCreatorRoleSid { get; set; } + /// + /// Whether to enable the Message Consumption Horizon feature + /// + public bool? ReadStatusEnabled { get; set; } + /// + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + public bool? ReachabilityEnabled { get; set; } + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + public int? TypingIndicatorTimeout { get; set; } + /// + /// DEPRECATED + /// + public int? ConsumptionReportInterval { get; set; } + /// + /// Whether to send a notification when a new message is added to a channel + /// + public bool? NotificationsNewMessageEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a new message is added to a channel + /// + public string NotificationsNewMessageTemplate { get; set; } + /// + /// The name of the sound to play when a new message is added to a channel + /// + public string NotificationsNewMessageSound { get; set; } + /// + /// Whether the new message badge is enabled + /// + public bool? NotificationsNewMessageBadgeCountEnabled { get; set; } + /// + /// Whether to send a notification when a member is added to a channel + /// + public bool? NotificationsAddedToChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a member is added to a channel + /// + public string NotificationsAddedToChannelTemplate { get; set; } + /// + /// The name of the sound to play when a member is added to a channel + /// + public string NotificationsAddedToChannelSound { get; set; } + /// + /// Whether to send a notification to a user when they are removed from a channel + /// + public bool? NotificationsRemovedFromChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed to a user when they are removed + /// + public string NotificationsRemovedFromChannelTemplate { get; set; } + /// + /// The name of the sound to play to a user when they are removed from a channel + /// + public string NotificationsRemovedFromChannelSound { get; set; } + /// + /// Whether to send a notification when a user is invited to a channel + /// + public bool? NotificationsInvitedToChannelEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a user is invited to a channel + /// + public string NotificationsInvitedToChannelTemplate { get; set; } + /// + /// The name of the sound to play when a user is invited to a channel + /// + public string NotificationsInvitedToChannelSound { get; set; } + /// + /// The webhook URL for pre-event webhooks + /// + public Uri PreWebhookUrl { get; set; } + /// + /// The URL for post-event webhooks + /// + public Uri PostWebhookUrl { get; set; } + /// + /// The HTTP method to use for both PRE and POST webhooks + /// + public Twilio.Http.HttpMethod WebhookMethod { get; set; } + /// + /// The list of webhook events that are enabled for this Service instance + /// + public List WebhookFilters { get; set; } + /// + /// The maximum number of Members that can be added to Channels within this Service + /// + public int? LimitsChannelMembers { get; set; } + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + public int? LimitsUserChannels { get; set; } + /// + /// The message to send when a media message has no text + /// + public string MediaCompatibilityMessage { get; set; } + /// + /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses + /// + public int? PreWebhookRetryCount { get; set; } + /// + /// The number of times calls to the `post_webhook_url` will be retried + /// + public int? PostWebhookRetryCount { get; set; } + /// + /// Whether to log notifications + /// + public bool? NotificationsLogEnabled { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The SID of the Service resource to update + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + WebhookFilters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DefaultServiceRoleSid != null) + { + p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); + } + + if (DefaultChannelRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); + } + + if (DefaultChannelCreatorRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); + } + + if (ReadStatusEnabled != null) + { + p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); + } + + if (TypingIndicatorTimeout != null) + { + p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); + } + + if (ConsumptionReportInterval != null) + { + p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); + } + + if (NotificationsNewMessageEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); + } + + if (NotificationsNewMessageTemplate != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); + } + + if (NotificationsNewMessageSound != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Sound", NotificationsNewMessageSound)); + } + + if (NotificationsNewMessageBadgeCountEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.BadgeCountEnabled", NotificationsNewMessageBadgeCountEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); + } + + if (NotificationsAddedToChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Sound", NotificationsAddedToChannelSound)); + } + + if (NotificationsRemovedFromChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsRemovedFromChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); + } + + if (NotificationsRemovedFromChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Sound", NotificationsRemovedFromChannelSound)); + } + + if (NotificationsInvitedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsInvitedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); + } + + if (NotificationsInvitedToChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Sound", NotificationsInvitedToChannelSound)); + } + + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); + } + + if (WebhookFilters != null) + { + p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); + } + + if (LimitsChannelMembers != null) + { + p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); + } + + if (LimitsUserChannels != null) + { + p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); + } + + if (MediaCompatibilityMessage != null) + { + p.Add(new KeyValuePair("Media.CompatibilityMessage", MediaCompatibilityMessage)); + } + + if (PreWebhookRetryCount != null) + { + p.Add(new KeyValuePair("PreWebhookRetryCount", PreWebhookRetryCount.ToString())); + } + + if (PostWebhookRetryCount != null) + { + p.Add(new KeyValuePair("PostWebhookRetryCount", PostWebhookRetryCount.ToString())); + } + + if (NotificationsLogEnabled != null) + { + p.Add(new KeyValuePair("Notifications.LogEnabled", NotificationsLogEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Chat/V2/ServiceResource.cs b/src/Twilio/Rest/Chat/V2/ServiceResource.cs index 8c06aae13..26157a822 100644 --- a/src/Twilio/Rest/Chat/V2/ServiceResource.cs +++ b/src/Twilio/Rest/Chat/V2/ServiceResource.cs @@ -16,705 +16,705 @@ using Twilio.Http; namespace Twilio.Rest.Chat.V2 -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Chat, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Chat, - "/v2/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Chat) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Chat, - "/v2/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service resource to update - /// A string to describe the resource - /// The service role assigned to users when they are added to the service - /// The channel role assigned to users when they are added to a channel - /// The channel role assigned to a channel creator when they join a new - /// channel - /// Whether to enable the Message Consumption Horizon feature - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - /// DEPRECATED - /// Whether to send a notification when a new message is added to a - /// channel - /// The template to use to create the notification text displayed when a - /// new message is added to a channel - /// The name of the sound to play when a new message is added to a channel - /// - /// Whether the new message badge is enabled - /// Whether to send a notification when a member is added to a - /// channel - /// The template to use to create the notification text displayed - /// when a member is added to a channel - /// The name of the sound to play when a member is added to a channel - /// - /// Whether to send a notification to a user when they are - /// removed from a channel - /// The template to use to create the notification text - /// displayed to a user when they are removed - /// The name of the sound to play to a user when they are removed - /// from a channel - /// Whether to send a notification when a user is invited to a - /// channel - /// The template to use to create the notification text displayed - /// when a user is invited to a channel - /// The name of the sound to play when a user is invited to a channel - /// - /// The webhook URL for pre-event webhooks - /// The URL for post-event webhooks - /// The HTTP method to use for both PRE and POST webhooks - /// The list of webhook events that are enabled for this Service instance - /// The maximum number of Members that can be added to Channels within this Service - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - /// The message to send when a media message has no text - /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP - /// responses - /// The number of times calls to the `post_webhook_url` will be retried - /// Whether to log notifications - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - string notificationsNewMessageSound = null, - bool? notificationsNewMessageBadgeCountEnabled = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - string notificationsAddedToChannelSound = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - string notificationsRemovedFromChannelSound = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - string notificationsInvitedToChannelSound = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - string mediaCompatibilityMessage = null, - int? preWebhookRetryCount = null, - int? postWebhookRetryCount = null, - bool? notificationsLogEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service resource to update - /// A string to describe the resource - /// The service role assigned to users when they are added to the service - /// The channel role assigned to users when they are added to a channel - /// The channel role assigned to a channel creator when they join a new - /// channel - /// Whether to enable the Message Consumption Horizon feature - /// Whether to enable the Reachability Indicator feature for this Service instance - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - /// DEPRECATED - /// Whether to send a notification when a new message is added to a - /// channel - /// The template to use to create the notification text displayed when a - /// new message is added to a channel - /// The name of the sound to play when a new message is added to a channel - /// - /// Whether the new message badge is enabled - /// Whether to send a notification when a member is added to a - /// channel - /// The template to use to create the notification text displayed - /// when a member is added to a channel - /// The name of the sound to play when a member is added to a channel - /// - /// Whether to send a notification to a user when they are - /// removed from a channel - /// The template to use to create the notification text - /// displayed to a user when they are removed - /// The name of the sound to play to a user when they are removed - /// from a channel - /// Whether to send a notification when a user is invited to a - /// channel - /// The template to use to create the notification text displayed - /// when a user is invited to a channel - /// The name of the sound to play when a user is invited to a channel - /// - /// The webhook URL for pre-event webhooks - /// The URL for post-event webhooks - /// The HTTP method to use for both PRE and POST webhooks - /// The list of webhook events that are enabled for this Service instance - /// The maximum number of Members that can be added to Channels within this Service - /// - /// The maximum number of Channels Users can be a Member of within this Service - /// - /// The message to send when a media message has no text - /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP - /// responses - /// The number of times calls to the `post_webhook_url` will be retried - /// Whether to log notifications - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - string notificationsNewMessageSound = null, - bool? notificationsNewMessageBadgeCountEnabled = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - string notificationsAddedToChannelSound = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - string notificationsRemovedFromChannelSound = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - string notificationsInvitedToChannelSound = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - string mediaCompatibilityMessage = null, - int? preWebhookRetryCount = null, - int? postWebhookRetryCount = null, - bool? notificationsLogEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The service role assigned to users when they are added to the service - /// - [JsonProperty("default_service_role_sid")] - public string DefaultServiceRoleSid { get; private set; } - /// - /// The channel role assigned to users when they are added to a channel - /// - [JsonProperty("default_channel_role_sid")] - public string DefaultChannelRoleSid { get; private set; } - /// - /// The channel role assigned to a channel creator when they join a new channel - /// - [JsonProperty("default_channel_creator_role_sid")] - public string DefaultChannelCreatorRoleSid { get; private set; } - /// - /// Whether the Message Consumption Horizon feature is enabled - /// - [JsonProperty("read_status_enabled")] - public bool? ReadStatusEnabled { get; private set; } - /// - /// Whether the Reachability Indicator feature is enabled for this Service instance - /// - [JsonProperty("reachability_enabled")] - public bool? ReachabilityEnabled { get; private set; } - /// - /// How long in seconds to wait before assuming the user is no longer typing - /// - [JsonProperty("typing_indicator_timeout")] - public int? TypingIndicatorTimeout { get; private set; } - /// - /// DEPRECATED - /// - [JsonProperty("consumption_report_interval")] - public int? ConsumptionReportInterval { get; private set; } - /// - /// An object that describes the limits of the service instance - /// - [JsonProperty("limits")] - public object Limits { get; private set; } - /// - /// The webhook URL for pre-event webhooks - /// - [JsonProperty("pre_webhook_url")] - public string PreWebhookUrl { get; private set; } - /// - /// The URL for post-event webhooks - /// - [JsonProperty("post_webhook_url")] - public string PostWebhookUrl { get; private set; } - /// - /// The HTTP method to use for both PRE and POST webhooks - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The list of webhook events that are enabled for this Service instance - /// - [JsonProperty("webhook_filters")] - public List WebhookFilters { get; private set; } - /// - /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses - /// - [JsonProperty("pre_webhook_retry_count")] - public int? PreWebhookRetryCount { get; private set; } - /// - /// The number of times calls to the `post_webhook_url` will be retried - /// - [JsonProperty("post_webhook_retry_count")] - public int? PostWebhookRetryCount { get; private set; } - /// - /// The notification configuration for the Service instance - /// - [JsonProperty("notifications")] - public object Notifications { get; private set; } - /// - /// The properties of the media that the service supports - /// - [JsonProperty("media")] - public object Media { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The absolute URLs of the Service's Channels, Roles, and Users - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Chat, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Chat, + "/v2/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Chat) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Chat, + "/v2/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service resource to update + /// A string to describe the resource + /// The service role assigned to users when they are added to the service + /// The channel role assigned to users when they are added to a channel + /// The channel role assigned to a channel creator when they join a new + /// channel + /// Whether to enable the Message Consumption Horizon feature + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + /// DEPRECATED + /// Whether to send a notification when a new message is added to a + /// channel + /// The template to use to create the notification text displayed when a + /// new message is added to a channel + /// The name of the sound to play when a new message is added to a channel + /// + /// Whether the new message badge is enabled + /// Whether to send a notification when a member is added to a + /// channel + /// The template to use to create the notification text displayed + /// when a member is added to a channel + /// The name of the sound to play when a member is added to a channel + /// + /// Whether to send a notification to a user when they are + /// removed from a channel + /// The template to use to create the notification text + /// displayed to a user when they are removed + /// The name of the sound to play to a user when they are removed + /// from a channel + /// Whether to send a notification when a user is invited to a + /// channel + /// The template to use to create the notification text displayed + /// when a user is invited to a channel + /// The name of the sound to play when a user is invited to a channel + /// + /// The webhook URL for pre-event webhooks + /// The URL for post-event webhooks + /// The HTTP method to use for both PRE and POST webhooks + /// The list of webhook events that are enabled for this Service instance + /// The maximum number of Members that can be added to Channels within this Service + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + /// The message to send when a media message has no text + /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP + /// responses + /// The number of times calls to the `post_webhook_url` will be retried + /// Whether to log notifications + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + string notificationsNewMessageSound = null, + bool? notificationsNewMessageBadgeCountEnabled = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + string notificationsAddedToChannelSound = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + string notificationsRemovedFromChannelSound = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + string notificationsInvitedToChannelSound = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + string mediaCompatibilityMessage = null, + int? preWebhookRetryCount = null, + int? postWebhookRetryCount = null, + bool? notificationsLogEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service resource to update + /// A string to describe the resource + /// The service role assigned to users when they are added to the service + /// The channel role assigned to users when they are added to a channel + /// The channel role assigned to a channel creator when they join a new + /// channel + /// Whether to enable the Message Consumption Horizon feature + /// Whether to enable the Reachability Indicator feature for this Service instance + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + /// DEPRECATED + /// Whether to send a notification when a new message is added to a + /// channel + /// The template to use to create the notification text displayed when a + /// new message is added to a channel + /// The name of the sound to play when a new message is added to a channel + /// + /// Whether the new message badge is enabled + /// Whether to send a notification when a member is added to a + /// channel + /// The template to use to create the notification text displayed + /// when a member is added to a channel + /// The name of the sound to play when a member is added to a channel + /// + /// Whether to send a notification to a user when they are + /// removed from a channel + /// The template to use to create the notification text + /// displayed to a user when they are removed + /// The name of the sound to play to a user when they are removed + /// from a channel + /// Whether to send a notification when a user is invited to a + /// channel + /// The template to use to create the notification text displayed + /// when a user is invited to a channel + /// The name of the sound to play when a user is invited to a channel + /// + /// The webhook URL for pre-event webhooks + /// The URL for post-event webhooks + /// The HTTP method to use for both PRE and POST webhooks + /// The list of webhook events that are enabled for this Service instance + /// The maximum number of Members that can be added to Channels within this Service + /// + /// The maximum number of Channels Users can be a Member of within this Service + /// + /// The message to send when a media message has no text + /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP + /// responses + /// The number of times calls to the `post_webhook_url` will be retried + /// Whether to log notifications + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + string notificationsNewMessageSound = null, + bool? notificationsNewMessageBadgeCountEnabled = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + string notificationsAddedToChannelSound = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + string notificationsRemovedFromChannelSound = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + string notificationsInvitedToChannelSound = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + string mediaCompatibilityMessage = null, + int? preWebhookRetryCount = null, + int? postWebhookRetryCount = null, + bool? notificationsLogEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The service role assigned to users when they are added to the service + /// + [JsonProperty("default_service_role_sid")] + public string DefaultServiceRoleSid { get; private set; } + /// + /// The channel role assigned to users when they are added to a channel + /// + [JsonProperty("default_channel_role_sid")] + public string DefaultChannelRoleSid { get; private set; } + /// + /// The channel role assigned to a channel creator when they join a new channel + /// + [JsonProperty("default_channel_creator_role_sid")] + public string DefaultChannelCreatorRoleSid { get; private set; } + /// + /// Whether the Message Consumption Horizon feature is enabled + /// + [JsonProperty("read_status_enabled")] + public bool? ReadStatusEnabled { get; private set; } + /// + /// Whether the Reachability Indicator feature is enabled for this Service instance + /// + [JsonProperty("reachability_enabled")] + public bool? ReachabilityEnabled { get; private set; } + /// + /// How long in seconds to wait before assuming the user is no longer typing + /// + [JsonProperty("typing_indicator_timeout")] + public int? TypingIndicatorTimeout { get; private set; } + /// + /// DEPRECATED + /// + [JsonProperty("consumption_report_interval")] + public int? ConsumptionReportInterval { get; private set; } + /// + /// An object that describes the limits of the service instance + /// + [JsonProperty("limits")] + public object Limits { get; private set; } + /// + /// The webhook URL for pre-event webhooks + /// + [JsonProperty("pre_webhook_url")] + public string PreWebhookUrl { get; private set; } + /// + /// The URL for post-event webhooks + /// + [JsonProperty("post_webhook_url")] + public string PostWebhookUrl { get; private set; } + /// + /// The HTTP method to use for both PRE and POST webhooks + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The list of webhook events that are enabled for this Service instance + /// + [JsonProperty("webhook_filters")] + public List WebhookFilters { get; private set; } + /// + /// Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses + /// + [JsonProperty("pre_webhook_retry_count")] + public int? PreWebhookRetryCount { get; private set; } + /// + /// The number of times calls to the `post_webhook_url` will be retried + /// + [JsonProperty("post_webhook_retry_count")] + public int? PostWebhookRetryCount { get; private set; } + /// + /// The notification configuration for the Service instance + /// + [JsonProperty("notifications")] + public object Notifications { get; private set; } + /// + /// The properties of the media that the service supports + /// + [JsonProperty("media")] + public object Media { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The absolute URLs of the Service's Channels, Roles, and Users + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Configuration/WebhookOptions.cs b/src/Twilio/Rest/Conversations/V1/Configuration/WebhookOptions.cs index be392b42a..dbcb4fdb0 100644 --- a/src/Twilio/Rest/Conversations/V1/Configuration/WebhookOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Configuration/WebhookOptions.cs @@ -10,90 +10,90 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Configuration -{ - +{ + + /// + /// FetchWebhookOptions + /// + public class FetchWebhookOptions : IOptions + { /// - /// FetchWebhookOptions + /// Generate the necessary parameters /// - public class FetchWebhookOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateWebhookOptions + /// + public class UpdateWebhookOptions : IOptions + { /// - /// UpdateWebhookOptions + /// The HTTP method to be used when sending a webhook request. /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The HTTP method to be used when sending a webhook request. - /// - public string Method { get; set; } - /// - /// The list of webhook event triggers that are enabled for this Service. - /// - public List Filters { get; set; } - /// - /// The absolute url the pre-event webhook request should be sent to. - /// - public string PreWebhookUrl { get; set; } - /// - /// The absolute url the post-event webhook request should be sent to. - /// - public string PostWebhookUrl { get; set; } - /// - /// The routing target of the webhook. - /// - public WebhookResource.TargetEnum Target { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - public UpdateWebhookOptions() - { - Filters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Method != null) - { - p.Add(new KeyValuePair("Method", Method)); - } - - if (Filters != null) - { - p.AddRange(Filters.Select(prop => new KeyValuePair("Filters", prop))); - } - - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", PreWebhookUrl)); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", PostWebhookUrl)); - } - - if (Target != null) - { - p.Add(new KeyValuePair("Target", Target.ToString())); - } - - return p; - } - } + public string Method { get; set; } + /// + /// The list of webhook event triggers that are enabled for this Service. + /// + public List Filters { get; set; } + /// + /// The absolute url the pre-event webhook request should be sent to. + /// + public string PreWebhookUrl { get; set; } + /// + /// The absolute url the post-event webhook request should be sent to. + /// + public string PostWebhookUrl { get; set; } + /// + /// The routing target of the webhook. + /// + public WebhookResource.TargetEnum Target { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + public UpdateWebhookOptions() + { + Filters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Method != null) + { + p.Add(new KeyValuePair("Method", Method)); + } + + if (Filters != null) + { + p.AddRange(Filters.Select(prop => new KeyValuePair("Filters", prop))); + } + + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", PreWebhookUrl)); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", PostWebhookUrl)); + } + + if (Target != null) + { + p.Add(new KeyValuePair("Target", Target.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Configuration/WebhookResource.cs b/src/Twilio/Rest/Conversations/V1/Configuration/WebhookResource.cs index 7b67ab89e..a46742c7b 100644 --- a/src/Twilio/Rest/Conversations/V1/Configuration/WebhookResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Configuration/WebhookResource.cs @@ -17,244 +17,244 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Configuration -{ - - public class WebhookResource : Resource - { - public sealed class TargetEnum : StringEnum - { - private TargetEnum(string value) : base(value) {} - public TargetEnum() {} - public static implicit operator TargetEnum(string value) - { - return new TargetEnum(value); - } - - public static readonly TargetEnum Webhook = new TargetEnum("webhook"); - public static readonly TargetEnum Flex = new TargetEnum("flex"); - } - - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Configuration/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Configuration/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The HTTP method to be used when sending a webhook request. - /// The list of webhook event triggers that are enabled for this Service. - /// The absolute url the pre-event webhook request should be sent to. - /// The absolute url the post-event webhook request should be sent to. - /// The routing target of the webhook. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string method = null, - List filters = null, - string preWebhookUrl = null, - string postWebhookUrl = null, - WebhookResource.TargetEnum target = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(){Method = method, Filters = filters, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Target = target}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The HTTP method to be used when sending a webhook request. - /// The list of webhook event triggers that are enabled for this Service. - /// The absolute url the pre-event webhook request should be sent to. - /// The absolute url the post-event webhook request should be sent to. - /// The routing target of the webhook. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string method = null, - List filters = null, - string preWebhookUrl = null, - string postWebhookUrl = null, - WebhookResource.TargetEnum target = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(){Method = method, Filters = filters, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Target = target}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The HTTP method to be used when sending a webhook request. - /// - [JsonProperty("method")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.MethodEnum Method { get; private set; } - /// - /// The list of webhook event triggers that are enabled for this Service. - /// - [JsonProperty("filters")] - public List Filters { get; private set; } - /// - /// The absolute url the pre-event webhook request should be sent to. - /// - [JsonProperty("pre_webhook_url")] - public string PreWebhookUrl { get; private set; } - /// - /// The absolute url the post-event webhook request should be sent to. - /// - [JsonProperty("post_webhook_url")] - public string PostWebhookUrl { get; private set; } - /// - /// The routing target of the webhook. - /// - [JsonProperty("target")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.TargetEnum Target { get; private set; } - /// - /// An absolute URL for this webhook. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class TargetEnum : StringEnum + { + private TargetEnum(string value) : base(value) { } + public TargetEnum() { } + public static implicit operator TargetEnum(string value) + { + return new TargetEnum(value); + } + + public static readonly TargetEnum Webhook = new TargetEnum("webhook"); + public static readonly TargetEnum Flex = new TargetEnum("flex"); + } + + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Configuration/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Configuration/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The HTTP method to be used when sending a webhook request. + /// The list of webhook event triggers that are enabled for this Service. + /// The absolute url the pre-event webhook request should be sent to. + /// The absolute url the post-event webhook request should be sent to. + /// The routing target of the webhook. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string method = null, + List filters = null, + string preWebhookUrl = null, + string postWebhookUrl = null, + WebhookResource.TargetEnum target = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions() { Method = method, Filters = filters, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Target = target }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The HTTP method to be used when sending a webhook request. + /// The list of webhook event triggers that are enabled for this Service. + /// The absolute url the pre-event webhook request should be sent to. + /// The absolute url the post-event webhook request should be sent to. + /// The routing target of the webhook. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string method = null, + List filters = null, + string preWebhookUrl = null, + string postWebhookUrl = null, + WebhookResource.TargetEnum target = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions() { Method = method, Filters = filters, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Target = target }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The HTTP method to be used when sending a webhook request. + /// + [JsonProperty("method")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.MethodEnum Method { get; private set; } + /// + /// The list of webhook event triggers that are enabled for this Service. + /// + [JsonProperty("filters")] + public List Filters { get; private set; } + /// + /// The absolute url the pre-event webhook request should be sent to. + /// + [JsonProperty("pre_webhook_url")] + public string PreWebhookUrl { get; private set; } + /// + /// The absolute url the post-event webhook request should be sent to. + /// + [JsonProperty("post_webhook_url")] + public string PostWebhookUrl { get; private set; } + /// + /// The routing target of the webhook. + /// + [JsonProperty("target")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.TargetEnum Target { get; private set; } + /// + /// An absolute URL for this webhook. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ConfigurationOptions.cs b/src/Twilio/Rest/Conversations/V1/ConfigurationOptions.cs index 6e353fbec..435ed6d70 100644 --- a/src/Twilio/Rest/Conversations/V1/ConfigurationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/ConfigurationOptions.cs @@ -9,73 +9,73 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Fetch the global configuration of conversations on your account + /// + public class FetchConfigurationOptions : IOptions + { /// - /// Fetch the global configuration of conversations on your account + /// Generate the necessary parameters /// - public class FetchConfigurationOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the global configuration of conversations on your account + /// + public class UpdateConfigurationOptions : IOptions + { /// - /// Update the global configuration of conversations on your account + /// The SID of the default Conversation Service that every new conversation will be associated with. /// - public class UpdateConfigurationOptions : IOptions - { - /// - /// The SID of the default Conversation Service that every new conversation will be associated with. - /// - public string DefaultChatServiceSid { get; set; } - /// - /// The SID of the default Messaging Service that every new conversation will be associated with. - /// - public string DefaultMessagingServiceSid { get; set; } - /// - /// Default ISO8601 duration when conversation will be switched to `inactive` state. - /// - public string DefaultInactiveTimer { get; set; } - /// - /// Default ISO8601 duration when conversation will be switched to `closed` state. - /// - public string DefaultClosedTimer { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DefaultChatServiceSid != null) - { - p.Add(new KeyValuePair("DefaultChatServiceSid", DefaultChatServiceSid.ToString())); - } - - if (DefaultMessagingServiceSid != null) - { - p.Add(new KeyValuePair("DefaultMessagingServiceSid", DefaultMessagingServiceSid.ToString())); - } - - if (DefaultInactiveTimer != null) - { - p.Add(new KeyValuePair("DefaultInactiveTimer", DefaultInactiveTimer)); - } - - if (DefaultClosedTimer != null) - { - p.Add(new KeyValuePair("DefaultClosedTimer", DefaultClosedTimer)); - } - - return p; - } - } + public string DefaultChatServiceSid { get; set; } + /// + /// The SID of the default Messaging Service that every new conversation will be associated with. + /// + public string DefaultMessagingServiceSid { get; set; } + /// + /// Default ISO8601 duration when conversation will be switched to `inactive` state. + /// + public string DefaultInactiveTimer { get; set; } + /// + /// Default ISO8601 duration when conversation will be switched to `closed` state. + /// + public string DefaultClosedTimer { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DefaultChatServiceSid != null) + { + p.Add(new KeyValuePair("DefaultChatServiceSid", DefaultChatServiceSid.ToString())); + } + + if (DefaultMessagingServiceSid != null) + { + p.Add(new KeyValuePair("DefaultMessagingServiceSid", DefaultMessagingServiceSid.ToString())); + } + + if (DefaultInactiveTimer != null) + { + p.Add(new KeyValuePair("DefaultInactiveTimer", DefaultInactiveTimer)); + } + + if (DefaultClosedTimer != null) + { + p.Add(new KeyValuePair("DefaultClosedTimer", DefaultClosedTimer)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ConfigurationResource.cs b/src/Twilio/Rest/Conversations/V1/ConfigurationResource.cs index 008d3671b..6bcc9b92f 100644 --- a/src/Twilio/Rest/Conversations/V1/ConfigurationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/ConfigurationResource.cs @@ -16,220 +16,220 @@ using Twilio.Http; namespace Twilio.Rest.Conversations.V1 -{ - - public class ConfigurationResource : Resource - { - private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Configuration", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the global configuration of conversations on your account - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the global configuration of conversations on your account - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the global configuration of conversations on your account - /// - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the global configuration of conversations on your account - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the global configuration of conversations on your account - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the global configuration of conversations on your account - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the global configuration of conversations on your account - /// - /// The SID of the default Conversation Service that every new conversation will - /// be associated with. - /// The SID of the default Messaging Service that every new conversation will - /// be associated with. - /// Default ISO8601 duration when conversation will be switched to `inactive` - /// state. - /// Default ISO8601 duration when conversation will be switched to `closed` state. - /// - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(string defaultChatServiceSid = null, - string defaultMessagingServiceSid = null, - string defaultInactiveTimer = null, - string defaultClosedTimer = null, - ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(){DefaultChatServiceSid = defaultChatServiceSid, DefaultMessagingServiceSid = defaultMessagingServiceSid, DefaultInactiveTimer = defaultInactiveTimer, DefaultClosedTimer = defaultClosedTimer}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the global configuration of conversations on your account - /// - /// The SID of the default Conversation Service that every new conversation will - /// be associated with. - /// The SID of the default Messaging Service that every new conversation will - /// be associated with. - /// Default ISO8601 duration when conversation will be switched to `inactive` - /// state. - /// Default ISO8601 duration when conversation will be switched to `closed` state. - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(string defaultChatServiceSid = null, - string defaultMessagingServiceSid = null, - string defaultInactiveTimer = null, - string defaultClosedTimer = null, - ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(){DefaultChatServiceSid = defaultChatServiceSid, DefaultMessagingServiceSid = defaultMessagingServiceSid, DefaultInactiveTimer = defaultInactiveTimer, DefaultClosedTimer = defaultClosedTimer}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConfigurationResource object - /// - /// Raw JSON string - /// ConfigurationResource object represented by the provided JSON - public static ConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account responsible for this configuration. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the default Conversation Service that every new conversation is associated with. - /// - [JsonProperty("default_chat_service_sid")] - public string DefaultChatServiceSid { get; private set; } - /// - /// The SID of the default Messaging Service that every new conversation is associated with. - /// - [JsonProperty("default_messaging_service_sid")] - public string DefaultMessagingServiceSid { get; private set; } - /// - /// Default ISO8601 duration when conversation will be switched to `inactive` state. - /// - [JsonProperty("default_inactive_timer")] - public string DefaultInactiveTimer { get; private set; } - /// - /// Default ISO8601 duration when conversation will be switched to `closed` state. - /// - [JsonProperty("default_closed_timer")] - public string DefaultClosedTimer { get; private set; } - /// - /// An absolute URL for this global configuration. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the webhook and default service configurations. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ConfigurationResource() - { - - } - } +{ + + public class ConfigurationResource : Resource + { + private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Configuration", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the global configuration of conversations on your account + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the global configuration of conversations on your account + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the global configuration of conversations on your account + /// + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the global configuration of conversations on your account + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions(); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the global configuration of conversations on your account + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the global configuration of conversations on your account + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the global configuration of conversations on your account + /// + /// The SID of the default Conversation Service that every new conversation will + /// be associated with. + /// The SID of the default Messaging Service that every new conversation will + /// be associated with. + /// Default ISO8601 duration when conversation will be switched to `inactive` + /// state. + /// Default ISO8601 duration when conversation will be switched to `closed` state. + /// + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(string defaultChatServiceSid = null, + string defaultMessagingServiceSid = null, + string defaultInactiveTimer = null, + string defaultClosedTimer = null, + ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions() { DefaultChatServiceSid = defaultChatServiceSid, DefaultMessagingServiceSid = defaultMessagingServiceSid, DefaultInactiveTimer = defaultInactiveTimer, DefaultClosedTimer = defaultClosedTimer }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the global configuration of conversations on your account + /// + /// The SID of the default Conversation Service that every new conversation will + /// be associated with. + /// The SID of the default Messaging Service that every new conversation will + /// be associated with. + /// Default ISO8601 duration when conversation will be switched to `inactive` + /// state. + /// Default ISO8601 duration when conversation will be switched to `closed` state. + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(string defaultChatServiceSid = null, + string defaultMessagingServiceSid = null, + string defaultInactiveTimer = null, + string defaultClosedTimer = null, + ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions() { DefaultChatServiceSid = defaultChatServiceSid, DefaultMessagingServiceSid = defaultMessagingServiceSid, DefaultInactiveTimer = defaultInactiveTimer, DefaultClosedTimer = defaultClosedTimer }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConfigurationResource object + /// + /// Raw JSON string + /// ConfigurationResource object represented by the provided JSON + public static ConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account responsible for this configuration. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the default Conversation Service that every new conversation is associated with. + /// + [JsonProperty("default_chat_service_sid")] + public string DefaultChatServiceSid { get; private set; } + /// + /// The SID of the default Messaging Service that every new conversation is associated with. + /// + [JsonProperty("default_messaging_service_sid")] + public string DefaultMessagingServiceSid { get; private set; } + /// + /// Default ISO8601 duration when conversation will be switched to `inactive` state. + /// + [JsonProperty("default_inactive_timer")] + public string DefaultInactiveTimer { get; private set; } + /// + /// Default ISO8601 duration when conversation will be switched to `closed` state. + /// + [JsonProperty("default_closed_timer")] + public string DefaultClosedTimer { get; private set; } + /// + /// An absolute URL for this global configuration. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the webhook and default service configurations. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptOptions.cs b/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptOptions.cs index e6222524f..5e387b9bb 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Conversation.Message -{ - +{ + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + public class FetchDeliveryReceiptOptions : IOptions + { /// - /// Fetch the delivery and read receipts of the conversation message + /// The unique ID of the Conversation for this delivery receipt. /// - public class FetchDeliveryReceiptOptions : IOptions - { - /// - /// The unique ID of the Conversation for this delivery receipt. - /// - public string PathConversationSid { get; } - /// - /// The SID of the message the delivery receipt belongs to. - /// - public string PathMessageSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDeliveryReceiptOptions - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - public FetchDeliveryReceiptOptions(string pathConversationSid, string pathMessageSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathMessageSid = pathMessageSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathConversationSid { get; } /// - /// Retrieve a list of all delivery and read receipts of the conversation message + /// The SID of the message the delivery receipt belongs to. /// - public class ReadDeliveryReceiptOptions : ReadOptions - { - /// - /// The unique ID of the Conversation for this delivery receipt. - /// - public string PathConversationSid { get; } - /// - /// The SID of the message the delivery receipt belongs to. - /// - public string PathMessageSid { get; } - - /// - /// Construct a new ReadDeliveryReceiptOptions - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - public ReadDeliveryReceiptOptions(string pathConversationSid, string pathMessageSid) - { - PathConversationSid = pathConversationSid; - PathMessageSid = pathMessageSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathMessageSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDeliveryReceiptOptions + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + public FetchDeliveryReceiptOptions(string pathConversationSid, string pathMessageSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathMessageSid = pathMessageSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + public class ReadDeliveryReceiptOptions : ReadOptions + { + /// + /// The unique ID of the Conversation for this delivery receipt. + /// + public string PathConversationSid { get; } + /// + /// The SID of the message the delivery receipt belongs to. + /// + public string PathMessageSid { get; } + + /// + /// Construct a new ReadDeliveryReceiptOptions + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + public ReadDeliveryReceiptOptions(string pathConversationSid, string pathMessageSid) + { + PathConversationSid = pathConversationSid; + PathMessageSid = pathMessageSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptResource.cs b/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptResource.cs index f81c77a76..74040fd5f 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/Message/DeliveryReceiptResource.cs @@ -17,320 +17,320 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Conversation.Message -{ - - public class DeliveryReceiptResource : Resource - { - public sealed class DeliveryStatusEnum : StringEnum - { - private DeliveryStatusEnum(string value) : base(value) {} - public DeliveryStatusEnum() {} - public static implicit operator DeliveryStatusEnum(string value) - { - return new DeliveryStatusEnum(value); - } - - public static readonly DeliveryStatusEnum Read = new DeliveryStatusEnum("read"); - public static readonly DeliveryStatusEnum Failed = new DeliveryStatusEnum("failed"); - public static readonly DeliveryStatusEnum Delivered = new DeliveryStatusEnum("delivered"); - public static readonly DeliveryStatusEnum Undelivered = new DeliveryStatusEnum("undelivered"); - public static readonly DeliveryStatusEnum Sent = new DeliveryStatusEnum("sent"); - } - - private static Request BuildFetchRequest(FetchDeliveryReceiptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// Fetch DeliveryReceipt parameters - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static DeliveryReceiptResource Fetch(FetchDeliveryReceiptOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// Fetch DeliveryReceipt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task FetchAsync(FetchDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static DeliveryReceiptResource Fetch(string pathConversationSid, - string pathMessageSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeliveryReceiptOptions(pathConversationSid, pathMessageSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, - string pathMessageSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeliveryReceiptOptions(pathConversationSid, pathMessageSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDeliveryReceiptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// Read DeliveryReceipt parameters - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static ResourceSet Read(ReadDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("delivery_receipts", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// Read DeliveryReceipt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task> ReadAsync(ReadDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("delivery_receipts", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static ResourceSet Read(string pathConversationSid, - string pathMessageSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeliveryReceiptOptions(pathConversationSid, pathMessageSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, - string pathMessageSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeliveryReceiptOptions(pathConversationSid, pathMessageSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Converts a JSON string into a DeliveryReceiptResource object - /// - /// Raw JSON string - /// DeliveryReceiptResource object represented by the provided JSON - public static DeliveryReceiptResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this participant. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation for this message. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the message the delivery receipt belongs to - /// - [JsonProperty("message_sid")] - public string MessageSid { get; private set; } - /// - /// A messaging channel-specific identifier for the message delivered to participant - /// - [JsonProperty("channel_message_sid")] - public string ChannelMessageSid { get; private set; } - /// - /// The unique ID of the participant the delivery receipt belongs to. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The message delivery status - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public DeliveryReceiptResource.DeliveryStatusEnum Status { get; private set; } - /// - /// The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this delivery receipt. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DeliveryReceiptResource() - { - - } - } +{ + + public class DeliveryReceiptResource : Resource + { + public sealed class DeliveryStatusEnum : StringEnum + { + private DeliveryStatusEnum(string value) : base(value) { } + public DeliveryStatusEnum() { } + public static implicit operator DeliveryStatusEnum(string value) + { + return new DeliveryStatusEnum(value); + } + + public static readonly DeliveryStatusEnum Read = new DeliveryStatusEnum("read"); + public static readonly DeliveryStatusEnum Failed = new DeliveryStatusEnum("failed"); + public static readonly DeliveryStatusEnum Delivered = new DeliveryStatusEnum("delivered"); + public static readonly DeliveryStatusEnum Undelivered = new DeliveryStatusEnum("undelivered"); + public static readonly DeliveryStatusEnum Sent = new DeliveryStatusEnum("sent"); + } + + private static Request BuildFetchRequest(FetchDeliveryReceiptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// Fetch DeliveryReceipt parameters + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static DeliveryReceiptResource Fetch(FetchDeliveryReceiptOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// Fetch DeliveryReceipt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task FetchAsync(FetchDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static DeliveryReceiptResource Fetch(string pathConversationSid, + string pathMessageSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeliveryReceiptOptions(pathConversationSid, pathMessageSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, + string pathMessageSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeliveryReceiptOptions(pathConversationSid, pathMessageSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDeliveryReceiptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// Read DeliveryReceipt parameters + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static ResourceSet Read(ReadDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("delivery_receipts", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// Read DeliveryReceipt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task> ReadAsync(ReadDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("delivery_receipts", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static ResourceSet Read(string pathConversationSid, + string pathMessageSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeliveryReceiptOptions(pathConversationSid, pathMessageSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, + string pathMessageSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeliveryReceiptOptions(pathConversationSid, pathMessageSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Converts a JSON string into a DeliveryReceiptResource object + /// + /// Raw JSON string + /// DeliveryReceiptResource object represented by the provided JSON + public static DeliveryReceiptResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this participant. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation for this message. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the message the delivery receipt belongs to + /// + [JsonProperty("message_sid")] + public string MessageSid { get; private set; } + /// + /// A messaging channel-specific identifier for the message delivered to participant + /// + [JsonProperty("channel_message_sid")] + public string ChannelMessageSid { get; private set; } + /// + /// The unique ID of the participant the delivery receipt belongs to. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The message delivery status + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public DeliveryReceiptResource.DeliveryStatusEnum Status { get; private set; } + /// + /// The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this delivery receipt. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DeliveryReceiptResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/MessageOptions.cs b/src/Twilio/Rest/Conversations/V1/Conversation/MessageOptions.cs index c216f7112..484146fc9 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/MessageOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/MessageOptions.cs @@ -9,336 +9,336 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Conversation -{ - +{ + + /// + /// Add a new message to the conversation + /// + public class CreateMessageOptions : IOptions + { /// - /// Add a new message to the conversation - /// - public class CreateMessageOptions : IOptions - { - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// The channel specific identifier of the message's author. - /// - public string Author { get; set; } - /// - /// The content of the message. - /// - public string Body { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The Media SID to be attached to the new Message. - /// - public string MediaSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The unique ID of the Conversation for this message. - public CreateMessageOptions(string pathConversationSid) - { - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Author != null) - { - p.Add(new KeyValuePair("Author", Author)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MediaSid != null) - { - p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } /// - /// Update an existing message in the conversation - /// - public class UpdateMessageOptions : IOptions - { - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The channel specific identifier of the message's author. - /// - public string Author { get; set; } - /// - /// The content of the message. - /// - public string Body { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public UpdateMessageOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Author != null) - { - p.Add(new KeyValuePair("Author", Author)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The channel specific identifier of the message's author. + /// + public string Author { get; set; } /// - /// Remove a message from the conversation - /// - public class DeleteMessageOptions : IOptions - { - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public DeleteMessageOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The content of the message. + /// + public string Body { get; set; } /// - /// Fetch a message from the conversation - /// - public class FetchMessageOptions : IOptions - { - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public FetchMessageOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } /// - /// Retrieve a list of all messages in the conversation - /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The unique ID of the Conversation for messages. - /// - public string PathConversationSid { get; } - /// - /// The sort order of the returned messages - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The unique ID of the Conversation for messages. - public ReadMessageOptions(string pathConversationSid) - { - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The Media SID to be attached to the new Message. + /// + public string MediaSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The unique ID of the Conversation for this message. + public CreateMessageOptions(string pathConversationSid) + { + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Author != null) + { + p.Add(new KeyValuePair("Author", Author)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MediaSid != null) + { + p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing message in the conversation + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The channel specific identifier of the message's author. + /// + public string Author { get; set; } + /// + /// The content of the message. + /// + public string Body { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public UpdateMessageOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Author != null) + { + p.Add(new KeyValuePair("Author", Author)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a message from the conversation + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public DeleteMessageOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a message from the conversation + /// + public class FetchMessageOptions : IOptions + { + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMessageOptions + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public FetchMessageOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all messages in the conversation + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The unique ID of the Conversation for messages. + /// + public string PathConversationSid { get; } + /// + /// The sort order of the returned messages + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The unique ID of the Conversation for messages. + public ReadMessageOptions(string pathConversationSid) + { + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/MessageResource.cs b/src/Twilio/Rest/Conversations/V1/Conversation/MessageResource.cs index 4f6366d69..0ae61848f 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/MessageResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/MessageResource.cs @@ -17,604 +17,604 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Conversation -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new message to the conversation - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new message to the conversation - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new message to the conversation - /// - /// The unique ID of the Conversation for this message. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The Media SID to be attached to the new Message. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathConversationSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathConversationSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new message to the conversation - /// - /// The unique ID of the Conversation for this message. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The Media SID to be attached to the new Message. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathConversationSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing message in the conversation - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing message in the conversation - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing message in the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathConversationSid, - string pathSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathConversationSid, pathSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing message in the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, - string pathSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathConversationSid, pathSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a message from the conversation - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a message from the conversation - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a message from the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathConversationSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a message from the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a message from the conversation - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a message from the conversation - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a message from the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a message from the conversation - /// - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all messages in the conversation - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all messages in the conversation - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all messages in the conversation - /// - /// The unique ID of the Conversation for messages. - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathConversationSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathConversationSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all messages in the conversation - /// - /// The unique ID of the Conversation for messages. - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathConversationSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this message. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation for this message. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The index of the message within the Conversation. - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The channel specific identifier of the message's author. - /// - [JsonProperty("author")] - public string Author { get; private set; } - /// - /// The content of the message. - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// An array of objects that describe the Message's media if attached, otherwise, null. - /// - [JsonProperty("media")] - public List Media { get; private set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The unique ID of messages's author participant. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute API URL for this message. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// An object that contains the summary of delivery statuses for the message to non-chat participants. - /// - [JsonProperty("delivery")] - public object Delivery { get; private set; } - /// - /// Absolute URL to access the receipts of this message. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new message to the conversation + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new message to the conversation + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new message to the conversation + /// + /// The unique ID of the Conversation for this message. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The Media SID to be attached to the new Message. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathConversationSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathConversationSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new message to the conversation + /// + /// The unique ID of the Conversation for this message. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The Media SID to be attached to the new Message. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathConversationSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing message in the conversation + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing message in the conversation + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing message in the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathConversationSid, + string pathSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathConversationSid, pathSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing message in the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, + string pathSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathConversationSid, pathSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a message from the conversation + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a message from the conversation + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a message from the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathConversationSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a message from the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a message from the conversation + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a message from the conversation + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a message from the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a message from the conversation + /// + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all messages in the conversation + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all messages in the conversation + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all messages in the conversation + /// + /// The unique ID of the Conversation for messages. + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathConversationSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathConversationSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all messages in the conversation + /// + /// The unique ID of the Conversation for messages. + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathConversationSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this message. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation for this message. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The index of the message within the Conversation. + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The channel specific identifier of the message's author. + /// + [JsonProperty("author")] + public string Author { get; private set; } + /// + /// The content of the message. + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// An array of objects that describe the Message's media if attached, otherwise, null. + /// + [JsonProperty("media")] + public List Media { get; private set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The unique ID of messages's author participant. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute API URL for this message. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// An object that contains the summary of delivery statuses for the message to non-chat participants. + /// + [JsonProperty("delivery")] + public object Delivery { get; private set; } + /// + /// Absolute URL to access the receipts of this message. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantOptions.cs b/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantOptions.cs index f1891ec46..8ad733689 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantOptions.cs @@ -9,381 +9,381 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Conversation -{ - +{ + + /// + /// Add a new participant to the conversation + /// + public class CreateParticipantOptions : IOptions + { /// - /// Add a new participant to the conversation - /// - public class CreateParticipantOptions : IOptions - { - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// The address of the participant's device. - /// - public string MessagingBindingAddress { get; set; } - /// - /// The address of the Twilio phone number that the participant is in contact with. - /// - public string MessagingBindingProxyAddress { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The address of the Twilio phone number that is used in Group MMS. - /// - public string MessagingBindingProjectedAddress { get; set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateParticipantOptions - /// - /// The unique ID of the Conversation for this participant. - public CreateParticipantOptions(string pathConversationSid) - { - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (MessagingBindingAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.Address", MessagingBindingAddress)); - } - - if (MessagingBindingProxyAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MessagingBindingProjectedAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } /// - /// Update an existing participant in the conversation - /// - public class UpdateParticipantOptions : IOptions - { - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - public string RoleSid { get; set; } - /// - /// The address of the Twilio phone number that the participant is in contact with. - /// - public string MessagingBindingProxyAddress { get; set; } - /// - /// The address of the Twilio phone number that is used in Group MMS. - /// - public string MessagingBindingProjectedAddress { get; set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// Index of last “read” message in the Conversation for the Participant. - /// - public int? LastReadMessageIndex { get; set; } - /// - /// Timestamp of last “read” message in the Conversation for the Participant. - /// - public string LastReadTimestamp { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateParticipantOptions - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public UpdateParticipantOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (MessagingBindingProxyAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); - } - - if (MessagingBindingProjectedAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (LastReadMessageIndex != null) - { - p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); - } - - if (LastReadTimestamp != null) - { - p.Add(new KeyValuePair("LastReadTimestamp", LastReadTimestamp)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// A unique string identifier for the conversation participant as Conversation User. + /// + public string Identity { get; set; } /// - /// Remove a participant from the conversation - /// - public class DeleteParticipantOptions : IOptions - { - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteParticipantOptions - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public DeleteParticipantOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The address of the participant's device. + /// + public string MessagingBindingAddress { get; set; } /// - /// Fetch a participant of the conversation - /// - public class FetchParticipantOptions : IOptions - { - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public FetchParticipantOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The address of the Twilio phone number that the participant is in contact with. + /// + public string MessagingBindingProxyAddress { get; set; } /// - /// Retrieve a list of all participants of the conversation + /// The date that this resource was created. /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The unique ID of the Conversation for participants. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The unique ID of the Conversation for participants. - public ReadParticipantOptions(string pathConversationSid) - { - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The address of the Twilio phone number that is used in Group MMS. + /// + public string MessagingBindingProjectedAddress { get; set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + public string RoleSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateParticipantOptions + /// + /// The unique ID of the Conversation for this participant. + public CreateParticipantOptions(string pathConversationSid) + { + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (MessagingBindingAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.Address", MessagingBindingAddress)); + } + + if (MessagingBindingProxyAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MessagingBindingProjectedAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing participant in the conversation + /// + public class UpdateParticipantOptions : IOptions + { + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + public string RoleSid { get; set; } + /// + /// The address of the Twilio phone number that the participant is in contact with. + /// + public string MessagingBindingProxyAddress { get; set; } + /// + /// The address of the Twilio phone number that is used in Group MMS. + /// + public string MessagingBindingProjectedAddress { get; set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + public string Identity { get; set; } + /// + /// Index of last “read” message in the Conversation for the Participant. + /// + public int? LastReadMessageIndex { get; set; } + /// + /// Timestamp of last “read” message in the Conversation for the Participant. + /// + public string LastReadTimestamp { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateParticipantOptions + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public UpdateParticipantOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (MessagingBindingProxyAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); + } + + if (MessagingBindingProjectedAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (LastReadMessageIndex != null) + { + p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); + } + + if (LastReadTimestamp != null) + { + p.Add(new KeyValuePair("LastReadTimestamp", LastReadTimestamp)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a participant from the conversation + /// + public class DeleteParticipantOptions : IOptions + { + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteParticipantOptions + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public DeleteParticipantOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a participant of the conversation + /// + public class FetchParticipantOptions : IOptions + { + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchParticipantOptions + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public FetchParticipantOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all participants of the conversation + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The unique ID of the Conversation for participants. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The unique ID of the Conversation for participants. + public ReadParticipantOptions(string pathConversationSid) + { + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantResource.cs b/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantResource.cs index 8c8ac5681..f88b02ba2 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/ParticipantResource.cs @@ -17,609 +17,609 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Conversation -{ - - public class ParticipantResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Participants", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new participant to the conversation - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new participant to the conversation - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new participant to the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A unique string identifier for the conversation participant as Conversation User. - /// The address of the participant's device. - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// The SID of a conversation-level Role to assign to the participant - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(string pathConversationSid, - string identity = null, - string messagingBindingAddress = null, - string messagingBindingProxyAddress = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingBindingProjectedAddress = null, - string roleSid = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathConversationSid){Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new participant to the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A unique string identifier for the conversation participant as Conversation User. - /// The address of the participant's device. - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// The SID of a conversation-level Role to assign to the participant - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, - string identity = null, - string messagingBindingAddress = null, - string messagingBindingProxyAddress = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingBindingProjectedAddress = null, - string roleSid = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathConversationSid){Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing participant in the conversation - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing participant in the conversation - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing participant in the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The SID of a conversation-level Role to assign to the participant - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// Index of last “read” message in the Conversation for the Participant. - /// Timestamp of last “read” message in the Conversation for the Participant. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(string pathConversationSid, - string pathSid, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string roleSid = null, - string messagingBindingProxyAddress = null, - string messagingBindingProjectedAddress = null, - string identity = null, - int? lastReadMessageIndex = null, - string lastReadTimestamp = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathConversationSid, pathSid){DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, Identity = identity, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing participant in the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The SID of a conversation-level Role to assign to the participant - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// Index of last “read” message in the Conversation for the Participant. - /// Timestamp of last “read” message in the Conversation for the Participant. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, - string pathSid, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string roleSid = null, - string messagingBindingProxyAddress = null, - string messagingBindingProjectedAddress = null, - string identity = null, - int? lastReadMessageIndex = null, - string lastReadTimestamp = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathConversationSid, pathSid){DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, Identity = identity, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a participant from the conversation - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a participant from the conversation - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a participant from the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(string pathConversationSid, - string pathSid, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a participant from the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, - string pathSid, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a participant of the conversation - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a participant of the conversation - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a participant of the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a participant of the conversation - /// - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Participants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all participants of the conversation - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all participants of the conversation - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all participants of the conversation - /// - /// The unique ID of the Conversation for participants. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathConversationSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all participants of the conversation - /// - /// The unique ID of the Conversation for participants. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathConversationSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this participant. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation for this participant. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Information about how this participant exchanges messages with the conversation. - /// - [JsonProperty("messaging_binding")] - public object MessagingBinding { get; private set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this participant. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Index of last “read” message in the Conversation for the Participant. - /// - [JsonProperty("last_read_message_index")] - public int? LastReadMessageIndex { get; private set; } - /// - /// Timestamp of last “read” message in the Conversation for the Participant. - /// - [JsonProperty("last_read_timestamp")] - public string LastReadTimestamp { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Participants", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new participant to the conversation + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new participant to the conversation + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new participant to the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A unique string identifier for the conversation participant as Conversation User. + /// The address of the participant's device. + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// The SID of a conversation-level Role to assign to the participant + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(string pathConversationSid, + string identity = null, + string messagingBindingAddress = null, + string messagingBindingProxyAddress = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingBindingProjectedAddress = null, + string roleSid = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathConversationSid) { Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new participant to the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A unique string identifier for the conversation participant as Conversation User. + /// The address of the participant's device. + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// The SID of a conversation-level Role to assign to the participant + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, + string identity = null, + string messagingBindingAddress = null, + string messagingBindingProxyAddress = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingBindingProjectedAddress = null, + string roleSid = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathConversationSid) { Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing participant in the conversation + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing participant in the conversation + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing participant in the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The SID of a conversation-level Role to assign to the participant + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// Index of last “read” message in the Conversation for the Participant. + /// Timestamp of last “read” message in the Conversation for the Participant. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(string pathConversationSid, + string pathSid, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string roleSid = null, + string messagingBindingProxyAddress = null, + string messagingBindingProjectedAddress = null, + string identity = null, + int? lastReadMessageIndex = null, + string lastReadTimestamp = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathConversationSid, pathSid) { DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, Identity = identity, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing participant in the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The SID of a conversation-level Role to assign to the participant + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// Index of last “read” message in the Conversation for the Participant. + /// Timestamp of last “read” message in the Conversation for the Participant. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, + string pathSid, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string roleSid = null, + string messagingBindingProxyAddress = null, + string messagingBindingProjectedAddress = null, + string identity = null, + int? lastReadMessageIndex = null, + string lastReadTimestamp = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathConversationSid, pathSid) { DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, Identity = identity, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a participant from the conversation + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a participant from the conversation + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a participant from the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(string pathConversationSid, + string pathSid, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a participant from the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, + string pathSid, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a participant of the conversation + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a participant of the conversation + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a participant of the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a participant of the conversation + /// + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Participants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all participants of the conversation + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all participants of the conversation + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all participants of the conversation + /// + /// The unique ID of the Conversation for participants. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathConversationSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all participants of the conversation + /// + /// The unique ID of the Conversation for participants. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathConversationSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this participant. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation for this participant. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Information about how this participant exchanges messages with the conversation. + /// + [JsonProperty("messaging_binding")] + public object MessagingBinding { get; private set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this participant. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Index of last “read” message in the Conversation for the Participant. + /// + [JsonProperty("last_read_message_index")] + public int? LastReadMessageIndex { get; private set; } + /// + /// Timestamp of last “read” message in the Conversation for the Participant. + /// + [JsonProperty("last_read_timestamp")] + public string LastReadTimestamp { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/WebhookOptions.cs b/src/Twilio/Rest/Conversations/V1/Conversation/WebhookOptions.cs index 20623e514..b02505296 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/WebhookOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/WebhookOptions.cs @@ -10,288 +10,288 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Conversation -{ - +{ + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + public class ReadWebhookOptions : ReadOptions + { /// - /// Retrieve a list of all webhooks scoped to the conversation + /// The unique ID of the Conversation for this webhook. /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// The unique ID of the Conversation for this webhook. - public ReadWebhookOptions(string pathConversationSid) - { - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathConversationSid { get; } + /// - /// Fetch the configuration of a conversation-scoped webhook + /// Construct a new ReadWebhookOptions /// - public class FetchWebhookOptions : IOptions - { - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public FetchWebhookOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique ID of the Conversation for this webhook. + public ReadWebhookOptions(string pathConversationSid) + { + PathConversationSid = pathConversationSid; + } + /// - /// Create a new webhook scoped to the conversation + /// Generate the necessary parameters /// - public class CreateWebhookOptions : IOptions - { - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// The target of this webhook. - /// - public WebhookResource.TargetEnum Target { get; } - /// - /// The absolute url the webhook request should be sent to. - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method to be used when sending a webhook request. - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The list of events, firing webhook event for this Conversation. - /// - public List ConfigurationFilters { get; set; } - /// - /// The list of keywords, firing webhook event for this Conversation. - /// - public List ConfigurationTriggers { get; set; } - /// - /// The studio flow SID, where the webhook should be sent to. - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The message index for which and it's successors the webhook will be replayed. - /// - public int? ConfigurationReplayAfter { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - public CreateWebhookOptions(string pathConversationSid, WebhookResource.TargetEnum target) - { - PathConversationSid = pathConversationSid; - Target = target; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Target != null) - { - p.Add(new KeyValuePair("Target", Target.ToString())); - } - - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationReplayAfter != null) - { - p.Add(new KeyValuePair("Configuration.ReplayAfter", ConfigurationReplayAfter.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + public class FetchWebhookOptions : IOptions + { /// - /// Update an existing conversation-scoped webhook + /// The unique ID of the Conversation for this webhook. /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The absolute url the webhook request should be sent to. - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method to be used when sending a webhook request. - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The list of events, firing webhook event for this Conversation. - /// - public List ConfigurationFilters { get; set; } - /// - /// The list of keywords, firing webhook event for this Conversation. - /// - public List ConfigurationTriggers { get; set; } - /// - /// The studio flow SID, where the webhook should be sent to. - /// - public string ConfigurationFlowSid { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public UpdateWebhookOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - return p; - } - } - + public string PathConversationSid { get; } /// - /// Remove an existing webhook scoped to the conversation + /// A 34 character string that uniquely identifies this resource. /// - public class DeleteWebhookOptions : IOptions - { - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public DeleteWebhookOptions(string pathConversationSid, string pathSid) - { - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public FetchWebhookOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Create a new webhook scoped to the conversation + /// + public class CreateWebhookOptions : IOptions + { + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// The target of this webhook. + /// + public WebhookResource.TargetEnum Target { get; } + /// + /// The absolute url the webhook request should be sent to. + /// + public string ConfigurationUrl { get; set; } + /// + /// The HTTP method to be used when sending a webhook request. + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The list of events, firing webhook event for this Conversation. + /// + public List ConfigurationFilters { get; set; } + /// + /// The list of keywords, firing webhook event for this Conversation. + /// + public List ConfigurationTriggers { get; set; } + /// + /// The studio flow SID, where the webhook should be sent to. + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The message index for which and it's successors the webhook will be replayed. + /// + public int? ConfigurationReplayAfter { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + public CreateWebhookOptions(string pathConversationSid, WebhookResource.TargetEnum target) + { + PathConversationSid = pathConversationSid; + Target = target; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Target != null) + { + p.Add(new KeyValuePair("Target", Target.ToString())); + } + + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationReplayAfter != null) + { + p.Add(new KeyValuePair("Configuration.ReplayAfter", ConfigurationReplayAfter.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation-scoped webhook + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The absolute url the webhook request should be sent to. + /// + public string ConfigurationUrl { get; set; } + /// + /// The HTTP method to be used when sending a webhook request. + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The list of events, firing webhook event for this Conversation. + /// + public List ConfigurationFilters { get; set; } + /// + /// The list of keywords, firing webhook event for this Conversation. + /// + public List ConfigurationTriggers { get; set; } + /// + /// The studio flow SID, where the webhook should be sent to. + /// + public string ConfigurationFlowSid { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public UpdateWebhookOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + return p; + } + } + + /// + /// Remove an existing webhook scoped to the conversation + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public DeleteWebhookOptions(string pathConversationSid, string pathSid) + { + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Conversation/WebhookResource.cs b/src/Twilio/Rest/Conversations/V1/Conversation/WebhookResource.cs index e41e2fca4..4c36ae2cf 100644 --- a/src/Twilio/Rest/Conversations/V1/Conversation/WebhookResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Conversation/WebhookResource.cs @@ -17,563 +17,563 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Conversation -{ - - public class WebhookResource : Resource - { - public sealed class TargetEnum : StringEnum - { - private TargetEnum(string value) : base(value) {} - public TargetEnum() {} - public static implicit operator TargetEnum(string value) - { - return new TargetEnum(value); - } - - public static readonly TargetEnum Webhook = new TargetEnum("webhook"); - public static readonly TargetEnum Trigger = new TargetEnum("trigger"); - public static readonly TargetEnum Studio = new TargetEnum("studio"); - } - - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathConversationSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathConversationSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new webhook scoped to the conversation - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new webhook scoped to the conversation - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new webhook scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// The message index for which and it's successors the webhook will be - /// replayed. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathConversationSid, - WebhookResource.TargetEnum target, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationReplayAfter = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathConversationSid, target){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new webhook scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// The message index for which and it's successors the webhook will be - /// replayed. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, - WebhookResource.TargetEnum target, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationReplayAfter = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathConversationSid, target){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing conversation-scoped webhook - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation-scoped webhook - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation-scoped webhook - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathConversationSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathConversationSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation-scoped webhook - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathConversationSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an existing webhook scoped to the conversation - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an existing webhook scoped to the conversation - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an existing webhook scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathConversationSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathConversationSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an existing webhook scoped to the conversation - /// - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathConversationSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation for this webhook. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// The target of this webhook. - /// - [JsonProperty("target")] - public string Target { get; private set; } - /// - /// An absolute URL for this webhook. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The configuration of this webhook. - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class TargetEnum : StringEnum + { + private TargetEnum(string value) : base(value) { } + public TargetEnum() { } + public static implicit operator TargetEnum(string value) + { + return new TargetEnum(value); + } + + public static readonly TargetEnum Webhook = new TargetEnum("webhook"); + public static readonly TargetEnum Trigger = new TargetEnum("trigger"); + public static readonly TargetEnum Studio = new TargetEnum("studio"); + } + + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathConversationSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathConversationSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathConversationSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new webhook scoped to the conversation + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new webhook scoped to the conversation + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new webhook scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// The message index for which and it's successors the webhook will be + /// replayed. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathConversationSid, + WebhookResource.TargetEnum target, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationReplayAfter = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathConversationSid, target) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new webhook scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// The message index for which and it's successors the webhook will be + /// replayed. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathConversationSid, + WebhookResource.TargetEnum target, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationReplayAfter = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathConversationSid, target) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing conversation-scoped webhook + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation-scoped webhook + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation-scoped webhook + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathConversationSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathConversationSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation-scoped webhook + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathConversationSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathConversationSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an existing webhook scoped to the conversation + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an existing webhook scoped to the conversation + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an existing webhook scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathConversationSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathConversationSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an existing webhook scoped to the conversation + /// + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathConversationSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation for this webhook. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// The target of this webhook. + /// + [JsonProperty("target")] + public string Target { get; private set; } + /// + /// An absolute URL for this webhook. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The configuration of this webhook. + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/ConversationOptions.cs index 06f50e183..e1a2d23dd 100644 --- a/src/Twilio/Rest/Conversations/V1/ConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/ConversationOptions.cs @@ -9,345 +9,345 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Create a new conversation in your account's default service + /// + public class CreateConversationOptions : IOptions + { /// - /// Create a new conversation in your account's default service - /// - public class CreateConversationOptions : IOptions - { - /// - /// The human-readable name of this conversation. - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - public string MessagingServiceSid { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// Current state of this conversation. - /// - public ConversationResource.StateEnum State { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// - public string TimersInactive { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `closed` state. - /// - public string TimersClosed { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (State != null) - { - p.Add(new KeyValuePair("State", State.ToString())); - } - - if (TimersInactive != null) - { - p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); - } - - if (TimersClosed != null) - { - p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The human-readable name of this conversation. + /// + public string FriendlyName { get; set; } /// - /// Update an existing conversation in your account's default service - /// - public class UpdateConversationOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The human-readable name of this conversation. - /// - public string FriendlyName { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - public string MessagingServiceSid { get; set; } - /// - /// Current state of this conversation. - /// - public ConversationResource.StateEnum State { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// - public string TimersInactive { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `closed` state. - /// - public string TimersClosed { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateConversationOptions - /// - /// A 34 character string that uniquely identifies this resource. - public UpdateConversationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (State != null) - { - p.Add(new KeyValuePair("State", State.ToString())); - } - - if (TimersInactive != null) - { - p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); - } - - if (TimersClosed != null) - { - p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } /// - /// Remove a conversation from your account's default service - /// - public class DeleteConversationOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteConversationOptions - /// - /// A 34 character string that uniquely identifies this resource. - public DeleteConversationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } /// - /// Fetch a conversation from your account's default service + /// The date that this resource was last updated. /// - public class FetchConversationOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConversationOptions - /// - /// A 34 character string that uniquely identifies this resource. - public FetchConversationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public DateTime? DateUpdated { get; set; } /// - /// Retrieve a list of conversations in your account's default service - /// - public class ReadConversationOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The unique ID of the Messaging Service this conversation belongs to. + /// + public string MessagingServiceSid { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// Current state of this conversation. + /// + public ConversationResource.StateEnum State { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// + public string TimersInactive { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `closed` state. + /// + public string TimersClosed { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (State != null) + { + p.Add(new KeyValuePair("State", State.ToString())); + } + + if (TimersInactive != null) + { + p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); + } + + if (TimersClosed != null) + { + p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation in your account's default service + /// + public class UpdateConversationOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The human-readable name of this conversation. + /// + public string FriendlyName { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The unique ID of the Messaging Service this conversation belongs to. + /// + public string MessagingServiceSid { get; set; } + /// + /// Current state of this conversation. + /// + public ConversationResource.StateEnum State { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// + public string TimersInactive { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `closed` state. + /// + public string TimersClosed { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateConversationOptions + /// + /// A 34 character string that uniquely identifies this resource. + public UpdateConversationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (State != null) + { + p.Add(new KeyValuePair("State", State.ToString())); + } + + if (TimersInactive != null) + { + p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); + } + + if (TimersClosed != null) + { + p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a conversation from your account's default service + /// + public class DeleteConversationOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteConversationOptions + /// + /// A 34 character string that uniquely identifies this resource. + public DeleteConversationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a conversation from your account's default service + /// + public class FetchConversationOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchConversationOptions + /// + /// A 34 character string that uniquely identifies this resource. + public FetchConversationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of conversations in your account's default service + /// + public class ReadConversationOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ConversationResource.cs b/src/Twilio/Rest/Conversations/V1/ConversationResource.cs index 65a5019a5..051f44dc1 100644 --- a/src/Twilio/Rest/Conversations/V1/ConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/ConversationResource.cs @@ -17,612 +17,612 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1 -{ - - public class ConversationResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildCreateRequest(CreateConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Create a new conversation in your account's default service - /// - /// Create Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Create(CreateConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new conversation in your account's default service - /// - /// Create Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task CreateAsync(CreateConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new conversation in your account's default service - /// - /// The human-readable name of this conversation. - /// An application-defined string that uniquely identifies the resource - /// The date that this resource was created. - /// The date that this resource was last updated. - /// The unique ID of the Messaging Service this conversation belongs to. - /// An optional string metadata field you can use to store any data you wish. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Create(string friendlyName = null, - string uniqueName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string messagingServiceSid = null, - string attributes = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConversationOptions(){FriendlyName = friendlyName, UniqueName = uniqueName, DateCreated = dateCreated, DateUpdated = dateUpdated, MessagingServiceSid = messagingServiceSid, Attributes = attributes, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new conversation in your account's default service - /// - /// The human-readable name of this conversation. - /// An application-defined string that uniquely identifies the resource - /// The date that this resource was created. - /// The date that this resource was last updated. - /// The unique ID of the Messaging Service this conversation belongs to. - /// An optional string metadata field you can use to store any data you wish. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - string uniqueName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string messagingServiceSid = null, - string attributes = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConversationOptions(){FriendlyName = friendlyName, UniqueName = uniqueName, DateCreated = dateCreated, DateUpdated = dateUpdated, MessagingServiceSid = messagingServiceSid, Attributes = attributes, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing conversation in your account's default service - /// - /// Update Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Update(UpdateConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation in your account's default service - /// - /// Update Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation in your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// The human-readable name of this conversation. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// An application-defined string that uniquely identifies the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Update(string pathSid, - string friendlyName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingServiceSid = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - string uniqueName = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConversationOptions(pathSid){FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation in your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// The human-readable name of this conversation. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// An application-defined string that uniquely identifies the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingServiceSid = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - string uniqueName = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConversationOptions(pathSid){FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a conversation from your account's default service - /// - /// Delete Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static bool Delete(DeleteConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a conversation from your account's default service - /// - /// Delete Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task DeleteAsync(DeleteConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a conversation from your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static bool Delete(string pathSid, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteConversationOptions(pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a conversation from your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteConversationOptions(pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a conversation from your account's default service - /// - /// Fetch Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Fetch(FetchConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a conversation from your account's default service - /// - /// Fetch Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task FetchAsync(FetchConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a conversation from your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchConversationOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a conversation from your account's default service - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchConversationOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Conversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of conversations in your account's default service - /// - /// Read Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ResourceSet Read(ReadConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conversations in your account's default service - /// - /// Read Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of conversations in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConversationOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conversations in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConversationOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a ConversationResource object - /// - /// Raw JSON string - /// ConversationResource object represented by the provided JSON - public static ConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Current state of this conversation. - /// - [JsonProperty("state")] - [JsonConverter(typeof(StringEnumConverter))] - public ConversationResource.StateEnum State { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("timers")] - public object Timers { get; private set; } - /// - /// An absolute URL for this conversation. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the participants, messages and webhooks of this conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The bindings - /// - [JsonProperty("bindings")] - public object Bindings { get; private set; } - - private ConversationResource() - { - - } - } +{ + + public class ConversationResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildCreateRequest(CreateConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Create a new conversation in your account's default service + /// + /// Create Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Create(CreateConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new conversation in your account's default service + /// + /// Create Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task CreateAsync(CreateConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new conversation in your account's default service + /// + /// The human-readable name of this conversation. + /// An application-defined string that uniquely identifies the resource + /// The date that this resource was created. + /// The date that this resource was last updated. + /// The unique ID of the Messaging Service this conversation belongs to. + /// An optional string metadata field you can use to store any data you wish. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Create(string friendlyName = null, + string uniqueName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string messagingServiceSid = null, + string attributes = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConversationOptions() { FriendlyName = friendlyName, UniqueName = uniqueName, DateCreated = dateCreated, DateUpdated = dateUpdated, MessagingServiceSid = messagingServiceSid, Attributes = attributes, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new conversation in your account's default service + /// + /// The human-readable name of this conversation. + /// An application-defined string that uniquely identifies the resource + /// The date that this resource was created. + /// The date that this resource was last updated. + /// The unique ID of the Messaging Service this conversation belongs to. + /// An optional string metadata field you can use to store any data you wish. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + string uniqueName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string messagingServiceSid = null, + string attributes = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConversationOptions() { FriendlyName = friendlyName, UniqueName = uniqueName, DateCreated = dateCreated, DateUpdated = dateUpdated, MessagingServiceSid = messagingServiceSid, Attributes = attributes, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing conversation in your account's default service + /// + /// Update Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Update(UpdateConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation in your account's default service + /// + /// Update Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation in your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// The human-readable name of this conversation. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// An application-defined string that uniquely identifies the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Update(string pathSid, + string friendlyName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingServiceSid = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + string uniqueName = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConversationOptions(pathSid) { FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation in your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// The human-readable name of this conversation. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// An application-defined string that uniquely identifies the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingServiceSid = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + string uniqueName = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConversationOptions(pathSid) { FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a conversation from your account's default service + /// + /// Delete Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static bool Delete(DeleteConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a conversation from your account's default service + /// + /// Delete Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task DeleteAsync(DeleteConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a conversation from your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static bool Delete(string pathSid, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteConversationOptions(pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a conversation from your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteConversationOptions(pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a conversation from your account's default service + /// + /// Fetch Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Fetch(FetchConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a conversation from your account's default service + /// + /// Fetch Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task FetchAsync(FetchConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a conversation from your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchConversationOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a conversation from your account's default service + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchConversationOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Conversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of conversations in your account's default service + /// + /// Read Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ResourceSet Read(ReadConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conversations in your account's default service + /// + /// Read Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of conversations in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConversationOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conversations in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConversationOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a ConversationResource object + /// + /// Raw JSON string + /// ConversationResource object represented by the provided JSON + public static ConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Messaging Service this conversation belongs to. + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Current state of this conversation. + /// + [JsonProperty("state")] + [JsonConverter(typeof(StringEnumConverter))] + public ConversationResource.StateEnum State { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("timers")] + public object Timers { get; private set; } + /// + /// An absolute URL for this conversation. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the participants, messages and webhooks of this conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The bindings + /// + [JsonProperty("bindings")] + public object Bindings { get; private set; } + + private ConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/CredentialOptions.cs b/src/Twilio/Rest/Conversations/V1/CredentialOptions.cs index 292c90d82..08796b11e 100644 --- a/src/Twilio/Rest/Conversations/V1/CredentialOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/CredentialOptions.cs @@ -9,264 +9,264 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Add a new push notification credential to your account + /// + public class CreateCredentialOptions : IOptions + { /// - /// Add a new push notification credential to your account + /// The type of push-notification service the credential is for. /// - public class CreateCredentialOptions : IOptions - { - /// - /// The type of push-notification service the credential is for. - /// - public CredentialResource.PushTypeEnum Type { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate. - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key. - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs. - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console. - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The type of push-notification service the credential is for. - public CreateCredentialOptions(CredentialResource.PushTypeEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushTypeEnum Type { get; } /// - /// Update an existing push notification credential on your account + /// A string to describe the resource /// - public class UpdateCredentialOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The type of push-notification service the credential is for. - /// - public CredentialResource.PushTypeEnum Type { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL encoded representation of the certificate. - /// - public string Certificate { get; set; } - /// - /// [APN only] The URL encoded representation of the private key. - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs. - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The Server key of your project from Firebase console. - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// A 34 character string that uniquely identifies this resource. - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string FriendlyName { get; set; } /// - /// Remove a push notification credential from your account + /// [APN only] The URL encoded representation of the certificate. /// - public class DeleteCredentialOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// A 34 character string that uniquely identifies this resource. - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Certificate { get; set; } /// - /// Fetch a push notification credential from your account + /// [APN only] The URL encoded representation of the private key. /// - public class FetchCredentialOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// A 34 character string that uniquely identifies this resource. - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PrivateKey { get; set; } /// - /// Retrieve a list of all push notification credentials on your account + /// [APN only] Whether to send the credential to sandbox APNs. /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console. + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The type of push-notification service the credential is for. + public CreateCredentialOptions(CredentialResource.PushTypeEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// Update an existing push notification credential on your account + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The type of push-notification service the credential is for. + /// + public CredentialResource.PushTypeEnum Type { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// [APN only] The URL encoded representation of the certificate. + /// + public string Certificate { get; set; } + /// + /// [APN only] The URL encoded representation of the private key. + /// + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs. + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The Server key of your project from Firebase console. + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// A 34 character string that uniquely identifies this resource. + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// Remove a push notification credential from your account + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// A 34 character string that uniquely identifies this resource. + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a push notification credential from your account + /// + public class FetchCredentialOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// A 34 character string that uniquely identifies this resource. + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all push notification credentials on your account + /// + public class ReadCredentialOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/CredentialResource.cs b/src/Twilio/Rest/Conversations/V1/CredentialResource.cs index 55fd2d0b1..e8807049f 100644 --- a/src/Twilio/Rest/Conversations/V1/CredentialResource.cs +++ b/src/Twilio/Rest/Conversations/V1/CredentialResource.cs @@ -17,542 +17,542 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1 -{ - - public class CredentialResource : Resource - { - public sealed class PushTypeEnum : StringEnum - { - private PushTypeEnum(string value) : base(value) {} - public PushTypeEnum() {} - public static implicit operator PushTypeEnum(string value) - { - return new PushTypeEnum(value); - } - - public static readonly PushTypeEnum Apn = new PushTypeEnum("apn"); - public static readonly PushTypeEnum Gcm = new PushTypeEnum("gcm"); - public static readonly PushTypeEnum Fcm = new PushTypeEnum("fcm"); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Add a new push notification credential to your account - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new push notification credential to your account - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new push notification credential to your account - /// - /// The type of push-notification service the credential is for. - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate. - /// [APN only] The URL encoded representation of the private key. - /// [APN only] Whether to send the credential to sandbox APNs. - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential. - /// [FCM only] The Server key of your project from Firebase console. - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushTypeEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new push notification credential to your account - /// - /// The type of push-notification service the credential is for. - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate. - /// [APN only] The URL encoded representation of the private key. - /// [APN only] Whether to send the credential to sandbox APNs. - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential. - /// [FCM only] The Server key of your project from Firebase console. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushTypeEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing push notification credential on your account - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing push notification credential on your account - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing push notification credential on your account - /// - /// A 34 character string that uniquely identifies this resource. - /// The type of push-notification service the credential is for. - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate. - /// [APN only] The URL encoded representation of the private key. - /// [APN only] Whether to send the credential to sandbox APNs. - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential. - /// [FCM only] The Server key of your project from Firebase console. - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - CredentialResource.PushTypeEnum type = null, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){Type = type, FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing push notification credential on your account - /// - /// A 34 character string that uniquely identifies this resource. - /// The type of push-notification service the credential is for. - /// A string to describe the resource - /// [APN only] The URL encoded representation of the certificate. - /// [APN only] The URL encoded representation of the private key. - /// [APN only] Whether to send the credential to sandbox APNs. - /// [GCM only] The API key for the project that was obtained from the Google Developer console - /// for your GCM Service application credential. - /// [FCM only] The Server key of your project from Firebase console. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - CredentialResource.PushTypeEnum type = null, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){Type = type, FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a push notification credential from your account - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a push notification credential from your account - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a push notification credential from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a push notification credential from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a push notification credential from your account - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a push notification credential from your account - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a push notification credential from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a push notification credential from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all push notification credentials on your account - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all push notification credentials on your account - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all push notification credentials on your account - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all push notification credentials on your account - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique ID of the Account responsible for this credential. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The human-readable name of this credential. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of push-notification service the credential is for. - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushTypeEnum Type { get; private set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs. - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this credential. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushTypeEnum : StringEnum + { + private PushTypeEnum(string value) : base(value) { } + public PushTypeEnum() { } + public static implicit operator PushTypeEnum(string value) + { + return new PushTypeEnum(value); + } + + public static readonly PushTypeEnum Apn = new PushTypeEnum("apn"); + public static readonly PushTypeEnum Gcm = new PushTypeEnum("gcm"); + public static readonly PushTypeEnum Fcm = new PushTypeEnum("fcm"); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Add a new push notification credential to your account + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new push notification credential to your account + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new push notification credential to your account + /// + /// The type of push-notification service the credential is for. + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate. + /// [APN only] The URL encoded representation of the private key. + /// [APN only] Whether to send the credential to sandbox APNs. + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential. + /// [FCM only] The Server key of your project from Firebase console. + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushTypeEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new push notification credential to your account + /// + /// The type of push-notification service the credential is for. + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate. + /// [APN only] The URL encoded representation of the private key. + /// [APN only] Whether to send the credential to sandbox APNs. + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential. + /// [FCM only] The Server key of your project from Firebase console. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushTypeEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing push notification credential on your account + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing push notification credential on your account + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing push notification credential on your account + /// + /// A 34 character string that uniquely identifies this resource. + /// The type of push-notification service the credential is for. + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate. + /// [APN only] The URL encoded representation of the private key. + /// [APN only] Whether to send the credential to sandbox APNs. + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential. + /// [FCM only] The Server key of your project from Firebase console. + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + CredentialResource.PushTypeEnum type = null, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { Type = type, FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing push notification credential on your account + /// + /// A 34 character string that uniquely identifies this resource. + /// The type of push-notification service the credential is for. + /// A string to describe the resource + /// [APN only] The URL encoded representation of the certificate. + /// [APN only] The URL encoded representation of the private key. + /// [APN only] Whether to send the credential to sandbox APNs. + /// [GCM only] The API key for the project that was obtained from the Google Developer console + /// for your GCM Service application credential. + /// [FCM only] The Server key of your project from Firebase console. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + CredentialResource.PushTypeEnum type = null, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { Type = type, FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a push notification credential from your account + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a push notification credential from your account + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a push notification credential from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a push notification credential from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a push notification credential from your account + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a push notification credential from your account + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a push notification credential from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a push notification credential from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all push notification credentials on your account + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all push notification credentials on your account + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all push notification credentials on your account + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all push notification credentials on your account + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique ID of the Account responsible for this credential. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The human-readable name of this credential. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of push-notification service the credential is for. + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushTypeEnum Type { get; private set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs. + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this credential. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ParticipantConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/ParticipantConversationOptions.cs index 726f2ed96..28f836222 100644 --- a/src/Twilio/Rest/Conversations/V1/ParticipantConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/ParticipantConversationOptions.cs @@ -9,46 +9,46 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + public class ReadParticipantConversationOptions : ReadOptions + { /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. + /// A unique string identifier for the conversation participant as Conversation User. /// - public class ReadParticipantConversationOptions : ReadOptions - { - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - public string Address { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (Address != null) - { - p.Add(new KeyValuePair("Address", Address)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string Identity { get; set; } + /// + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + public string Address { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (Address != null) + { + p.Add(new KeyValuePair("Address", Address)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ParticipantConversationResource.cs b/src/Twilio/Rest/Conversations/V1/ParticipantConversationResource.cs index 3d99d1d12..5cd958d0a 100644 --- a/src/Twilio/Rest/Conversations/V1/ParticipantConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/ParticipantConversationResource.cs @@ -17,274 +17,274 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1 -{ - - public class ParticipantConversationResource : Resource - { - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildReadRequest(ReadParticipantConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/ParticipantConversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// Read ParticipantConversation parameters - /// Client to make requests to Twilio - /// A single instance of ParticipantConversation - public static ResourceSet Read(ReadParticipantConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// Read ParticipantConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ParticipantConversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ParticipantConversation - public static ResourceSet Read(string identity = null, - string address = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantConversationOptions(){Identity = identity, Address = address, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ParticipantConversation - public static async System.Threading.Tasks.Task> ReadAsync(string identity = null, - string address = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantConversationOptions(){Identity = identity, Address = address, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantConversationResource object - /// - /// Raw JSON string - /// ParticipantConversationResource object represented by the provided JSON - public static ParticipantConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Participant. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The unique ID for the conversation participant as Conversation User. - /// - [JsonProperty("participant_user_sid")] - public string ParticipantUserSid { get; private set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - [JsonProperty("participant_identity")] - public string ParticipantIdentity { get; private set; } - /// - /// Information about how this participant exchanges messages with the conversation. - /// - [JsonProperty("participant_messaging_binding")] - public object ParticipantMessagingBinding { get; private set; } - /// - /// The unique ID of the Conversation this Participant belongs to. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// An application-defined string that uniquely identifies the Conversation resource - /// - [JsonProperty("conversation_unique_name")] - public string ConversationUniqueName { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("conversation_friendly_name")] - public string ConversationFriendlyName { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("conversation_attributes")] - public string ConversationAttributes { get; private set; } - /// - /// The date that this conversation was created. - /// - [JsonProperty("conversation_date_created")] - public DateTime? ConversationDateCreated { get; private set; } - /// - /// The date that this conversation was last updated. - /// - [JsonProperty("conversation_date_updated")] - public DateTime? ConversationDateUpdated { get; private set; } - /// - /// Creator of this conversation. - /// - [JsonProperty("conversation_created_by")] - public string ConversationCreatedBy { get; private set; } - /// - /// The current state of this User Conversation - /// - [JsonProperty("conversation_state")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantConversationResource.StateEnum ConversationState { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("conversation_timers")] - public object ConversationTimers { get; private set; } - /// - /// Absolute URLs to access the participant and conversation of this Participant Conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ParticipantConversationResource() - { - - } - } +{ + + public class ParticipantConversationResource : Resource + { + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildReadRequest(ReadParticipantConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/ParticipantConversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// Read ParticipantConversation parameters + /// Client to make requests to Twilio + /// A single instance of ParticipantConversation + public static ResourceSet Read(ReadParticipantConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// Read ParticipantConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ParticipantConversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ParticipantConversation + public static ResourceSet Read(string identity = null, + string address = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantConversationOptions() { Identity = identity, Address = address, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ParticipantConversation + public static async System.Threading.Tasks.Task> ReadAsync(string identity = null, + string address = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantConversationOptions() { Identity = identity, Address = address, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantConversationResource object + /// + /// Raw JSON string + /// ParticipantConversationResource object represented by the provided JSON + public static ParticipantConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Participant. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The unique ID for the conversation participant as Conversation User. + /// + [JsonProperty("participant_user_sid")] + public string ParticipantUserSid { get; private set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + [JsonProperty("participant_identity")] + public string ParticipantIdentity { get; private set; } + /// + /// Information about how this participant exchanges messages with the conversation. + /// + [JsonProperty("participant_messaging_binding")] + public object ParticipantMessagingBinding { get; private set; } + /// + /// The unique ID of the Conversation this Participant belongs to. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// An application-defined string that uniquely identifies the Conversation resource + /// + [JsonProperty("conversation_unique_name")] + public string ConversationUniqueName { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("conversation_friendly_name")] + public string ConversationFriendlyName { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("conversation_attributes")] + public string ConversationAttributes { get; private set; } + /// + /// The date that this conversation was created. + /// + [JsonProperty("conversation_date_created")] + public DateTime? ConversationDateCreated { get; private set; } + /// + /// The date that this conversation was last updated. + /// + [JsonProperty("conversation_date_updated")] + public DateTime? ConversationDateUpdated { get; private set; } + /// + /// Creator of this conversation. + /// + [JsonProperty("conversation_created_by")] + public string ConversationCreatedBy { get; private set; } + /// + /// The current state of this User Conversation + /// + [JsonProperty("conversation_state")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantConversationResource.StateEnum ConversationState { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("conversation_timers")] + public object ConversationTimers { get; private set; } + /// + /// Absolute URLs to access the participant and conversation of this Participant Conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ParticipantConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/RoleOptions.cs b/src/Twilio/Rest/Conversations/V1/RoleOptions.cs index aebaaf3dd..2ecda4a16 100644 --- a/src/Twilio/Rest/Conversations/V1/RoleOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/RoleOptions.cs @@ -10,180 +10,180 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Create a new user role in your account's default service + /// + public class CreateRoleOptions : IOptions + { /// - /// Create a new user role in your account's default service - /// - public class CreateRoleOptions : IOptions - { - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; } - /// - /// The type of role - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - public CreateRoleOptions(string friendlyName, RoleResource.RoleTypeEnum type, List permission) - { - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// A string to describe the new resource + /// + public string FriendlyName { get; } /// - /// Update an existing user role in your account's default service - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The SID of the Role resource to update - /// - public string PathSid { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The SID of the Role resource to update - /// A permission the role should have - public UpdateRoleOptions(string pathSid, List permission) - { - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// The type of role + /// + public RoleResource.RoleTypeEnum Type { get; } /// - /// Remove a user role from your account's default service + /// A permission the role should have /// - public class DeleteRoleOptions : IOptions - { - /// - /// The SID of the Role resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The SID of the Role resource to delete - public DeleteRoleOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List Permission { get; } + /// - /// Fetch a user role from your account's default service + /// Construct a new CreateRoleOptions /// - public class FetchRoleOptions : IOptions - { - /// - /// The SID of the Role resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The SID of the Role resource to fetch - public FetchRoleOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + public CreateRoleOptions(string friendlyName, RoleResource.RoleTypeEnum type, List permission) + { + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + /// - /// Retrieve a list of all user roles in your account's default service - /// - public class ReadRoleOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// Update an existing user role in your account's default service + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The SID of the Role resource to update + /// + public string PathSid { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The SID of the Role resource to update + /// A permission the role should have + public UpdateRoleOptions(string pathSid, List permission) + { + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// Remove a user role from your account's default service + /// + public class DeleteRoleOptions : IOptions + { + /// + /// The SID of the Role resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The SID of the Role resource to delete + public DeleteRoleOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a user role from your account's default service + /// + public class FetchRoleOptions : IOptions + { + /// + /// The SID of the Role resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRoleOptions + /// + /// The SID of the Role resource to fetch + public FetchRoleOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all user roles in your account's default service + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/RoleResource.cs b/src/Twilio/Rest/Conversations/V1/RoleResource.cs index 0ad54bac1..1bd1120ca 100644 --- a/src/Twilio/Rest/Conversations/V1/RoleResource.cs +++ b/src/Twilio/Rest/Conversations/V1/RoleResource.cs @@ -17,500 +17,500 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1 -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Conversation = new RoleTypeEnum("conversation"); - public static readonly RoleTypeEnum Service = new RoleTypeEnum("service"); - } - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new user role in your account's default service - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new user role in your account's default service - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new user role in your account's default service - /// - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new user role in your account's default service - /// - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing user role in your account's default service - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing user role in your account's default service - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing user role in your account's default service - /// - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathSid, List permission, ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing user role in your account's default service - /// - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a user role from your account's default service - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a user role from your account's default service - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a user role from your account's default service - /// - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a user role from your account's default service - /// - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a user role from your account's default service - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a user role from your account's default service - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a user role from your account's default service - /// - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a user role from your account's default service - /// - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all user roles in your account's default service - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all user roles in your account's default service - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all user roles in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all user roles in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of role - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// An array of the permissions the role has been granted - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this user role. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Conversation = new RoleTypeEnum("conversation"); + public static readonly RoleTypeEnum Service = new RoleTypeEnum("service"); + } + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new user role in your account's default service + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new user role in your account's default service + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new user role in your account's default service + /// + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new user role in your account's default service + /// + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing user role in your account's default service + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing user role in your account's default service + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing user role in your account's default service + /// + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathSid, List permission, ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing user role in your account's default service + /// + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a user role from your account's default service + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a user role from your account's default service + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a user role from your account's default service + /// + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a user role from your account's default service + /// + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a user role from your account's default service + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a user role from your account's default service + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a user role from your account's default service + /// + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a user role from your account's default service + /// + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all user roles in your account's default service + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all user roles in your account's default service + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all user roles in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all user roles in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of role + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// An array of the permissions the role has been granted + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this user role. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/BindingOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/BindingOptions.cs index 324f05ff8..f291dc473 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/BindingOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/BindingOptions.cs @@ -10,130 +10,130 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Remove a push notification binding from the conversation service + /// + public class DeleteBindingOptions : IOptions + { /// - /// Remove a push notification binding from the conversation service + /// The SID of the Conversation Service to delete the resource from /// - public class DeleteBindingOptions : IOptions - { - /// - /// The SID of the Conversation Service to delete the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBindingOptions - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the resource to delete - public DeleteBindingOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathChatServiceSid { get; } /// - /// Fetch a push notification binding from the conversation service + /// The SID of the resource to delete /// - public class FetchBindingOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBindingOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - public FetchBindingOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a list of all push notification bindings in the conversation service + /// Construct a new DeleteBindingOptions /// - public class ReadBindingOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The push technology used by the Binding resources to read. - /// - public List BindingType { get; set; } - /// - /// The identity of Conversation User associated with this binding. - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadBindingOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - public ReadBindingOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - BindingType = new List(); - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (BindingType != null) - { - p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); - } - - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Conversation Service to delete the resource from + /// The SID of the resource to delete + public DeleteBindingOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a push notification binding from the conversation service + /// + public class FetchBindingOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBindingOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + public FetchBindingOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all push notification bindings in the conversation service + /// + public class ReadBindingOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The push technology used by the Binding resources to read. + /// + public List BindingType { get; set; } + /// + /// The identity of Conversation User associated with this binding. + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadBindingOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + public ReadBindingOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + BindingType = new List(); + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (BindingType != null) + { + p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); + } + + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/BindingResource.cs b/src/Twilio/Rest/Conversations/V1/Service/BindingResource.cs index c702b92f7..154f0c48e 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/BindingResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/BindingResource.cs @@ -17,384 +17,384 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class BindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - } - - private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a push notification binding from the conversation service - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a push notification binding from the conversation service - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a push notification binding from the conversation service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathChatServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a push notification binding from the conversation service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathChatServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a push notification binding from the conversation service - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a push notification binding from the conversation service - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a push notification binding from the conversation service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathChatServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a push notification binding from the conversation service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathChatServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all push notification bindings in the conversation service - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all push notification bindings in the conversation service - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all push notification bindings in the conversation service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The push technology used by the Binding resources to read. - /// The identity of Conversation User associated with this binding. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(string pathChatServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathChatServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all push notification bindings in the conversation service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The push technology used by the Binding resources to read. - /// The identity of Conversation User associated with this binding. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathChatServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Converts a JSON string into a BindingResource object - /// - /// Raw JSON string - /// BindingResource object represented by the provided JSON - public static BindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique ID of the Account responsible for this binding. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The SID of the Credential for the binding. - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique endpoint identifier for the Binding. - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The identity of Conversation User associated with this binding. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The push technology to use for the binding. - /// - [JsonProperty("binding_type")] - [JsonConverter(typeof(StringEnumConverter))] - public BindingResource.BindingTypeEnum BindingType { get; private set; } - /// - /// The Conversation message types the binding is subscribed to. - /// - [JsonProperty("message_types")] - public List MessageTypes { get; private set; } - /// - /// An absolute URL for this binding. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private BindingResource() - { - - } - } +{ + + public class BindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + } + + private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a push notification binding from the conversation service + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a push notification binding from the conversation service + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a push notification binding from the conversation service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathChatServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a push notification binding from the conversation service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathChatServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a push notification binding from the conversation service + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a push notification binding from the conversation service + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a push notification binding from the conversation service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathChatServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a push notification binding from the conversation service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathChatServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all push notification bindings in the conversation service + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all push notification bindings in the conversation service + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all push notification bindings in the conversation service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The push technology used by the Binding resources to read. + /// The identity of Conversation User associated with this binding. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(string pathChatServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathChatServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all push notification bindings in the conversation service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The push technology used by the Binding resources to read. + /// The identity of Conversation User associated with this binding. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathChatServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Converts a JSON string into a BindingResource object + /// + /// Raw JSON string + /// BindingResource object represented by the provided JSON + public static BindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique ID of the Account responsible for this binding. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The SID of the Credential for the binding. + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique endpoint identifier for the Binding. + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The identity of Conversation User associated with this binding. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The push technology to use for the binding. + /// + [JsonProperty("binding_type")] + [JsonConverter(typeof(StringEnumConverter))] + public BindingResource.BindingTypeEnum BindingType { get; private set; } + /// + /// The Conversation message types the binding is subscribed to. + /// + [JsonProperty("message_types")] + public List MessageTypes { get; private set; } + /// + /// An absolute URL for this binding. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private BindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationOptions.cs index bab24ded1..3aa05e4b0 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationOptions.cs @@ -9,181 +9,181 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Configuration -{ - +{ + + /// + /// Update push notification service settings + /// + public class UpdateNotificationOptions : IOptions + { /// - /// Update push notification service settings - /// - public class UpdateNotificationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// - public string PathChatServiceSid { get; } - /// - /// Weather the notification logging is enabled. - /// - public bool? LogEnabled { get; set; } - /// - /// Whether to send a notification when a new message is added to a conversation. - /// - public bool? NewMessageEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a new message is added to a conversation. - /// - public string NewMessageTemplate { get; set; } - /// - /// The name of the sound to play when a new message is added to a conversation. - /// - public string NewMessageSound { get; set; } - /// - /// Whether the new message badge is enabled. - /// - public bool? NewMessageBadgeCountEnabled { get; set; } - /// - /// Whether to send a notification when a participant is added to a conversation. - /// - public bool? AddedToConversationEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a participant is added to a conversation. - /// - public string AddedToConversationTemplate { get; set; } - /// - /// The name of the sound to play when a participant is added to a conversation. - /// - public string AddedToConversationSound { get; set; } - /// - /// Whether to send a notification to a user when they are removed from a conversation. - /// - public bool? RemovedFromConversationEnabled { get; set; } - /// - /// The template to use to create the notification text displayed to a user when they are removed. - /// - public string RemovedFromConversationTemplate { get; set; } - /// - /// The name of the sound to play to a user when they are removed from a conversation. - /// - public string RemovedFromConversationSound { get; set; } - /// - /// Whether to send a notification when a new message with media/file attachments is added to a conversation. - /// - public bool? NewMessageWithMediaEnabled { get; set; } - /// - /// The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation. - /// - public string NewMessageWithMediaTemplate { get; set; } - - /// - /// Construct a new UpdateNotificationOptions - /// - /// The SID of the Conversation Service that the Configuration applies to. - public UpdateNotificationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (LogEnabled != null) - { - p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); - } - - if (NewMessageEnabled != null) - { - p.Add(new KeyValuePair("NewMessage.Enabled", NewMessageEnabled.Value.ToString().ToLower())); - } - - if (NewMessageTemplate != null) - { - p.Add(new KeyValuePair("NewMessage.Template", NewMessageTemplate)); - } - - if (NewMessageSound != null) - { - p.Add(new KeyValuePair("NewMessage.Sound", NewMessageSound)); - } - - if (NewMessageBadgeCountEnabled != null) - { - p.Add(new KeyValuePair("NewMessage.BadgeCountEnabled", NewMessageBadgeCountEnabled.Value.ToString().ToLower())); - } - - if (AddedToConversationEnabled != null) - { - p.Add(new KeyValuePair("AddedToConversation.Enabled", AddedToConversationEnabled.Value.ToString().ToLower())); - } - - if (AddedToConversationTemplate != null) - { - p.Add(new KeyValuePair("AddedToConversation.Template", AddedToConversationTemplate)); - } - - if (AddedToConversationSound != null) - { - p.Add(new KeyValuePair("AddedToConversation.Sound", AddedToConversationSound)); - } - - if (RemovedFromConversationEnabled != null) - { - p.Add(new KeyValuePair("RemovedFromConversation.Enabled", RemovedFromConversationEnabled.Value.ToString().ToLower())); - } - - if (RemovedFromConversationTemplate != null) - { - p.Add(new KeyValuePair("RemovedFromConversation.Template", RemovedFromConversationTemplate)); - } - - if (RemovedFromConversationSound != null) - { - p.Add(new KeyValuePair("RemovedFromConversation.Sound", RemovedFromConversationSound)); - } - - if (NewMessageWithMediaEnabled != null) - { - p.Add(new KeyValuePair("NewMessage.WithMedia.Enabled", NewMessageWithMediaEnabled.Value.ToString().ToLower())); - } - - if (NewMessageWithMediaTemplate != null) - { - p.Add(new KeyValuePair("NewMessage.WithMedia.Template", NewMessageWithMediaTemplate)); - } - - return p; - } - } - + /// The SID of the Conversation Service that the Configuration applies to. + /// + public string PathChatServiceSid { get; } /// - /// Fetch push notification service settings + /// Weather the notification logging is enabled. /// - public class FetchNotificationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new FetchNotificationOptions - /// - /// The SID of the Conversation Service that the Configuration applies to. - public FetchNotificationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public bool? LogEnabled { get; set; } + /// + /// Whether to send a notification when a new message is added to a conversation. + /// + public bool? NewMessageEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a new message is added to a conversation. + /// + public string NewMessageTemplate { get; set; } + /// + /// The name of the sound to play when a new message is added to a conversation. + /// + public string NewMessageSound { get; set; } + /// + /// Whether the new message badge is enabled. + /// + public bool? NewMessageBadgeCountEnabled { get; set; } + /// + /// Whether to send a notification when a participant is added to a conversation. + /// + public bool? AddedToConversationEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a participant is added to a conversation. + /// + public string AddedToConversationTemplate { get; set; } + /// + /// The name of the sound to play when a participant is added to a conversation. + /// + public string AddedToConversationSound { get; set; } + /// + /// Whether to send a notification to a user when they are removed from a conversation. + /// + public bool? RemovedFromConversationEnabled { get; set; } + /// + /// The template to use to create the notification text displayed to a user when they are removed. + /// + public string RemovedFromConversationTemplate { get; set; } + /// + /// The name of the sound to play to a user when they are removed from a conversation. + /// + public string RemovedFromConversationSound { get; set; } + /// + /// Whether to send a notification when a new message with media/file attachments is added to a conversation. + /// + public bool? NewMessageWithMediaEnabled { get; set; } + /// + /// The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation. + /// + public string NewMessageWithMediaTemplate { get; set; } + + /// + /// Construct a new UpdateNotificationOptions + /// + /// The SID of the Conversation Service that the Configuration applies to. + public UpdateNotificationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (LogEnabled != null) + { + p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); + } + + if (NewMessageEnabled != null) + { + p.Add(new KeyValuePair("NewMessage.Enabled", NewMessageEnabled.Value.ToString().ToLower())); + } + + if (NewMessageTemplate != null) + { + p.Add(new KeyValuePair("NewMessage.Template", NewMessageTemplate)); + } + + if (NewMessageSound != null) + { + p.Add(new KeyValuePair("NewMessage.Sound", NewMessageSound)); + } + + if (NewMessageBadgeCountEnabled != null) + { + p.Add(new KeyValuePair("NewMessage.BadgeCountEnabled", NewMessageBadgeCountEnabled.Value.ToString().ToLower())); + } + + if (AddedToConversationEnabled != null) + { + p.Add(new KeyValuePair("AddedToConversation.Enabled", AddedToConversationEnabled.Value.ToString().ToLower())); + } + + if (AddedToConversationTemplate != null) + { + p.Add(new KeyValuePair("AddedToConversation.Template", AddedToConversationTemplate)); + } + + if (AddedToConversationSound != null) + { + p.Add(new KeyValuePair("AddedToConversation.Sound", AddedToConversationSound)); + } + + if (RemovedFromConversationEnabled != null) + { + p.Add(new KeyValuePair("RemovedFromConversation.Enabled", RemovedFromConversationEnabled.Value.ToString().ToLower())); + } + + if (RemovedFromConversationTemplate != null) + { + p.Add(new KeyValuePair("RemovedFromConversation.Template", RemovedFromConversationTemplate)); + } + + if (RemovedFromConversationSound != null) + { + p.Add(new KeyValuePair("RemovedFromConversation.Sound", RemovedFromConversationSound)); + } + + if (NewMessageWithMediaEnabled != null) + { + p.Add(new KeyValuePair("NewMessage.WithMedia.Enabled", NewMessageWithMediaEnabled.Value.ToString().ToLower())); + } + + if (NewMessageWithMediaTemplate != null) + { + p.Add(new KeyValuePair("NewMessage.WithMedia.Template", NewMessageWithMediaTemplate)); + } + + return p; + } + } + + /// + /// Fetch push notification service settings + /// + public class FetchNotificationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// + public string PathChatServiceSid { get; } + + /// + /// Construct a new FetchNotificationOptions + /// + /// The SID of the Conversation Service that the Configuration applies to. + public FetchNotificationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationResource.cs index 5ec10dac3..89dc47100 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Configuration/NotificationResource.cs @@ -16,275 +16,275 @@ using Twilio.Http; namespace Twilio.Rest.Conversations.V1.Service.Configuration -{ - - public class NotificationResource : Resource - { - private static Request BuildUpdateRequest(UpdateNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Notifications", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update push notification service settings - /// - /// Update Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Update(UpdateNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update push notification service settings - /// - /// Update Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task UpdateAsync(UpdateNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update push notification service settings - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// Weather the notification logging is enabled. - /// Whether to send a notification when a new message is added to a conversation. - /// - /// The template to use to create the notification text displayed when a new message - /// is added to a conversation. - /// The name of the sound to play when a new message is added to a conversation. - /// Whether the new message badge is enabled. - /// Whether to send a notification when a participant is added to a - /// conversation. - /// The template to use to create the notification text displayed when a - /// participant is added to a conversation. - /// The name of the sound to play when a participant is added to a - /// conversation. - /// Whether to send a notification to a user when they are removed from a - /// conversation. - /// The template to use to create the notification text displayed to a - /// user when they are removed. - /// The name of the sound to play to a user when they are removed from a - /// conversation. - /// Whether to send a notification when a new message with media/file - /// attachments is added to a conversation. - /// The template to use to create the notification text displayed when a new - /// message with media/file attachments is added to a conversation. - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Update(string pathChatServiceSid, - bool? logEnabled = null, - bool? newMessageEnabled = null, - string newMessageTemplate = null, - string newMessageSound = null, - bool? newMessageBadgeCountEnabled = null, - bool? addedToConversationEnabled = null, - string addedToConversationTemplate = null, - string addedToConversationSound = null, - bool? removedFromConversationEnabled = null, - string removedFromConversationTemplate = null, - string removedFromConversationSound = null, - bool? newMessageWithMediaEnabled = null, - string newMessageWithMediaTemplate = null, - ITwilioRestClient client = null) - { - var options = new UpdateNotificationOptions(pathChatServiceSid){LogEnabled = logEnabled, NewMessageEnabled = newMessageEnabled, NewMessageTemplate = newMessageTemplate, NewMessageSound = newMessageSound, NewMessageBadgeCountEnabled = newMessageBadgeCountEnabled, AddedToConversationEnabled = addedToConversationEnabled, AddedToConversationTemplate = addedToConversationTemplate, AddedToConversationSound = addedToConversationSound, RemovedFromConversationEnabled = removedFromConversationEnabled, RemovedFromConversationTemplate = removedFromConversationTemplate, RemovedFromConversationSound = removedFromConversationSound, NewMessageWithMediaEnabled = newMessageWithMediaEnabled, NewMessageWithMediaTemplate = newMessageWithMediaTemplate}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update push notification service settings - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// Weather the notification logging is enabled. - /// Whether to send a notification when a new message is added to a conversation. - /// - /// The template to use to create the notification text displayed when a new message - /// is added to a conversation. - /// The name of the sound to play when a new message is added to a conversation. - /// Whether the new message badge is enabled. - /// Whether to send a notification when a participant is added to a - /// conversation. - /// The template to use to create the notification text displayed when a - /// participant is added to a conversation. - /// The name of the sound to play when a participant is added to a - /// conversation. - /// Whether to send a notification to a user when they are removed from a - /// conversation. - /// The template to use to create the notification text displayed to a - /// user when they are removed. - /// The name of the sound to play to a user when they are removed from a - /// conversation. - /// Whether to send a notification when a new message with media/file - /// attachments is added to a conversation. - /// The template to use to create the notification text displayed when a new - /// message with media/file attachments is added to a conversation. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - bool? logEnabled = null, - bool? newMessageEnabled = null, - string newMessageTemplate = null, - string newMessageSound = null, - bool? newMessageBadgeCountEnabled = null, - bool? addedToConversationEnabled = null, - string addedToConversationTemplate = null, - string addedToConversationSound = null, - bool? removedFromConversationEnabled = null, - string removedFromConversationTemplate = null, - string removedFromConversationSound = null, - bool? newMessageWithMediaEnabled = null, - string newMessageWithMediaTemplate = null, - ITwilioRestClient client = null) - { - var options = new UpdateNotificationOptions(pathChatServiceSid){LogEnabled = logEnabled, NewMessageEnabled = newMessageEnabled, NewMessageTemplate = newMessageTemplate, NewMessageSound = newMessageSound, NewMessageBadgeCountEnabled = newMessageBadgeCountEnabled, AddedToConversationEnabled = addedToConversationEnabled, AddedToConversationTemplate = addedToConversationTemplate, AddedToConversationSound = addedToConversationSound, RemovedFromConversationEnabled = removedFromConversationEnabled, RemovedFromConversationTemplate = removedFromConversationTemplate, RemovedFromConversationSound = removedFromConversationSound, NewMessageWithMediaEnabled = newMessageWithMediaEnabled, NewMessageWithMediaTemplate = newMessageWithMediaTemplate}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Notifications", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch push notification service settings - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch push notification service settings - /// - /// Fetch Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch push notification service settings - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathChatServiceSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch push notification service settings - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - ITwilioRestClient client = null) - { - var options = new FetchNotificationOptions(pathChatServiceSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NotificationResource object - /// - /// Raw JSON string - /// NotificationResource object represented by the provided JSON - public static NotificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this configuration. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the Configuration applies to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The Push Notification configuration for New Messages. - /// - [JsonProperty("new_message")] - public object NewMessage { get; private set; } - /// - /// The Push Notification configuration for being added to a Conversation. - /// - [JsonProperty("added_to_conversation")] - public object AddedToConversation { get; private set; } - /// - /// The Push Notification configuration for being removed from a Conversation. - /// - [JsonProperty("removed_from_conversation")] - public object RemovedFromConversation { get; private set; } - /// - /// Weather the notification logging is enabled. - /// - [JsonProperty("log_enabled")] - public bool? LogEnabled { get; private set; } - /// - /// An absolute URL for this configuration. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NotificationResource() - { - - } - } +{ + + public class NotificationResource : Resource + { + private static Request BuildUpdateRequest(UpdateNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Notifications", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update push notification service settings + /// + /// Update Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Update(UpdateNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update push notification service settings + /// + /// Update Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task UpdateAsync(UpdateNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update push notification service settings + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// Weather the notification logging is enabled. + /// Whether to send a notification when a new message is added to a conversation. + /// + /// The template to use to create the notification text displayed when a new message + /// is added to a conversation. + /// The name of the sound to play when a new message is added to a conversation. + /// Whether the new message badge is enabled. + /// Whether to send a notification when a participant is added to a + /// conversation. + /// The template to use to create the notification text displayed when a + /// participant is added to a conversation. + /// The name of the sound to play when a participant is added to a + /// conversation. + /// Whether to send a notification to a user when they are removed from a + /// conversation. + /// The template to use to create the notification text displayed to a + /// user when they are removed. + /// The name of the sound to play to a user when they are removed from a + /// conversation. + /// Whether to send a notification when a new message with media/file + /// attachments is added to a conversation. + /// The template to use to create the notification text displayed when a new + /// message with media/file attachments is added to a conversation. + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Update(string pathChatServiceSid, + bool? logEnabled = null, + bool? newMessageEnabled = null, + string newMessageTemplate = null, + string newMessageSound = null, + bool? newMessageBadgeCountEnabled = null, + bool? addedToConversationEnabled = null, + string addedToConversationTemplate = null, + string addedToConversationSound = null, + bool? removedFromConversationEnabled = null, + string removedFromConversationTemplate = null, + string removedFromConversationSound = null, + bool? newMessageWithMediaEnabled = null, + string newMessageWithMediaTemplate = null, + ITwilioRestClient client = null) + { + var options = new UpdateNotificationOptions(pathChatServiceSid) { LogEnabled = logEnabled, NewMessageEnabled = newMessageEnabled, NewMessageTemplate = newMessageTemplate, NewMessageSound = newMessageSound, NewMessageBadgeCountEnabled = newMessageBadgeCountEnabled, AddedToConversationEnabled = addedToConversationEnabled, AddedToConversationTemplate = addedToConversationTemplate, AddedToConversationSound = addedToConversationSound, RemovedFromConversationEnabled = removedFromConversationEnabled, RemovedFromConversationTemplate = removedFromConversationTemplate, RemovedFromConversationSound = removedFromConversationSound, NewMessageWithMediaEnabled = newMessageWithMediaEnabled, NewMessageWithMediaTemplate = newMessageWithMediaTemplate }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update push notification service settings + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// Weather the notification logging is enabled. + /// Whether to send a notification when a new message is added to a conversation. + /// + /// The template to use to create the notification text displayed when a new message + /// is added to a conversation. + /// The name of the sound to play when a new message is added to a conversation. + /// Whether the new message badge is enabled. + /// Whether to send a notification when a participant is added to a + /// conversation. + /// The template to use to create the notification text displayed when a + /// participant is added to a conversation. + /// The name of the sound to play when a participant is added to a + /// conversation. + /// Whether to send a notification to a user when they are removed from a + /// conversation. + /// The template to use to create the notification text displayed to a + /// user when they are removed. + /// The name of the sound to play to a user when they are removed from a + /// conversation. + /// Whether to send a notification when a new message with media/file + /// attachments is added to a conversation. + /// The template to use to create the notification text displayed when a new + /// message with media/file attachments is added to a conversation. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + bool? logEnabled = null, + bool? newMessageEnabled = null, + string newMessageTemplate = null, + string newMessageSound = null, + bool? newMessageBadgeCountEnabled = null, + bool? addedToConversationEnabled = null, + string addedToConversationTemplate = null, + string addedToConversationSound = null, + bool? removedFromConversationEnabled = null, + string removedFromConversationTemplate = null, + string removedFromConversationSound = null, + bool? newMessageWithMediaEnabled = null, + string newMessageWithMediaTemplate = null, + ITwilioRestClient client = null) + { + var options = new UpdateNotificationOptions(pathChatServiceSid) { LogEnabled = logEnabled, NewMessageEnabled = newMessageEnabled, NewMessageTemplate = newMessageTemplate, NewMessageSound = newMessageSound, NewMessageBadgeCountEnabled = newMessageBadgeCountEnabled, AddedToConversationEnabled = addedToConversationEnabled, AddedToConversationTemplate = addedToConversationTemplate, AddedToConversationSound = addedToConversationSound, RemovedFromConversationEnabled = removedFromConversationEnabled, RemovedFromConversationTemplate = removedFromConversationTemplate, RemovedFromConversationSound = removedFromConversationSound, NewMessageWithMediaEnabled = newMessageWithMediaEnabled, NewMessageWithMediaTemplate = newMessageWithMediaTemplate }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Notifications", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch push notification service settings + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(FetchNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch push notification service settings + /// + /// Fetch Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(FetchNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch push notification service settings + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathChatServiceSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch push notification service settings + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + ITwilioRestClient client = null) + { + var options = new FetchNotificationOptions(pathChatServiceSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NotificationResource object + /// + /// Raw JSON string + /// NotificationResource object represented by the provided JSON + public static NotificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this configuration. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the Configuration applies to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The Push Notification configuration for New Messages. + /// + [JsonProperty("new_message")] + public object NewMessage { get; private set; } + /// + /// The Push Notification configuration for being added to a Conversation. + /// + [JsonProperty("added_to_conversation")] + public object AddedToConversation { get; private set; } + /// + /// The Push Notification configuration for being removed from a Conversation. + /// + [JsonProperty("removed_from_conversation")] + public object RemovedFromConversation { get; private set; } + /// + /// Weather the notification logging is enabled. + /// + [JsonProperty("log_enabled")] + public bool? LogEnabled { get; private set; } + /// + /// An absolute URL for this configuration. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NotificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookOptions.cs index 42b8f0353..4e0cdaa04 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookOptions.cs @@ -10,105 +10,105 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Configuration -{ - +{ + + /// + /// Update a specific Webhook. + /// + public class UpdateWebhookOptions : IOptions + { /// - /// Update a specific Webhook. + /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. - /// - public string PathChatServiceSid { get; } - /// - /// The absolute url the pre-event webhook request should be sent to. - /// - public Uri PreWebhookUrl { get; set; } - /// - /// The absolute url the post-event webhook request should be sent to. - /// - public Uri PostWebhookUrl { get; set; } - /// - /// The list of events that your configured webhook targets will receive. Events not configured here will not fire. - /// - public List Filters { get; set; } - /// - /// The HTTP method to be used when sending a webhook request - /// - public string Method { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - public UpdateWebhookOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - Filters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); - } - - if (Filters != null) - { - p.AddRange(Filters.Select(prop => new KeyValuePair("Filters", prop))); - } - - if (Method != null) - { - p.Add(new KeyValuePair("Method", Method)); - } - - return p; - } - } - + public string PathChatServiceSid { get; } /// - /// Fetch a specific service webhook configuration. + /// The absolute url the pre-event webhook request should be sent to. /// - public class FetchWebhookOptions : IOptions - { - /// - /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - public FetchWebhookOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public Uri PreWebhookUrl { get; set; } + /// + /// The absolute url the post-event webhook request should be sent to. + /// + public Uri PostWebhookUrl { get; set; } + /// + /// The list of events that your configured webhook targets will receive. Events not configured here will not fire. + /// + public List Filters { get; set; } + /// + /// The HTTP method to be used when sending a webhook request + /// + public string Method { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + public UpdateWebhookOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + Filters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); + } + + if (Filters != null) + { + p.AddRange(Filters.Select(prop => new KeyValuePair("Filters", prop))); + } + + if (Method != null) + { + p.Add(new KeyValuePair("Method", Method)); + } + + return p; + } + } + + /// + /// Fetch a specific service webhook configuration. + /// + public class FetchWebhookOptions : IOptions + { + /// + /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. + /// + public string PathChatServiceSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + public FetchWebhookOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookResource.cs index 33b3d0ecc..5e4acffe8 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Configuration/WebhookResource.cs @@ -17,243 +17,243 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.Configuration -{ - - public class WebhookResource : Resource - { - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Webhook. - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Webhook. - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Webhook. - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - /// The absolute url the pre-event webhook request should be sent to. - /// The absolute url the post-event webhook request should be sent to. - /// The list of events that your configured webhook targets will receive. Events not configured - /// here will not fire. - /// The HTTP method to be used when sending a webhook request - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathChatServiceSid, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - List filters = null, - string method = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathChatServiceSid){PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Filters = filters, Method = method}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Webhook. - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - /// The absolute url the pre-event webhook request should be sent to. - /// The absolute url the post-event webhook request should be sent to. - /// The list of events that your configured webhook targets will receive. Events not configured - /// here will not fire. - /// The HTTP method to be used when sending a webhook request - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - List filters = null, - string method = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathChatServiceSid){PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Filters = filters, Method = method}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific service webhook configuration. - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific service webhook configuration. - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific service webhook configuration. - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathChatServiceSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific service webhook configuration. - /// - /// The unique ID of the [Conversation - /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation - /// belongs to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathChatServiceSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this service. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The absolute url the pre-event webhook request should be sent to. - /// - [JsonProperty("pre_webhook_url")] - public Uri PreWebhookUrl { get; private set; } - /// - /// The absolute url the post-event webhook request should be sent to. - /// - [JsonProperty("post_webhook_url")] - public Uri PostWebhookUrl { get; private set; } - /// - /// The list of events that your configured webhook targets will receive. Events not configured here will not fire. - /// - [JsonProperty("filters")] - public List Filters { get; private set; } - /// - /// The HTTP method to be used when sending a webhook request - /// - [JsonProperty("method")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.MethodEnum Method { get; private set; } - /// - /// An absolute URL for this webhook. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Webhook. + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Webhook. + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Webhook. + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + /// The absolute url the pre-event webhook request should be sent to. + /// The absolute url the post-event webhook request should be sent to. + /// The list of events that your configured webhook targets will receive. Events not configured + /// here will not fire. + /// The HTTP method to be used when sending a webhook request + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathChatServiceSid, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + List filters = null, + string method = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathChatServiceSid) { PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Filters = filters, Method = method }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Webhook. + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + /// The absolute url the pre-event webhook request should be sent to. + /// The absolute url the post-event webhook request should be sent to. + /// The list of events that your configured webhook targets will receive. Events not configured + /// here will not fire. + /// The HTTP method to be used when sending a webhook request + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + List filters = null, + string method = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathChatServiceSid) { PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, Filters = filters, Method = method }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific service webhook configuration. + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific service webhook configuration. + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific service webhook configuration. + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathChatServiceSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific service webhook configuration. + /// + /// The unique ID of the [Conversation + /// Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation + /// belongs to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathChatServiceSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this service. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The absolute url the pre-event webhook request should be sent to. + /// + [JsonProperty("pre_webhook_url")] + public Uri PreWebhookUrl { get; private set; } + /// + /// The absolute url the post-event webhook request should be sent to. + /// + [JsonProperty("post_webhook_url")] + public Uri PostWebhookUrl { get; private set; } + /// + /// The list of events that your configured webhook targets will receive. Events not configured here will not fire. + /// + [JsonProperty("filters")] + public List Filters { get; private set; } + /// + /// The HTTP method to be used when sending a webhook request + /// + [JsonProperty("method")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.MethodEnum Method { get; private set; } + /// + /// An absolute URL for this webhook. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ConfigurationOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/ConfigurationOptions.cs index bf0349c87..2d5a94f9b 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ConfigurationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ConfigurationOptions.cs @@ -9,100 +9,100 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Fetch the configuration of a conversation service + /// + public class FetchConfigurationOptions : IOptions + { /// - /// Fetch the configuration of a conversation service + /// The SID of the Service configuration resource to fetch /// - public class FetchConfigurationOptions : IOptions - { - /// - /// The SID of the Service configuration resource to fetch - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new FetchConfigurationOptions - /// - /// The SID of the Service configuration resource to fetch - public FetchConfigurationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathChatServiceSid { get; } + /// - /// Update configuration settings of a conversation service + /// Construct a new FetchConfigurationOptions /// - public class UpdateConfigurationOptions : IOptions - { - /// - /// The SID of the Service configuration resource to update - /// - public string PathChatServiceSid { get; } - /// - /// The role assigned to a conversation creator when they join a new conversation - /// - public string DefaultConversationCreatorRoleSid { get; set; } - /// - /// The role assigned to users when they are added to a conversation - /// - public string DefaultConversationRoleSid { get; set; } - /// - /// The service role assigned to users when they are added to the service - /// - public string DefaultChatServiceRoleSid { get; set; } - /// - /// Whether the Reachability Indicator feature is enabled for this Conversations Service - /// - public bool? ReachabilityEnabled { get; set; } - - /// - /// Construct a new UpdateConfigurationOptions - /// - /// The SID of the Service configuration resource to update - public UpdateConfigurationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DefaultConversationCreatorRoleSid != null) - { - p.Add(new KeyValuePair("DefaultConversationCreatorRoleSid", DefaultConversationCreatorRoleSid.ToString())); - } - - if (DefaultConversationRoleSid != null) - { - p.Add(new KeyValuePair("DefaultConversationRoleSid", DefaultConversationRoleSid.ToString())); - } - - if (DefaultChatServiceRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChatServiceRoleSid", DefaultChatServiceRoleSid.ToString())); - } - - if (ReachabilityEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the Service configuration resource to fetch + public FetchConfigurationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update configuration settings of a conversation service + /// + public class UpdateConfigurationOptions : IOptions + { + /// + /// The SID of the Service configuration resource to update + /// + public string PathChatServiceSid { get; } + /// + /// The role assigned to a conversation creator when they join a new conversation + /// + public string DefaultConversationCreatorRoleSid { get; set; } + /// + /// The role assigned to users when they are added to a conversation + /// + public string DefaultConversationRoleSid { get; set; } + /// + /// The service role assigned to users when they are added to the service + /// + public string DefaultChatServiceRoleSid { get; set; } + /// + /// Whether the Reachability Indicator feature is enabled for this Conversations Service + /// + public bool? ReachabilityEnabled { get; set; } + + /// + /// Construct a new UpdateConfigurationOptions + /// + /// The SID of the Service configuration resource to update + public UpdateConfigurationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DefaultConversationCreatorRoleSid != null) + { + p.Add(new KeyValuePair("DefaultConversationCreatorRoleSid", DefaultConversationCreatorRoleSid.ToString())); + } + + if (DefaultConversationRoleSid != null) + { + p.Add(new KeyValuePair("DefaultConversationRoleSid", DefaultConversationRoleSid.ToString())); + } + + if (DefaultChatServiceRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChatServiceRoleSid", DefaultChatServiceRoleSid.ToString())); + } + + if (ReachabilityEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ConfigurationResource.cs b/src/Twilio/Rest/Conversations/V1/Service/ConfigurationResource.cs index 11eff907c..0c94db962 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ConfigurationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ConfigurationResource.cs @@ -16,225 +16,225 @@ using Twilio.Http; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class ConfigurationResource : Resource - { - private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the configuration of a conversation service - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation service - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the configuration of a conversation service - /// - /// The SID of the Service configuration resource to fetch - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(pathChatServiceSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation service - /// - /// The SID of the Service configuration resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(pathChatServiceSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update configuration settings of a conversation service - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update configuration settings of a conversation service - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update configuration settings of a conversation service - /// - /// The SID of the Service configuration resource to update - /// The role assigned to a conversation creator when they join a new - /// conversation - /// The role assigned to users when they are added to a conversation - /// The service role assigned to users when they are added to the service - /// - /// Whether the Reachability Indicator feature is enabled for this Conversations - /// Service - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(string pathChatServiceSid, - string defaultConversationCreatorRoleSid = null, - string defaultConversationRoleSid = null, - string defaultChatServiceRoleSid = null, - bool? reachabilityEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(pathChatServiceSid){DefaultConversationCreatorRoleSid = defaultConversationCreatorRoleSid, DefaultConversationRoleSid = defaultConversationRoleSid, DefaultChatServiceRoleSid = defaultChatServiceRoleSid, ReachabilityEnabled = reachabilityEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update configuration settings of a conversation service - /// - /// The SID of the Service configuration resource to update - /// The role assigned to a conversation creator when they join a new - /// conversation - /// The role assigned to users when they are added to a conversation - /// The service role assigned to users when they are added to the service - /// - /// Whether the Reachability Indicator feature is enabled for this Conversations - /// Service - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string defaultConversationCreatorRoleSid = null, - string defaultConversationRoleSid = null, - string defaultChatServiceRoleSid = null, - bool? reachabilityEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(pathChatServiceSid){DefaultConversationCreatorRoleSid = defaultConversationCreatorRoleSid, DefaultConversationRoleSid = defaultConversationRoleSid, DefaultChatServiceRoleSid = defaultChatServiceRoleSid, ReachabilityEnabled = reachabilityEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConfigurationResource object - /// - /// Raw JSON string - /// ConfigurationResource object represented by the provided JSON - public static ConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The role assigned to a conversation creator user when they join a new conversation - /// - [JsonProperty("default_conversation_creator_role_sid")] - public string DefaultConversationCreatorRoleSid { get; private set; } - /// - /// The role assigned to users when they are added to a conversation - /// - [JsonProperty("default_conversation_role_sid")] - public string DefaultConversationRoleSid { get; private set; } - /// - /// The service role assigned to users when they are added to the service - /// - [JsonProperty("default_chat_service_role_sid")] - public string DefaultChatServiceRoleSid { get; private set; } - /// - /// An absolute URL for this service configuration. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URL to access the push notifications configuration of this service. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// Whether the Reachability Indicator feature is enabled for this Conversations Service - /// - [JsonProperty("reachability_enabled")] - public bool? ReachabilityEnabled { get; private set; } - - private ConfigurationResource() - { - - } - } +{ + + public class ConfigurationResource : Resource + { + private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the configuration of a conversation service + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation service + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the configuration of a conversation service + /// + /// The SID of the Service configuration resource to fetch + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(string pathChatServiceSid, ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions(pathChatServiceSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation service + /// + /// The SID of the Service configuration resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions(pathChatServiceSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update configuration settings of a conversation service + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update configuration settings of a conversation service + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update configuration settings of a conversation service + /// + /// The SID of the Service configuration resource to update + /// The role assigned to a conversation creator when they join a new + /// conversation + /// The role assigned to users when they are added to a conversation + /// The service role assigned to users when they are added to the service + /// + /// Whether the Reachability Indicator feature is enabled for this Conversations + /// Service + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(string pathChatServiceSid, + string defaultConversationCreatorRoleSid = null, + string defaultConversationRoleSid = null, + string defaultChatServiceRoleSid = null, + bool? reachabilityEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions(pathChatServiceSid) { DefaultConversationCreatorRoleSid = defaultConversationCreatorRoleSid, DefaultConversationRoleSid = defaultConversationRoleSid, DefaultChatServiceRoleSid = defaultChatServiceRoleSid, ReachabilityEnabled = reachabilityEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update configuration settings of a conversation service + /// + /// The SID of the Service configuration resource to update + /// The role assigned to a conversation creator when they join a new + /// conversation + /// The role assigned to users when they are added to a conversation + /// The service role assigned to users when they are added to the service + /// + /// Whether the Reachability Indicator feature is enabled for this Conversations + /// Service + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string defaultConversationCreatorRoleSid = null, + string defaultConversationRoleSid = null, + string defaultChatServiceRoleSid = null, + bool? reachabilityEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions(pathChatServiceSid) { DefaultConversationCreatorRoleSid = defaultConversationCreatorRoleSid, DefaultConversationRoleSid = defaultConversationRoleSid, DefaultChatServiceRoleSid = defaultChatServiceRoleSid, ReachabilityEnabled = reachabilityEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConfigurationResource object + /// + /// Raw JSON string + /// ConfigurationResource object represented by the provided JSON + public static ConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The role assigned to a conversation creator user when they join a new conversation + /// + [JsonProperty("default_conversation_creator_role_sid")] + public string DefaultConversationCreatorRoleSid { get; private set; } + /// + /// The role assigned to users when they are added to a conversation + /// + [JsonProperty("default_conversation_role_sid")] + public string DefaultConversationRoleSid { get; private set; } + /// + /// The service role assigned to users when they are added to the service + /// + [JsonProperty("default_chat_service_role_sid")] + public string DefaultChatServiceRoleSid { get; private set; } + /// + /// An absolute URL for this service configuration. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URL to access the push notifications configuration of this service. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// Whether the Reachability Indicator feature is enabled for this Conversations Service + /// + [JsonProperty("reachability_enabled")] + public bool? ReachabilityEnabled { get; private set; } + + private ConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptOptions.cs index b86d19fd3..f25af3e0f 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptOptions.cs @@ -9,102 +9,102 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Conversation.Message -{ - +{ + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + public class FetchDeliveryReceiptOptions : IOptions + { /// - /// Fetch the delivery and read receipts of the conversation message + /// The SID of the Conversation Service that the resource is associated with. /// - public class FetchDeliveryReceiptOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this delivery receipt. - /// - public string PathConversationSid { get; } - /// - /// The SID of the message the delivery receipt belongs to. - /// - public string PathMessageSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDeliveryReceiptOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - public FetchDeliveryReceiptOptions(string pathChatServiceSid, - string pathConversationSid, - string pathMessageSid, - string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathMessageSid = pathMessageSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathChatServiceSid { get; } /// - /// Retrieve a list of all delivery and read receipts of the conversation message + /// The unique ID of the Conversation for this delivery receipt. /// - public class ReadDeliveryReceiptOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this delivery receipt. - /// - public string PathConversationSid { get; } - /// - /// The SID of the message the delivery receipt belongs to. - /// - public string PathMessageSid { get; } - - /// - /// Construct a new ReadDeliveryReceiptOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - public ReadDeliveryReceiptOptions(string pathChatServiceSid, string pathConversationSid, string pathMessageSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathMessageSid = pathMessageSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathConversationSid { get; } + /// + /// The SID of the message the delivery receipt belongs to. + /// + public string PathMessageSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDeliveryReceiptOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + public FetchDeliveryReceiptOptions(string pathChatServiceSid, + string pathConversationSid, + string pathMessageSid, + string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathMessageSid = pathMessageSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + public class ReadDeliveryReceiptOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this delivery receipt. + /// + public string PathConversationSid { get; } + /// + /// The SID of the message the delivery receipt belongs to. + /// + public string PathMessageSid { get; } + + /// + /// Construct a new ReadDeliveryReceiptOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + public ReadDeliveryReceiptOptions(string pathChatServiceSid, string pathConversationSid, string pathMessageSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathMessageSid = pathMessageSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptResource.cs index 781e66c5d..60623de2c 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/Message/DeliveryReceiptResource.cs @@ -17,333 +17,333 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.Conversation.Message -{ - - public class DeliveryReceiptResource : Resource - { - public sealed class DeliveryStatusEnum : StringEnum - { - private DeliveryStatusEnum(string value) : base(value) {} - public DeliveryStatusEnum() {} - public static implicit operator DeliveryStatusEnum(string value) - { - return new DeliveryStatusEnum(value); - } - - public static readonly DeliveryStatusEnum Read = new DeliveryStatusEnum("read"); - public static readonly DeliveryStatusEnum Failed = new DeliveryStatusEnum("failed"); - public static readonly DeliveryStatusEnum Delivered = new DeliveryStatusEnum("delivered"); - public static readonly DeliveryStatusEnum Undelivered = new DeliveryStatusEnum("undelivered"); - public static readonly DeliveryStatusEnum Sent = new DeliveryStatusEnum("sent"); - } - - private static Request BuildFetchRequest(FetchDeliveryReceiptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// Fetch DeliveryReceipt parameters - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static DeliveryReceiptResource Fetch(FetchDeliveryReceiptOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// Fetch DeliveryReceipt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task FetchAsync(FetchDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static DeliveryReceiptResource Fetch(string pathChatServiceSid, - string pathConversationSid, - string pathMessageSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the delivery and read receipts of the conversation message - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathConversationSid, - string pathMessageSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDeliveryReceiptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// Read DeliveryReceipt parameters - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static ResourceSet Read(ReadDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("delivery_receipts", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// Read DeliveryReceipt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task> ReadAsync(ReadDeliveryReceiptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("delivery_receipts", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DeliveryReceipt - public static ResourceSet Read(string pathChatServiceSid, - string pathConversationSid, - string pathMessageSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all delivery and read receipts of the conversation message - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this delivery receipt. - /// The SID of the message the delivery receipt belongs to. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DeliveryReceipt - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string pathConversationSid, - string pathMessageSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("delivery_receipts", response.Content); - } - - /// - /// Converts a JSON string into a DeliveryReceiptResource object - /// - /// Raw JSON string - /// DeliveryReceiptResource object represented by the provided JSON - public static DeliveryReceiptResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this participant. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this message. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// The SID of the message the delivery receipt belongs to - /// - [JsonProperty("message_sid")] - public string MessageSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A messaging channel-specific identifier for the message delivered to participant - /// - [JsonProperty("channel_message_sid")] - public string ChannelMessageSid { get; private set; } - /// - /// The unique ID of the participant the delivery receipt belongs to. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The message delivery status - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public DeliveryReceiptResource.DeliveryStatusEnum Status { get; private set; } - /// - /// The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this delivery receipt. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DeliveryReceiptResource() - { - - } - } +{ + + public class DeliveryReceiptResource : Resource + { + public sealed class DeliveryStatusEnum : StringEnum + { + private DeliveryStatusEnum(string value) : base(value) { } + public DeliveryStatusEnum() { } + public static implicit operator DeliveryStatusEnum(string value) + { + return new DeliveryStatusEnum(value); + } + + public static readonly DeliveryStatusEnum Read = new DeliveryStatusEnum("read"); + public static readonly DeliveryStatusEnum Failed = new DeliveryStatusEnum("failed"); + public static readonly DeliveryStatusEnum Delivered = new DeliveryStatusEnum("delivered"); + public static readonly DeliveryStatusEnum Undelivered = new DeliveryStatusEnum("undelivered"); + public static readonly DeliveryStatusEnum Sent = new DeliveryStatusEnum("sent"); + } + + private static Request BuildFetchRequest(FetchDeliveryReceiptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// Fetch DeliveryReceipt parameters + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static DeliveryReceiptResource Fetch(FetchDeliveryReceiptOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// Fetch DeliveryReceipt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task FetchAsync(FetchDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static DeliveryReceiptResource Fetch(string pathChatServiceSid, + string pathConversationSid, + string pathMessageSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the delivery and read receipts of the conversation message + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathConversationSid, + string pathMessageSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDeliveryReceiptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathMessageSid + "/Receipts", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// Read DeliveryReceipt parameters + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static ResourceSet Read(ReadDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("delivery_receipts", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// Read DeliveryReceipt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task> ReadAsync(ReadDeliveryReceiptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("delivery_receipts", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DeliveryReceipt + public static ResourceSet Read(string pathChatServiceSid, + string pathConversationSid, + string pathMessageSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all delivery and read receipts of the conversation message + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this delivery receipt. + /// The SID of the message the delivery receipt belongs to. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DeliveryReceipt + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string pathConversationSid, + string pathMessageSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeliveryReceiptOptions(pathChatServiceSid, pathConversationSid, pathMessageSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("delivery_receipts", response.Content); + } + + /// + /// Converts a JSON string into a DeliveryReceiptResource object + /// + /// Raw JSON string + /// DeliveryReceiptResource object represented by the provided JSON + public static DeliveryReceiptResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this participant. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this message. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// The SID of the message the delivery receipt belongs to + /// + [JsonProperty("message_sid")] + public string MessageSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A messaging channel-specific identifier for the message delivered to participant + /// + [JsonProperty("channel_message_sid")] + public string ChannelMessageSid { get; private set; } + /// + /// The unique ID of the participant the delivery receipt belongs to. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The message delivery status + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public DeliveryReceiptResource.DeliveryStatusEnum Status { get; private set; } + /// + /// The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this delivery receipt. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DeliveryReceiptResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageOptions.cs index 51f69ff1f..2076c57ae 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageOptions.cs @@ -9,366 +9,366 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - +{ + + /// + /// Add a new message to the conversation in a specific service + /// + public class CreateMessageOptions : IOptions + { /// - /// Add a new message to the conversation in a specific service - /// - public class CreateMessageOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// The channel specific identifier of the message's author. - /// - public string Author { get; set; } - /// - /// The content of the message. - /// - public string Body { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The Media SID to be attached to the new Message. - /// - public string MediaSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - public CreateMessageOptions(string pathChatServiceSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Author != null) - { - p.Add(new KeyValuePair("Author", Author)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MediaSid != null) - { - p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } /// - /// Update an existing message in the conversation - /// - public class UpdateMessageOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The channel specific identifier of the message's author. - /// - public string Author { get; set; } - /// - /// The content of the message. - /// - public string Body { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public UpdateMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Author != null) - { - p.Add(new KeyValuePair("Author", Author)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } /// - /// Remove a message from the conversation - /// - public class DeleteMessageOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public DeleteMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The channel specific identifier of the message's author. + /// + public string Author { get; set; } /// - /// Fetch a message from the conversation - /// - public class FetchMessageOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this message. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - public FetchMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The content of the message. + /// + public string Body { get; set; } /// - /// Retrieve a list of all messages in the conversation - /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for messages. - /// - public string PathConversationSid { get; } - /// - /// The sort order of the returned messages - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for messages. - public ReadMessageOptions(string pathChatServiceSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The Media SID to be attached to the new Message. + /// + public string MediaSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + public CreateMessageOptions(string pathChatServiceSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Author != null) + { + p.Add(new KeyValuePair("Author", Author)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MediaSid != null) + { + p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing message in the conversation + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The channel specific identifier of the message's author. + /// + public string Author { get; set; } + /// + /// The content of the message. + /// + public string Body { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public UpdateMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Author != null) + { + p.Add(new KeyValuePair("Author", Author)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a message from the conversation + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public DeleteMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a message from the conversation + /// + public class FetchMessageOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this message. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMessageOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + public FetchMessageOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all messages in the conversation + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for messages. + /// + public string PathConversationSid { get; } + /// + /// The sort order of the returned messages + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for messages. + public ReadMessageOptions(string pathChatServiceSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageResource.cs index 51b3765a0..b20b175f9 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/MessageResource.cs @@ -17,631 +17,631 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new message to the conversation in a specific service - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new message to the conversation in a specific service - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new message to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The Media SID to be attached to the new Message. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathChatServiceSid, - string pathConversationSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathChatServiceSid, pathConversationSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new message to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The Media SID to be attached to the new Message. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string pathConversationSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathChatServiceSid, pathConversationSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing message in the conversation - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing message in the conversation - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing message in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathChatServiceSid, pathConversationSid, pathSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing message in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The channel specific identifier of the message's author. - /// The content of the message. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A string metadata field you can use to store any data you wish. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - string author = null, - string body = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathChatServiceSid, pathConversationSid, pathSid){Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a message from the conversation - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a message from the conversation - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a message from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathChatServiceSid, pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a message from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathChatServiceSid, pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a message from the conversation - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a message from the conversation - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a message from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathChatServiceSid, pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a message from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this message. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathChatServiceSid, pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all messages in the conversation - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all messages in the conversation - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all messages in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for messages. - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathChatServiceSid, - string pathConversationSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all messages in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for messages. - /// The sort order of the returned messages - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string pathConversationSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this message. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this message. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The index of the message within the Conversation. - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The channel specific identifier of the message's author. - /// - [JsonProperty("author")] - public string Author { get; private set; } - /// - /// The content of the message. - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// An array of objects that describe the Message's media if attached, otherwise, null. - /// - [JsonProperty("media")] - public List Media { get; private set; } - /// - /// A string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The unique ID of messages's author participant. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An object that contains the summary of delivery statuses for the message to non-chat participants. - /// - [JsonProperty("delivery")] - public object Delivery { get; private set; } - /// - /// An absolute URL for this message. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URL to access the receipts of this message. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new message to the conversation in a specific service + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new message to the conversation in a specific service + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new message to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The Media SID to be attached to the new Message. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathChatServiceSid, + string pathConversationSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathChatServiceSid, pathConversationSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new message to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The Media SID to be attached to the new Message. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string pathConversationSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathChatServiceSid, pathConversationSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing message in the conversation + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing message in the conversation + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing message in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathChatServiceSid, pathConversationSid, pathSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing message in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The channel specific identifier of the message's author. + /// The content of the message. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A string metadata field you can use to store any data you wish. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + string author = null, + string body = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathChatServiceSid, pathConversationSid, pathSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a message from the conversation + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a message from the conversation + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a message from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathChatServiceSid, pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a message from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathChatServiceSid, pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a message from the conversation + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a message from the conversation + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a message from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathChatServiceSid, pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a message from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this message. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathChatServiceSid, pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all messages in the conversation + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all messages in the conversation + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all messages in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for messages. + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathChatServiceSid, + string pathConversationSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all messages in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for messages. + /// The sort order of the returned messages + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string pathConversationSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this message. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this message. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The index of the message within the Conversation. + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The channel specific identifier of the message's author. + /// + [JsonProperty("author")] + public string Author { get; private set; } + /// + /// The content of the message. + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// An array of objects that describe the Message's media if attached, otherwise, null. + /// + [JsonProperty("media")] + public List Media { get; private set; } + /// + /// A string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The unique ID of messages's author participant. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An object that contains the summary of delivery statuses for the message to non-chat participants. + /// + [JsonProperty("delivery")] + public object Delivery { get; private set; } + /// + /// An absolute URL for this message. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URL to access the receipts of this message. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantOptions.cs index 997fdb1bd..3e21df989 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantOptions.cs @@ -9,411 +9,411 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - +{ + + /// + /// Add a new participant to the conversation in a specific service + /// + public class CreateParticipantOptions : IOptions + { /// - /// Add a new participant to the conversation in a specific service - /// - public class CreateParticipantOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// The address of the participant's device. - /// - public string MessagingBindingAddress { get; set; } - /// - /// The address of the Twilio phone number that the participant is in contact with. - /// - public string MessagingBindingProxyAddress { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The address of the Twilio phone number that is used in Group MMS. - /// - public string MessagingBindingProjectedAddress { get; set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateParticipantOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - public CreateParticipantOptions(string pathChatServiceSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (MessagingBindingAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.Address", MessagingBindingAddress)); - } - - if (MessagingBindingProxyAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MessagingBindingProjectedAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } /// - /// Update an existing participant in the conversation - /// - public class UpdateParticipantOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - public string RoleSid { get; set; } - /// - /// The address of the Twilio phone number that the participant is in contact with. - /// - public string MessagingBindingProxyAddress { get; set; } - /// - /// The address of the Twilio phone number that is used in Group MMS. - /// - public string MessagingBindingProjectedAddress { get; set; } - /// - /// Index of last “read” message in the Conversation for the Participant. - /// - public int? LastReadMessageIndex { get; set; } - /// - /// Timestamp of last “read” message in the Conversation for the Participant. - /// - public string LastReadTimestamp { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateParticipantOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public UpdateParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (MessagingBindingProxyAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); - } - - if (MessagingBindingProjectedAddress != null) - { - p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); - } - - if (LastReadMessageIndex != null) - { - p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); - } - - if (LastReadTimestamp != null) - { - p.Add(new KeyValuePair("LastReadTimestamp", LastReadTimestamp)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } /// - /// Remove a participant from the conversation - /// - public class DeleteParticipantOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteParticipantOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public DeleteParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// A unique string identifier for the conversation participant as Conversation User. + /// + public string Identity { get; set; } /// - /// Fetch a participant of the conversation - /// - public class FetchParticipantOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this participant. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - public FetchParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The address of the participant's device. + /// + public string MessagingBindingAddress { get; set; } /// - /// Retrieve a list of all participants of the conversation - /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for participants. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for participants. - public ReadParticipantOptions(string pathChatServiceSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The address of the Twilio phone number that the participant is in contact with. + /// + public string MessagingBindingProxyAddress { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The address of the Twilio phone number that is used in Group MMS. + /// + public string MessagingBindingProjectedAddress { get; set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + public string RoleSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateParticipantOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + public CreateParticipantOptions(string pathChatServiceSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (MessagingBindingAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.Address", MessagingBindingAddress)); + } + + if (MessagingBindingProxyAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MessagingBindingProjectedAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing participant in the conversation + /// + public class UpdateParticipantOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + public string Identity { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + public string RoleSid { get; set; } + /// + /// The address of the Twilio phone number that the participant is in contact with. + /// + public string MessagingBindingProxyAddress { get; set; } + /// + /// The address of the Twilio phone number that is used in Group MMS. + /// + public string MessagingBindingProjectedAddress { get; set; } + /// + /// Index of last “read” message in the Conversation for the Participant. + /// + public int? LastReadMessageIndex { get; set; } + /// + /// Timestamp of last “read” message in the Conversation for the Participant. + /// + public string LastReadTimestamp { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateParticipantOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public UpdateParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (MessagingBindingProxyAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProxyAddress", MessagingBindingProxyAddress)); + } + + if (MessagingBindingProjectedAddress != null) + { + p.Add(new KeyValuePair("MessagingBinding.ProjectedAddress", MessagingBindingProjectedAddress)); + } + + if (LastReadMessageIndex != null) + { + p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); + } + + if (LastReadTimestamp != null) + { + p.Add(new KeyValuePair("LastReadTimestamp", LastReadTimestamp)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a participant from the conversation + /// + public class DeleteParticipantOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ParticipantResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteParticipantOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public DeleteParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a participant of the conversation + /// + public class FetchParticipantOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this participant. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchParticipantOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + public FetchParticipantOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all participants of the conversation + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for participants. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for participants. + public ReadParticipantOptions(string pathChatServiceSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantResource.cs index 5f92ae0ad..1e16a82e6 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/ParticipantResource.cs @@ -17,636 +17,636 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - - public class ParticipantResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new participant to the conversation in a specific service - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new participant to the conversation in a specific service - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new participant to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A unique string identifier for the conversation participant as Conversation User. - /// The address of the participant's device. - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// The SID of a conversation-level Role to assign to the participant - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(string pathChatServiceSid, - string pathConversationSid, - string identity = null, - string messagingBindingAddress = null, - string messagingBindingProxyAddress = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingBindingProjectedAddress = null, - string roleSid = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathChatServiceSid, pathConversationSid){Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new participant to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A unique string identifier for the conversation participant as Conversation User. - /// The address of the participant's device. - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// The SID of a conversation-level Role to assign to the participant - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string pathConversationSid, - string identity = null, - string messagingBindingAddress = null, - string messagingBindingProxyAddress = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingBindingProjectedAddress = null, - string roleSid = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathChatServiceSid, pathConversationSid){Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing participant in the conversation - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing participant in the conversation - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing participant in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A unique string identifier for the conversation participant as Conversation User. - /// An optional string metadata field you can use to store any data you wish. - /// The SID of a conversation-level Role to assign to the participant - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// Index of last “read” message in the Conversation for the Participant. - /// Timestamp of last “read” message in the Conversation for the Participant. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string identity = null, - string attributes = null, - string roleSid = null, - string messagingBindingProxyAddress = null, - string messagingBindingProjectedAddress = null, - int? lastReadMessageIndex = null, - string lastReadTimestamp = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid){DateCreated = dateCreated, DateUpdated = dateUpdated, Identity = identity, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing participant in the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// A unique string identifier for the conversation participant as Conversation User. - /// An optional string metadata field you can use to store any data you wish. - /// The SID of a conversation-level Role to assign to the participant - /// The address of the Twilio phone number that the participant is in - /// contact with. - /// The address of the Twilio phone number that is used in Group MMS. - /// - /// Index of last “read” message in the Conversation for the Participant. - /// Timestamp of last “read” message in the Conversation for the Participant. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string identity = null, - string attributes = null, - string roleSid = null, - string messagingBindingProxyAddress = null, - string messagingBindingProjectedAddress = null, - int? lastReadMessageIndex = null, - string lastReadTimestamp = null, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid){DateCreated = dateCreated, DateUpdated = dateUpdated, Identity = identity, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a participant from the conversation - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a participant from the conversation - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a participant from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a participant from the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a participant of the conversation - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a participant of the conversation - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a participant of the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a participant of the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this participant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all participants of the conversation - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all participants of the conversation - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all participants of the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for participants. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathChatServiceSid, - string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathChatServiceSid, pathConversationSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all participants of the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for participants. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathChatServiceSid, pathConversationSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this participant. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this participant. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Information about how this participant exchanges messages with the conversation. - /// - [JsonProperty("messaging_binding")] - public object MessagingBinding { get; private set; } - /// - /// The SID of a conversation-level Role to assign to the participant - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this participant. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Index of last “read” message in the Conversation for the Participant. - /// - [JsonProperty("last_read_message_index")] - public int? LastReadMessageIndex { get; private set; } - /// - /// Timestamp of last “read” message in the Conversation for the Participant. - /// - [JsonProperty("last_read_timestamp")] - public string LastReadTimestamp { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new participant to the conversation in a specific service + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new participant to the conversation in a specific service + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new participant to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A unique string identifier for the conversation participant as Conversation User. + /// The address of the participant's device. + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// The SID of a conversation-level Role to assign to the participant + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(string pathChatServiceSid, + string pathConversationSid, + string identity = null, + string messagingBindingAddress = null, + string messagingBindingProxyAddress = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingBindingProjectedAddress = null, + string roleSid = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathChatServiceSid, pathConversationSid) { Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new participant to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A unique string identifier for the conversation participant as Conversation User. + /// The address of the participant's device. + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// The SID of a conversation-level Role to assign to the participant + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string pathConversationSid, + string identity = null, + string messagingBindingAddress = null, + string messagingBindingProxyAddress = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingBindingProjectedAddress = null, + string roleSid = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathChatServiceSid, pathConversationSid) { Identity = identity, MessagingBindingAddress = messagingBindingAddress, MessagingBindingProxyAddress = messagingBindingProxyAddress, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing participant in the conversation + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing participant in the conversation + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing participant in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A unique string identifier for the conversation participant as Conversation User. + /// An optional string metadata field you can use to store any data you wish. + /// The SID of a conversation-level Role to assign to the participant + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// Index of last “read” message in the Conversation for the Participant. + /// Timestamp of last “read” message in the Conversation for the Participant. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string identity = null, + string attributes = null, + string roleSid = null, + string messagingBindingProxyAddress = null, + string messagingBindingProjectedAddress = null, + int? lastReadMessageIndex = null, + string lastReadTimestamp = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid) { DateCreated = dateCreated, DateUpdated = dateUpdated, Identity = identity, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing participant in the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// A unique string identifier for the conversation participant as Conversation User. + /// An optional string metadata field you can use to store any data you wish. + /// The SID of a conversation-level Role to assign to the participant + /// The address of the Twilio phone number that the participant is in + /// contact with. + /// The address of the Twilio phone number that is used in Group MMS. + /// + /// Index of last “read” message in the Conversation for the Participant. + /// Timestamp of last “read” message in the Conversation for the Participant. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string identity = null, + string attributes = null, + string roleSid = null, + string messagingBindingProxyAddress = null, + string messagingBindingProjectedAddress = null, + int? lastReadMessageIndex = null, + string lastReadTimestamp = null, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid) { DateCreated = dateCreated, DateUpdated = dateUpdated, Identity = identity, Attributes = attributes, RoleSid = roleSid, MessagingBindingProxyAddress = messagingBindingProxyAddress, MessagingBindingProjectedAddress = messagingBindingProjectedAddress, LastReadMessageIndex = lastReadMessageIndex, LastReadTimestamp = lastReadTimestamp, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a participant from the conversation + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a participant from the conversation + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a participant from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a participant from the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ParticipantResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a participant of the conversation + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a participant of the conversation + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a participant of the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a participant of the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this participant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathChatServiceSid, pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Participants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all participants of the conversation + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all participants of the conversation + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all participants of the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for participants. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathChatServiceSid, + string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathChatServiceSid, pathConversationSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all participants of the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for participants. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathChatServiceSid, pathConversationSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this participant. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this participant. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Information about how this participant exchanges messages with the conversation. + /// + [JsonProperty("messaging_binding")] + public object MessagingBinding { get; private set; } + /// + /// The SID of a conversation-level Role to assign to the participant + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this participant. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Index of last “read” message in the Conversation for the Participant. + /// + [JsonProperty("last_read_message_index")] + public int? LastReadMessageIndex { get; private set; } + /// + /// Timestamp of last “read” message in the Conversation for the Participant. + /// + [JsonProperty("last_read_timestamp")] + public string LastReadTimestamp { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookOptions.cs index 34ad0f257..2541cfea6 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookOptions.cs @@ -10,318 +10,318 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - +{ + + /// + /// Create a new webhook scoped to the conversation in a specific service + /// + public class CreateWebhookOptions : IOptions + { /// - /// Create a new webhook scoped to the conversation in a specific service - /// - public class CreateWebhookOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// The target of this webhook. - /// - public WebhookResource.TargetEnum Target { get; } - /// - /// The absolute url the webhook request should be sent to. - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method to be used when sending a webhook request. - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The list of events, firing webhook event for this Conversation. - /// - public List ConfigurationFilters { get; set; } - /// - /// The list of keywords, firing webhook event for this Conversation. - /// - public List ConfigurationTriggers { get; set; } - /// - /// The studio flow SID, where the webhook should be sent to. - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The message index for which and it's successors the webhook will be replayed. - /// - public int? ConfigurationReplayAfter { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - public CreateWebhookOptions(string pathChatServiceSid, string pathConversationSid, WebhookResource.TargetEnum target) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - Target = target; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Target != null) - { - p.Add(new KeyValuePair("Target", Target.ToString())); - } - - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationReplayAfter != null) - { - p.Add(new KeyValuePair("Configuration.ReplayAfter", ConfigurationReplayAfter.ToString())); - } - - return p; - } - } - + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } /// - /// Update an existing conversation-scoped webhook - /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The absolute url the webhook request should be sent to. - /// - public string ConfigurationUrl { get; set; } - /// - /// The HTTP method to be used when sending a webhook request. - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The list of events, firing webhook event for this Conversation. - /// - public List ConfigurationFilters { get; set; } - /// - /// The list of keywords, firing webhook event for this Conversation. - /// - public List ConfigurationTriggers { get; set; } - /// - /// The studio flow SID, where the webhook should be sent to. - /// - public string ConfigurationFlowSid { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public UpdateWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - return p; - } - } - + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } /// - /// Remove an existing webhook scoped to the conversation - /// - public class DeleteWebhookOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public DeleteWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The target of this webhook. + /// + public WebhookResource.TargetEnum Target { get; } /// - /// Fetch the configuration of a conversation-scoped webhook - /// - public class FetchWebhookOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - public FetchWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The absolute url the webhook request should be sent to. + /// + public string ConfigurationUrl { get; set; } /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique ID of the Conversation for this webhook. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - public ReadWebhookOptions(string pathChatServiceSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The HTTP method to be used when sending a webhook request. + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The list of events, firing webhook event for this Conversation. + /// + public List ConfigurationFilters { get; set; } + /// + /// The list of keywords, firing webhook event for this Conversation. + /// + public List ConfigurationTriggers { get; set; } + /// + /// The studio flow SID, where the webhook should be sent to. + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The message index for which and it's successors the webhook will be replayed. + /// + public int? ConfigurationReplayAfter { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + public CreateWebhookOptions(string pathChatServiceSid, string pathConversationSid, WebhookResource.TargetEnum target) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + Target = target; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Target != null) + { + p.Add(new KeyValuePair("Target", Target.ToString())); + } + + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationReplayAfter != null) + { + p.Add(new KeyValuePair("Configuration.ReplayAfter", ConfigurationReplayAfter.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation-scoped webhook + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The absolute url the webhook request should be sent to. + /// + public string ConfigurationUrl { get; set; } + /// + /// The HTTP method to be used when sending a webhook request. + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The list of events, firing webhook event for this Conversation. + /// + public List ConfigurationFilters { get; set; } + /// + /// The list of keywords, firing webhook event for this Conversation. + /// + public List ConfigurationTriggers { get; set; } + /// + /// The studio flow SID, where the webhook should be sent to. + /// + public string ConfigurationFlowSid { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public UpdateWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + return p; + } + } + + /// + /// Remove an existing webhook scoped to the conversation + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public DeleteWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + public class FetchWebhookOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + public FetchWebhookOptions(string pathChatServiceSid, string pathConversationSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + public class ReadWebhookOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique ID of the Conversation for this webhook. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new ReadWebhookOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + public ReadWebhookOptions(string pathChatServiceSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookResource.cs b/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookResource.cs index 858b56034..dd51cb890 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/Conversation/WebhookResource.cs @@ -17,592 +17,592 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.Conversation -{ - - public class WebhookResource : Resource - { - public sealed class TargetEnum : StringEnum - { - private TargetEnum(string value) : base(value) {} - public TargetEnum() {} - public static implicit operator TargetEnum(string value) - { - return new TargetEnum(value); - } - - public static readonly TargetEnum Webhook = new TargetEnum("webhook"); - public static readonly TargetEnum Trigger = new TargetEnum("trigger"); - public static readonly TargetEnum Studio = new TargetEnum("studio"); - } - - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new webhook scoped to the conversation in a specific service - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new webhook scoped to the conversation in a specific service - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new webhook scoped to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// The message index for which and it's successors the webhook will be - /// replayed. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathChatServiceSid, - string pathConversationSid, - WebhookResource.TargetEnum target, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationReplayAfter = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathChatServiceSid, pathConversationSid, target){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new webhook scoped to the conversation in a specific service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// The target of this webhook. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// The message index for which and it's successors the webhook will be - /// replayed. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string pathConversationSid, - WebhookResource.TargetEnum target, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationReplayAfter = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathChatServiceSid, pathConversationSid, target){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing conversation-scoped webhook - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation-scoped webhook - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation-scoped webhook - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation-scoped webhook - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// The absolute url the webhook request should be sent to. - /// The HTTP method to be used when sending a webhook request. - /// The list of events, firing webhook event for this Conversation. - /// The list of keywords, firing webhook event for this Conversation. - /// The studio flow SID, where the webhook should be sent to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an existing webhook scoped to the conversation - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an existing webhook scoped to the conversation - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an existing webhook scoped to the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an existing webhook scoped to the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the configuration of a conversation-scoped webhook - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathConversationSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathChatServiceSid, - string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathChatServiceSid, pathConversationSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all webhooks scoped to the conversation - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique ID of the Conversation for this webhook. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string pathConversationSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathChatServiceSid, pathConversationSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this webhook. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// The target of this webhook. - /// - [JsonProperty("target")] - public string Target { get; private set; } - /// - /// An absolute URL for this webhook. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The configuration of this webhook. - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class TargetEnum : StringEnum + { + private TargetEnum(string value) : base(value) { } + public TargetEnum() { } + public static implicit operator TargetEnum(string value) + { + return new TargetEnum(value); + } + + public static readonly TargetEnum Webhook = new TargetEnum("webhook"); + public static readonly TargetEnum Trigger = new TargetEnum("trigger"); + public static readonly TargetEnum Studio = new TargetEnum("studio"); + } + + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new webhook scoped to the conversation in a specific service + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new webhook scoped to the conversation in a specific service + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new webhook scoped to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// The message index for which and it's successors the webhook will be + /// replayed. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathChatServiceSid, + string pathConversationSid, + WebhookResource.TargetEnum target, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationReplayAfter = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathChatServiceSid, pathConversationSid, target) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new webhook scoped to the conversation in a specific service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// The target of this webhook. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// The message index for which and it's successors the webhook will be + /// replayed. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string pathConversationSid, + WebhookResource.TargetEnum target, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationReplayAfter = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathChatServiceSid, pathConversationSid, target) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationReplayAfter = configurationReplayAfter }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing conversation-scoped webhook + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation-scoped webhook + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation-scoped webhook + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation-scoped webhook + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// The absolute url the webhook request should be sent to. + /// The HTTP method to be used when sending a webhook request. + /// The list of events, firing webhook event for this Conversation. + /// The list of keywords, firing webhook event for this Conversation. + /// The studio flow SID, where the webhook should be sent to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an existing webhook scoped to the conversation + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an existing webhook scoped to the conversation + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an existing webhook scoped to the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an existing webhook scoped to the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the configuration of a conversation-scoped webhook + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathConversationSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathChatServiceSid, pathConversationSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathChatServiceSid, + string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathChatServiceSid, pathConversationSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all webhooks scoped to the conversation + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique ID of the Conversation for this webhook. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string pathConversationSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathChatServiceSid, pathConversationSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this webhook. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// The target of this webhook. + /// + [JsonProperty("target")] + public string Target { get; private set; } + /// + /// An absolute URL for this webhook. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The configuration of this webhook. + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/ConversationOptions.cs index f7f95ac35..47e4462ae 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ConversationOptions.cs @@ -9,390 +9,390 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Create a new conversation in your service + /// + public class CreateConversationOptions : IOptions + { /// - /// Create a new conversation in your service - /// - public class CreateConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The human-readable name of this conversation. - /// - public string FriendlyName { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - public string MessagingServiceSid { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// Current state of this conversation. - /// - public ConversationResource.StateEnum State { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// - public string TimersInactive { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `closed` state. - /// - public string TimersClosed { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - public CreateConversationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (State != null) - { - p.Add(new KeyValuePair("State", State.ToString())); - } - - if (TimersInactive != null) - { - p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); - } - - if (TimersClosed != null) - { - p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } /// - /// Update an existing conversation in your service - /// - public class UpdateConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The human-readable name of this conversation. - /// - public string FriendlyName { get; set; } - /// - /// The date that this resource was created. - /// - public DateTime? DateCreated { get; set; } - /// - /// The date that this resource was last updated. - /// - public DateTime? DateUpdated { get; set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - public string Attributes { get; set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - public string MessagingServiceSid { get; set; } - /// - /// Current state of this conversation. - /// - public ConversationResource.StateEnum State { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// - public string TimersInactive { get; set; } - /// - /// ISO8601 duration when conversation will be switched to `closed` state. - /// - public string TimersClosed { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - public UpdateConversationOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (State != null) - { - p.Add(new KeyValuePair("State", State.ToString())); - } - - if (TimersInactive != null) - { - p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); - } - - if (TimersClosed != null) - { - p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The human-readable name of this conversation. + /// + public string FriendlyName { get; set; } /// - /// Remove a conversation from your service - /// - public class DeleteConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - public DeleteConversationOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } /// - /// Fetch a conversation from your service - /// - public class FetchConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - public FetchConversationOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } /// - /// Retrieve a list of conversations in your service + /// The unique ID of the Messaging Service this conversation belongs to. /// - public class ReadConversationOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new ReadConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - public ReadConversationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string MessagingServiceSid { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// Current state of this conversation. + /// + public ConversationResource.StateEnum State { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// + public string TimersInactive { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `closed` state. + /// + public string TimersClosed { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + public CreateConversationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (State != null) + { + p.Add(new KeyValuePair("State", State.ToString())); + } + + if (TimersInactive != null) + { + p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); + } + + if (TimersClosed != null) + { + p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation in your service + /// + public class UpdateConversationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The human-readable name of this conversation. + /// + public string FriendlyName { get; set; } + /// + /// The date that this resource was created. + /// + public DateTime? DateCreated { get; set; } + /// + /// The date that this resource was last updated. + /// + public DateTime? DateUpdated { get; set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + public string Attributes { get; set; } + /// + /// The unique ID of the Messaging Service this conversation belongs to. + /// + public string MessagingServiceSid { get; set; } + /// + /// Current state of this conversation. + /// + public ConversationResource.StateEnum State { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// + public string TimersInactive { get; set; } + /// + /// ISO8601 duration when conversation will be switched to `closed` state. + /// + public string TimersClosed { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + public UpdateConversationOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (State != null) + { + p.Add(new KeyValuePair("State", State.ToString())); + } + + if (TimersInactive != null) + { + p.Add(new KeyValuePair("Timers.Inactive", TimersInactive)); + } + + if (TimersClosed != null) + { + p.Add(new KeyValuePair("Timers.Closed", TimersClosed)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a conversation from your service + /// + public class DeleteConversationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ConversationResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + public DeleteConversationOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a conversation from your service + /// + public class FetchConversationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + public FetchConversationOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of conversations in your service + /// + public class ReadConversationOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + + /// + /// Construct a new ReadConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + public ReadConversationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ConversationResource.cs b/src/Twilio/Rest/Conversations/V1/Service/ConversationResource.cs index 741c3de13..000534a71 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ConversationResource.cs @@ -17,631 +17,631 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class ConversationResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildCreateRequest(CreateConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Create a new conversation in your service - /// - /// Create Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Create(CreateConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new conversation in your service - /// - /// Create Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task CreateAsync(CreateConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new conversation in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The human-readable name of this conversation. - /// An application-defined string that uniquely identifies the resource - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Create(string pathChatServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - string messagingServiceSid = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConversationOptions(pathChatServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, MessagingServiceSid = messagingServiceSid, DateCreated = dateCreated, DateUpdated = dateUpdated, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new conversation in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The human-readable name of this conversation. - /// An application-defined string that uniquely identifies the resource - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - string messagingServiceSid = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConversationOptions(pathChatServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, MessagingServiceSid = messagingServiceSid, DateCreated = dateCreated, DateUpdated = dateUpdated, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing conversation in your service - /// - /// Update Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Update(UpdateConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation in your service - /// - /// Update Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// The human-readable name of this conversation. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// An application-defined string that uniquely identifies the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Update(string pathChatServiceSid, - string pathSid, - string friendlyName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingServiceSid = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - string uniqueName = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConversationOptions(pathChatServiceSid, pathSid){FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// The human-readable name of this conversation. - /// The date that this resource was created. - /// The date that this resource was last updated. - /// An optional string metadata field you can use to store any data you wish. - /// The unique ID of the Messaging Service this conversation belongs to. - /// Current state of this conversation. - /// ISO8601 duration when conversation will be switched to `inactive` state. - /// ISO8601 duration when conversation will be switched to `closed` state. - /// An application-defined string that uniquely identifies the resource - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathSid, - string friendlyName = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - string messagingServiceSid = null, - ConversationResource.StateEnum state = null, - string timersInactive = null, - string timersClosed = null, - string uniqueName = null, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConversationOptions(pathChatServiceSid, pathSid){FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a conversation from your service - /// - /// Delete Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static bool Delete(DeleteConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a conversation from your service - /// - /// Delete Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task DeleteAsync(DeleteConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a conversation from your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Conversation - public static bool Delete(string pathChatServiceSid, - string pathSid, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteConversationOptions(pathChatServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a conversation from your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathSid, - ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteConversationOptions(pathChatServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a conversation from your service - /// - /// Fetch Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Fetch(FetchConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a conversation from your service - /// - /// Fetch Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task FetchAsync(FetchConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a conversation from your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ConversationResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchConversationOptions(pathChatServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a conversation from your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchConversationOptions(pathChatServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Conversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of conversations in your service - /// - /// Read Conversation parameters - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ResourceSet Read(ReadConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conversations in your service - /// - /// Read Conversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of conversations in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Conversation - public static ResourceSet Read(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConversationOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of conversations in your service - /// - /// The SID of the Conversation Service that the resource is associated with. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Conversation - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConversationOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a ConversationResource object - /// - /// Raw JSON string - /// ConversationResource object represented by the provided JSON - public static ConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Messaging Service this conversation belongs to. - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Current state of this conversation. - /// - [JsonProperty("state")] - [JsonConverter(typeof(StringEnumConverter))] - public ConversationResource.StateEnum State { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("timers")] - public object Timers { get; private set; } - /// - /// An absolute URL for this conversation. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the participants, messages and webhooks of this conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The bindings - /// - [JsonProperty("bindings")] - public object Bindings { get; private set; } - - private ConversationResource() - { - - } - } +{ + + public class ConversationResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildCreateRequest(CreateConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Create a new conversation in your service + /// + /// Create Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Create(CreateConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new conversation in your service + /// + /// Create Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task CreateAsync(CreateConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new conversation in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The human-readable name of this conversation. + /// An application-defined string that uniquely identifies the resource + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Create(string pathChatServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + string messagingServiceSid = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConversationOptions(pathChatServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, MessagingServiceSid = messagingServiceSid, DateCreated = dateCreated, DateUpdated = dateUpdated, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new conversation in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The human-readable name of this conversation. + /// An application-defined string that uniquely identifies the resource + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + string messagingServiceSid = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConversationOptions(pathChatServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, MessagingServiceSid = messagingServiceSid, DateCreated = dateCreated, DateUpdated = dateUpdated, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing conversation in your service + /// + /// Update Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Update(UpdateConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation in your service + /// + /// Update Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// The human-readable name of this conversation. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// An application-defined string that uniquely identifies the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Update(string pathChatServiceSid, + string pathSid, + string friendlyName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingServiceSid = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + string uniqueName = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConversationOptions(pathChatServiceSid, pathSid) { FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// The human-readable name of this conversation. + /// The date that this resource was created. + /// The date that this resource was last updated. + /// An optional string metadata field you can use to store any data you wish. + /// The unique ID of the Messaging Service this conversation belongs to. + /// Current state of this conversation. + /// ISO8601 duration when conversation will be switched to `inactive` state. + /// ISO8601 duration when conversation will be switched to `closed` state. + /// An application-defined string that uniquely identifies the resource + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathSid, + string friendlyName = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + string messagingServiceSid = null, + ConversationResource.StateEnum state = null, + string timersInactive = null, + string timersClosed = null, + string uniqueName = null, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConversationOptions(pathChatServiceSid, pathSid) { FriendlyName = friendlyName, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MessagingServiceSid = messagingServiceSid, State = state, TimersInactive = timersInactive, TimersClosed = timersClosed, UniqueName = uniqueName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a conversation from your service + /// + /// Delete Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static bool Delete(DeleteConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a conversation from your service + /// + /// Delete Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task DeleteAsync(DeleteConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a conversation from your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Conversation + public static bool Delete(string pathChatServiceSid, + string pathSid, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteConversationOptions(pathChatServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a conversation from your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathSid, + ConversationResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteConversationOptions(pathChatServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a conversation from your service + /// + /// Fetch Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Fetch(FetchConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a conversation from your service + /// + /// Fetch Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task FetchAsync(FetchConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a conversation from your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ConversationResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchConversationOptions(pathChatServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a conversation from your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchConversationOptions(pathChatServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Conversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of conversations in your service + /// + /// Read Conversation parameters + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ResourceSet Read(ReadConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conversations in your service + /// + /// Read Conversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of conversations in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Conversation + public static ResourceSet Read(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConversationOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of conversations in your service + /// + /// The SID of the Conversation Service that the resource is associated with. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Conversation + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConversationOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a ConversationResource object + /// + /// Raw JSON string + /// ConversationResource object represented by the provided JSON + public static ConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Messaging Service this conversation belongs to. + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Current state of this conversation. + /// + [JsonProperty("state")] + [JsonConverter(typeof(StringEnumConverter))] + public ConversationResource.StateEnum State { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("timers")] + public object Timers { get; private set; } + /// + /// An absolute URL for this conversation. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the participants, messages and webhooks of this conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The bindings + /// + [JsonProperty("bindings")] + public object Bindings { get; private set; } + + private ConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationOptions.cs index dfc05532b..12ff6bc7f 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationOptions.cs @@ -9,59 +9,59 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + public class ReadParticipantConversationOptions : ReadOptions + { /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. + /// The SID of the Conversation Service that the resource is associated with. /// - public class ReadParticipantConversationOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - public string Identity { get; set; } - /// - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - public string Address { get; set; } - - /// - /// Construct a new ReadParticipantConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - public ReadParticipantConversationOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (Address != null) - { - p.Add(new KeyValuePair("Address", Address)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathChatServiceSid { get; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + public string Identity { get; set; } + /// + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + public string Address { get; set; } + + /// + /// Construct a new ReadParticipantConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + public ReadParticipantConversationOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (Address != null) + { + p.Add(new KeyValuePair("Address", Address)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationResource.cs b/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationResource.cs index 34622c632..101d9702e 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/ParticipantConversationResource.cs @@ -17,278 +17,278 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class ParticipantConversationResource : Resource - { - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildReadRequest(ReadParticipantConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/ParticipantConversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// Read ParticipantConversation parameters - /// Client to make requests to Twilio - /// A single instance of ParticipantConversation - public static ResourceSet Read(ReadParticipantConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// Read ParticipantConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ParticipantConversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A unique string identifier for the conversation participant as Conversation User. - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ParticipantConversation - public static ResourceSet Read(string pathChatServiceSid, - string identity = null, - string address = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantConversationOptions(pathChatServiceSid){Identity = identity, Address = address, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter - /// should be specified. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// A unique string identifier for the conversation participant as Conversation User. - /// A unique string identifier for the conversation participant who's not a Conversation User. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ParticipantConversation - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string identity = null, - string address = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantConversationOptions(pathChatServiceSid){Identity = identity, Address = address, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantConversationResource object - /// - /// Raw JSON string - /// ParticipantConversationResource object represented by the provided JSON - public static ParticipantConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Participant. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The unique ID for the conversation participant as Conversation User. - /// - [JsonProperty("participant_user_sid")] - public string ParticipantUserSid { get; private set; } - /// - /// A unique string identifier for the conversation participant as Conversation User. - /// - [JsonProperty("participant_identity")] - public string ParticipantIdentity { get; private set; } - /// - /// Information about how this participant exchanges messages with the conversation. - /// - [JsonProperty("participant_messaging_binding")] - public object ParticipantMessagingBinding { get; private set; } - /// - /// The unique ID of the Conversation this Participant belongs to. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// An application-defined string that uniquely identifies the Conversation resource. - /// - [JsonProperty("conversation_unique_name")] - public string ConversationUniqueName { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("conversation_friendly_name")] - public string ConversationFriendlyName { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("conversation_attributes")] - public string ConversationAttributes { get; private set; } - /// - /// The date that this conversation was created. - /// - [JsonProperty("conversation_date_created")] - public DateTime? ConversationDateCreated { get; private set; } - /// - /// The date that this conversation was last updated. - /// - [JsonProperty("conversation_date_updated")] - public DateTime? ConversationDateUpdated { get; private set; } - /// - /// Creator of this conversation. - /// - [JsonProperty("conversation_created_by")] - public string ConversationCreatedBy { get; private set; } - /// - /// The current state of this User Conversation - /// - [JsonProperty("conversation_state")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantConversationResource.StateEnum ConversationState { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("conversation_timers")] - public object ConversationTimers { get; private set; } - /// - /// Absolute URLs to access the participant and conversation of this Participant Conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ParticipantConversationResource() - { - - } - } +{ + + public class ParticipantConversationResource : Resource + { + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildReadRequest(ReadParticipantConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/ParticipantConversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// Read ParticipantConversation parameters + /// Client to make requests to Twilio + /// A single instance of ParticipantConversation + public static ResourceSet Read(ReadParticipantConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// Read ParticipantConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ParticipantConversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A unique string identifier for the conversation participant as Conversation User. + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ParticipantConversation + public static ResourceSet Read(string pathChatServiceSid, + string identity = null, + string address = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantConversationOptions(pathChatServiceSid) { Identity = identity, Address = address, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Conversations that this Participant belongs to by identity or by address. Only one parameter + /// should be specified. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// A unique string identifier for the conversation participant as Conversation User. + /// A unique string identifier for the conversation participant who's not a Conversation User. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ParticipantConversation + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string identity = null, + string address = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantConversationOptions(pathChatServiceSid) { Identity = identity, Address = address, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantConversationResource object + /// + /// Raw JSON string + /// ParticipantConversationResource object represented by the provided JSON + public static ParticipantConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Participant. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The unique ID for the conversation participant as Conversation User. + /// + [JsonProperty("participant_user_sid")] + public string ParticipantUserSid { get; private set; } + /// + /// A unique string identifier for the conversation participant as Conversation User. + /// + [JsonProperty("participant_identity")] + public string ParticipantIdentity { get; private set; } + /// + /// Information about how this participant exchanges messages with the conversation. + /// + [JsonProperty("participant_messaging_binding")] + public object ParticipantMessagingBinding { get; private set; } + /// + /// The unique ID of the Conversation this Participant belongs to. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// An application-defined string that uniquely identifies the Conversation resource. + /// + [JsonProperty("conversation_unique_name")] + public string ConversationUniqueName { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("conversation_friendly_name")] + public string ConversationFriendlyName { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("conversation_attributes")] + public string ConversationAttributes { get; private set; } + /// + /// The date that this conversation was created. + /// + [JsonProperty("conversation_date_created")] + public DateTime? ConversationDateCreated { get; private set; } + /// + /// The date that this conversation was last updated. + /// + [JsonProperty("conversation_date_updated")] + public DateTime? ConversationDateUpdated { get; private set; } + /// + /// Creator of this conversation. + /// + [JsonProperty("conversation_created_by")] + public string ConversationCreatedBy { get; private set; } + /// + /// The current state of this User Conversation + /// + [JsonProperty("conversation_state")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantConversationResource.StateEnum ConversationState { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("conversation_timers")] + public object ConversationTimers { get; private set; } + /// + /// Absolute URLs to access the participant and conversation of this Participant Conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ParticipantConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/RoleOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/RoleOptions.cs index b75e8f8f7..cb1a013e8 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/RoleOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/RoleOptions.cs @@ -10,221 +10,221 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Create a new user role in your service + /// + public class CreateRoleOptions : IOptions + { /// - /// Create a new user role in your service - /// - public class CreateRoleOptions : IOptions - { - /// - /// The SID of the Conversation Service to create the resource under - /// - public string PathChatServiceSid { get; } - /// - /// A string to describe the new resource - /// - public string FriendlyName { get; } - /// - /// The type of role - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// The SID of the Conversation Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - public CreateRoleOptions(string pathChatServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission) - { - PathChatServiceSid = pathChatServiceSid; - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// The SID of the Conversation Service to create the resource under + /// + public string PathChatServiceSid { get; } /// - /// Update an existing user role in your service - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The SID of the Conversation Service to update the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the Role resource to update - /// - public string PathSid { get; } - /// - /// A permission the role should have - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The SID of the Conversation Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - public UpdateRoleOptions(string pathChatServiceSid, string pathSid, List permission) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// A string to describe the new resource + /// + public string FriendlyName { get; } /// - /// Remove a user role from your service - /// - public class DeleteRoleOptions : IOptions - { - /// - /// The SID of the Conversation Service to delete the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the Role resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the Role resource to delete - public DeleteRoleOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The type of role + /// + public RoleResource.RoleTypeEnum Type { get; } /// - /// Fetch a user role from your service - /// - public class FetchRoleOptions : IOptions - { - /// - /// The SID of the Conversation Service to fetch the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the Role resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the Role resource to fetch - public FetchRoleOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A permission the role should have + /// + public List Permission { get; } + /// - /// Retrieve a list of all user roles in your service + /// Construct a new CreateRoleOptions /// - public class ReadRoleOptions : ReadOptions - { - /// - /// The SID of the Conversation Service to read the resources from - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new ReadRoleOptions - /// - /// The SID of the Conversation Service to read the resources from - public ReadRoleOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Conversation Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + public CreateRoleOptions(string pathChatServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission) + { + PathChatServiceSid = pathChatServiceSid; + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// Update an existing user role in your service + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The SID of the Conversation Service to update the resource from + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the Role resource to update + /// + public string PathSid { get; } + /// + /// A permission the role should have + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The SID of the Conversation Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + public UpdateRoleOptions(string pathChatServiceSid, string pathSid, List permission) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// Remove a user role from your service + /// + public class DeleteRoleOptions : IOptions + { + /// + /// The SID of the Conversation Service to delete the resource from + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the Role resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the Role resource to delete + public DeleteRoleOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a user role from your service + /// + public class FetchRoleOptions : IOptions + { + /// + /// The SID of the Conversation Service to fetch the resource from + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the Role resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRoleOptions + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the Role resource to fetch + public FetchRoleOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all user roles in your service + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// The SID of the Conversation Service to read the resources from + /// + public string PathChatServiceSid { get; } + + /// + /// Construct a new ReadRoleOptions + /// + /// The SID of the Conversation Service to read the resources from + public ReadRoleOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/RoleResource.cs b/src/Twilio/Rest/Conversations/V1/Service/RoleResource.cs index 24e20dc0e..e90bd4816 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/RoleResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/RoleResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Conversation = new RoleTypeEnum("conversation"); - public static readonly RoleTypeEnum Service = new RoleTypeEnum("service"); - } - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new user role in your service - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new user role in your service - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new user role in your service - /// - /// The SID of the Conversation Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string pathChatServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathChatServiceSid, friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new user role in your service - /// - /// The SID of the Conversation Service to create the resource under - /// A string to describe the new resource - /// The type of role - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathChatServiceSid, friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing user role in your service - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing user role in your service - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing user role in your service - /// - /// The SID of the Conversation Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathChatServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathChatServiceSid, pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing user role in your service - /// - /// The SID of the Conversation Service to update the resource from - /// The SID of the Role resource to update - /// A permission the role should have - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathChatServiceSid, pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a user role from your service - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a user role from your service - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a user role from your service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathChatServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a user role from your service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the Role resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathChatServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a user role from your service - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a user role from your service - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a user role from your service - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathChatServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a user role from your service - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the Role resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathChatServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all user roles in your service - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all user roles in your service - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all user roles in your service - /// - /// The SID of the Conversation Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all user roles in your service - /// - /// The SID of the Conversation Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of role - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// An array of the permissions the role has been granted - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this user role. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Conversation = new RoleTypeEnum("conversation"); + public static readonly RoleTypeEnum Service = new RoleTypeEnum("service"); + } + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new user role in your service + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new user role in your service + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new user role in your service + /// + /// The SID of the Conversation Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string pathChatServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathChatServiceSid, friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new user role in your service + /// + /// The SID of the Conversation Service to create the resource under + /// A string to describe the new resource + /// The type of role + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathChatServiceSid, friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing user role in your service + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing user role in your service + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing user role in your service + /// + /// The SID of the Conversation Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathChatServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathChatServiceSid, pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing user role in your service + /// + /// The SID of the Conversation Service to update the resource from + /// The SID of the Role resource to update + /// A permission the role should have + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathChatServiceSid, pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a user role from your service + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a user role from your service + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a user role from your service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathChatServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a user role from your service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the Role resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathChatServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a user role from your service + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a user role from your service + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a user role from your service + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathChatServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a user role from your service + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the Role resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathChatServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all user roles in your service + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all user roles in your service + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all user roles in your service + /// + /// The SID of the Conversation Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all user roles in your service + /// + /// The SID of the Conversation Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of role + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// An array of the permissions the role has been granted + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this user role. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationOptions.cs index 0ce00a555..57e61f9f7 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationOptions.cs @@ -9,196 +9,196 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service.User -{ - +{ + + /// + /// Update a specific User Conversation. + /// + public class UpdateUserConversationOptions : IOptions + { /// - /// Update a specific User Conversation. - /// - public class UpdateUserConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - /// - /// The Notification Level of this User Conversation. - /// - public UserConversationResource.NotificationLevelEnum NotificationLevel { get; set; } - /// - /// The date of the last message read in conversation by the user. - /// - public DateTime? LastReadTimestamp { get; set; } - /// - /// The index of the last read Message. - /// - public int? LastReadMessageIndex { get; set; } - - /// - /// Construct a new UpdateUserConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public UpdateUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (NotificationLevel != null) - { - p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); - } - - if (LastReadTimestamp != null) - { - p.Add(new KeyValuePair("LastReadTimestamp", Serializers.DateTimeIso8601(LastReadTimestamp))); - } - - if (LastReadMessageIndex != null) - { - p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); - } - - return p; - } - } - + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } /// - /// Delete a specific User Conversation. - /// - public class DeleteUserConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new DeleteUserConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public DeleteUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } /// - /// Fetch a specific User Conversation. - /// - public class FetchUserConversationOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new FetchUserConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public FetchUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) - { - PathChatServiceSid = pathChatServiceSid; - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } /// - /// Retrieve a list of all User Conversations for the User. - /// - public class ReadUserConversationOptions : ReadOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with. - /// - public string PathChatServiceSid { get; } - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserConversationOptions - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - public ReadUserConversationOptions(string pathChatServiceSid, string pathUserSid) - { - PathChatServiceSid = pathChatServiceSid; - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The Notification Level of this User Conversation. + /// + public UserConversationResource.NotificationLevelEnum NotificationLevel { get; set; } + /// + /// The date of the last message read in conversation by the user. + /// + public DateTime? LastReadTimestamp { get; set; } + /// + /// The index of the last read Message. + /// + public int? LastReadMessageIndex { get; set; } + + /// + /// Construct a new UpdateUserConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public UpdateUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (NotificationLevel != null) + { + p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); + } + + if (LastReadTimestamp != null) + { + p.Add(new KeyValuePair("LastReadTimestamp", Serializers.DateTimeIso8601(LastReadTimestamp))); + } + + if (LastReadMessageIndex != null) + { + p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); + } + + return p; + } + } + + /// + /// Delete a specific User Conversation. + /// + public class DeleteUserConversationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + /// + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new DeleteUserConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public DeleteUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a specific User Conversation. + /// + public class FetchUserConversationOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + /// + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new FetchUserConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public FetchUserConversationOptions(string pathChatServiceSid, string pathUserSid, string pathConversationSid) + { + PathChatServiceSid = pathChatServiceSid; + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all User Conversations for the User. + /// + public class ReadUserConversationOptions : ReadOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with. + /// + public string PathChatServiceSid { get; } + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + + /// + /// Construct a new ReadUserConversationOptions + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + public ReadUserConversationOptions(string pathChatServiceSid, string pathUserSid) + { + PathChatServiceSid = pathChatServiceSid; + PathUserSid = pathUserSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationResource.cs b/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationResource.cs index 9b23f3cad..70735b6e6 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/User/UserConversationResource.cs @@ -17,531 +17,531 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service.User -{ - - public class UserConversationResource : Resource - { - public sealed class NotificationLevelEnum : StringEnum - { - private NotificationLevelEnum(string value) : base(value) {} - public NotificationLevelEnum() {} - public static implicit operator NotificationLevelEnum(string value) - { - return new NotificationLevelEnum(value); - } - - public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); - public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); - } - - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildUpdateRequest(UpdateUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific User Conversation. - /// - /// Update UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Update(UpdateUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific User Conversation. - /// - /// Update UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// The Notification Level of this User Conversation. - /// The date of the last message read in conversation by the user. - /// The index of the last read Message. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Update(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - UserConversationResource.NotificationLevelEnum notificationLevel = null, - DateTime? lastReadTimestamp = null, - int? lastReadMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid){NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// The Notification Level of this User Conversation. - /// The date of the last message read in conversation by the user. - /// The index of the last read Message. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - UserConversationResource.NotificationLevelEnum notificationLevel = null, - DateTime? lastReadTimestamp = null, - int? lastReadMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid){NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific User Conversation. - /// - /// Delete UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static bool Delete(DeleteUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific User Conversation. - /// - /// Delete UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static bool Delete(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific User Conversation. - /// - /// Fetch UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Fetch(FetchUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific User Conversation. - /// - /// Fetch UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task FetchAsync(FetchUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Fetch(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new FetchUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific User Conversation. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new FetchUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// Read UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static ResourceSet Read(ReadUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// Read UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static ResourceSet Read(string pathChatServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserConversationOptions(pathChatServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// The SID of the Conversation Service that the resource is associated with. - /// The unique SID identifier of the User. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserConversationOptions(pathChatServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a UserConversationResource object - /// - /// Raw JSON string - /// UserConversationResource object represented by the provided JSON - public static UserConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this User Conversation. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// The number of unread Messages in the Conversation. - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// The index of the last read Message . - /// - [JsonProperty("last_read_message_index")] - public int? LastReadMessageIndex { get; private set; } - /// - /// Participant Sid. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The unique ID for the User. - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The current state of this User Conversation - /// - [JsonProperty("conversation_state")] - [JsonConverter(typeof(StringEnumConverter))] - public UserConversationResource.StateEnum ConversationState { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("timers")] - public object Timers { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The date that this conversation was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this conversation was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Creator of this conversation. - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The Notification Level of this User Conversation. - /// - [JsonProperty("notification_level")] - [JsonConverter(typeof(StringEnumConverter))] - public UserConversationResource.NotificationLevelEnum NotificationLevel { get; private set; } - /// - /// An application-defined string that uniquely identifies the Conversation resource. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the participant and conversation of this user conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserConversationResource() - { - - } - } +{ + + public class UserConversationResource : Resource + { + public sealed class NotificationLevelEnum : StringEnum + { + private NotificationLevelEnum(string value) : base(value) { } + public NotificationLevelEnum() { } + public static implicit operator NotificationLevelEnum(string value) + { + return new NotificationLevelEnum(value); + } + + public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); + public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); + } + + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildUpdateRequest(UpdateUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific User Conversation. + /// + /// Update UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Update(UpdateUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific User Conversation. + /// + /// Update UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// The Notification Level of this User Conversation. + /// The date of the last message read in conversation by the user. + /// The index of the last read Message. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Update(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + UserConversationResource.NotificationLevelEnum notificationLevel = null, + DateTime? lastReadTimestamp = null, + int? lastReadMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid) { NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// The Notification Level of this User Conversation. + /// The date of the last message read in conversation by the user. + /// The index of the last read Message. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + UserConversationResource.NotificationLevelEnum notificationLevel = null, + DateTime? lastReadTimestamp = null, + int? lastReadMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid) { NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific User Conversation. + /// + /// Delete UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static bool Delete(DeleteUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific User Conversation. + /// + /// Delete UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static bool Delete(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific User Conversation. + /// + /// Fetch UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Fetch(FetchUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific User Conversation. + /// + /// Fetch UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task FetchAsync(FetchUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Fetch(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new FetchUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific User Conversation. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new FetchUserConversationOptions(pathChatServiceSid, pathUserSid, pathConversationSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathUserSid + "/Conversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// Read UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static ResourceSet Read(ReadUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// Read UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static ResourceSet Read(string pathChatServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserConversationOptions(pathChatServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// The SID of the Conversation Service that the resource is associated with. + /// The unique SID identifier of the User. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserConversationOptions(pathChatServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a UserConversationResource object + /// + /// Raw JSON string + /// UserConversationResource object represented by the provided JSON + public static UserConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this User Conversation. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// The number of unread Messages in the Conversation. + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// The index of the last read Message . + /// + [JsonProperty("last_read_message_index")] + public int? LastReadMessageIndex { get; private set; } + /// + /// Participant Sid. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The unique ID for the User. + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The current state of this User Conversation + /// + [JsonProperty("conversation_state")] + [JsonConverter(typeof(StringEnumConverter))] + public UserConversationResource.StateEnum ConversationState { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("timers")] + public object Timers { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The date that this conversation was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this conversation was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Creator of this conversation. + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The Notification Level of this User Conversation. + /// + [JsonProperty("notification_level")] + [JsonConverter(typeof(StringEnumConverter))] + public UserConversationResource.NotificationLevelEnum NotificationLevel { get; private set; } + /// + /// An application-defined string that uniquely identifies the Conversation resource. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the participant and conversation of this user conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/UserOptions.cs b/src/Twilio/Rest/Conversations/V1/Service/UserOptions.cs index 75dbc412d..c7034729e 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/UserOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/UserOptions.cs @@ -9,293 +9,293 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.Service -{ - +{ + + /// + /// Add a new conversation user to your service + /// + public class CreateUserOptions : IOptions + { /// - /// Add a new conversation user to your service + /// The SID of the Conversation Service that the resource is associated with /// - public class CreateUserOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with - /// - public string PathChatServiceSid { get; } - /// - /// The string that identifies the resource's User - /// - public string Identity { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The JSON Object string that stores application-specific data - /// - public string Attributes { get; set; } - /// - /// The SID of a service-level Role to assign to the user - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The SID of the Conversation Service that the resource is associated with - /// The string that identifies the resource's User - public CreateUserOptions(string pathChatServiceSid, string identity) - { - PathChatServiceSid = pathChatServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string PathChatServiceSid { get; } /// - /// Update an existing conversation user in your service + /// The string that identifies the resource's User /// - public class UpdateUserOptions : IOptions - { - /// - /// The SID of the Conversation Service that the resource is associated with - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the User resource to update - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The JSON Object string that stores application-specific data - /// - public string Attributes { get; set; } - /// - /// The SID of a service-level Role to assign to the user - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The SID of the Conversation Service that the resource is associated with - /// The SID of the User resource to update - public UpdateUserOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string Identity { get; } /// - /// Remove a conversation user from your service + /// The string that you assigned to describe the resource /// - public class DeleteUserOptions : IOptions - { - /// - /// The SID of the Conversation Service to delete the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the User resource to delete - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the User resource to delete - public DeleteUserOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; set; } /// - /// Fetch a conversation user from your service + /// The JSON Object string that stores application-specific data /// - public class FetchUserOptions : IOptions - { - /// - /// The SID of the Conversation Service to fetch the resource from - /// - public string PathChatServiceSid { get; } - /// - /// The SID of the User resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the User resource to fetch - public FetchUserOptions(string pathChatServiceSid, string pathSid) - { - PathChatServiceSid = pathChatServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Attributes { get; set; } /// - /// Retrieve a list of all conversation users in your service + /// The SID of a service-level Role to assign to the user /// - public class ReadUserOptions : ReadOptions - { - /// - /// The SID of the Conversation Service to read the User resources from - /// - public string PathChatServiceSid { get; } - - /// - /// Construct a new ReadUserOptions - /// - /// The SID of the Conversation Service to read the User resources from - public ReadUserOptions(string pathChatServiceSid) - { - PathChatServiceSid = pathChatServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string RoleSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The SID of the Conversation Service that the resource is associated with + /// The string that identifies the resource's User + public CreateUserOptions(string pathChatServiceSid, string identity) + { + PathChatServiceSid = pathChatServiceSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation user in your service + /// + public class UpdateUserOptions : IOptions + { + /// + /// The SID of the Conversation Service that the resource is associated with + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the User resource to update + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The JSON Object string that stores application-specific data + /// + public string Attributes { get; set; } + /// + /// The SID of a service-level Role to assign to the user + /// + public string RoleSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The SID of the Conversation Service that the resource is associated with + /// The SID of the User resource to update + public UpdateUserOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a conversation user from your service + /// + public class DeleteUserOptions : IOptions + { + /// + /// The SID of the Conversation Service to delete the resource from + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the User resource to delete + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the User resource to delete + public DeleteUserOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a conversation user from your service + /// + public class FetchUserOptions : IOptions + { + /// + /// The SID of the Conversation Service to fetch the resource from + /// + public string PathChatServiceSid { get; } + /// + /// The SID of the User resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchUserOptions + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the User resource to fetch + public FetchUserOptions(string pathChatServiceSid, string pathSid) + { + PathChatServiceSid = pathChatServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all conversation users in your service + /// + public class ReadUserOptions : ReadOptions + { + /// + /// The SID of the Conversation Service to read the User resources from + /// + public string PathChatServiceSid { get; } + + /// + /// Construct a new ReadUserOptions + /// + /// The SID of the Conversation Service to read the User resources from + public ReadUserOptions(string pathChatServiceSid) + { + PathChatServiceSid = pathChatServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/Service/UserResource.cs b/src/Twilio/Rest/Conversations/V1/Service/UserResource.cs index c410d9fec..69d985fc4 100644 --- a/src/Twilio/Rest/Conversations/V1/Service/UserResource.cs +++ b/src/Twilio/Rest/Conversations/V1/Service/UserResource.cs @@ -17,566 +17,566 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.Service -{ - - public class UserResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new conversation user to your service - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new conversation user to your service - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new conversation user to your service - /// - /// The SID of the Conversation Service that the resource is associated with - /// The string that identifies the resource's User - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string pathChatServiceSid, - string identity, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathChatServiceSid, identity){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new conversation user to your service - /// - /// The SID of the Conversation Service that the resource is associated with - /// The string that identifies the resource's User - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, - string identity, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathChatServiceSid, identity){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing conversation user in your service - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation user in your service - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation user in your service - /// - /// The SID of the Conversation Service that the resource is associated with - /// The SID of the User resource to update - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathChatServiceSid, - string pathSid, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathChatServiceSid, pathSid){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation user in your service - /// - /// The SID of the Conversation Service that the resource is associated with - /// The SID of the User resource to update - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, - string pathSid, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathChatServiceSid, pathSid){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a conversation user from your service - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a conversation user from your service - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a conversation user from your service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the User resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathChatServiceSid, - string pathSid, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathChatServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a conversation user from your service - /// - /// The SID of the Conversation Service to delete the resource from - /// The SID of the User resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, - string pathSid, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathChatServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a conversation user from your service - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a conversation user from your service - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a conversation user from your service - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathChatServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a conversation user from your service - /// - /// The SID of the Conversation Service to fetch the resource from - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathChatServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathChatServiceSid + "/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all conversation users in your service - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation users in your service - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all conversation users in your service - /// - /// The SID of the Conversation Service to read the User resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation users in your service - /// - /// The SID of the Conversation Service to read the User resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathChatServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The SID of a service-level Role assigned to the user - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The JSON Object string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Whether the User is actively connected to this Conversations Service and online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// Whether the User has a potentially valid Push Notification registration for this Conversations Service - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this user. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new conversation user to your service + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new conversation user to your service + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new conversation user to your service + /// + /// The SID of the Conversation Service that the resource is associated with + /// The string that identifies the resource's User + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string pathChatServiceSid, + string identity, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathChatServiceSid, identity) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new conversation user to your service + /// + /// The SID of the Conversation Service that the resource is associated with + /// The string that identifies the resource's User + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string pathChatServiceSid, + string identity, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathChatServiceSid, identity) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing conversation user in your service + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation user in your service + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation user in your service + /// + /// The SID of the Conversation Service that the resource is associated with + /// The SID of the User resource to update + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathChatServiceSid, + string pathSid, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathChatServiceSid, pathSid) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation user in your service + /// + /// The SID of the Conversation Service that the resource is associated with + /// The SID of the User resource to update + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathChatServiceSid, + string pathSid, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathChatServiceSid, pathSid) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a conversation user from your service + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a conversation user from your service + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a conversation user from your service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the User resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathChatServiceSid, + string pathSid, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathChatServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a conversation user from your service + /// + /// The SID of the Conversation Service to delete the resource from + /// The SID of the User resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathChatServiceSid, + string pathSid, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathChatServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a conversation user from your service + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a conversation user from your service + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a conversation user from your service + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathChatServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathChatServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a conversation user from your service + /// + /// The SID of the Conversation Service to fetch the resource from + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathChatServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathChatServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathChatServiceSid + "/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all conversation users in your service + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation users in your service + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all conversation users in your service + /// + /// The SID of the Conversation Service to read the User resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation users in your service + /// + /// The SID of the Conversation Service to read the User resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(string pathChatServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathChatServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The SID of a service-level Role assigned to the user + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The JSON Object string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Whether the User is actively connected to this Conversations Service and online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// Whether the User has a potentially valid Push Notification registration for this Conversations Service + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this user. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ServiceOptions.cs b/src/Twilio/Rest/Conversations/V1/ServiceOptions.cs index d38bb414a..e9c0ff9b6 100644 --- a/src/Twilio/Rest/Conversations/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/ServiceOptions.cs @@ -9,118 +9,118 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Create a new conversation service on your account + /// + public class CreateServiceOptions : IOptions + { /// - /// Create a new conversation service on your account + /// The human-readable name of this service. /// - public class CreateServiceOptions : IOptions - { - /// - /// The human-readable name of this service. - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateServiceOptions - /// - /// The human-readable name of this service. - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string FriendlyName { get; } + /// - /// Remove a conversation service with all its nested resources from your account + /// Construct a new CreateServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// A 34 character string that uniquely identifies this resource. - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The human-readable name of this service. + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + /// - /// Fetch a conversation service from your account + /// Generate the necessary parameters /// - public class FetchServiceOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// A 34 character string that uniquely identifies this resource. - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// Remove a conversation service with all its nested resources from your account + /// + public class DeleteServiceOptions : IOptions + { /// - /// Retrieve a list of all conversation services on your account + /// A 34 character string that uniquely identifies this resource. /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// A 34 character string that uniquely identifies this resource. + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a conversation service from your account + /// + public class FetchServiceOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchServiceOptions + /// + /// A 34 character string that uniquely identifies this resource. + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all conversation services on your account + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/ServiceResource.cs b/src/Twilio/Rest/Conversations/V1/ServiceResource.cs index 43e75d25a..194374dda 100644 --- a/src/Twilio/Rest/Conversations/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Conversations/V1/ServiceResource.cs @@ -16,397 +16,397 @@ using Twilio.Http; namespace Twilio.Rest.Conversations.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new conversation service on your account - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new conversation service on your account - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new conversation service on your account - /// - /// The human-readable name of this service. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new conversation service on your account - /// - /// The human-readable name of this service. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a conversation service with all its nested resources from your account - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a conversation service with all its nested resources from your account - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a conversation service with all its nested resources from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a conversation service with all its nested resources from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a conversation service from your account - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a conversation service from your account - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a conversation service from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a conversation service from your account - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all conversation services on your account - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation services on your account - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all conversation services on your account - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation services on your account - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this service. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The human-readable name of this service. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date that this resource was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this service. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the conversations, users, roles, bindings and configuration of this service. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new conversation service on your account + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new conversation service on your account + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new conversation service on your account + /// + /// The human-readable name of this service. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new conversation service on your account + /// + /// The human-readable name of this service. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a conversation service with all its nested resources from your account + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a conversation service with all its nested resources from your account + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a conversation service with all its nested resources from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a conversation service with all its nested resources from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a conversation service from your account + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a conversation service from your account + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a conversation service from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a conversation service from your account + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all conversation services on your account + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation services on your account + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all conversation services on your account + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation services on your account + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this service. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The human-readable name of this service. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date that this resource was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this service. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the conversations, users, roles, bindings and configuration of this service. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/User/UserConversationOptions.cs b/src/Twilio/Rest/Conversations/V1/User/UserConversationOptions.cs index 482a3374d..cbd517f8d 100644 --- a/src/Twilio/Rest/Conversations/V1/User/UserConversationOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/User/UserConversationOptions.cs @@ -9,172 +9,172 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1.User -{ - +{ + + /// + /// Update a specific User Conversation. + /// + public class UpdateUserConversationOptions : IOptions + { /// - /// Update a specific User Conversation. - /// - public class UpdateUserConversationOptions : IOptions - { - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - /// - /// The Notification Level of this User Conversation. - /// - public UserConversationResource.NotificationLevelEnum NotificationLevel { get; set; } - /// - /// The date of the last message read in conversation by the user. - /// - public DateTime? LastReadTimestamp { get; set; } - /// - /// The index of the last read Message. - /// - public int? LastReadMessageIndex { get; set; } - - /// - /// Construct a new UpdateUserConversationOptions - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public UpdateUserConversationOptions(string pathUserSid, string pathConversationSid) - { - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (NotificationLevel != null) - { - p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); - } - - if (LastReadTimestamp != null) - { - p.Add(new KeyValuePair("LastReadTimestamp", Serializers.DateTimeIso8601(LastReadTimestamp))); - } - - if (LastReadMessageIndex != null) - { - p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); - } - - return p; - } - } - + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } /// - /// Delete a specific User Conversation. - /// - public class DeleteUserConversationOptions : IOptions - { - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new DeleteUserConversationOptions - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public DeleteUserConversationOptions(string pathUserSid, string pathConversationSid) - { - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } /// - /// Fetch a specific User Conversation. - /// - public class FetchUserConversationOptions : IOptions - { - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - /// - /// The unique SID identifier of the Conversation. - /// - public string PathConversationSid { get; } - - /// - /// Construct a new FetchUserConversationOptions - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - public FetchUserConversationOptions(string pathUserSid, string pathConversationSid) - { - PathUserSid = pathUserSid; - PathConversationSid = pathConversationSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The Notification Level of this User Conversation. + /// + public UserConversationResource.NotificationLevelEnum NotificationLevel { get; set; } /// - /// Retrieve a list of all User Conversations for the User. + /// The date of the last message read in conversation by the user. /// - public class ReadUserConversationOptions : ReadOptions - { - /// - /// The unique SID identifier of the User. - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserConversationOptions - /// - /// The unique SID identifier of the User. - public ReadUserConversationOptions(string pathUserSid) - { - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public DateTime? LastReadTimestamp { get; set; } + /// + /// The index of the last read Message. + /// + public int? LastReadMessageIndex { get; set; } + + /// + /// Construct a new UpdateUserConversationOptions + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public UpdateUserConversationOptions(string pathUserSid, string pathConversationSid) + { + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (NotificationLevel != null) + { + p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); + } + + if (LastReadTimestamp != null) + { + p.Add(new KeyValuePair("LastReadTimestamp", Serializers.DateTimeIso8601(LastReadTimestamp))); + } + + if (LastReadMessageIndex != null) + { + p.Add(new KeyValuePair("LastReadMessageIndex", LastReadMessageIndex.ToString())); + } + + return p; + } + } + + /// + /// Delete a specific User Conversation. + /// + public class DeleteUserConversationOptions : IOptions + { + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + /// + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new DeleteUserConversationOptions + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public DeleteUserConversationOptions(string pathUserSid, string pathConversationSid) + { + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Fetch a specific User Conversation. + /// + public class FetchUserConversationOptions : IOptions + { + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + /// + /// The unique SID identifier of the Conversation. + /// + public string PathConversationSid { get; } + + /// + /// Construct a new FetchUserConversationOptions + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + public FetchUserConversationOptions(string pathUserSid, string pathConversationSid) + { + PathUserSid = pathUserSid; + PathConversationSid = pathConversationSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all User Conversations for the User. + /// + public class ReadUserConversationOptions : ReadOptions + { + /// + /// The unique SID identifier of the User. + /// + public string PathUserSid { get; } + + /// + /// Construct a new ReadUserConversationOptions + /// + /// The unique SID identifier of the User. + public ReadUserConversationOptions(string pathUserSid) + { + PathUserSid = pathUserSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/User/UserConversationResource.cs b/src/Twilio/Rest/Conversations/V1/User/UserConversationResource.cs index ca5004786..38cb63d30 100644 --- a/src/Twilio/Rest/Conversations/V1/User/UserConversationResource.cs +++ b/src/Twilio/Rest/Conversations/V1/User/UserConversationResource.cs @@ -17,513 +17,513 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1.User -{ - - public class UserConversationResource : Resource - { - public sealed class NotificationLevelEnum : StringEnum - { - private NotificationLevelEnum(string value) : base(value) {} - public NotificationLevelEnum() {} - public static implicit operator NotificationLevelEnum(string value) - { - return new NotificationLevelEnum(value); - } - - public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); - public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); - } - - public sealed class StateEnum : StringEnum - { - private StateEnum(string value) : base(value) {} - public StateEnum() {} - public static implicit operator StateEnum(string value) - { - return new StateEnum(value); - } - - public static readonly StateEnum Inactive = new StateEnum("inactive"); - public static readonly StateEnum Active = new StateEnum("active"); - public static readonly StateEnum Closed = new StateEnum("closed"); - } - - private static Request BuildUpdateRequest(UpdateUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific User Conversation. - /// - /// Update UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Update(UpdateUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific User Conversation. - /// - /// Update UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// The Notification Level of this User Conversation. - /// The date of the last message read in conversation by the user. - /// The index of the last read Message. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Update(string pathUserSid, - string pathConversationSid, - UserConversationResource.NotificationLevelEnum notificationLevel = null, - DateTime? lastReadTimestamp = null, - int? lastReadMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserConversationOptions(pathUserSid, pathConversationSid){NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// The Notification Level of this User Conversation. - /// The date of the last message read in conversation by the user. - /// The index of the last read Message. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task UpdateAsync(string pathUserSid, - string pathConversationSid, - UserConversationResource.NotificationLevelEnum notificationLevel = null, - DateTime? lastReadTimestamp = null, - int? lastReadMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserConversationOptions(pathUserSid, pathConversationSid){NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific User Conversation. - /// - /// Delete UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static bool Delete(DeleteUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific User Conversation. - /// - /// Delete UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static bool Delete(string pathUserSid, string pathConversationSid, ITwilioRestClient client = null) - { - var options = new DeleteUserConversationOptions(pathUserSid, pathConversationSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task DeleteAsync(string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserConversationOptions(pathUserSid, pathConversationSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific User Conversation. - /// - /// Fetch UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Fetch(FetchUserConversationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific User Conversation. - /// - /// Fetch UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task FetchAsync(FetchUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static UserConversationResource Fetch(string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new FetchUserConversationOptions(pathUserSid, pathConversationSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific User Conversation. - /// - /// The unique SID identifier of the User. - /// The unique SID identifier of the Conversation. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task FetchAsync(string pathUserSid, - string pathConversationSid, - ITwilioRestClient client = null) - { - var options = new FetchUserConversationOptions(pathUserSid, pathConversationSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserConversationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathUserSid + "/Conversations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// Read UserConversation parameters - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static ResourceSet Read(ReadUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// Read UserConversation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserConversationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("conversations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// The unique SID identifier of the User. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserConversation - public static ResourceSet Read(string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserConversationOptions(pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all User Conversations for the User. - /// - /// The unique SID identifier of the User. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserConversation - public static async System.Threading.Tasks.Task> ReadAsync(string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserConversationOptions(pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("conversations", response.Content); - } - - /// - /// Converts a JSON string into a UserConversationResource object - /// - /// Raw JSON string - /// UserConversationResource object represented by the provided JSON - public static UserConversationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account responsible for this conversation. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Conversation Service this conversation belongs to. - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The unique ID of the Conversation for this User Conversation. - /// - [JsonProperty("conversation_sid")] - public string ConversationSid { get; private set; } - /// - /// The number of unread Messages in the Conversation. - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// The index of the last read Message . - /// - [JsonProperty("last_read_message_index")] - public int? LastReadMessageIndex { get; private set; } - /// - /// Participant Sid. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The unique ID for the User. - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The human-readable name of this conversation. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The current state of this User Conversation - /// - [JsonProperty("conversation_state")] - [JsonConverter(typeof(StringEnumConverter))] - public UserConversationResource.StateEnum ConversationState { get; private set; } - /// - /// Timer date values for this conversation. - /// - [JsonProperty("timers")] - public object Timers { get; private set; } - /// - /// An optional string metadata field you can use to store any data you wish. - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The date that this conversation was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this conversation was last updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Creator of this conversation. - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The Notification Level of this User Conversation. - /// - [JsonProperty("notification_level")] - [JsonConverter(typeof(StringEnumConverter))] - public UserConversationResource.NotificationLevelEnum NotificationLevel { get; private set; } - /// - /// An application-defined string that uniquely identifies the Conversation resource. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Absolute URLs to access the participant and conversation of this user conversation. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserConversationResource() - { - - } - } +{ + + public class UserConversationResource : Resource + { + public sealed class NotificationLevelEnum : StringEnum + { + private NotificationLevelEnum(string value) : base(value) { } + public NotificationLevelEnum() { } + public static implicit operator NotificationLevelEnum(string value) + { + return new NotificationLevelEnum(value); + } + + public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); + public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); + } + + public sealed class StateEnum : StringEnum + { + private StateEnum(string value) : base(value) { } + public StateEnum() { } + public static implicit operator StateEnum(string value) + { + return new StateEnum(value); + } + + public static readonly StateEnum Inactive = new StateEnum("inactive"); + public static readonly StateEnum Active = new StateEnum("active"); + public static readonly StateEnum Closed = new StateEnum("closed"); + } + + private static Request BuildUpdateRequest(UpdateUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific User Conversation. + /// + /// Update UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Update(UpdateUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific User Conversation. + /// + /// Update UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// The Notification Level of this User Conversation. + /// The date of the last message read in conversation by the user. + /// The index of the last read Message. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Update(string pathUserSid, + string pathConversationSid, + UserConversationResource.NotificationLevelEnum notificationLevel = null, + DateTime? lastReadTimestamp = null, + int? lastReadMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserConversationOptions(pathUserSid, pathConversationSid) { NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// The Notification Level of this User Conversation. + /// The date of the last message read in conversation by the user. + /// The index of the last read Message. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task UpdateAsync(string pathUserSid, + string pathConversationSid, + UserConversationResource.NotificationLevelEnum notificationLevel = null, + DateTime? lastReadTimestamp = null, + int? lastReadMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserConversationOptions(pathUserSid, pathConversationSid) { NotificationLevel = notificationLevel, LastReadTimestamp = lastReadTimestamp, LastReadMessageIndex = lastReadMessageIndex }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific User Conversation. + /// + /// Delete UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static bool Delete(DeleteUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific User Conversation. + /// + /// Delete UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static bool Delete(string pathUserSid, string pathConversationSid, ITwilioRestClient client = null) + { + var options = new DeleteUserConversationOptions(pathUserSid, pathConversationSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task DeleteAsync(string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserConversationOptions(pathUserSid, pathConversationSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathUserSid + "/Conversations/" + options.PathConversationSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific User Conversation. + /// + /// Fetch UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Fetch(FetchUserConversationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific User Conversation. + /// + /// Fetch UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task FetchAsync(FetchUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static UserConversationResource Fetch(string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new FetchUserConversationOptions(pathUserSid, pathConversationSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific User Conversation. + /// + /// The unique SID identifier of the User. + /// The unique SID identifier of the Conversation. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task FetchAsync(string pathUserSid, + string pathConversationSid, + ITwilioRestClient client = null) + { + var options = new FetchUserConversationOptions(pathUserSid, pathConversationSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserConversationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathUserSid + "/Conversations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// Read UserConversation parameters + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static ResourceSet Read(ReadUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// Read UserConversation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserConversationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("conversations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// The unique SID identifier of the User. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserConversation + public static ResourceSet Read(string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserConversationOptions(pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all User Conversations for the User. + /// + /// The unique SID identifier of the User. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserConversation + public static async System.Threading.Tasks.Task> ReadAsync(string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserConversationOptions(pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("conversations", response.Content); + } + + /// + /// Converts a JSON string into a UserConversationResource object + /// + /// Raw JSON string + /// UserConversationResource object represented by the provided JSON + public static UserConversationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account responsible for this conversation. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Conversation Service this conversation belongs to. + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The unique ID of the Conversation for this User Conversation. + /// + [JsonProperty("conversation_sid")] + public string ConversationSid { get; private set; } + /// + /// The number of unread Messages in the Conversation. + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// The index of the last read Message . + /// + [JsonProperty("last_read_message_index")] + public int? LastReadMessageIndex { get; private set; } + /// + /// Participant Sid. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The unique ID for the User. + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The human-readable name of this conversation. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The current state of this User Conversation + /// + [JsonProperty("conversation_state")] + [JsonConverter(typeof(StringEnumConverter))] + public UserConversationResource.StateEnum ConversationState { get; private set; } + /// + /// Timer date values for this conversation. + /// + [JsonProperty("timers")] + public object Timers { get; private set; } + /// + /// An optional string metadata field you can use to store any data you wish. + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The date that this conversation was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this conversation was last updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Creator of this conversation. + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The Notification Level of this User Conversation. + /// + [JsonProperty("notification_level")] + [JsonConverter(typeof(StringEnumConverter))] + public UserConversationResource.NotificationLevelEnum NotificationLevel { get; private set; } + /// + /// An application-defined string that uniquely identifies the Conversation resource. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Absolute URLs to access the participant and conversation of this user conversation. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserConversationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/UserOptions.cs b/src/Twilio/Rest/Conversations/V1/UserOptions.cs index a09ce6734..bfd8dd962 100644 --- a/src/Twilio/Rest/Conversations/V1/UserOptions.cs +++ b/src/Twilio/Rest/Conversations/V1/UserOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.Conversations.V1 -{ - +{ + + /// + /// Add a new conversation user to your account's default service + /// + public class CreateUserOptions : IOptions + { /// - /// Add a new conversation user to your account's default service + /// The string that identifies the resource's User /// - public class CreateUserOptions : IOptions - { - /// - /// The string that identifies the resource's User - /// - public string Identity { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The JSON Object string that stores application-specific data - /// - public string Attributes { get; set; } - /// - /// The SID of a service-level Role to assign to the user - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The string that identifies the resource's User - public CreateUserOptions(string identity) - { - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string Identity { get; } /// - /// Update an existing conversation user in your account's default service + /// The string that you assigned to describe the resource /// - public class UpdateUserOptions : IOptions - { - /// - /// The SID of the User resource to update - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The JSON Object string that stores application-specific data - /// - public string Attributes { get; set; } - /// - /// The SID of a service-level Role to assign to the user - /// - public string RoleSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The SID of the User resource to update - public UpdateUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; set; } /// - /// Remove a conversation user from your account's default service + /// The JSON Object string that stores application-specific data /// - public class DeleteUserOptions : IOptions - { - /// - /// The SID of the User resource to delete - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The SID of the User resource to delete - public DeleteUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + public string Attributes { get; set; } /// - /// Fetch a conversation user from your account's default service + /// The SID of a service-level Role to assign to the user /// - public class FetchUserOptions : IOptions - { - /// - /// The SID of the User resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The SID of the User resource to fetch - public FetchUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string RoleSid { get; set; } /// - /// Retrieve a list of all conversation users in your account's default service + /// The X-Twilio-Webhook-Enabled HTTP request header /// - public class ReadUserOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The string that identifies the resource's User + public CreateUserOptions(string identity) + { + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Update an existing conversation user in your account's default service + /// + public class UpdateUserOptions : IOptions + { + /// + /// The SID of the User resource to update + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The JSON Object string that stores application-specific data + /// + public string Attributes { get; set; } + /// + /// The SID of a service-level Role to assign to the user + /// + public string RoleSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The SID of the User resource to update + public UpdateUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Remove a conversation user from your account's default service + /// + public class DeleteUserOptions : IOptions + { + /// + /// The SID of the User resource to delete + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The SID of the User resource to delete + public DeleteUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// Fetch a conversation user from your account's default service + /// + public class FetchUserOptions : IOptions + { + /// + /// The SID of the User resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchUserOptions + /// + /// The SID of the User resource to fetch + public FetchUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all conversation users in your account's default service + /// + public class ReadUserOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Conversations/V1/UserResource.cs b/src/Twilio/Rest/Conversations/V1/UserResource.cs index 3ce629796..f251be459 100644 --- a/src/Twilio/Rest/Conversations/V1/UserResource.cs +++ b/src/Twilio/Rest/Conversations/V1/UserResource.cs @@ -17,547 +17,547 @@ using Twilio.Types; namespace Twilio.Rest.Conversations.V1 -{ - - public class UserResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Users", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Add a new conversation user to your account's default service - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new conversation user to your account's default service - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new conversation user to your account's default service - /// - /// The string that identifies the resource's User - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string identity, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(identity){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new conversation user to your account's default service - /// - /// The string that identifies the resource's User - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string identity, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(identity){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Update an existing conversation user in your account's default service - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing conversation user in your account's default service - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing conversation user in your account's default service - /// - /// The SID of the User resource to update - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathSid, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing conversation user in your account's default service - /// - /// The SID of the User resource to update - /// The string that you assigned to describe the resource - /// The JSON Object string that stores application-specific data - /// The SID of a service-level Role to assign to the user - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string attributes = null, - string roleSid = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Remove a conversation user from your account's default service - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a conversation user from your account's default service - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a conversation user from your account's default service - /// - /// The SID of the User resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathSid, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a conversation user from your account's default service - /// - /// The SID of the User resource to delete - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a conversation user from your account's default service - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a conversation user from your account's default service - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a conversation user from your account's default service - /// - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a conversation user from your account's default service - /// - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Conversations, - "/v1/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all conversation users in your account's default service - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation users in your account's default service - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all conversation users in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all conversation users in your account's default service - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Conversations) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Conversation Service that the resource is associated with - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The SID of a service-level Role assigned to the user - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The JSON Object string that stores application-specific data - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Whether the User is actively connected to this Conversations Service and online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// Whether the User has a potentially valid Push Notification registration for this Conversations Service - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An absolute URL for this user. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Users", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Add a new conversation user to your account's default service + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new conversation user to your account's default service + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new conversation user to your account's default service + /// + /// The string that identifies the resource's User + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string identity, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(identity) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new conversation user to your account's default service + /// + /// The string that identifies the resource's User + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string identity, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(identity) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Update an existing conversation user in your account's default service + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing conversation user in your account's default service + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing conversation user in your account's default service + /// + /// The SID of the User resource to update + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathSid, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing conversation user in your account's default service + /// + /// The SID of the User resource to update + /// The string that you assigned to describe the resource + /// The JSON Object string that stores application-specific data + /// The SID of a service-level Role to assign to the user + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string attributes = null, + string roleSid = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes, RoleSid = roleSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Remove a conversation user from your account's default service + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a conversation user from your account's default service + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a conversation user from your account's default service + /// + /// The SID of the User resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathSid, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a conversation user from your account's default service + /// + /// The SID of the User resource to delete + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a conversation user from your account's default service + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a conversation user from your account's default service + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a conversation user from your account's default service + /// + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a conversation user from your account's default service + /// + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Conversations, + "/v1/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all conversation users in your account's default service + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation users in your account's default service + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all conversation users in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all conversation users in your account's default service + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Conversations) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Conversation Service that the resource is associated with + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The SID of a service-level Role assigned to the user + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The JSON Object string that stores application-specific data + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Whether the User is actively connected to this Conversations Service and online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// Whether the User has a potentially valid Push Notification registration for this Conversations Service + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An absolute URL for this user. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Domain.cs b/src/Twilio/Rest/Domain.cs index 19a5eb7de..d1172110b 100644 --- a/src/Twilio/Rest/Domain.cs +++ b/src/Twilio/Rest/Domain.cs @@ -6,49 +6,49 @@ using Twilio.Types; namespace Twilio.Rest -{ - - public sealed class Domain : StringEnum - { - private Domain(string value) : base(value) {} - public Domain() {} - public static implicit operator Domain(string value) - { - return new Domain(value); - } - - public static readonly Domain Accounts = new Domain("accounts"); - public static readonly Domain Api = new Domain("api"); - public static readonly Domain Autopilot = new Domain("autopilot"); - public static readonly Domain Chat = new Domain("chat"); - public static readonly Domain Conversations = new Domain("conversations"); - public static readonly Domain Events = new Domain("events"); - public static readonly Domain Fax = new Domain("fax"); - public static readonly Domain FlexApi = new Domain("flex-api"); - public static readonly Domain FrontlineApi = new Domain("frontline-api"); - public static readonly Domain Insights = new Domain("insights"); - public static readonly Domain IpMessaging = new Domain("ip-messaging"); - public static readonly Domain Lookups = new Domain("lookups"); - public static readonly Domain Media = new Domain("media"); - public static readonly Domain Messaging = new Domain("messaging"); - public static readonly Domain Monitor = new Domain("monitor"); - public static readonly Domain Notify = new Domain("notify"); - public static readonly Domain Numbers = new Domain("numbers"); - public static readonly Domain Preview = new Domain("preview"); - public static readonly Domain Pricing = new Domain("pricing"); - public static readonly Domain Proxy = new Domain("proxy"); - public static readonly Domain Serverless = new Domain("serverless"); - public static readonly Domain Studio = new Domain("studio"); - public static readonly Domain Sync = new Domain("sync"); - public static readonly Domain Taskrouter = new Domain("taskrouter"); - public static readonly Domain Trunking = new Domain("trunking"); - public static readonly Domain Trusthub = new Domain("trusthub"); - public static readonly Domain Verify = new Domain("verify"); - public static readonly Domain Video = new Domain("video"); - public static readonly Domain Voice = new Domain("voice"); - public static readonly Domain Wireless = new Domain("wireless"); - public static readonly Domain Supersim = new Domain("supersim"); - public static readonly Domain Bulkexports = new Domain("bulkexports"); - } +{ + + public sealed class Domain : StringEnum + { + private Domain(string value) : base(value) { } + public Domain() { } + public static implicit operator Domain(string value) + { + return new Domain(value); + } + + public static readonly Domain Accounts = new Domain("accounts"); + public static readonly Domain Api = new Domain("api"); + public static readonly Domain Autopilot = new Domain("autopilot"); + public static readonly Domain Chat = new Domain("chat"); + public static readonly Domain Conversations = new Domain("conversations"); + public static readonly Domain Events = new Domain("events"); + public static readonly Domain Fax = new Domain("fax"); + public static readonly Domain FlexApi = new Domain("flex-api"); + public static readonly Domain FrontlineApi = new Domain("frontline-api"); + public static readonly Domain Insights = new Domain("insights"); + public static readonly Domain IpMessaging = new Domain("ip-messaging"); + public static readonly Domain Lookups = new Domain("lookups"); + public static readonly Domain Media = new Domain("media"); + public static readonly Domain Messaging = new Domain("messaging"); + public static readonly Domain Monitor = new Domain("monitor"); + public static readonly Domain Notify = new Domain("notify"); + public static readonly Domain Numbers = new Domain("numbers"); + public static readonly Domain Preview = new Domain("preview"); + public static readonly Domain Pricing = new Domain("pricing"); + public static readonly Domain Proxy = new Domain("proxy"); + public static readonly Domain Serverless = new Domain("serverless"); + public static readonly Domain Studio = new Domain("studio"); + public static readonly Domain Sync = new Domain("sync"); + public static readonly Domain Taskrouter = new Domain("taskrouter"); + public static readonly Domain Trunking = new Domain("trunking"); + public static readonly Domain Trusthub = new Domain("trusthub"); + public static readonly Domain Verify = new Domain("verify"); + public static readonly Domain Video = new Domain("video"); + public static readonly Domain Voice = new Domain("voice"); + public static readonly Domain Wireless = new Domain("wireless"); + public static readonly Domain Supersim = new Domain("supersim"); + public static readonly Domain Bulkexports = new Domain("bulkexports"); + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/EventTypeOptions.cs b/src/Twilio/Rest/Events/V1/EventTypeOptions.cs index 941bc6475..4e512f626 100644 --- a/src/Twilio/Rest/Events/V1/EventTypeOptions.cs +++ b/src/Twilio/Rest/Events/V1/EventTypeOptions.cs @@ -9,69 +9,69 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a paginated list of all the available Event Types. + /// + public class ReadEventTypeOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a paginated list of all the available Event Types. + /// A string to filter Event Types by schema. /// - public class ReadEventTypeOptions : ReadOptions - { - /// - /// A string to filter Event Types by schema. - /// - public string SchemaId { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (SchemaId != null) - { - p.Add(new KeyValuePair("SchemaId", SchemaId)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string SchemaId { get; set; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Event Type. + /// Generate the necessary parameters /// - public class FetchEventTypeOptions : IOptions - { - /// - /// A string that uniquely identifies this Event Type. - /// - public string PathType { get; } - - /// - /// Construct a new FetchEventTypeOptions - /// - /// A string that uniquely identifies this Event Type. - public FetchEventTypeOptions(string pathType) - { - PathType = pathType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public override List> GetParams() + { + var p = new List>(); + if (SchemaId != null) + { + p.Add(new KeyValuePair("SchemaId", SchemaId)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Event Type. + /// + public class FetchEventTypeOptions : IOptions + { + /// + /// A string that uniquely identifies this Event Type. + /// + public string PathType { get; } + + /// + /// Construct a new FetchEventTypeOptions + /// + /// A string that uniquely identifies this Event Type. + public FetchEventTypeOptions(string pathType) + { + PathType = pathType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/EventTypeResource.cs b/src/Twilio/Rest/Events/V1/EventTypeResource.cs index c98c8efc3..87b1370fa 100644 --- a/src/Twilio/Rest/Events/V1/EventTypeResource.cs +++ b/src/Twilio/Rest/Events/V1/EventTypeResource.cs @@ -18,268 +18,268 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1 -{ - - public class EventTypeResource : Resource - { - private static Request BuildReadRequest(ReadEventTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Types", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a paginated list of all the available Event Types. - /// - /// Read EventType parameters - /// Client to make requests to Twilio - /// A single instance of EventType - public static ResourceSet Read(ReadEventTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of all the available Event Types. - /// - /// Read EventType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EventType - public static async System.Threading.Tasks.Task> ReadAsync(ReadEventTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a paginated list of all the available Event Types. - /// - /// A string to filter Event Types by schema. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of EventType - public static ResourceSet Read(string schemaId = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventTypeOptions(){SchemaId = schemaId, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of all the available Event Types. - /// - /// A string to filter Event Types by schema. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EventType - public static async System.Threading.Tasks.Task> ReadAsync(string schemaId = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventTypeOptions(){SchemaId = schemaId, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - private static Request BuildFetchRequest(FetchEventTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Types/" + options.PathType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Event Type. - /// - /// Fetch EventType parameters - /// Client to make requests to Twilio - /// A single instance of EventType - public static EventTypeResource Fetch(FetchEventTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Event Type. - /// - /// Fetch EventType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EventType - public static async System.Threading.Tasks.Task FetchAsync(FetchEventTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Event Type. - /// - /// A string that uniquely identifies this Event Type. - /// Client to make requests to Twilio - /// A single instance of EventType - public static EventTypeResource Fetch(string pathType, ITwilioRestClient client = null) - { - var options = new FetchEventTypeOptions(pathType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Event Type. - /// - /// A string that uniquely identifies this Event Type. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EventType - public static async System.Threading.Tasks.Task FetchAsync(string pathType, - ITwilioRestClient client = null) - { - var options = new FetchEventTypeOptions(pathType); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EventTypeResource object - /// - /// Raw JSON string - /// EventTypeResource object represented by the provided JSON - public static EventTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The Event Type identifier. - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The Schema identifier for this Event Type. - /// - [JsonProperty("schema_id")] - public string SchemaId { get; private set; } - /// - /// The date this Event Type was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Event Type was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Event Type description. - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private EventTypeResource() - { - - } - } +{ + + public class EventTypeResource : Resource + { + private static Request BuildReadRequest(ReadEventTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Types", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a paginated list of all the available Event Types. + /// + /// Read EventType parameters + /// Client to make requests to Twilio + /// A single instance of EventType + public static ResourceSet Read(ReadEventTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of all the available Event Types. + /// + /// Read EventType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EventType + public static async System.Threading.Tasks.Task> ReadAsync(ReadEventTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a paginated list of all the available Event Types. + /// + /// A string to filter Event Types by schema. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of EventType + public static ResourceSet Read(string schemaId = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventTypeOptions() { SchemaId = schemaId, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of all the available Event Types. + /// + /// A string to filter Event Types by schema. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EventType + public static async System.Threading.Tasks.Task> ReadAsync(string schemaId = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventTypeOptions() { SchemaId = schemaId, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + private static Request BuildFetchRequest(FetchEventTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Types/" + options.PathType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Event Type. + /// + /// Fetch EventType parameters + /// Client to make requests to Twilio + /// A single instance of EventType + public static EventTypeResource Fetch(FetchEventTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Event Type. + /// + /// Fetch EventType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EventType + public static async System.Threading.Tasks.Task FetchAsync(FetchEventTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Event Type. + /// + /// A string that uniquely identifies this Event Type. + /// Client to make requests to Twilio + /// A single instance of EventType + public static EventTypeResource Fetch(string pathType, ITwilioRestClient client = null) + { + var options = new FetchEventTypeOptions(pathType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Event Type. + /// + /// A string that uniquely identifies this Event Type. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EventType + public static async System.Threading.Tasks.Task FetchAsync(string pathType, + ITwilioRestClient client = null) + { + var options = new FetchEventTypeOptions(pathType); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EventTypeResource object + /// + /// Raw JSON string + /// EventTypeResource object represented by the provided JSON + public static EventTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The Event Type identifier. + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The Schema identifier for this Event Type. + /// + [JsonProperty("schema_id")] + public string SchemaId { get; private set; } + /// + /// The date this Event Type was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Event Type was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Event Type description. + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private EventTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Schema/SchemaVersionOptions.cs b/src/Twilio/Rest/Events/V1/Schema/SchemaVersionOptions.cs index 5f37ab8ce..9a87eb84f 100644 --- a/src/Twilio/Rest/Events/V1/Schema/SchemaVersionOptions.cs +++ b/src/Twilio/Rest/Events/V1/Schema/SchemaVersionOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1.Schema -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a paginated list of versions of the schema. + /// + public class ReadSchemaVersionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a paginated list of versions of the schema. + /// The unique identifier of the schema. /// - public class ReadSchemaVersionOptions : ReadOptions - { - /// - /// The unique identifier of the schema. - /// - public string PathId { get; } - - /// - /// Construct a new ReadSchemaVersionOptions - /// - /// The unique identifier of the schema. - public ReadSchemaVersionOptions(string pathId) - { - PathId = pathId; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathId { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific schema and version. + /// Construct a new ReadSchemaVersionOptions /// - public class FetchSchemaVersionOptions : IOptions - { - /// - /// The unique identifier of the schema. - /// - public string PathId { get; } - /// - /// The version of the schema - /// - public int? PathSchemaVersion { get; } - - /// - /// Construct a new FetchSchemaVersionOptions - /// - /// The unique identifier of the schema. - /// The version of the schema - public FetchSchemaVersionOptions(string pathId, int? pathSchemaVersion) - { - PathId = pathId; - PathSchemaVersion = pathSchemaVersion; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique identifier of the schema. + public ReadSchemaVersionOptions(string pathId) + { + PathId = pathId; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific schema and version. + /// + public class FetchSchemaVersionOptions : IOptions + { + /// + /// The unique identifier of the schema. + /// + public string PathId { get; } + /// + /// The version of the schema + /// + public int? PathSchemaVersion { get; } + + /// + /// Construct a new FetchSchemaVersionOptions + /// + /// The unique identifier of the schema. + /// The version of the schema + public FetchSchemaVersionOptions(string pathId, int? pathSchemaVersion) + { + PathId = pathId; + PathSchemaVersion = pathSchemaVersion; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Schema/SchemaVersionResource.cs b/src/Twilio/Rest/Events/V1/Schema/SchemaVersionResource.cs index 9bc5aec3b..fa5c8ef13 100644 --- a/src/Twilio/Rest/Events/V1/Schema/SchemaVersionResource.cs +++ b/src/Twilio/Rest/Events/V1/Schema/SchemaVersionResource.cs @@ -18,262 +18,262 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1.Schema -{ - - public class SchemaVersionResource : Resource - { - private static Request BuildReadRequest(ReadSchemaVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Schemas/" + options.PathId + "/Versions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a paginated list of versions of the schema. - /// - /// Read SchemaVersion parameters - /// Client to make requests to Twilio - /// A single instance of SchemaVersion - public static ResourceSet Read(ReadSchemaVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("schema_versions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of versions of the schema. - /// - /// Read SchemaVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SchemaVersion - public static async System.Threading.Tasks.Task> ReadAsync(ReadSchemaVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("schema_versions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a paginated list of versions of the schema. - /// - /// The unique identifier of the schema. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SchemaVersion - public static ResourceSet Read(string pathId, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSchemaVersionOptions(pathId){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of versions of the schema. - /// - /// The unique identifier of the schema. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SchemaVersion - public static async System.Threading.Tasks.Task> ReadAsync(string pathId, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSchemaVersionOptions(pathId){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("schema_versions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("schema_versions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("schema_versions", response.Content); - } - - private static Request BuildFetchRequest(FetchSchemaVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Schemas/" + options.PathId + "/Versions/" + options.PathSchemaVersion + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific schema and version. - /// - /// Fetch SchemaVersion parameters - /// Client to make requests to Twilio - /// A single instance of SchemaVersion - public static SchemaVersionResource Fetch(FetchSchemaVersionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific schema and version. - /// - /// Fetch SchemaVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SchemaVersion - public static async System.Threading.Tasks.Task FetchAsync(FetchSchemaVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific schema and version. - /// - /// The unique identifier of the schema. - /// The version of the schema - /// Client to make requests to Twilio - /// A single instance of SchemaVersion - public static SchemaVersionResource Fetch(string pathId, int? pathSchemaVersion, ITwilioRestClient client = null) - { - var options = new FetchSchemaVersionOptions(pathId, pathSchemaVersion); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific schema and version. - /// - /// The unique identifier of the schema. - /// The version of the schema - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SchemaVersion - public static async System.Threading.Tasks.Task FetchAsync(string pathId, - int? pathSchemaVersion, - ITwilioRestClient client = null) - { - var options = new FetchSchemaVersionOptions(pathId, pathSchemaVersion); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SchemaVersionResource object - /// - /// Raw JSON string - /// SchemaVersionResource object represented by the provided JSON - public static SchemaVersionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique identifier of the schema. - /// - [JsonProperty("id")] - public string Id { get; private set; } - /// - /// The version of this schema. - /// - [JsonProperty("schema_version")] - public int? SchemaVersion { get; private set; } - /// - /// The date the schema version was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The raw - /// - [JsonProperty("raw")] - public Uri Raw { get; private set; } - - private SchemaVersionResource() - { - - } - } +{ + + public class SchemaVersionResource : Resource + { + private static Request BuildReadRequest(ReadSchemaVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Schemas/" + options.PathId + "/Versions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a paginated list of versions of the schema. + /// + /// Read SchemaVersion parameters + /// Client to make requests to Twilio + /// A single instance of SchemaVersion + public static ResourceSet Read(ReadSchemaVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("schema_versions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of versions of the schema. + /// + /// Read SchemaVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SchemaVersion + public static async System.Threading.Tasks.Task> ReadAsync(ReadSchemaVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("schema_versions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a paginated list of versions of the schema. + /// + /// The unique identifier of the schema. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SchemaVersion + public static ResourceSet Read(string pathId, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSchemaVersionOptions(pathId) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of versions of the schema. + /// + /// The unique identifier of the schema. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SchemaVersion + public static async System.Threading.Tasks.Task> ReadAsync(string pathId, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSchemaVersionOptions(pathId) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("schema_versions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("schema_versions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("schema_versions", response.Content); + } + + private static Request BuildFetchRequest(FetchSchemaVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Schemas/" + options.PathId + "/Versions/" + options.PathSchemaVersion + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific schema and version. + /// + /// Fetch SchemaVersion parameters + /// Client to make requests to Twilio + /// A single instance of SchemaVersion + public static SchemaVersionResource Fetch(FetchSchemaVersionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific schema and version. + /// + /// Fetch SchemaVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SchemaVersion + public static async System.Threading.Tasks.Task FetchAsync(FetchSchemaVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific schema and version. + /// + /// The unique identifier of the schema. + /// The version of the schema + /// Client to make requests to Twilio + /// A single instance of SchemaVersion + public static SchemaVersionResource Fetch(string pathId, int? pathSchemaVersion, ITwilioRestClient client = null) + { + var options = new FetchSchemaVersionOptions(pathId, pathSchemaVersion); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific schema and version. + /// + /// The unique identifier of the schema. + /// The version of the schema + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SchemaVersion + public static async System.Threading.Tasks.Task FetchAsync(string pathId, + int? pathSchemaVersion, + ITwilioRestClient client = null) + { + var options = new FetchSchemaVersionOptions(pathId, pathSchemaVersion); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SchemaVersionResource object + /// + /// Raw JSON string + /// SchemaVersionResource object represented by the provided JSON + public static SchemaVersionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique identifier of the schema. + /// + [JsonProperty("id")] + public string Id { get; private set; } + /// + /// The version of this schema. + /// + [JsonProperty("schema_version")] + public int? SchemaVersion { get; private set; } + /// + /// The date the schema version was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The raw + /// + [JsonProperty("raw")] + public Uri Raw { get; private set; } + + private SchemaVersionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SchemaOptions.cs b/src/Twilio/Rest/Events/V1/SchemaOptions.cs index 64df2af7b..f5ef47254 100644 --- a/src/Twilio/Rest/Events/V1/SchemaOptions.cs +++ b/src/Twilio/Rest/Events/V1/SchemaOptions.cs @@ -9,37 +9,37 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific schema with its nested versions. + /// + public class FetchSchemaOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific schema with its nested versions. + /// The unique identifier of the schema. /// - public class FetchSchemaOptions : IOptions - { - /// - /// The unique identifier of the schema. - /// - public string PathId { get; } - - /// - /// Construct a new FetchSchemaOptions - /// - /// The unique identifier of the schema. - public FetchSchemaOptions(string pathId) - { - PathId = pathId; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathId { get; } + + /// + /// Construct a new FetchSchemaOptions + /// + /// The unique identifier of the schema. + public FetchSchemaOptions(string pathId) + { + PathId = pathId; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SchemaResource.cs b/src/Twilio/Rest/Events/V1/SchemaResource.cs index 808d8d57e..7b707ffed 100644 --- a/src/Twilio/Rest/Events/V1/SchemaResource.cs +++ b/src/Twilio/Rest/Events/V1/SchemaResource.cs @@ -18,125 +18,125 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1 -{ - - public class SchemaResource : Resource - { - private static Request BuildFetchRequest(FetchSchemaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Schemas/" + options.PathId + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific schema with its nested versions. - /// - /// Fetch Schema parameters - /// Client to make requests to Twilio - /// A single instance of Schema - public static SchemaResource Fetch(FetchSchemaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific schema with its nested versions. - /// - /// Fetch Schema parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Schema - public static async System.Threading.Tasks.Task FetchAsync(FetchSchemaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific schema with its nested versions. - /// - /// The unique identifier of the schema. - /// Client to make requests to Twilio - /// A single instance of Schema - public static SchemaResource Fetch(string pathId, ITwilioRestClient client = null) - { - var options = new FetchSchemaOptions(pathId); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific schema with its nested versions. - /// - /// The unique identifier of the schema. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Schema - public static async System.Threading.Tasks.Task FetchAsync(string pathId, - ITwilioRestClient client = null) - { - var options = new FetchSchemaOptions(pathId); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SchemaResource object - /// - /// Raw JSON string - /// SchemaResource object represented by the provided JSON - public static SchemaResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Schema Identifier. - /// - [JsonProperty("id")] - public string Id { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The date that the latest schema version was created. - /// - [JsonProperty("latest_version_date_created")] - public DateTime? LatestVersionDateCreated { get; private set; } - /// - /// Latest schema version. - /// - [JsonProperty("latest_version")] - public int? LatestVersion { get; private set; } - - private SchemaResource() - { - - } - } +{ + + public class SchemaResource : Resource + { + private static Request BuildFetchRequest(FetchSchemaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Schemas/" + options.PathId + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific schema with its nested versions. + /// + /// Fetch Schema parameters + /// Client to make requests to Twilio + /// A single instance of Schema + public static SchemaResource Fetch(FetchSchemaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific schema with its nested versions. + /// + /// Fetch Schema parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Schema + public static async System.Threading.Tasks.Task FetchAsync(FetchSchemaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific schema with its nested versions. + /// + /// The unique identifier of the schema. + /// Client to make requests to Twilio + /// A single instance of Schema + public static SchemaResource Fetch(string pathId, ITwilioRestClient client = null) + { + var options = new FetchSchemaOptions(pathId); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific schema with its nested versions. + /// + /// The unique identifier of the schema. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Schema + public static async System.Threading.Tasks.Task FetchAsync(string pathId, + ITwilioRestClient client = null) + { + var options = new FetchSchemaOptions(pathId); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SchemaResource object + /// + /// Raw JSON string + /// SchemaResource object represented by the provided JSON + public static SchemaResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Schema Identifier. + /// + [JsonProperty("id")] + public string Id { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The date that the latest schema version was created. + /// + [JsonProperty("latest_version_date_created")] + public DateTime? LatestVersionDateCreated { get; private set; } + /// + /// Latest schema version. + /// + [JsonProperty("latest_version")] + public int? LatestVersion { get; private set; } + + private SchemaResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Sink/SinkTestOptions.cs b/src/Twilio/Rest/Events/V1/Sink/SinkTestOptions.cs index 51292c99a..b2637b1ac 100644 --- a/src/Twilio/Rest/Events/V1/Sink/SinkTestOptions.cs +++ b/src/Twilio/Rest/Events/V1/Sink/SinkTestOptions.cs @@ -9,37 +9,37 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1.Sink -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Sink Test Event for the given Sink. + /// + public class CreateSinkTestOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Sink Test Event for the given Sink. + /// A string that uniquely identifies the Sink to be Tested. /// - public class CreateSinkTestOptions : IOptions - { - /// - /// A string that uniquely identifies the Sink to be Tested. - /// - public string PathSid { get; } - - /// - /// Construct a new CreateSinkTestOptions - /// - /// A string that uniquely identifies the Sink to be Tested. - public CreateSinkTestOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new CreateSinkTestOptions + /// + /// A string that uniquely identifies the Sink to be Tested. + public CreateSinkTestOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Sink/SinkTestResource.cs b/src/Twilio/Rest/Events/V1/Sink/SinkTestResource.cs index 212b888a0..085a6917a 100644 --- a/src/Twilio/Rest/Events/V1/Sink/SinkTestResource.cs +++ b/src/Twilio/Rest/Events/V1/Sink/SinkTestResource.cs @@ -18,105 +18,105 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1.Sink -{ - - public class SinkTestResource : Resource - { - private static Request BuildCreateRequest(CreateSinkTestOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Sinks/" + options.PathSid + "/Test", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Sink Test Event for the given Sink. - /// - /// Create SinkTest parameters - /// Client to make requests to Twilio - /// A single instance of SinkTest - public static SinkTestResource Create(CreateSinkTestOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Sink Test Event for the given Sink. - /// - /// Create SinkTest parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SinkTest - public static async System.Threading.Tasks.Task CreateAsync(CreateSinkTestOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Sink Test Event for the given Sink. - /// - /// A string that uniquely identifies the Sink to be Tested. - /// Client to make requests to Twilio - /// A single instance of SinkTest - public static SinkTestResource Create(string pathSid, ITwilioRestClient client = null) - { - var options = new CreateSinkTestOptions(pathSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Sink Test Event for the given Sink. - /// - /// A string that uniquely identifies the Sink to be Tested. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SinkTest - public static async System.Threading.Tasks.Task CreateAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new CreateSinkTestOptions(pathSid); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SinkTestResource object - /// - /// Raw JSON string - /// SinkTestResource object represented by the provided JSON - public static SinkTestResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Feedback indicating whether the test event was generated. - /// - [JsonProperty("result")] - public string Result { get; private set; } - - private SinkTestResource() - { - - } - } +{ + + public class SinkTestResource : Resource + { + private static Request BuildCreateRequest(CreateSinkTestOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Sinks/" + options.PathSid + "/Test", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Sink Test Event for the given Sink. + /// + /// Create SinkTest parameters + /// Client to make requests to Twilio + /// A single instance of SinkTest + public static SinkTestResource Create(CreateSinkTestOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Sink Test Event for the given Sink. + /// + /// Create SinkTest parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SinkTest + public static async System.Threading.Tasks.Task CreateAsync(CreateSinkTestOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Sink Test Event for the given Sink. + /// + /// A string that uniquely identifies the Sink to be Tested. + /// Client to make requests to Twilio + /// A single instance of SinkTest + public static SinkTestResource Create(string pathSid, ITwilioRestClient client = null) + { + var options = new CreateSinkTestOptions(pathSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Sink Test Event for the given Sink. + /// + /// A string that uniquely identifies the Sink to be Tested. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SinkTest + public static async System.Threading.Tasks.Task CreateAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new CreateSinkTestOptions(pathSid); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SinkTestResource object + /// + /// Raw JSON string + /// SinkTestResource object represented by the provided JSON + public static SinkTestResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Feedback indicating whether the test event was generated. + /// + [JsonProperty("result")] + public string Result { get; private set; } + + private SinkTestResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Sink/SinkValidateOptions.cs b/src/Twilio/Rest/Events/V1/Sink/SinkValidateOptions.cs index 19afe9e85..860bac7d5 100644 --- a/src/Twilio/Rest/Events/V1/Sink/SinkValidateOptions.cs +++ b/src/Twilio/Rest/Events/V1/Sink/SinkValidateOptions.cs @@ -9,48 +9,48 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1.Sink -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Validate that a test event for a Sink was received. + /// + public class CreateSinkValidateOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Validate that a test event for a Sink was received. + /// A string that uniquely identifies the Sink being validated. /// - public class CreateSinkValidateOptions : IOptions - { - /// - /// A string that uniquely identifies the Sink being validated. - /// - public string PathSid { get; } - /// - /// A string that uniquely identifies the test event for a Sink being validated. - /// - public string TestId { get; } - - /// - /// Construct a new CreateSinkValidateOptions - /// - /// A string that uniquely identifies the Sink being validated. - /// A string that uniquely identifies the test event for a Sink being validated. - public CreateSinkValidateOptions(string pathSid, string testId) - { - PathSid = pathSid; - TestId = testId; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TestId != null) - { - p.Add(new KeyValuePair("TestId", TestId)); - } - - return p; - } - } + public string PathSid { get; } + /// + /// A string that uniquely identifies the test event for a Sink being validated. + /// + public string TestId { get; } + + /// + /// Construct a new CreateSinkValidateOptions + /// + /// A string that uniquely identifies the Sink being validated. + /// A string that uniquely identifies the test event for a Sink being validated. + public CreateSinkValidateOptions(string pathSid, string testId) + { + PathSid = pathSid; + TestId = testId; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TestId != null) + { + p.Add(new KeyValuePair("TestId", TestId)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Sink/SinkValidateResource.cs b/src/Twilio/Rest/Events/V1/Sink/SinkValidateResource.cs index f16e914d7..3c559c5c6 100644 --- a/src/Twilio/Rest/Events/V1/Sink/SinkValidateResource.cs +++ b/src/Twilio/Rest/Events/V1/Sink/SinkValidateResource.cs @@ -18,108 +18,108 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1.Sink -{ - - public class SinkValidateResource : Resource - { - private static Request BuildCreateRequest(CreateSinkValidateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Sinks/" + options.PathSid + "/Validate", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Validate that a test event for a Sink was received. - /// - /// Create SinkValidate parameters - /// Client to make requests to Twilio - /// A single instance of SinkValidate - public static SinkValidateResource Create(CreateSinkValidateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Validate that a test event for a Sink was received. - /// - /// Create SinkValidate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SinkValidate - public static async System.Threading.Tasks.Task CreateAsync(CreateSinkValidateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Validate that a test event for a Sink was received. - /// - /// A string that uniquely identifies the Sink being validated. - /// A string that uniquely identifies the test event for a Sink being validated. - /// Client to make requests to Twilio - /// A single instance of SinkValidate - public static SinkValidateResource Create(string pathSid, string testId, ITwilioRestClient client = null) - { - var options = new CreateSinkValidateOptions(pathSid, testId); - return Create(options, client); - } - - #if !NET35 - /// - /// Validate that a test event for a Sink was received. - /// - /// A string that uniquely identifies the Sink being validated. - /// A string that uniquely identifies the test event for a Sink being validated. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SinkValidate - public static async System.Threading.Tasks.Task CreateAsync(string pathSid, - string testId, - ITwilioRestClient client = null) - { - var options = new CreateSinkValidateOptions(pathSid, testId); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SinkValidateResource object - /// - /// Raw JSON string - /// SinkValidateResource object represented by the provided JSON - public static SinkValidateResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Feedback indicating whether the given Sink was validated. - /// - [JsonProperty("result")] - public string Result { get; private set; } - - private SinkValidateResource() - { - - } - } +{ + + public class SinkValidateResource : Resource + { + private static Request BuildCreateRequest(CreateSinkValidateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Sinks/" + options.PathSid + "/Validate", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Validate that a test event for a Sink was received. + /// + /// Create SinkValidate parameters + /// Client to make requests to Twilio + /// A single instance of SinkValidate + public static SinkValidateResource Create(CreateSinkValidateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Validate that a test event for a Sink was received. + /// + /// Create SinkValidate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SinkValidate + public static async System.Threading.Tasks.Task CreateAsync(CreateSinkValidateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Validate that a test event for a Sink was received. + /// + /// A string that uniquely identifies the Sink being validated. + /// A string that uniquely identifies the test event for a Sink being validated. + /// Client to make requests to Twilio + /// A single instance of SinkValidate + public static SinkValidateResource Create(string pathSid, string testId, ITwilioRestClient client = null) + { + var options = new CreateSinkValidateOptions(pathSid, testId); + return Create(options, client); + } + +#if !NET35 + /// + /// Validate that a test event for a Sink was received. + /// + /// A string that uniquely identifies the Sink being validated. + /// A string that uniquely identifies the test event for a Sink being validated. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SinkValidate + public static async System.Threading.Tasks.Task CreateAsync(string pathSid, + string testId, + ITwilioRestClient client = null) + { + var options = new CreateSinkValidateOptions(pathSid, testId); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SinkValidateResource object + /// + /// Raw JSON string + /// SinkValidateResource object represented by the provided JSON + public static SinkValidateResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Feedback indicating whether the given Sink was validated. + /// + [JsonProperty("result")] + public string Result { get; private set; } + + private SinkValidateResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SinkOptions.cs b/src/Twilio/Rest/Events/V1/SinkOptions.cs index d82225da1..48d2d59bb 100644 --- a/src/Twilio/Rest/Events/V1/SinkOptions.cs +++ b/src/Twilio/Rest/Events/V1/SinkOptions.cs @@ -9,209 +9,209 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Sink. + /// + public class FetchSinkOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Sink. + /// A string that uniquely identifies this Sink. /// - public class FetchSinkOptions : IOptions - { - /// - /// A string that uniquely identifies this Sink. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSinkOptions - /// - /// A string that uniquely identifies this Sink. - public FetchSinkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Sink - /// - public class CreateSinkOptions : IOptions - { - /// - /// Sink Description. - /// - public string Description { get; } - /// - /// JSON Sink configuration. - /// - public object SinkConfiguration { get; } - /// - /// Sink type. - /// - public SinkResource.SinkTypeEnum SinkType { get; } - - /// - /// Construct a new CreateSinkOptions - /// - /// Sink Description. - /// JSON Sink configuration. - /// Sink type. - public CreateSinkOptions(string description, object sinkConfiguration, SinkResource.SinkTypeEnum sinkType) - { - Description = description; - SinkConfiguration = sinkConfiguration; - SinkType = sinkType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (SinkConfiguration != null) - { - p.Add(new KeyValuePair("SinkConfiguration", Serializers.JsonObject(SinkConfiguration))); - } - - if (SinkType != null) - { - p.Add(new KeyValuePair("SinkType", SinkType.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSinkOptions + /// + /// A string that uniquely identifies this Sink. + public FetchSinkOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Sink. + /// Generate the necessary parameters /// - public class DeleteSinkOptions : IOptions - { - /// - /// A string that uniquely identifies this Sink. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSinkOptions - /// - /// A string that uniquely identifies this Sink. - public DeleteSinkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Sink + /// + public class CreateSinkOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a paginated list of Sinks belonging to the account used to make the request. - /// - public class ReadSinkOptions : ReadOptions - { - /// - /// A boolean to return sinks used/not used by a subscription. - /// - public bool? InUse { get; set; } - /// - /// A string to filter sinks by status. - /// - public string Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (InUse != null) - { - p.Add(new KeyValuePair("InUse", InUse.Value.ToString().ToLower())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Sink Description. + /// + public string Description { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Sink - /// - public class UpdateSinkOptions : IOptions - { - /// - /// A string that uniquely identifies this Sink. - /// - public string PathSid { get; } - /// - /// Sink Description - /// - public string Description { get; } - - /// - /// Construct a new UpdateSinkOptions - /// - /// A string that uniquely identifies this Sink. - /// Sink Description - public UpdateSinkOptions(string pathSid, string description) - { - PathSid = pathSid; - Description = description; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - return p; - } - } + /// JSON Sink configuration. + /// + public object SinkConfiguration { get; } + /// + /// Sink type. + /// + public SinkResource.SinkTypeEnum SinkType { get; } + + /// + /// Construct a new CreateSinkOptions + /// + /// Sink Description. + /// JSON Sink configuration. + /// Sink type. + public CreateSinkOptions(string description, object sinkConfiguration, SinkResource.SinkTypeEnum sinkType) + { + Description = description; + SinkConfiguration = sinkConfiguration; + SinkType = sinkType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (SinkConfiguration != null) + { + p.Add(new KeyValuePair("SinkConfiguration", Serializers.JsonObject(SinkConfiguration))); + } + + if (SinkType != null) + { + p.Add(new KeyValuePair("SinkType", SinkType.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Sink. + /// + public class DeleteSinkOptions : IOptions + { + /// + /// A string that uniquely identifies this Sink. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSinkOptions + /// + /// A string that uniquely identifies this Sink. + public DeleteSinkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a paginated list of Sinks belonging to the account used to make the request. + /// + public class ReadSinkOptions : ReadOptions + { + /// + /// A boolean to return sinks used/not used by a subscription. + /// + public bool? InUse { get; set; } + /// + /// A string to filter sinks by status. + /// + public string Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (InUse != null) + { + p.Add(new KeyValuePair("InUse", InUse.Value.ToString().ToLower())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Sink + /// + public class UpdateSinkOptions : IOptions + { + /// + /// A string that uniquely identifies this Sink. + /// + public string PathSid { get; } + /// + /// Sink Description + /// + public string Description { get; } + + /// + /// Construct a new UpdateSinkOptions + /// + /// A string that uniquely identifies this Sink. + /// Sink Description + public UpdateSinkOptions(string pathSid, string description) + { + PathSid = pathSid; + Description = description; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SinkResource.cs b/src/Twilio/Rest/Events/V1/SinkResource.cs index a6cfdbf1c..fabb1e490 100644 --- a/src/Twilio/Rest/Events/V1/SinkResource.cs +++ b/src/Twilio/Rest/Events/V1/SinkResource.cs @@ -19,525 +19,525 @@ using Twilio.Types; namespace Twilio.Rest.Events.V1 -{ - - public class SinkResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Initialized = new StatusEnum("initialized"); - public static readonly StatusEnum Validating = new StatusEnum("validating"); - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class SinkTypeEnum : StringEnum - { - private SinkTypeEnum(string value) : base(value) {} - public SinkTypeEnum() {} - public static implicit operator SinkTypeEnum(string value) - { - return new SinkTypeEnum(value); - } - - public static readonly SinkTypeEnum Kinesis = new SinkTypeEnum("kinesis"); - public static readonly SinkTypeEnum Webhook = new SinkTypeEnum("webhook"); - public static readonly SinkTypeEnum Segment = new SinkTypeEnum("segment"); - } - - private static Request BuildFetchRequest(FetchSinkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Sinks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sink. - /// - /// Fetch Sink parameters - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Fetch(FetchSinkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sink. - /// - /// Fetch Sink parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task FetchAsync(FetchSinkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sink. - /// - /// A string that uniquely identifies this Sink. - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSinkOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sink. - /// - /// A string that uniquely identifies this Sink. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSinkOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSinkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Sinks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Sink - /// - /// Create Sink parameters - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Create(CreateSinkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Sink - /// - /// Create Sink parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task CreateAsync(CreateSinkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Sink - /// - /// Sink Description. - /// JSON Sink configuration. - /// Sink type. - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Create(string description, - object sinkConfiguration, - SinkResource.SinkTypeEnum sinkType, - ITwilioRestClient client = null) - { - var options = new CreateSinkOptions(description, sinkConfiguration, sinkType); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Sink - /// - /// Sink Description. - /// JSON Sink configuration. - /// Sink type. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task CreateAsync(string description, - object sinkConfiguration, - SinkResource.SinkTypeEnum sinkType, - ITwilioRestClient client = null) - { - var options = new CreateSinkOptions(description, sinkConfiguration, sinkType); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSinkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Events, - "/v1/Sinks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sink. - /// - /// Delete Sink parameters - /// Client to make requests to Twilio - /// A single instance of Sink - public static bool Delete(DeleteSinkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sink. - /// - /// Delete Sink parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSinkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sink. - /// - /// A string that uniquely identifies this Sink. - /// Client to make requests to Twilio - /// A single instance of Sink - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSinkOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sink. - /// - /// A string that uniquely identifies this Sink. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSinkOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSinkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Sinks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a paginated list of Sinks belonging to the account used to make the request. - /// - /// Read Sink parameters - /// Client to make requests to Twilio - /// A single instance of Sink - public static ResourceSet Read(ReadSinkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sinks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of Sinks belonging to the account used to make the request. - /// - /// Read Sink parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task> ReadAsync(ReadSinkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sinks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a paginated list of Sinks belonging to the account used to make the request. - /// - /// A boolean to return sinks used/not used by a subscription. - /// A string to filter sinks by status. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sink - public static ResourceSet Read(bool? inUse = null, - string status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSinkOptions(){InUse = inUse, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of Sinks belonging to the account used to make the request. - /// - /// A boolean to return sinks used/not used by a subscription. - /// A string to filter sinks by status. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task> ReadAsync(bool? inUse = null, - string status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSinkOptions(){InUse = inUse, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sinks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("sinks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("sinks", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSinkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Sinks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Sink - /// - /// Update Sink parameters - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Update(UpdateSinkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Sink - /// - /// Update Sink parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSinkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Sink - /// - /// A string that uniquely identifies this Sink. - /// Sink Description - /// Client to make requests to Twilio - /// A single instance of Sink - public static SinkResource Update(string pathSid, string description, ITwilioRestClient client = null) - { - var options = new UpdateSinkOptions(pathSid, description); - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Sink - /// - /// A string that uniquely identifies this Sink. - /// Sink Description - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sink - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string description, - ITwilioRestClient client = null) - { - var options = new UpdateSinkOptions(pathSid, description); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SinkResource object - /// - /// Raw JSON string - /// SinkResource object represented by the provided JSON - public static SinkResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The date this Sink was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Sink was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Sink Description - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// A string that uniquely identifies this Sink. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// JSON Sink configuration. - /// - [JsonProperty("sink_configuration")] - public object SinkConfiguration { get; private set; } - /// - /// Sink type. - /// - [JsonProperty("sink_type")] - [JsonConverter(typeof(StringEnumConverter))] - public SinkResource.SinkTypeEnum SinkType { get; private set; } - /// - /// The Status of this Sink - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SinkResource.StatusEnum Status { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private SinkResource() - { - - } - } +{ + + public class SinkResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Initialized = new StatusEnum("initialized"); + public static readonly StatusEnum Validating = new StatusEnum("validating"); + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class SinkTypeEnum : StringEnum + { + private SinkTypeEnum(string value) : base(value) { } + public SinkTypeEnum() { } + public static implicit operator SinkTypeEnum(string value) + { + return new SinkTypeEnum(value); + } + + public static readonly SinkTypeEnum Kinesis = new SinkTypeEnum("kinesis"); + public static readonly SinkTypeEnum Webhook = new SinkTypeEnum("webhook"); + public static readonly SinkTypeEnum Segment = new SinkTypeEnum("segment"); + } + + private static Request BuildFetchRequest(FetchSinkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Sinks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sink. + /// + /// Fetch Sink parameters + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Fetch(FetchSinkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sink. + /// + /// Fetch Sink parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task FetchAsync(FetchSinkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sink. + /// + /// A string that uniquely identifies this Sink. + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSinkOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sink. + /// + /// A string that uniquely identifies this Sink. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSinkOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSinkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Sinks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Sink + /// + /// Create Sink parameters + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Create(CreateSinkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Sink + /// + /// Create Sink parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task CreateAsync(CreateSinkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Sink + /// + /// Sink Description. + /// JSON Sink configuration. + /// Sink type. + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Create(string description, + object sinkConfiguration, + SinkResource.SinkTypeEnum sinkType, + ITwilioRestClient client = null) + { + var options = new CreateSinkOptions(description, sinkConfiguration, sinkType); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Sink + /// + /// Sink Description. + /// JSON Sink configuration. + /// Sink type. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task CreateAsync(string description, + object sinkConfiguration, + SinkResource.SinkTypeEnum sinkType, + ITwilioRestClient client = null) + { + var options = new CreateSinkOptions(description, sinkConfiguration, sinkType); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSinkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Events, + "/v1/Sinks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sink. + /// + /// Delete Sink parameters + /// Client to make requests to Twilio + /// A single instance of Sink + public static bool Delete(DeleteSinkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sink. + /// + /// Delete Sink parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSinkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sink. + /// + /// A string that uniquely identifies this Sink. + /// Client to make requests to Twilio + /// A single instance of Sink + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSinkOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sink. + /// + /// A string that uniquely identifies this Sink. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSinkOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSinkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Sinks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a paginated list of Sinks belonging to the account used to make the request. + /// + /// Read Sink parameters + /// Client to make requests to Twilio + /// A single instance of Sink + public static ResourceSet Read(ReadSinkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sinks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of Sinks belonging to the account used to make the request. + /// + /// Read Sink parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task> ReadAsync(ReadSinkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sinks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a paginated list of Sinks belonging to the account used to make the request. + /// + /// A boolean to return sinks used/not used by a subscription. + /// A string to filter sinks by status. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sink + public static ResourceSet Read(bool? inUse = null, + string status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSinkOptions() { InUse = inUse, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of Sinks belonging to the account used to make the request. + /// + /// A boolean to return sinks used/not used by a subscription. + /// A string to filter sinks by status. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task> ReadAsync(bool? inUse = null, + string status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSinkOptions() { InUse = inUse, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sinks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("sinks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("sinks", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSinkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Sinks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Sink + /// + /// Update Sink parameters + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Update(UpdateSinkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Sink + /// + /// Update Sink parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSinkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Sink + /// + /// A string that uniquely identifies this Sink. + /// Sink Description + /// Client to make requests to Twilio + /// A single instance of Sink + public static SinkResource Update(string pathSid, string description, ITwilioRestClient client = null) + { + var options = new UpdateSinkOptions(pathSid, description); + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Sink + /// + /// A string that uniquely identifies this Sink. + /// Sink Description + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sink + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string description, + ITwilioRestClient client = null) + { + var options = new UpdateSinkOptions(pathSid, description); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SinkResource object + /// + /// Raw JSON string + /// SinkResource object represented by the provided JSON + public static SinkResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The date this Sink was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Sink was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Sink Description + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// A string that uniquely identifies this Sink. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// JSON Sink configuration. + /// + [JsonProperty("sink_configuration")] + public object SinkConfiguration { get; private set; } + /// + /// Sink type. + /// + [JsonProperty("sink_type")] + [JsonConverter(typeof(StringEnumConverter))] + public SinkResource.SinkTypeEnum SinkType { get; private set; } + /// + /// The Status of this Sink + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SinkResource.StatusEnum Status { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private SinkResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventOptions.cs b/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventOptions.cs index d463942a7..aba47e2a6 100644 --- a/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventOptions.cs +++ b/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventOptions.cs @@ -9,213 +9,213 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1.Subscription -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Subscribed Event types for a Subscription. + /// + public class ReadSubscribedEventOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Subscribed Event types for a Subscription. + /// Subscription SID. /// - public class ReadSubscribedEventOptions : ReadOptions - { - /// - /// Subscription SID. - /// - public string PathSubscriptionSid { get; } - - /// - /// Construct a new ReadSubscribedEventOptions - /// - /// Subscription SID. - public ReadSubscribedEventOptions(string pathSubscriptionSid) - { - PathSubscriptionSid = pathSubscriptionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSubscriptionSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Subscribed Event type for the subscription - /// - public class CreateSubscribedEventOptions : IOptions - { - /// - /// Subscription SID. - /// - public string PathSubscriptionSid { get; } - /// - /// Type of event being subscribed to. - /// - public string Type { get; } - /// - /// The schema version that the subscription should use. - /// - public int? SchemaVersion { get; set; } - - /// - /// Construct a new CreateSubscribedEventOptions - /// - /// Subscription SID. - /// Type of event being subscribed to. - public CreateSubscribedEventOptions(string pathSubscriptionSid, string type) - { - PathSubscriptionSid = pathSubscriptionSid; - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type)); - } - - if (SchemaVersion != null) - { - p.Add(new KeyValuePair("SchemaVersion", SchemaVersion.ToString())); - } - - return p; - } - } - + /// Construct a new ReadSubscribedEventOptions + /// + /// Subscription SID. + public ReadSubscribedEventOptions(string pathSubscriptionSid) + { + PathSubscriptionSid = pathSubscriptionSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Read an Event for a Subscription. - /// - public class FetchSubscribedEventOptions : IOptions - { - /// - /// Subscription SID. - /// - public string PathSubscriptionSid { get; } - /// - /// Type of event being subscribed to. - /// - public string PathType { get; } - - /// - /// Construct a new FetchSubscribedEventOptions - /// - /// Subscription SID. - /// Type of event being subscribed to. - public FetchSubscribedEventOptions(string pathSubscriptionSid, string pathType) - { - PathSubscriptionSid = pathSubscriptionSid; - PathType = pathType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Subscribed Event type for the subscription + /// + public class CreateSubscribedEventOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update an Event for a Subscription. - /// - public class UpdateSubscribedEventOptions : IOptions - { - /// - /// Subscription SID. - /// - public string PathSubscriptionSid { get; } - /// - /// Type of event being subscribed to. - /// - public string PathType { get; } - /// - /// The schema version that the subscription should use. - /// - public int? SchemaVersion { get; set; } - - /// - /// Construct a new UpdateSubscribedEventOptions - /// - /// Subscription SID. - /// Type of event being subscribed to. - public UpdateSubscribedEventOptions(string pathSubscriptionSid, string pathType) - { - PathSubscriptionSid = pathSubscriptionSid; - PathType = pathType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (SchemaVersion != null) - { - p.Add(new KeyValuePair("SchemaVersion", SchemaVersion.ToString())); - } - - return p; - } - } - + /// Subscription SID. + /// + public string PathSubscriptionSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Remove an event type from a subscription. - /// - public class DeleteSubscribedEventOptions : IOptions - { - /// - /// Subscription SID. - /// - public string PathSubscriptionSid { get; } - /// - /// Type of event being subscribed to. - /// - public string PathType { get; } - - /// - /// Construct a new DeleteSubscribedEventOptions - /// - /// Subscription SID. - /// Type of event being subscribed to. - public DeleteSubscribedEventOptions(string pathSubscriptionSid, string pathType) - { - PathSubscriptionSid = pathSubscriptionSid; - PathType = pathType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Type of event being subscribed to. + /// + public string Type { get; } + /// + /// The schema version that the subscription should use. + /// + public int? SchemaVersion { get; set; } + + /// + /// Construct a new CreateSubscribedEventOptions + /// + /// Subscription SID. + /// Type of event being subscribed to. + public CreateSubscribedEventOptions(string pathSubscriptionSid, string type) + { + PathSubscriptionSid = pathSubscriptionSid; + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type)); + } + + if (SchemaVersion != null) + { + p.Add(new KeyValuePair("SchemaVersion", SchemaVersion.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Read an Event for a Subscription. + /// + public class FetchSubscribedEventOptions : IOptions + { + /// + /// Subscription SID. + /// + public string PathSubscriptionSid { get; } + /// + /// Type of event being subscribed to. + /// + public string PathType { get; } + + /// + /// Construct a new FetchSubscribedEventOptions + /// + /// Subscription SID. + /// Type of event being subscribed to. + public FetchSubscribedEventOptions(string pathSubscriptionSid, string pathType) + { + PathSubscriptionSid = pathSubscriptionSid; + PathType = pathType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update an Event for a Subscription. + /// + public class UpdateSubscribedEventOptions : IOptions + { + /// + /// Subscription SID. + /// + public string PathSubscriptionSid { get; } + /// + /// Type of event being subscribed to. + /// + public string PathType { get; } + /// + /// The schema version that the subscription should use. + /// + public int? SchemaVersion { get; set; } + + /// + /// Construct a new UpdateSubscribedEventOptions + /// + /// Subscription SID. + /// Type of event being subscribed to. + public UpdateSubscribedEventOptions(string pathSubscriptionSid, string pathType) + { + PathSubscriptionSid = pathSubscriptionSid; + PathType = pathType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (SchemaVersion != null) + { + p.Add(new KeyValuePair("SchemaVersion", SchemaVersion.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Remove an event type from a subscription. + /// + public class DeleteSubscribedEventOptions : IOptions + { + /// + /// Subscription SID. + /// + public string PathSubscriptionSid { get; } + /// + /// Type of event being subscribed to. + /// + public string PathType { get; } + + /// + /// Construct a new DeleteSubscribedEventOptions + /// + /// Subscription SID. + /// Type of event being subscribed to. + public DeleteSubscribedEventOptions(string pathSubscriptionSid, string pathType) + { + PathSubscriptionSid = pathSubscriptionSid; + PathType = pathType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventResource.cs b/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventResource.cs index a3a05b10b..17fdd58ca 100644 --- a/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventResource.cs +++ b/src/Twilio/Rest/Events/V1/Subscription/SubscribedEventResource.cs @@ -18,487 +18,487 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1.Subscription -{ - - public class SubscribedEventResource : Resource - { - private static Request BuildReadRequest(ReadSubscribedEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Subscribed Event types for a Subscription. - /// - /// Read SubscribedEvent parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static ResourceSet Read(ReadSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Subscribed Event types for a Subscription. - /// - /// Read SubscribedEvent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Subscribed Event types for a Subscription. - /// - /// Subscription SID. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static ResourceSet Read(string pathSubscriptionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscribedEventOptions(pathSubscriptionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Subscribed Event types for a Subscription. - /// - /// Subscription SID. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task> ReadAsync(string pathSubscriptionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscribedEventOptions(pathSubscriptionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("types", response.Content); - } - - private static Request BuildCreateRequest(CreateSubscribedEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Subscribed Event type for the subscription - /// - /// Create SubscribedEvent parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Create(CreateSubscribedEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Subscribed Event type for the subscription - /// - /// Create SubscribedEvent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task CreateAsync(CreateSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Subscribed Event type for the subscription - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// The schema version that the subscription should use. - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Create(string pathSubscriptionSid, - string type, - int? schemaVersion = null, - ITwilioRestClient client = null) - { - var options = new CreateSubscribedEventOptions(pathSubscriptionSid, type){SchemaVersion = schemaVersion}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Subscribed Event type for the subscription - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// The schema version that the subscription should use. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task CreateAsync(string pathSubscriptionSid, - string type, - int? schemaVersion = null, - ITwilioRestClient client = null) - { - var options = new CreateSubscribedEventOptions(pathSubscriptionSid, type){SchemaVersion = schemaVersion}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchSubscribedEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Read an Event for a Subscription. - /// - /// Fetch SubscribedEvent parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Fetch(FetchSubscribedEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Read an Event for a Subscription. - /// - /// Fetch SubscribedEvent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Read an Event for a Subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Fetch(string pathSubscriptionSid, - string pathType, - ITwilioRestClient client = null) - { - var options = new FetchSubscribedEventOptions(pathSubscriptionSid, pathType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Read an Event for a Subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task FetchAsync(string pathSubscriptionSid, - string pathType, - ITwilioRestClient client = null) - { - var options = new FetchSubscribedEventOptions(pathSubscriptionSid, pathType); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSubscribedEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an Event for a Subscription. - /// - /// Update SubscribedEvent parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Update(UpdateSubscribedEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an Event for a Subscription. - /// - /// Update SubscribedEvent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an Event for a Subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// The schema version that the subscription should use. - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static SubscribedEventResource Update(string pathSubscriptionSid, - string pathType, - int? schemaVersion = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscribedEventOptions(pathSubscriptionSid, pathType){SchemaVersion = schemaVersion}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an Event for a Subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// The schema version that the subscription should use. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task UpdateAsync(string pathSubscriptionSid, - string pathType, - int? schemaVersion = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscribedEventOptions(pathSubscriptionSid, pathType){SchemaVersion = schemaVersion}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSubscribedEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an event type from a subscription. - /// - /// Delete SubscribedEvent parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static bool Delete(DeleteSubscribedEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an event type from a subscription. - /// - /// Delete SubscribedEvent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSubscribedEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an event type from a subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// Client to make requests to Twilio - /// A single instance of SubscribedEvent - public static bool Delete(string pathSubscriptionSid, string pathType, ITwilioRestClient client = null) - { - var options = new DeleteSubscribedEventOptions(pathSubscriptionSid, pathType); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an event type from a subscription. - /// - /// Subscription SID. - /// Type of event being subscribed to. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedEvent - public static async System.Threading.Tasks.Task DeleteAsync(string pathSubscriptionSid, - string pathType, - ITwilioRestClient client = null) - { - var options = new DeleteSubscribedEventOptions(pathSubscriptionSid, pathType); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SubscribedEventResource object - /// - /// Raw JSON string - /// SubscribedEventResource object represented by the provided JSON - public static SubscribedEventResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account SID. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Type of event being subscribed to. - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The schema version that the subscription should use. - /// - [JsonProperty("schema_version")] - public int? SchemaVersion { get; private set; } - /// - /// Subscription SID. - /// - [JsonProperty("subscription_sid")] - public string SubscriptionSid { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SubscribedEventResource() - { - - } - } +{ + + public class SubscribedEventResource : Resource + { + private static Request BuildReadRequest(ReadSubscribedEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Subscribed Event types for a Subscription. + /// + /// Read SubscribedEvent parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static ResourceSet Read(ReadSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Subscribed Event types for a Subscription. + /// + /// Read SubscribedEvent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Subscribed Event types for a Subscription. + /// + /// Subscription SID. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static ResourceSet Read(string pathSubscriptionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscribedEventOptions(pathSubscriptionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Subscribed Event types for a Subscription. + /// + /// Subscription SID. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task> ReadAsync(string pathSubscriptionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscribedEventOptions(pathSubscriptionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("types", response.Content); + } + + private static Request BuildCreateRequest(CreateSubscribedEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Subscribed Event type for the subscription + /// + /// Create SubscribedEvent parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Create(CreateSubscribedEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Subscribed Event type for the subscription + /// + /// Create SubscribedEvent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task CreateAsync(CreateSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Subscribed Event type for the subscription + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// The schema version that the subscription should use. + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Create(string pathSubscriptionSid, + string type, + int? schemaVersion = null, + ITwilioRestClient client = null) + { + var options = new CreateSubscribedEventOptions(pathSubscriptionSid, type) { SchemaVersion = schemaVersion }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Subscribed Event type for the subscription + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// The schema version that the subscription should use. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task CreateAsync(string pathSubscriptionSid, + string type, + int? schemaVersion = null, + ITwilioRestClient client = null) + { + var options = new CreateSubscribedEventOptions(pathSubscriptionSid, type) { SchemaVersion = schemaVersion }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchSubscribedEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Read an Event for a Subscription. + /// + /// Fetch SubscribedEvent parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Fetch(FetchSubscribedEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Read an Event for a Subscription. + /// + /// Fetch SubscribedEvent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Read an Event for a Subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Fetch(string pathSubscriptionSid, + string pathType, + ITwilioRestClient client = null) + { + var options = new FetchSubscribedEventOptions(pathSubscriptionSid, pathType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Read an Event for a Subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task FetchAsync(string pathSubscriptionSid, + string pathType, + ITwilioRestClient client = null) + { + var options = new FetchSubscribedEventOptions(pathSubscriptionSid, pathType); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSubscribedEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an Event for a Subscription. + /// + /// Update SubscribedEvent parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Update(UpdateSubscribedEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an Event for a Subscription. + /// + /// Update SubscribedEvent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an Event for a Subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// The schema version that the subscription should use. + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static SubscribedEventResource Update(string pathSubscriptionSid, + string pathType, + int? schemaVersion = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscribedEventOptions(pathSubscriptionSid, pathType) { SchemaVersion = schemaVersion }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an Event for a Subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// The schema version that the subscription should use. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task UpdateAsync(string pathSubscriptionSid, + string pathType, + int? schemaVersion = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscribedEventOptions(pathSubscriptionSid, pathType) { SchemaVersion = schemaVersion }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSubscribedEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSubscriptionSid + "/SubscribedEvents/" + options.PathType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an event type from a subscription. + /// + /// Delete SubscribedEvent parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static bool Delete(DeleteSubscribedEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an event type from a subscription. + /// + /// Delete SubscribedEvent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSubscribedEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an event type from a subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// Client to make requests to Twilio + /// A single instance of SubscribedEvent + public static bool Delete(string pathSubscriptionSid, string pathType, ITwilioRestClient client = null) + { + var options = new DeleteSubscribedEventOptions(pathSubscriptionSid, pathType); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an event type from a subscription. + /// + /// Subscription SID. + /// Type of event being subscribed to. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedEvent + public static async System.Threading.Tasks.Task DeleteAsync(string pathSubscriptionSid, + string pathType, + ITwilioRestClient client = null) + { + var options = new DeleteSubscribedEventOptions(pathSubscriptionSid, pathType); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SubscribedEventResource object + /// + /// Raw JSON string + /// SubscribedEventResource object represented by the provided JSON + public static SubscribedEventResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account SID. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Type of event being subscribed to. + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The schema version that the subscription should use. + /// + [JsonProperty("schema_version")] + public int? SchemaVersion { get; private set; } + /// + /// Subscription SID. + /// + [JsonProperty("subscription_sid")] + public string SubscriptionSid { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SubscribedEventResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SubscriptionOptions.cs b/src/Twilio/Rest/Events/V1/SubscriptionOptions.cs index edfd8de21..7d6bfe181 100644 --- a/src/Twilio/Rest/Events/V1/SubscriptionOptions.cs +++ b/src/Twilio/Rest/Events/V1/SubscriptionOptions.cs @@ -10,207 +10,207 @@ using Twilio.Converters; namespace Twilio.Rest.Events.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// + public class ReadSubscriptionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// Sink SID. /// - public class ReadSubscriptionOptions : ReadOptions - { - /// - /// Sink SID. - /// - public string SinkSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (SinkSid != null) - { - p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string SinkSid { get; set; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Subscription. + /// Generate the necessary parameters /// - public class FetchSubscriptionOptions : IOptions - { - /// - /// A string that uniquely identifies this Subscription. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSubscriptionOptions - /// - /// A string that uniquely identifies this Subscription. - public FetchSubscriptionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (SinkSid != null) + { + p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Subscription. + /// + public class FetchSubscriptionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Subscription. - /// - public class CreateSubscriptionOptions : IOptions - { - /// - /// Subscription description - /// - public string Description { get; } - /// - /// Sink SID. - /// - public string SinkSid { get; } - /// - /// Subscribed Event Types - /// - public List Types { get; } - - /// - /// Construct a new CreateSubscriptionOptions - /// - /// Subscription description - /// Sink SID. - /// Subscribed Event Types - public CreateSubscriptionOptions(string description, string sinkSid, List types) - { - Description = description; - SinkSid = sinkSid; - Types = types; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (SinkSid != null) - { - p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); - } - - if (Types != null) - { - p.AddRange(Types.Select(prop => new KeyValuePair("Types", Serializers.JsonObject(prop)))); - } - - return p; - } - } - + /// A string that uniquely identifies this Subscription. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a Subscription. - /// - public class UpdateSubscriptionOptions : IOptions - { - /// - /// A string that uniquely identifies this Subscription. - /// - public string PathSid { get; } - /// - /// Subscription description. - /// - public string Description { get; set; } - /// - /// Sink SID. - /// - public string SinkSid { get; set; } - - /// - /// Construct a new UpdateSubscriptionOptions - /// - /// A string that uniquely identifies this Subscription. - public UpdateSubscriptionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (SinkSid != null) - { - p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSubscriptionOptions + /// + /// A string that uniquely identifies this Subscription. + public FetchSubscriptionOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Subscription. + /// Generate the necessary parameters /// - public class DeleteSubscriptionOptions : IOptions - { - /// - /// A string that uniquely identifies this Subscription. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSubscriptionOptions - /// - /// A string that uniquely identifies this Subscription. - public DeleteSubscriptionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Subscription. + /// + public class CreateSubscriptionOptions : IOptions + { + /// + /// Subscription description + /// + public string Description { get; } + /// + /// Sink SID. + /// + public string SinkSid { get; } + /// + /// Subscribed Event Types + /// + public List Types { get; } + + /// + /// Construct a new CreateSubscriptionOptions + /// + /// Subscription description + /// Sink SID. + /// Subscribed Event Types + public CreateSubscriptionOptions(string description, string sinkSid, List types) + { + Description = description; + SinkSid = sinkSid; + Types = types; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (SinkSid != null) + { + p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); + } + + if (Types != null) + { + p.AddRange(Types.Select(prop => new KeyValuePair("Types", Serializers.JsonObject(prop)))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a Subscription. + /// + public class UpdateSubscriptionOptions : IOptions + { + /// + /// A string that uniquely identifies this Subscription. + /// + public string PathSid { get; } + /// + /// Subscription description. + /// + public string Description { get; set; } + /// + /// Sink SID. + /// + public string SinkSid { get; set; } + + /// + /// Construct a new UpdateSubscriptionOptions + /// + /// A string that uniquely identifies this Subscription. + public UpdateSubscriptionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (SinkSid != null) + { + p.Add(new KeyValuePair("SinkSid", SinkSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Subscription. + /// + public class DeleteSubscriptionOptions : IOptions + { + /// + /// A string that uniquely identifies this Subscription. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSubscriptionOptions + /// + /// A string that uniquely identifies this Subscription. + public DeleteSubscriptionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Events/V1/SubscriptionResource.cs b/src/Twilio/Rest/Events/V1/SubscriptionResource.cs index 545c0e9cb..7b6287745 100644 --- a/src/Twilio/Rest/Events/V1/SubscriptionResource.cs +++ b/src/Twilio/Rest/Events/V1/SubscriptionResource.cs @@ -18,492 +18,492 @@ using Twilio.Http; namespace Twilio.Rest.Events.V1 -{ - - public class SubscriptionResource : Resource - { - private static Request BuildReadRequest(ReadSubscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Subscriptions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. - /// - /// Read Subscription parameters - /// Client to make requests to Twilio - /// A single instance of Subscription - public static ResourceSet Read(ReadSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("subscriptions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. - /// - /// Read Subscription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("subscriptions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. - /// - /// Sink SID. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Subscription - public static ResourceSet Read(string sinkSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscriptionOptions(){SinkSid = sinkSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. - /// - /// Sink SID. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task> ReadAsync(string sinkSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscriptionOptions(){SinkSid = sinkSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("subscriptions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("subscriptions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Events) - ); - - var response = client.Request(request); - return Page.FromJson("subscriptions", response.Content); - } - - private static Request BuildFetchRequest(FetchSubscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Subscription. - /// - /// Fetch Subscription parameters - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Fetch(FetchSubscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Subscription. - /// - /// Fetch Subscription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task FetchAsync(FetchSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSubscriptionOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSubscriptionOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSubscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Subscriptions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Subscription. - /// - /// Create Subscription parameters - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Create(CreateSubscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Subscription. - /// - /// Create Subscription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task CreateAsync(CreateSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Subscription. - /// - /// Subscription description - /// Sink SID. - /// Subscribed Event Types - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Create(string description, - string sinkSid, - List types, - ITwilioRestClient client = null) - { - var options = new CreateSubscriptionOptions(description, sinkSid, types); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Subscription. - /// - /// Subscription description - /// Sink SID. - /// Subscribed Event Types - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task CreateAsync(string description, - string sinkSid, - List types, - ITwilioRestClient client = null) - { - var options = new CreateSubscriptionOptions(description, sinkSid, types); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSubscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a Subscription. - /// - /// Update Subscription parameters - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Update(UpdateSubscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a Subscription. - /// - /// Update Subscription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Subscription description. - /// Sink SID. - /// Client to make requests to Twilio - /// A single instance of Subscription - public static SubscriptionResource Update(string pathSid, - string description = null, - string sinkSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscriptionOptions(pathSid){Description = description, SinkSid = sinkSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Subscription description. - /// Sink SID. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string description = null, - string sinkSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscriptionOptions(pathSid){Description = description, SinkSid = sinkSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSubscriptionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Events, - "/v1/Subscriptions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Subscription. - /// - /// Delete Subscription parameters - /// Client to make requests to Twilio - /// A single instance of Subscription - public static bool Delete(DeleteSubscriptionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Subscription. - /// - /// Delete Subscription parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSubscriptionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Client to make requests to Twilio - /// A single instance of Subscription - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSubscriptionOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Subscription. - /// - /// A string that uniquely identifies this Subscription. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Subscription - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSubscriptionOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SubscriptionResource object - /// - /// Raw JSON string - /// SubscriptionResource object represented by the provided JSON - public static SubscriptionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account SID. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A string that uniquely identifies this Subscription. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The date this Subscription was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Subscription was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Subscription description - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// Sink SID. - /// - [JsonProperty("sink_sid")] - public string SinkSid { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private SubscriptionResource() - { - - } - } +{ + + public class SubscriptionResource : Resource + { + private static Request BuildReadRequest(ReadSubscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Subscriptions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// + /// Read Subscription parameters + /// Client to make requests to Twilio + /// A single instance of Subscription + public static ResourceSet Read(ReadSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("subscriptions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// + /// Read Subscription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("subscriptions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// + /// Sink SID. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Subscription + public static ResourceSet Read(string sinkSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscriptionOptions() { SinkSid = sinkSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a paginated list of Subscriptions belonging to the account used to make the request. + /// + /// Sink SID. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task> ReadAsync(string sinkSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscriptionOptions() { SinkSid = sinkSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("subscriptions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("subscriptions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Events) + ); + + var response = client.Request(request); + return Page.FromJson("subscriptions", response.Content); + } + + private static Request BuildFetchRequest(FetchSubscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Subscription. + /// + /// Fetch Subscription parameters + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Fetch(FetchSubscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Subscription. + /// + /// Fetch Subscription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task FetchAsync(FetchSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSubscriptionOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSubscriptionOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSubscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Subscriptions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Subscription. + /// + /// Create Subscription parameters + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Create(CreateSubscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Subscription. + /// + /// Create Subscription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task CreateAsync(CreateSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Subscription. + /// + /// Subscription description + /// Sink SID. + /// Subscribed Event Types + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Create(string description, + string sinkSid, + List types, + ITwilioRestClient client = null) + { + var options = new CreateSubscriptionOptions(description, sinkSid, types); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Subscription. + /// + /// Subscription description + /// Sink SID. + /// Subscribed Event Types + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task CreateAsync(string description, + string sinkSid, + List types, + ITwilioRestClient client = null) + { + var options = new CreateSubscriptionOptions(description, sinkSid, types); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSubscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a Subscription. + /// + /// Update Subscription parameters + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Update(UpdateSubscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a Subscription. + /// + /// Update Subscription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Subscription description. + /// Sink SID. + /// Client to make requests to Twilio + /// A single instance of Subscription + public static SubscriptionResource Update(string pathSid, + string description = null, + string sinkSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscriptionOptions(pathSid) { Description = description, SinkSid = sinkSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Subscription description. + /// Sink SID. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string description = null, + string sinkSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscriptionOptions(pathSid) { Description = description, SinkSid = sinkSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSubscriptionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Events, + "/v1/Subscriptions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Subscription. + /// + /// Delete Subscription parameters + /// Client to make requests to Twilio + /// A single instance of Subscription + public static bool Delete(DeleteSubscriptionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Subscription. + /// + /// Delete Subscription parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSubscriptionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Client to make requests to Twilio + /// A single instance of Subscription + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSubscriptionOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Subscription. + /// + /// A string that uniquely identifies this Subscription. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Subscription + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSubscriptionOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SubscriptionResource object + /// + /// Raw JSON string + /// SubscriptionResource object represented by the provided JSON + public static SubscriptionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account SID. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A string that uniquely identifies this Subscription. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The date this Subscription was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Subscription was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Subscription description + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// Sink SID. + /// + [JsonProperty("sink_sid")] + public string SinkSid { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private SubscriptionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Fax/V1/Fax/FaxMediaOptions.cs b/src/Twilio/Rest/Fax/V1/Fax/FaxMediaOptions.cs index 0bb6557de..6a3ae9baa 100644 --- a/src/Twilio/Rest/Fax/V1/Fax/FaxMediaOptions.cs +++ b/src/Twilio/Rest/Fax/V1/Fax/FaxMediaOptions.cs @@ -9,116 +9,116 @@ using Twilio.Converters; namespace Twilio.Rest.Fax.V1.Fax -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific fax media instance. + /// + public class FetchFaxMediaOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific fax media instance. + /// The SID of the fax with the FaxMedia resource to fetch /// - public class FetchFaxMediaOptions : IOptions - { - /// - /// The SID of the fax with the FaxMedia resource to fetch - /// - public string PathFaxSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFaxMediaOptions - /// - /// The SID of the fax with the FaxMedia resource to fetch - /// The unique string that identifies the resource to fetch - public FetchFaxMediaOptions(string pathFaxSid, string pathSid) - { - PathFaxSid = pathFaxSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathFaxSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all fax media instances for the specified fax. + /// The unique string that identifies the resource to fetch /// - public class ReadFaxMediaOptions : ReadOptions - { - /// - /// The SID of the fax with the FaxMedia resources to read - /// - public string PathFaxSid { get; } - - /// - /// Construct a new ReadFaxMediaOptions - /// - /// The SID of the fax with the FaxMedia resources to read - public ReadFaxMediaOptions(string pathFaxSid) - { - PathFaxSid = pathFaxSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific fax media instance. + /// Construct a new FetchFaxMediaOptions /// - public class DeleteFaxMediaOptions : IOptions - { - /// - /// The SID of the fax with the FaxMedia resource to delete - /// - public string PathFaxSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFaxMediaOptions - /// - /// The SID of the fax with the FaxMedia resource to delete - /// The unique string that identifies the resource - public DeleteFaxMediaOptions(string pathFaxSid, string pathSid) - { - PathFaxSid = pathFaxSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the fax with the FaxMedia resource to fetch + /// The unique string that identifies the resource to fetch + public FetchFaxMediaOptions(string pathFaxSid, string pathSid) + { + PathFaxSid = pathFaxSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all fax media instances for the specified fax. + /// + public class ReadFaxMediaOptions : ReadOptions + { + /// + /// The SID of the fax with the FaxMedia resources to read + /// + public string PathFaxSid { get; } + + /// + /// Construct a new ReadFaxMediaOptions + /// + /// The SID of the fax with the FaxMedia resources to read + public ReadFaxMediaOptions(string pathFaxSid) + { + PathFaxSid = pathFaxSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific fax media instance. + /// + public class DeleteFaxMediaOptions : IOptions + { + /// + /// The SID of the fax with the FaxMedia resource to delete + /// + public string PathFaxSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFaxMediaOptions + /// + /// The SID of the fax with the FaxMedia resource to delete + /// The unique string that identifies the resource + public DeleteFaxMediaOptions(string pathFaxSid, string pathSid) + { + PathFaxSid = pathFaxSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Fax/V1/Fax/FaxMediaResource.cs b/src/Twilio/Rest/Fax/V1/Fax/FaxMediaResource.cs index d5192c3c8..19f6991bc 100644 --- a/src/Twilio/Rest/Fax/V1/Fax/FaxMediaResource.cs +++ b/src/Twilio/Rest/Fax/V1/Fax/FaxMediaResource.cs @@ -18,341 +18,341 @@ using Twilio.Http; namespace Twilio.Rest.Fax.V1.Fax -{ - - public class FaxMediaResource : Resource - { - private static Request BuildFetchRequest(FetchFaxMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathFaxSid + "/Media/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific fax media instance. - /// - /// Fetch FaxMedia parameters - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static FaxMediaResource Fetch(FetchFaxMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific fax media instance. - /// - /// Fetch FaxMedia parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task FetchAsync(FetchFaxMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific fax media instance. - /// - /// The SID of the fax with the FaxMedia resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static FaxMediaResource Fetch(string pathFaxSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFaxMediaOptions(pathFaxSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific fax media instance. - /// - /// The SID of the fax with the FaxMedia resource to fetch - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task FetchAsync(string pathFaxSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFaxMediaOptions(pathFaxSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFaxMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathFaxSid + "/Media", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all fax media instances for the specified fax. - /// - /// Read FaxMedia parameters - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static ResourceSet Read(ReadFaxMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("media", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all fax media instances for the specified fax. - /// - /// Read FaxMedia parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task> ReadAsync(ReadFaxMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("media", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all fax media instances for the specified fax. - /// - /// The SID of the fax with the FaxMedia resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static ResourceSet Read(string pathFaxSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFaxMediaOptions(pathFaxSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all fax media instances for the specified fax. - /// - /// The SID of the fax with the FaxMedia resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task> ReadAsync(string pathFaxSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFaxMediaOptions(pathFaxSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("media", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Fax) - ); - - var response = client.Request(request); - return Page.FromJson("media", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Fax) - ); - - var response = client.Request(request); - return Page.FromJson("media", response.Content); - } - - private static Request BuildDeleteRequest(DeleteFaxMediaOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathFaxSid + "/Media/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific fax media instance. - /// - /// Delete FaxMedia parameters - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static bool Delete(DeleteFaxMediaOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific fax media instance. - /// - /// Delete FaxMedia parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFaxMediaOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific fax media instance. - /// - /// The SID of the fax with the FaxMedia resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of FaxMedia - public static bool Delete(string pathFaxSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFaxMediaOptions(pathFaxSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific fax media instance. - /// - /// The SID of the fax with the FaxMedia resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FaxMedia - public static async System.Threading.Tasks.Task DeleteAsync(string pathFaxSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFaxMediaOptions(pathFaxSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FaxMediaResource object - /// - /// Raw JSON string - /// FaxMediaResource object represented by the provided JSON - public static FaxMediaResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the fax the FaxMedia resource is associated with - /// - [JsonProperty("fax_sid")] - public string FaxSid { get; private set; } - /// - /// The content type of the stored fax media - /// - [JsonProperty("content_type")] - public string ContentType { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the FaxMedia resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FaxMediaResource() - { - - } - } +{ + + public class FaxMediaResource : Resource + { + private static Request BuildFetchRequest(FetchFaxMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathFaxSid + "/Media/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific fax media instance. + /// + /// Fetch FaxMedia parameters + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static FaxMediaResource Fetch(FetchFaxMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific fax media instance. + /// + /// Fetch FaxMedia parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task FetchAsync(FetchFaxMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific fax media instance. + /// + /// The SID of the fax with the FaxMedia resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static FaxMediaResource Fetch(string pathFaxSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFaxMediaOptions(pathFaxSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific fax media instance. + /// + /// The SID of the fax with the FaxMedia resource to fetch + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task FetchAsync(string pathFaxSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFaxMediaOptions(pathFaxSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFaxMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathFaxSid + "/Media", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all fax media instances for the specified fax. + /// + /// Read FaxMedia parameters + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static ResourceSet Read(ReadFaxMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("media", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all fax media instances for the specified fax. + /// + /// Read FaxMedia parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task> ReadAsync(ReadFaxMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("media", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all fax media instances for the specified fax. + /// + /// The SID of the fax with the FaxMedia resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static ResourceSet Read(string pathFaxSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFaxMediaOptions(pathFaxSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all fax media instances for the specified fax. + /// + /// The SID of the fax with the FaxMedia resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task> ReadAsync(string pathFaxSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFaxMediaOptions(pathFaxSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("media", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Fax) + ); + + var response = client.Request(request); + return Page.FromJson("media", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Fax) + ); + + var response = client.Request(request); + return Page.FromJson("media", response.Content); + } + + private static Request BuildDeleteRequest(DeleteFaxMediaOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathFaxSid + "/Media/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific fax media instance. + /// + /// Delete FaxMedia parameters + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static bool Delete(DeleteFaxMediaOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific fax media instance. + /// + /// Delete FaxMedia parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFaxMediaOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific fax media instance. + /// + /// The SID of the fax with the FaxMedia resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of FaxMedia + public static bool Delete(string pathFaxSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFaxMediaOptions(pathFaxSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific fax media instance. + /// + /// The SID of the fax with the FaxMedia resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FaxMedia + public static async System.Threading.Tasks.Task DeleteAsync(string pathFaxSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFaxMediaOptions(pathFaxSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FaxMediaResource object + /// + /// Raw JSON string + /// FaxMediaResource object represented by the provided JSON + public static FaxMediaResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the fax the FaxMedia resource is associated with + /// + [JsonProperty("fax_sid")] + public string FaxSid { get; private set; } + /// + /// The content type of the stored fax media + /// + [JsonProperty("content_type")] + public string ContentType { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the FaxMedia resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FaxMediaResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Fax/V1/FaxOptions.cs b/src/Twilio/Rest/Fax/V1/FaxOptions.cs index 67e9d651d..25aeb9d86 100644 --- a/src/Twilio/Rest/Fax/V1/FaxOptions.cs +++ b/src/Twilio/Rest/Fax/V1/FaxOptions.cs @@ -9,277 +9,277 @@ using Twilio.Converters; namespace Twilio.Rest.Fax.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific fax. + /// + public class FetchFaxOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific fax. + /// The unique string that identifies the resource /// - public class FetchFaxOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFaxOptions - /// - /// The unique string that identifies the resource - public FetchFaxOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all faxes. + /// Construct a new FetchFaxOptions /// - public class ReadFaxOptions : ReadOptions - { - /// - /// Retrieve only those faxes sent from this phone number - /// - public string From { get; set; } - /// - /// Retrieve only those faxes sent to this phone number - /// - public string To { get; set; } - /// - /// Retrieve only faxes created on or before this date - /// - public DateTime? DateCreatedOnOrBefore { get; set; } - /// - /// Retrieve only faxes created after this date - /// - public DateTime? DateCreatedAfter { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (DateCreatedOnOrBefore != null) - { - p.Add(new KeyValuePair("DateCreatedOnOrBefore", Serializers.DateTimeIso8601(DateCreatedOnOrBefore))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + public FetchFaxOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new fax to send to a phone number or SIP endpoint. + /// Generate the necessary parameters /// - public class CreateFaxOptions : IOptions - { - /// - /// The phone number to receive the fax - /// - public string To { get; } - /// - /// The URL of the PDF that contains the fax - /// - public Uri MediaUrl { get; } - /// - /// The quality of this fax - /// - public FaxResource.QualityEnum Quality { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The number the fax was sent from - /// - public string From { get; set; } - /// - /// The username for SIP authentication - /// - public string SipAuthUsername { get; set; } - /// - /// The password for SIP authentication - /// - public string SipAuthPassword { get; set; } - /// - /// Whether to store a copy of the sent media - /// - public bool? StoreMedia { get; set; } - /// - /// How long in minutes to try to send the fax - /// - public int? Ttl { get; set; } - - /// - /// Construct a new CreateFaxOptions - /// - /// The phone number to receive the fax - /// The URL of the PDF that contains the fax - public CreateFaxOptions(string to, Uri mediaUrl) - { - To = to; - MediaUrl = mediaUrl; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (MediaUrl != null) - { - p.Add(new KeyValuePair("MediaUrl", Serializers.Url(MediaUrl))); - } - - if (Quality != null) - { - p.Add(new KeyValuePair("Quality", Quality.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (SipAuthUsername != null) - { - p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); - } - - if (SipAuthPassword != null) - { - p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); - } - - if (StoreMedia != null) - { - p.Add(new KeyValuePair("StoreMedia", StoreMedia.Value.ToString().ToLower())); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all faxes. + /// + public class ReadFaxOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific fax. + /// Retrieve only those faxes sent from this phone number /// - public class UpdateFaxOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The new status of the resource - /// - public FaxResource.UpdateStatusEnum Status { get; set; } - - /// - /// Construct a new UpdateFaxOptions - /// - /// The unique string that identifies the resource - public UpdateFaxOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } - + public string From { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific fax and its associated media. + /// Retrieve only those faxes sent to this phone number /// - public class DeleteFaxOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFaxOptions - /// - /// The unique string that identifies the resource - public DeleteFaxOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string To { get; set; } + /// + /// Retrieve only faxes created on or before this date + /// + public DateTime? DateCreatedOnOrBefore { get; set; } + /// + /// Retrieve only faxes created after this date + /// + public DateTime? DateCreatedAfter { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (DateCreatedOnOrBefore != null) + { + p.Add(new KeyValuePair("DateCreatedOnOrBefore", Serializers.DateTimeIso8601(DateCreatedOnOrBefore))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new fax to send to a phone number or SIP endpoint. + /// + public class CreateFaxOptions : IOptions + { + /// + /// The phone number to receive the fax + /// + public string To { get; } + /// + /// The URL of the PDF that contains the fax + /// + public Uri MediaUrl { get; } + /// + /// The quality of this fax + /// + public FaxResource.QualityEnum Quality { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The number the fax was sent from + /// + public string From { get; set; } + /// + /// The username for SIP authentication + /// + public string SipAuthUsername { get; set; } + /// + /// The password for SIP authentication + /// + public string SipAuthPassword { get; set; } + /// + /// Whether to store a copy of the sent media + /// + public bool? StoreMedia { get; set; } + /// + /// How long in minutes to try to send the fax + /// + public int? Ttl { get; set; } + + /// + /// Construct a new CreateFaxOptions + /// + /// The phone number to receive the fax + /// The URL of the PDF that contains the fax + public CreateFaxOptions(string to, Uri mediaUrl) + { + To = to; + MediaUrl = mediaUrl; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (MediaUrl != null) + { + p.Add(new KeyValuePair("MediaUrl", Serializers.Url(MediaUrl))); + } + + if (Quality != null) + { + p.Add(new KeyValuePair("Quality", Quality.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (SipAuthUsername != null) + { + p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); + } + + if (SipAuthPassword != null) + { + p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); + } + + if (StoreMedia != null) + { + p.Add(new KeyValuePair("StoreMedia", StoreMedia.Value.ToString().ToLower())); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific fax. + /// + public class UpdateFaxOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The new status of the resource + /// + public FaxResource.UpdateStatusEnum Status { get; set; } + + /// + /// Construct a new UpdateFaxOptions + /// + /// The unique string that identifies the resource + public UpdateFaxOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific fax and its associated media. + /// + public class DeleteFaxOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFaxOptions + /// + /// The unique string that identifies the resource + public DeleteFaxOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Fax/V1/FaxResource.cs b/src/Twilio/Rest/Fax/V1/FaxResource.cs index 8ae7b7bec..cde83ed01 100644 --- a/src/Twilio/Rest/Fax/V1/FaxResource.cs +++ b/src/Twilio/Rest/Fax/V1/FaxResource.cs @@ -19,636 +19,636 @@ using Twilio.Types; namespace Twilio.Rest.Fax.V1 -{ - - public class FaxResource : Resource - { - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum Inbound = new DirectionEnum("inbound"); - public static readonly DirectionEnum Outbound = new DirectionEnum("outbound"); - } - - public sealed class QualityEnum : StringEnum - { - private QualityEnum(string value) : base(value) {} - public QualityEnum() {} - public static implicit operator QualityEnum(string value) - { - return new QualityEnum(value); - } - - public static readonly QualityEnum Standard = new QualityEnum("standard"); - public static readonly QualityEnum Fine = new QualityEnum("fine"); - public static readonly QualityEnum Superfine = new QualityEnum("superfine"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Sending = new StatusEnum("sending"); - public static readonly StatusEnum Delivered = new StatusEnum("delivered"); - public static readonly StatusEnum Receiving = new StatusEnum("receiving"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum NoAnswer = new StatusEnum("no-answer"); - public static readonly StatusEnum Busy = new StatusEnum("busy"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); - } - - private static Request BuildFetchRequest(FetchFaxOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific fax. - /// - /// Fetch Fax parameters - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Fetch(FetchFaxOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific fax. - /// - /// Fetch Fax parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task FetchAsync(FetchFaxOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific fax. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFaxOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific fax. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFaxOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFaxOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Fax, - "/v1/Faxes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all faxes. - /// - /// Read Fax parameters - /// Client to make requests to Twilio - /// A single instance of Fax - public static ResourceSet Read(ReadFaxOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("faxes", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all faxes. - /// - /// Read Fax parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task> ReadAsync(ReadFaxOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("faxes", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all faxes. - /// - /// Retrieve only those faxes sent from this phone number - /// Retrieve only those faxes sent to this phone number - /// Retrieve only faxes created on or before this date - /// Retrieve only faxes created after this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Fax - public static ResourceSet Read(string from = null, - string to = null, - DateTime? dateCreatedOnOrBefore = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFaxOptions(){From = from, To = to, DateCreatedOnOrBefore = dateCreatedOnOrBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all faxes. - /// - /// Retrieve only those faxes sent from this phone number - /// Retrieve only those faxes sent to this phone number - /// Retrieve only faxes created on or before this date - /// Retrieve only faxes created after this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task> ReadAsync(string from = null, - string to = null, - DateTime? dateCreatedOnOrBefore = null, - DateTime? dateCreatedAfter = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFaxOptions(){From = from, To = to, DateCreatedOnOrBefore = dateCreatedOnOrBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("faxes", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Fax) - ); - - var response = client.Request(request); - return Page.FromJson("faxes", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Fax) - ); - - var response = client.Request(request); - return Page.FromJson("faxes", response.Content); - } - - private static Request BuildCreateRequest(CreateFaxOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Fax, - "/v1/Faxes", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new fax to send to a phone number or SIP endpoint. - /// - /// Create Fax parameters - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Create(CreateFaxOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new fax to send to a phone number or SIP endpoint. - /// - /// Create Fax parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task CreateAsync(CreateFaxOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new fax to send to a phone number or SIP endpoint. - /// - /// The phone number to receive the fax - /// The URL of the PDF that contains the fax - /// The quality of this fax - /// The URL we should call to send status information to your application - /// The number the fax was sent from - /// The username for SIP authentication - /// The password for SIP authentication - /// Whether to store a copy of the sent media - /// How long in minutes to try to send the fax - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Create(string to, - Uri mediaUrl, - FaxResource.QualityEnum quality = null, - Uri statusCallback = null, - string from = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - bool? storeMedia = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateFaxOptions(to, mediaUrl){Quality = quality, StatusCallback = statusCallback, From = from, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, StoreMedia = storeMedia, Ttl = ttl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new fax to send to a phone number or SIP endpoint. - /// - /// The phone number to receive the fax - /// The URL of the PDF that contains the fax - /// The quality of this fax - /// The URL we should call to send status information to your application - /// The number the fax was sent from - /// The username for SIP authentication - /// The password for SIP authentication - /// Whether to store a copy of the sent media - /// How long in minutes to try to send the fax - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task CreateAsync(string to, - Uri mediaUrl, - FaxResource.QualityEnum quality = null, - Uri statusCallback = null, - string from = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - bool? storeMedia = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateFaxOptions(to, mediaUrl){Quality = quality, StatusCallback = statusCallback, From = from, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, StoreMedia = storeMedia, Ttl = ttl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFaxOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific fax. - /// - /// Update Fax parameters - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Update(UpdateFaxOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific fax. - /// - /// Update Fax parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFaxOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific fax. - /// - /// The unique string that identifies the resource - /// The new status of the resource - /// Client to make requests to Twilio - /// A single instance of Fax - public static FaxResource Update(string pathSid, - FaxResource.UpdateStatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateFaxOptions(pathSid){Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific fax. - /// - /// The unique string that identifies the resource - /// The new status of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - FaxResource.UpdateStatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateFaxOptions(pathSid){Status = status}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFaxOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Fax, - "/v1/Faxes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific fax and its associated media. - /// - /// Delete Fax parameters - /// Client to make requests to Twilio - /// A single instance of Fax - public static bool Delete(DeleteFaxOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific fax and its associated media. - /// - /// Delete Fax parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFaxOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific fax and its associated media. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Fax - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFaxOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific fax and its associated media. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fax - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFaxOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FaxResource object - /// - /// Raw JSON string - /// FaxResource object represented by the provided JSON - public static FaxResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number the fax was sent from - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The phone number that received the fax - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The quality of the fax - /// - [JsonProperty("quality")] - [JsonConverter(typeof(StringEnumConverter))] - public FaxResource.QualityEnum Quality { get; private set; } - /// - /// The SID of the FaxMedia resource that is associated with the Fax - /// - [JsonProperty("media_sid")] - public string MediaSid { get; private set; } - /// - /// The Twilio-hosted URL that can be used to download fax media - /// - [JsonProperty("media_url")] - public string MediaUrl { get; private set; } - /// - /// The number of pages contained in the fax document - /// - [JsonProperty("num_pages")] - public int? NumPages { get; private set; } - /// - /// The time it took to transmit the fax - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The status of the fax - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FaxResource.StatusEnum Status { get; private set; } - /// - /// The direction of the fax - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public FaxResource.DirectionEnum Direction { get; private set; } - /// - /// The API version used to transmit the fax - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The fax transmission price - /// - [JsonProperty("price")] - public decimal? Price { get; private set; } - /// - /// The ISO 4217 currency used for billing - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The ISO 8601 formatted date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 formatted date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URLs of the fax's related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The absolute URL of the fax resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FaxResource() - { - - } - } +{ + + public class FaxResource : Resource + { + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum Inbound = new DirectionEnum("inbound"); + public static readonly DirectionEnum Outbound = new DirectionEnum("outbound"); + } + + public sealed class QualityEnum : StringEnum + { + private QualityEnum(string value) : base(value) { } + public QualityEnum() { } + public static implicit operator QualityEnum(string value) + { + return new QualityEnum(value); + } + + public static readonly QualityEnum Standard = new QualityEnum("standard"); + public static readonly QualityEnum Fine = new QualityEnum("fine"); + public static readonly QualityEnum Superfine = new QualityEnum("superfine"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Sending = new StatusEnum("sending"); + public static readonly StatusEnum Delivered = new StatusEnum("delivered"); + public static readonly StatusEnum Receiving = new StatusEnum("receiving"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum NoAnswer = new StatusEnum("no-answer"); + public static readonly StatusEnum Busy = new StatusEnum("busy"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Canceled = new UpdateStatusEnum("canceled"); + } + + private static Request BuildFetchRequest(FetchFaxOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific fax. + /// + /// Fetch Fax parameters + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Fetch(FetchFaxOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific fax. + /// + /// Fetch Fax parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task FetchAsync(FetchFaxOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific fax. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFaxOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific fax. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFaxOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFaxOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Fax, + "/v1/Faxes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all faxes. + /// + /// Read Fax parameters + /// Client to make requests to Twilio + /// A single instance of Fax + public static ResourceSet Read(ReadFaxOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("faxes", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all faxes. + /// + /// Read Fax parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task> ReadAsync(ReadFaxOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("faxes", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all faxes. + /// + /// Retrieve only those faxes sent from this phone number + /// Retrieve only those faxes sent to this phone number + /// Retrieve only faxes created on or before this date + /// Retrieve only faxes created after this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Fax + public static ResourceSet Read(string from = null, + string to = null, + DateTime? dateCreatedOnOrBefore = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFaxOptions() { From = from, To = to, DateCreatedOnOrBefore = dateCreatedOnOrBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all faxes. + /// + /// Retrieve only those faxes sent from this phone number + /// Retrieve only those faxes sent to this phone number + /// Retrieve only faxes created on or before this date + /// Retrieve only faxes created after this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task> ReadAsync(string from = null, + string to = null, + DateTime? dateCreatedOnOrBefore = null, + DateTime? dateCreatedAfter = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFaxOptions() { From = from, To = to, DateCreatedOnOrBefore = dateCreatedOnOrBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("faxes", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Fax) + ); + + var response = client.Request(request); + return Page.FromJson("faxes", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Fax) + ); + + var response = client.Request(request); + return Page.FromJson("faxes", response.Content); + } + + private static Request BuildCreateRequest(CreateFaxOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Fax, + "/v1/Faxes", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new fax to send to a phone number or SIP endpoint. + /// + /// Create Fax parameters + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Create(CreateFaxOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new fax to send to a phone number or SIP endpoint. + /// + /// Create Fax parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task CreateAsync(CreateFaxOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new fax to send to a phone number or SIP endpoint. + /// + /// The phone number to receive the fax + /// The URL of the PDF that contains the fax + /// The quality of this fax + /// The URL we should call to send status information to your application + /// The number the fax was sent from + /// The username for SIP authentication + /// The password for SIP authentication + /// Whether to store a copy of the sent media + /// How long in minutes to try to send the fax + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Create(string to, + Uri mediaUrl, + FaxResource.QualityEnum quality = null, + Uri statusCallback = null, + string from = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + bool? storeMedia = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateFaxOptions(to, mediaUrl) { Quality = quality, StatusCallback = statusCallback, From = from, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, StoreMedia = storeMedia, Ttl = ttl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new fax to send to a phone number or SIP endpoint. + /// + /// The phone number to receive the fax + /// The URL of the PDF that contains the fax + /// The quality of this fax + /// The URL we should call to send status information to your application + /// The number the fax was sent from + /// The username for SIP authentication + /// The password for SIP authentication + /// Whether to store a copy of the sent media + /// How long in minutes to try to send the fax + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task CreateAsync(string to, + Uri mediaUrl, + FaxResource.QualityEnum quality = null, + Uri statusCallback = null, + string from = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + bool? storeMedia = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateFaxOptions(to, mediaUrl) { Quality = quality, StatusCallback = statusCallback, From = from, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, StoreMedia = storeMedia, Ttl = ttl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFaxOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific fax. + /// + /// Update Fax parameters + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Update(UpdateFaxOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific fax. + /// + /// Update Fax parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFaxOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific fax. + /// + /// The unique string that identifies the resource + /// The new status of the resource + /// Client to make requests to Twilio + /// A single instance of Fax + public static FaxResource Update(string pathSid, + FaxResource.UpdateStatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateFaxOptions(pathSid) { Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific fax. + /// + /// The unique string that identifies the resource + /// The new status of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + FaxResource.UpdateStatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateFaxOptions(pathSid) { Status = status }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFaxOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Fax, + "/v1/Faxes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific fax and its associated media. + /// + /// Delete Fax parameters + /// Client to make requests to Twilio + /// A single instance of Fax + public static bool Delete(DeleteFaxOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific fax and its associated media. + /// + /// Delete Fax parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFaxOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific fax and its associated media. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Fax + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFaxOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific fax and its associated media. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fax + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFaxOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FaxResource object + /// + /// Raw JSON string + /// FaxResource object represented by the provided JSON + public static FaxResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number the fax was sent from + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The phone number that received the fax + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The quality of the fax + /// + [JsonProperty("quality")] + [JsonConverter(typeof(StringEnumConverter))] + public FaxResource.QualityEnum Quality { get; private set; } + /// + /// The SID of the FaxMedia resource that is associated with the Fax + /// + [JsonProperty("media_sid")] + public string MediaSid { get; private set; } + /// + /// The Twilio-hosted URL that can be used to download fax media + /// + [JsonProperty("media_url")] + public string MediaUrl { get; private set; } + /// + /// The number of pages contained in the fax document + /// + [JsonProperty("num_pages")] + public int? NumPages { get; private set; } + /// + /// The time it took to transmit the fax + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The status of the fax + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FaxResource.StatusEnum Status { get; private set; } + /// + /// The direction of the fax + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public FaxResource.DirectionEnum Direction { get; private set; } + /// + /// The API version used to transmit the fax + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The fax transmission price + /// + [JsonProperty("price")] + public decimal? Price { get; private set; } + /// + /// The ISO 4217 currency used for billing + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The ISO 8601 formatted date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 formatted date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URLs of the fax's related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The absolute URL of the fax resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FaxResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/ChannelOptions.cs b/src/Twilio/Rest/FlexApi/V1/ChannelOptions.cs index 39d698f34..de09b3b63 100644 --- a/src/Twilio/Rest/FlexApi/V1/ChannelOptions.cs +++ b/src/Twilio/Rest/FlexApi/V1/ChannelOptions.cs @@ -9,208 +9,208 @@ using Twilio.Converters; namespace Twilio.Rest.FlexApi.V1 -{ - +{ + + /// + /// ReadChannelOptions + /// + public class ReadChannelOptions : ReadOptions + { /// - /// ReadChannelOptions - /// - public class ReadChannelOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchChannelOptions + /// + public class FetchChannelOptions : IOptions + { /// - /// FetchChannelOptions + /// The SID that identifies the Flex chat channel resource to fetch /// - public class FetchChannelOptions : IOptions - { - /// - /// The SID that identifies the Flex chat channel resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChannelOptions - /// - /// The SID that identifies the Flex chat channel resource to fetch - public FetchChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateChannelOptions - /// - public class CreateChannelOptions : IOptions - { - /// - /// The SID of the Flex Flow - /// - public string FlexFlowSid { get; } - /// - /// The identity value that identifies the new resource's chat User - /// - public string Identity { get; } - /// - /// The chat participant's friendly name - /// - public string ChatUserFriendlyName { get; } - /// - /// The chat channel's friendly name - /// - public string ChatFriendlyName { get; } - /// - /// The Target Contact Identity - /// - public string Target { get; set; } - /// - /// The chat channel's unique name - /// - public string ChatUniqueName { get; set; } - /// - /// The pre-engagement data - /// - public string PreEngagementData { get; set; } - /// - /// The SID of the TaskRouter Task - /// - public string TaskSid { get; set; } - /// - /// The Task attributes to be added for the TaskRouter Task - /// - public string TaskAttributes { get; set; } - /// - /// Whether to create the channel as long-lived - /// - public bool? LongLived { get; set; } - - /// - /// Construct a new CreateChannelOptions - /// - /// The SID of the Flex Flow - /// The identity value that identifies the new resource's chat User - /// The chat participant's friendly name - /// The chat channel's friendly name - public CreateChannelOptions(string flexFlowSid, - string identity, - string chatUserFriendlyName, - string chatFriendlyName) - { - FlexFlowSid = flexFlowSid; - Identity = identity; - ChatUserFriendlyName = chatUserFriendlyName; - ChatFriendlyName = chatFriendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FlexFlowSid != null) - { - p.Add(new KeyValuePair("FlexFlowSid", FlexFlowSid.ToString())); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (ChatUserFriendlyName != null) - { - p.Add(new KeyValuePair("ChatUserFriendlyName", ChatUserFriendlyName)); - } - - if (ChatFriendlyName != null) - { - p.Add(new KeyValuePair("ChatFriendlyName", ChatFriendlyName)); - } - - if (Target != null) - { - p.Add(new KeyValuePair("Target", Target)); - } - - if (ChatUniqueName != null) - { - p.Add(new KeyValuePair("ChatUniqueName", ChatUniqueName)); - } - - if (PreEngagementData != null) - { - p.Add(new KeyValuePair("PreEngagementData", PreEngagementData)); - } - - if (TaskSid != null) - { - p.Add(new KeyValuePair("TaskSid", TaskSid.ToString())); - } - - if (TaskAttributes != null) - { - p.Add(new KeyValuePair("TaskAttributes", TaskAttributes)); - } - - if (LongLived != null) - { - p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Construct a new FetchChannelOptions + /// + /// The SID that identifies the Flex chat channel resource to fetch + public FetchChannelOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// DeleteChannelOptions + /// Generate the necessary parameters /// - public class DeleteChannelOptions : IOptions - { - /// - /// The SID of the Flex chat channel resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteChannelOptions - /// - /// The SID of the Flex chat channel resource to delete - public DeleteChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateChannelOptions + /// + public class CreateChannelOptions : IOptions + { + /// + /// The SID of the Flex Flow + /// + public string FlexFlowSid { get; } + /// + /// The identity value that identifies the new resource's chat User + /// + public string Identity { get; } + /// + /// The chat participant's friendly name + /// + public string ChatUserFriendlyName { get; } + /// + /// The chat channel's friendly name + /// + public string ChatFriendlyName { get; } + /// + /// The Target Contact Identity + /// + public string Target { get; set; } + /// + /// The chat channel's unique name + /// + public string ChatUniqueName { get; set; } + /// + /// The pre-engagement data + /// + public string PreEngagementData { get; set; } + /// + /// The SID of the TaskRouter Task + /// + public string TaskSid { get; set; } + /// + /// The Task attributes to be added for the TaskRouter Task + /// + public string TaskAttributes { get; set; } + /// + /// Whether to create the channel as long-lived + /// + public bool? LongLived { get; set; } + + /// + /// Construct a new CreateChannelOptions + /// + /// The SID of the Flex Flow + /// The identity value that identifies the new resource's chat User + /// The chat participant's friendly name + /// The chat channel's friendly name + public CreateChannelOptions(string flexFlowSid, + string identity, + string chatUserFriendlyName, + string chatFriendlyName) + { + FlexFlowSid = flexFlowSid; + Identity = identity; + ChatUserFriendlyName = chatUserFriendlyName; + ChatFriendlyName = chatFriendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FlexFlowSid != null) + { + p.Add(new KeyValuePair("FlexFlowSid", FlexFlowSid.ToString())); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (ChatUserFriendlyName != null) + { + p.Add(new KeyValuePair("ChatUserFriendlyName", ChatUserFriendlyName)); + } + + if (ChatFriendlyName != null) + { + p.Add(new KeyValuePair("ChatFriendlyName", ChatFriendlyName)); + } + + if (Target != null) + { + p.Add(new KeyValuePair("Target", Target)); + } + + if (ChatUniqueName != null) + { + p.Add(new KeyValuePair("ChatUniqueName", ChatUniqueName)); + } + + if (PreEngagementData != null) + { + p.Add(new KeyValuePair("PreEngagementData", PreEngagementData)); + } + + if (TaskSid != null) + { + p.Add(new KeyValuePair("TaskSid", TaskSid.ToString())); + } + + if (TaskAttributes != null) + { + p.Add(new KeyValuePair("TaskAttributes", TaskAttributes)); + } + + if (LongLived != null) + { + p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// DeleteChannelOptions + /// + public class DeleteChannelOptions : IOptions + { + /// + /// The SID of the Flex chat channel resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteChannelOptions + /// + /// The SID of the Flex chat channel resource to delete + public DeleteChannelOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/ChannelResource.cs b/src/Twilio/Rest/FlexApi/V1/ChannelResource.cs index f56a387f1..22ac60775 100644 --- a/src/Twilio/Rest/FlexApi/V1/ChannelResource.cs +++ b/src/Twilio/Rest/FlexApi/V1/ChannelResource.cs @@ -16,439 +16,439 @@ using Twilio.Http; namespace Twilio.Rest.FlexApi.V1 -{ - - public class ChannelResource : Resource - { - private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_chat_channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_chat_channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the Flex chat channel resource to fetch - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the Flex chat channel resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/Channels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Flex Flow - /// The identity value that identifies the new resource's chat User - /// The chat participant's friendly name - /// The chat channel's friendly name - /// The Target Contact Identity - /// The chat channel's unique name - /// The pre-engagement data - /// The SID of the TaskRouter Task - /// The Task attributes to be added for the TaskRouter Task - /// Whether to create the channel as long-lived - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string flexFlowSid, - string identity, - string chatUserFriendlyName, - string chatFriendlyName, - string target = null, - string chatUniqueName = null, - string preEngagementData = null, - string taskSid = null, - string taskAttributes = null, - bool? longLived = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(flexFlowSid, identity, chatUserFriendlyName, chatFriendlyName){Target = target, ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData, TaskSid = taskSid, TaskAttributes = taskAttributes, LongLived = longLived}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Flex Flow - /// The identity value that identifies the new resource's chat User - /// The chat participant's friendly name - /// The chat channel's friendly name - /// The Target Contact Identity - /// The chat channel's unique name - /// The pre-engagement data - /// The SID of the TaskRouter Task - /// The Task attributes to be added for the TaskRouter Task - /// Whether to create the channel as long-lived - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string flexFlowSid, - string identity, - string chatUserFriendlyName, - string chatFriendlyName, - string target = null, - string chatUniqueName = null, - string preEngagementData = null, - string taskSid = null, - string taskAttributes = null, - bool? longLived = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(flexFlowSid, identity, chatUserFriendlyName, chatFriendlyName){Target = target, ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData, TaskSid = taskSid, TaskAttributes = taskAttributes, LongLived = longLived}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.FlexApi, - "/v1/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Flex chat channel resource to delete - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Flex chat channel resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource and owns this Workflow - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flex Flow - /// - [JsonProperty("flex_flow_sid")] - public string FlexFlowSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the chat user - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The SID of the TaskRouter Task - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The absolute URL of the Flex chat channel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Flex chat channel was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Flex chat channel was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_chat_channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_chat_channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the Flex chat channel resource to fetch + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the Flex chat channel resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/Channels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Flex Flow + /// The identity value that identifies the new resource's chat User + /// The chat participant's friendly name + /// The chat channel's friendly name + /// The Target Contact Identity + /// The chat channel's unique name + /// The pre-engagement data + /// The SID of the TaskRouter Task + /// The Task attributes to be added for the TaskRouter Task + /// Whether to create the channel as long-lived + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string flexFlowSid, + string identity, + string chatUserFriendlyName, + string chatFriendlyName, + string target = null, + string chatUniqueName = null, + string preEngagementData = null, + string taskSid = null, + string taskAttributes = null, + bool? longLived = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(flexFlowSid, identity, chatUserFriendlyName, chatFriendlyName) { Target = target, ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData, TaskSid = taskSid, TaskAttributes = taskAttributes, LongLived = longLived }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Flex Flow + /// The identity value that identifies the new resource's chat User + /// The chat participant's friendly name + /// The chat channel's friendly name + /// The Target Contact Identity + /// The chat channel's unique name + /// The pre-engagement data + /// The SID of the TaskRouter Task + /// The Task attributes to be added for the TaskRouter Task + /// Whether to create the channel as long-lived + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string flexFlowSid, + string identity, + string chatUserFriendlyName, + string chatFriendlyName, + string target = null, + string chatUniqueName = null, + string preEngagementData = null, + string taskSid = null, + string taskAttributes = null, + bool? longLived = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(flexFlowSid, identity, chatUserFriendlyName, chatFriendlyName) { Target = target, ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData, TaskSid = taskSid, TaskAttributes = taskAttributes, LongLived = longLived }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.FlexApi, + "/v1/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Flex chat channel resource to delete + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Flex chat channel resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource and owns this Workflow + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flex Flow + /// + [JsonProperty("flex_flow_sid")] + public string FlexFlowSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the chat user + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The SID of the TaskRouter Task + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The absolute URL of the Flex chat channel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Flex chat channel was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Flex chat channel was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.cs b/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.cs index 166512856..f94b7309b 100644 --- a/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.cs +++ b/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.cs @@ -9,61 +9,61 @@ using Twilio.Converters; namespace Twilio.Rest.FlexApi.V1 -{ - +{ + + /// + /// FetchConfigurationOptions + /// + public class FetchConfigurationOptions : IOptions + { /// - /// FetchConfigurationOptions + /// The Pinned UI version of the Configuration resource to fetch /// - public class FetchConfigurationOptions : IOptions - { - /// - /// The Pinned UI version of the Configuration resource to fetch - /// - public string UiVersion { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UiVersion != null) - { - p.Add(new KeyValuePair("UiVersion", UiVersion)); - } - - return p; - } - } - + public string UiVersion { get; set; } + /// - /// CreateConfigurationOptions + /// Generate the necessary parameters /// - public class CreateConfigurationOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + if (UiVersion != null) + { + p.Add(new KeyValuePair("UiVersion", UiVersion)); + } + + return p; + } + } + + /// + /// CreateConfigurationOptions + /// + public class CreateConfigurationOptions : IOptions + { + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateConfigurationOptions + /// + public class UpdateConfigurationOptions : IOptions + { /// - /// UpdateConfigurationOptions + /// Generate the necessary parameters /// - public class UpdateConfigurationOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/ConfigurationResource.cs b/src/Twilio/Rest/FlexApi/V1/ConfigurationResource.cs index c98b0f47b..92dc808cb 100644 --- a/src/Twilio/Rest/FlexApi/V1/ConfigurationResource.cs +++ b/src/Twilio/Rest/FlexApi/V1/ConfigurationResource.cs @@ -17,453 +17,453 @@ using Twilio.Types; namespace Twilio.Rest.FlexApi.V1 -{ - - public class ConfigurationResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Ok = new StatusEnum("ok"); - public static readonly StatusEnum Inprogress = new StatusEnum("inprogress"); - public static readonly StatusEnum Notstarted = new StatusEnum("notstarted"); - } - - private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/Configuration", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The Pinned UI version of the Configuration resource to fetch - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Fetch(string uiVersion = null, ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(){UiVersion = uiVersion}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The Pinned UI version of the Configuration resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task FetchAsync(string uiVersion = null, - ITwilioRestClient client = null) - { - var options = new FetchConfigurationOptions(){UiVersion = uiVersion}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Create(CreateConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task CreateAsync(CreateConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Create(ITwilioRestClient client = null) - { - var options = new CreateConfigurationOptions(); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task CreateAsync(ITwilioRestClient client = null) - { - var options = new CreateConfigurationOptions(); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Configuration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// Client to make requests to Twilio - /// A single instance of Configuration - public static ConfigurationResource Update(ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Configuration - public static async System.Threading.Tasks.Task UpdateAsync(ITwilioRestClient client = null) - { - var options = new UpdateConfigurationOptions(); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConfigurationResource object - /// - /// Raw JSON string - /// ConfigurationResource object represented by the provided JSON - public static ConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Configuration resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Configuration resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// An object that contains application-specific data - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The status of the Flex onboarding - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ConfigurationResource.StatusEnum Status { get; private set; } - /// - /// The SID of the TaskRouter Workspace - /// - [JsonProperty("taskrouter_workspace_sid")] - public string TaskrouterWorkspaceSid { get; private set; } - /// - /// The SID of the TaskRouter target Workflow - /// - [JsonProperty("taskrouter_target_workflow_sid")] - public string TaskrouterTargetWorkflowSid { get; private set; } - /// - /// The SID of the TaskRouter Target TaskQueue - /// - [JsonProperty("taskrouter_target_taskqueue_sid")] - public string TaskrouterTargetTaskqueueSid { get; private set; } - /// - /// The list of TaskRouter TaskQueues - /// - [JsonProperty("taskrouter_taskqueues")] - public List TaskrouterTaskqueues { get; private set; } - /// - /// The Skill description for TaskRouter workers - /// - [JsonProperty("taskrouter_skills")] - public List TaskrouterSkills { get; private set; } - /// - /// The TaskRouter default channel capacities and availability for workers - /// - [JsonProperty("taskrouter_worker_channels")] - public object TaskrouterWorkerChannels { get; private set; } - /// - /// The TaskRouter Worker attributes - /// - [JsonProperty("taskrouter_worker_attributes")] - public object TaskrouterWorkerAttributes { get; private set; } - /// - /// The TaskRouter SID of the offline activity - /// - [JsonProperty("taskrouter_offline_activity_sid")] - public string TaskrouterOfflineActivitySid { get; private set; } - /// - /// The URL where the Flex instance is hosted - /// - [JsonProperty("runtime_domain")] - public Uri RuntimeDomain { get; private set; } - /// - /// The SID of the Messaging service instance - /// - [JsonProperty("messaging_service_instance_sid")] - public string MessagingServiceInstanceSid { get; private set; } - /// - /// The SID of the chat service this user belongs to - /// - [JsonProperty("chat_service_instance_sid")] - public string ChatServiceInstanceSid { get; private set; } - /// - /// The SID of the Flex service instance - /// - [JsonProperty("flex_service_instance_sid")] - public string FlexServiceInstanceSid { get; private set; } - /// - /// The primary language of the Flex UI - /// - [JsonProperty("ui_language")] - public string UiLanguage { get; private set; } - /// - /// The object that describes Flex UI characteristics and settings - /// - [JsonProperty("ui_attributes")] - public object UiAttributes { get; private set; } - /// - /// The object that defines the NPM packages and versions to be used in Hosted Flex - /// - [JsonProperty("ui_dependencies")] - public object UiDependencies { get; private set; } - /// - /// The Pinned UI version - /// - [JsonProperty("ui_version")] - public string UiVersion { get; private set; } - /// - /// The Flex Service version - /// - [JsonProperty("service_version")] - public string ServiceVersion { get; private set; } - /// - /// Whether call recording is enabled - /// - [JsonProperty("call_recording_enabled")] - public bool? CallRecordingEnabled { get; private set; } - /// - /// The call recording webhook URL - /// - [JsonProperty("call_recording_webhook_url")] - public Uri CallRecordingWebhookUrl { get; private set; } - /// - /// Whether CRM is present for Flex - /// - [JsonProperty("crm_enabled")] - public bool? CrmEnabled { get; private set; } - /// - /// The CRM Type - /// - [JsonProperty("crm_type")] - public string CrmType { get; private set; } - /// - /// The CRM Callback URL - /// - [JsonProperty("crm_callback_url")] - public Uri CrmCallbackUrl { get; private set; } - /// - /// The CRM Fallback URL - /// - [JsonProperty("crm_fallback_url")] - public Uri CrmFallbackUrl { get; private set; } - /// - /// An object that contains the CRM attributes - /// - [JsonProperty("crm_attributes")] - public object CrmAttributes { get; private set; } - /// - /// The list of public attributes - /// - [JsonProperty("public_attributes")] - public object PublicAttributes { get; private set; } - /// - /// Whether the plugin service enabled - /// - [JsonProperty("plugin_service_enabled")] - public bool? PluginServiceEnabled { get; private set; } - /// - /// The plugin service attributes - /// - [JsonProperty("plugin_service_attributes")] - public object PluginServiceAttributes { get; private set; } - /// - /// A list of objects that contain the configurations for the Integrations supported in this configuration - /// - [JsonProperty("integrations")] - public List Integrations { get; private set; } - /// - /// The list of outbound call flows - /// - [JsonProperty("outbound_call_flows")] - public object OutboundCallFlows { get; private set; } - /// - /// The list of serverless service SIDs - /// - [JsonProperty("serverless_service_sids")] - public List ServerlessServiceSids { get; private set; } - /// - /// Configurable parameters for Queues Statistics - /// - [JsonProperty("queue_stats_configuration")] - public object QueueStatsConfiguration { get; private set; } - /// - /// Configurable parameters for Notifications - /// - [JsonProperty("notifications")] - public object Notifications { get; private set; } - /// - /// Configurable parameters for Markdown - /// - [JsonProperty("markdown")] - public object Markdown { get; private set; } - /// - /// The absolute URL of the Configuration resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Object that controls workspace reporting - /// - [JsonProperty("flex_insights_hr")] - public object FlexInsightsHr { get; private set; } - /// - /// Setting to enable Flex UI redirection - /// - [JsonProperty("flex_insights_drilldown")] - public bool? FlexInsightsDrilldown { get; private set; } - /// - /// URL to redirect to in case drilldown is enabled. - /// - [JsonProperty("flex_url")] - public Uri FlexUrl { get; private set; } - - private ConfigurationResource() - { - - } - } +{ + + public class ConfigurationResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Ok = new StatusEnum("ok"); + public static readonly StatusEnum Inprogress = new StatusEnum("inprogress"); + public static readonly StatusEnum Notstarted = new StatusEnum("notstarted"); + } + + private static Request BuildFetchRequest(FetchConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/Configuration", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(FetchConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(FetchConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The Pinned UI version of the Configuration resource to fetch + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Fetch(string uiVersion = null, ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions() { UiVersion = uiVersion }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The Pinned UI version of the Configuration resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task FetchAsync(string uiVersion = null, + ITwilioRestClient client = null) + { + var options = new FetchConfigurationOptions() { UiVersion = uiVersion }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Create(CreateConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task CreateAsync(CreateConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Create(ITwilioRestClient client = null) + { + var options = new CreateConfigurationOptions(); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task CreateAsync(ITwilioRestClient client = null) + { + var options = new CreateConfigurationOptions(); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(UpdateConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Configuration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// Client to make requests to Twilio + /// A single instance of Configuration + public static ConfigurationResource Update(ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions(); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Configuration + public static async System.Threading.Tasks.Task UpdateAsync(ITwilioRestClient client = null) + { + var options = new UpdateConfigurationOptions(); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConfigurationResource object + /// + /// Raw JSON string + /// ConfigurationResource object represented by the provided JSON + public static ConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Configuration resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Configuration resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// An object that contains application-specific data + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The status of the Flex onboarding + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ConfigurationResource.StatusEnum Status { get; private set; } + /// + /// The SID of the TaskRouter Workspace + /// + [JsonProperty("taskrouter_workspace_sid")] + public string TaskrouterWorkspaceSid { get; private set; } + /// + /// The SID of the TaskRouter target Workflow + /// + [JsonProperty("taskrouter_target_workflow_sid")] + public string TaskrouterTargetWorkflowSid { get; private set; } + /// + /// The SID of the TaskRouter Target TaskQueue + /// + [JsonProperty("taskrouter_target_taskqueue_sid")] + public string TaskrouterTargetTaskqueueSid { get; private set; } + /// + /// The list of TaskRouter TaskQueues + /// + [JsonProperty("taskrouter_taskqueues")] + public List TaskrouterTaskqueues { get; private set; } + /// + /// The Skill description for TaskRouter workers + /// + [JsonProperty("taskrouter_skills")] + public List TaskrouterSkills { get; private set; } + /// + /// The TaskRouter default channel capacities and availability for workers + /// + [JsonProperty("taskrouter_worker_channels")] + public object TaskrouterWorkerChannels { get; private set; } + /// + /// The TaskRouter Worker attributes + /// + [JsonProperty("taskrouter_worker_attributes")] + public object TaskrouterWorkerAttributes { get; private set; } + /// + /// The TaskRouter SID of the offline activity + /// + [JsonProperty("taskrouter_offline_activity_sid")] + public string TaskrouterOfflineActivitySid { get; private set; } + /// + /// The URL where the Flex instance is hosted + /// + [JsonProperty("runtime_domain")] + public Uri RuntimeDomain { get; private set; } + /// + /// The SID of the Messaging service instance + /// + [JsonProperty("messaging_service_instance_sid")] + public string MessagingServiceInstanceSid { get; private set; } + /// + /// The SID of the chat service this user belongs to + /// + [JsonProperty("chat_service_instance_sid")] + public string ChatServiceInstanceSid { get; private set; } + /// + /// The SID of the Flex service instance + /// + [JsonProperty("flex_service_instance_sid")] + public string FlexServiceInstanceSid { get; private set; } + /// + /// The primary language of the Flex UI + /// + [JsonProperty("ui_language")] + public string UiLanguage { get; private set; } + /// + /// The object that describes Flex UI characteristics and settings + /// + [JsonProperty("ui_attributes")] + public object UiAttributes { get; private set; } + /// + /// The object that defines the NPM packages and versions to be used in Hosted Flex + /// + [JsonProperty("ui_dependencies")] + public object UiDependencies { get; private set; } + /// + /// The Pinned UI version + /// + [JsonProperty("ui_version")] + public string UiVersion { get; private set; } + /// + /// The Flex Service version + /// + [JsonProperty("service_version")] + public string ServiceVersion { get; private set; } + /// + /// Whether call recording is enabled + /// + [JsonProperty("call_recording_enabled")] + public bool? CallRecordingEnabled { get; private set; } + /// + /// The call recording webhook URL + /// + [JsonProperty("call_recording_webhook_url")] + public Uri CallRecordingWebhookUrl { get; private set; } + /// + /// Whether CRM is present for Flex + /// + [JsonProperty("crm_enabled")] + public bool? CrmEnabled { get; private set; } + /// + /// The CRM Type + /// + [JsonProperty("crm_type")] + public string CrmType { get; private set; } + /// + /// The CRM Callback URL + /// + [JsonProperty("crm_callback_url")] + public Uri CrmCallbackUrl { get; private set; } + /// + /// The CRM Fallback URL + /// + [JsonProperty("crm_fallback_url")] + public Uri CrmFallbackUrl { get; private set; } + /// + /// An object that contains the CRM attributes + /// + [JsonProperty("crm_attributes")] + public object CrmAttributes { get; private set; } + /// + /// The list of public attributes + /// + [JsonProperty("public_attributes")] + public object PublicAttributes { get; private set; } + /// + /// Whether the plugin service enabled + /// + [JsonProperty("plugin_service_enabled")] + public bool? PluginServiceEnabled { get; private set; } + /// + /// The plugin service attributes + /// + [JsonProperty("plugin_service_attributes")] + public object PluginServiceAttributes { get; private set; } + /// + /// A list of objects that contain the configurations for the Integrations supported in this configuration + /// + [JsonProperty("integrations")] + public List Integrations { get; private set; } + /// + /// The list of outbound call flows + /// + [JsonProperty("outbound_call_flows")] + public object OutboundCallFlows { get; private set; } + /// + /// The list of serverless service SIDs + /// + [JsonProperty("serverless_service_sids")] + public List ServerlessServiceSids { get; private set; } + /// + /// Configurable parameters for Queues Statistics + /// + [JsonProperty("queue_stats_configuration")] + public object QueueStatsConfiguration { get; private set; } + /// + /// Configurable parameters for Notifications + /// + [JsonProperty("notifications")] + public object Notifications { get; private set; } + /// + /// Configurable parameters for Markdown + /// + [JsonProperty("markdown")] + public object Markdown { get; private set; } + /// + /// The absolute URL of the Configuration resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Object that controls workspace reporting + /// + [JsonProperty("flex_insights_hr")] + public object FlexInsightsHr { get; private set; } + /// + /// Setting to enable Flex UI redirection + /// + [JsonProperty("flex_insights_drilldown")] + public bool? FlexInsightsDrilldown { get; private set; } + /// + /// URL to redirect to in case drilldown is enabled. + /// + [JsonProperty("flex_url")] + public Uri FlexUrl { get; private set; } + + private ConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/FlexFlowOptions.cs b/src/Twilio/Rest/FlexApi/V1/FlexFlowOptions.cs index b508b7170..d93225325 100644 --- a/src/Twilio/Rest/FlexApi/V1/FlexFlowOptions.cs +++ b/src/Twilio/Rest/FlexApi/V1/FlexFlowOptions.cs @@ -9,460 +9,460 @@ using Twilio.Converters; namespace Twilio.Rest.FlexApi.V1 -{ - +{ + + /// + /// ReadFlexFlowOptions + /// + public class ReadFlexFlowOptions : ReadOptions + { /// - /// ReadFlexFlowOptions + /// The `friendly_name` of the Flex Flow resources to read /// - public class ReadFlexFlowOptions : ReadOptions - { - /// - /// The `friendly_name` of the Flex Flow resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; set; } + /// - /// FetchFlexFlowOptions + /// Generate the necessary parameters /// - public class FetchFlexFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFlexFlowOptions - /// - /// The SID that identifies the resource to fetch - public FetchFlexFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchFlexFlowOptions + /// + public class FetchFlexFlowOptions : IOptions + { /// - /// CreateFlexFlowOptions - /// - public class CreateFlexFlowOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// The SID of the chat service - /// - public string ChatServiceSid { get; } - /// - /// The channel type - /// - public FlexFlowResource.ChannelTypeEnum ChannelType { get; } - /// - /// The channel contact's Identity - /// - public string ContactIdentity { get; set; } - /// - /// Whether the new Flex Flow is enabled - /// - public bool? Enabled { get; set; } - /// - /// The software that will handle inbound messages. - /// - public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; set; } - /// - /// The SID of the Studio Flow - /// - public string IntegrationFlowSid { get; set; } - /// - /// The External Webhook URL - /// - public Uri IntegrationUrl { get; set; } - /// - /// The Workspace SID for a new Task - /// - public string IntegrationWorkspaceSid { get; set; } - /// - /// The Workflow SID for a new Task - /// - public string IntegrationWorkflowSid { get; set; } - /// - /// The Task Channel for a new Task - /// - public string IntegrationChannel { get; set; } - /// - /// The Task timeout in seconds for a new Task - /// - public int? IntegrationTimeout { get; set; } - /// - /// The Task priority of a new Task - /// - public int? IntegrationPriority { get; set; } - /// - /// Whether to create a Task when the first message arrives - /// - public bool? IntegrationCreationOnMessage { get; set; } - /// - /// Reuse this chat channel for future interactions with a contact - /// - public bool? LongLived { get; set; } - /// - /// Remove active Proxy sessions if the corresponding Task is deleted - /// - public bool? JanitorEnabled { get; set; } - /// - /// The number of times to retry the webhook if the first attempt fails - /// - public int? IntegrationRetryCount { get; set; } - - /// - /// Construct a new CreateFlexFlowOptions - /// - /// A string to describe the resource - /// The SID of the chat service - /// The channel type - public CreateFlexFlowOptions(string friendlyName, - string chatServiceSid, - FlexFlowResource.ChannelTypeEnum channelType) - { - FriendlyName = friendlyName; - ChatServiceSid = chatServiceSid; - ChannelType = channelType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ChatServiceSid != null) - { - p.Add(new KeyValuePair("ChatServiceSid", ChatServiceSid.ToString())); - } - - if (ChannelType != null) - { - p.Add(new KeyValuePair("ChannelType", ChannelType.ToString())); - } - - if (ContactIdentity != null) - { - p.Add(new KeyValuePair("ContactIdentity", ContactIdentity)); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (IntegrationType != null) - { - p.Add(new KeyValuePair("IntegrationType", IntegrationType.ToString())); - } - - if (IntegrationFlowSid != null) - { - p.Add(new KeyValuePair("Integration.FlowSid", IntegrationFlowSid.ToString())); - } - - if (IntegrationUrl != null) - { - p.Add(new KeyValuePair("Integration.Url", Serializers.Url(IntegrationUrl))); - } - - if (IntegrationWorkspaceSid != null) - { - p.Add(new KeyValuePair("Integration.WorkspaceSid", IntegrationWorkspaceSid.ToString())); - } - - if (IntegrationWorkflowSid != null) - { - p.Add(new KeyValuePair("Integration.WorkflowSid", IntegrationWorkflowSid.ToString())); - } - - if (IntegrationChannel != null) - { - p.Add(new KeyValuePair("Integration.Channel", IntegrationChannel)); - } - - if (IntegrationTimeout != null) - { - p.Add(new KeyValuePair("Integration.Timeout", IntegrationTimeout.ToString())); - } - - if (IntegrationPriority != null) - { - p.Add(new KeyValuePair("Integration.Priority", IntegrationPriority.ToString())); - } - - if (IntegrationCreationOnMessage != null) - { - p.Add(new KeyValuePair("Integration.CreationOnMessage", IntegrationCreationOnMessage.Value.ToString().ToLower())); - } - - if (LongLived != null) - { - p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); - } - - if (JanitorEnabled != null) - { - p.Add(new KeyValuePair("JanitorEnabled", JanitorEnabled.Value.ToString().ToLower())); - } - - if (IntegrationRetryCount != null) - { - p.Add(new KeyValuePair("Integration.RetryCount", IntegrationRetryCount.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + /// - /// UpdateFlexFlowOptions - /// - public class UpdateFlexFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The SID of the chat service - /// - public string ChatServiceSid { get; set; } - /// - /// The channel type - /// - public FlexFlowResource.ChannelTypeEnum ChannelType { get; set; } - /// - /// The channel contact's Identity - /// - public string ContactIdentity { get; set; } - /// - /// Whether the new Flex Flow is enabled - /// - public bool? Enabled { get; set; } - /// - /// The software that will handle inbound messages. - /// - public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; set; } - /// - /// The SID of the Studio Flow - /// - public string IntegrationFlowSid { get; set; } - /// - /// The External Webhook URL - /// - public Uri IntegrationUrl { get; set; } - /// - /// The Workspace SID for a new Task - /// - public string IntegrationWorkspaceSid { get; set; } - /// - /// The Workflow SID for a new Task - /// - public string IntegrationWorkflowSid { get; set; } - /// - /// The Task Channel for a new Task - /// - public string IntegrationChannel { get; set; } - /// - /// The Task timeout in seconds for a new Task - /// - public int? IntegrationTimeout { get; set; } - /// - /// The Task priority of a new Task - /// - public int? IntegrationPriority { get; set; } - /// - /// Whether to create a Task when the first message arrives - /// - public bool? IntegrationCreationOnMessage { get; set; } - /// - /// Reuse this chat channel for future interactions with a contact - /// - public bool? LongLived { get; set; } - /// - /// Remove active Proxy sessions if the corresponding Task is deleted - /// - public bool? JanitorEnabled { get; set; } - /// - /// The number of times to retry the webhook if the first attempt fails - /// - public int? IntegrationRetryCount { get; set; } - - /// - /// Construct a new UpdateFlexFlowOptions - /// - /// The SID that identifies the resource to update - public UpdateFlexFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ChatServiceSid != null) - { - p.Add(new KeyValuePair("ChatServiceSid", ChatServiceSid.ToString())); - } - - if (ChannelType != null) - { - p.Add(new KeyValuePair("ChannelType", ChannelType.ToString())); - } - - if (ContactIdentity != null) - { - p.Add(new KeyValuePair("ContactIdentity", ContactIdentity)); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (IntegrationType != null) - { - p.Add(new KeyValuePair("IntegrationType", IntegrationType.ToString())); - } - - if (IntegrationFlowSid != null) - { - p.Add(new KeyValuePair("Integration.FlowSid", IntegrationFlowSid.ToString())); - } - - if (IntegrationUrl != null) - { - p.Add(new KeyValuePair("Integration.Url", Serializers.Url(IntegrationUrl))); - } - - if (IntegrationWorkspaceSid != null) - { - p.Add(new KeyValuePair("Integration.WorkspaceSid", IntegrationWorkspaceSid.ToString())); - } - - if (IntegrationWorkflowSid != null) - { - p.Add(new KeyValuePair("Integration.WorkflowSid", IntegrationWorkflowSid.ToString())); - } - - if (IntegrationChannel != null) - { - p.Add(new KeyValuePair("Integration.Channel", IntegrationChannel)); - } - - if (IntegrationTimeout != null) - { - p.Add(new KeyValuePair("Integration.Timeout", IntegrationTimeout.ToString())); - } - - if (IntegrationPriority != null) - { - p.Add(new KeyValuePair("Integration.Priority", IntegrationPriority.ToString())); - } - - if (IntegrationCreationOnMessage != null) - { - p.Add(new KeyValuePair("Integration.CreationOnMessage", IntegrationCreationOnMessage.Value.ToString().ToLower())); - } - - if (LongLived != null) - { - p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); - } - - if (JanitorEnabled != null) - { - p.Add(new KeyValuePair("JanitorEnabled", JanitorEnabled.Value.ToString().ToLower())); - } - - if (IntegrationRetryCount != null) - { - p.Add(new KeyValuePair("Integration.RetryCount", IntegrationRetryCount.ToString())); - } - - return p; - } - } - + /// Construct a new FetchFlexFlowOptions + /// + /// The SID that identifies the resource to fetch + public FetchFlexFlowOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// DeleteFlexFlowOptions + /// Generate the necessary parameters /// - public class DeleteFlexFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFlexFlowOptions - /// - /// The SID that identifies the resource to delete - public DeleteFlexFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateFlexFlowOptions + /// + public class CreateFlexFlowOptions : IOptions + { + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + /// + /// The SID of the chat service + /// + public string ChatServiceSid { get; } + /// + /// The channel type + /// + public FlexFlowResource.ChannelTypeEnum ChannelType { get; } + /// + /// The channel contact's Identity + /// + public string ContactIdentity { get; set; } + /// + /// Whether the new Flex Flow is enabled + /// + public bool? Enabled { get; set; } + /// + /// The software that will handle inbound messages. + /// + public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; set; } + /// + /// The SID of the Studio Flow + /// + public string IntegrationFlowSid { get; set; } + /// + /// The External Webhook URL + /// + public Uri IntegrationUrl { get; set; } + /// + /// The Workspace SID for a new Task + /// + public string IntegrationWorkspaceSid { get; set; } + /// + /// The Workflow SID for a new Task + /// + public string IntegrationWorkflowSid { get; set; } + /// + /// The Task Channel for a new Task + /// + public string IntegrationChannel { get; set; } + /// + /// The Task timeout in seconds for a new Task + /// + public int? IntegrationTimeout { get; set; } + /// + /// The Task priority of a new Task + /// + public int? IntegrationPriority { get; set; } + /// + /// Whether to create a Task when the first message arrives + /// + public bool? IntegrationCreationOnMessage { get; set; } + /// + /// Reuse this chat channel for future interactions with a contact + /// + public bool? LongLived { get; set; } + /// + /// Remove active Proxy sessions if the corresponding Task is deleted + /// + public bool? JanitorEnabled { get; set; } + /// + /// The number of times to retry the webhook if the first attempt fails + /// + public int? IntegrationRetryCount { get; set; } + + /// + /// Construct a new CreateFlexFlowOptions + /// + /// A string to describe the resource + /// The SID of the chat service + /// The channel type + public CreateFlexFlowOptions(string friendlyName, + string chatServiceSid, + FlexFlowResource.ChannelTypeEnum channelType) + { + FriendlyName = friendlyName; + ChatServiceSid = chatServiceSid; + ChannelType = channelType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ChatServiceSid != null) + { + p.Add(new KeyValuePair("ChatServiceSid", ChatServiceSid.ToString())); + } + + if (ChannelType != null) + { + p.Add(new KeyValuePair("ChannelType", ChannelType.ToString())); + } + + if (ContactIdentity != null) + { + p.Add(new KeyValuePair("ContactIdentity", ContactIdentity)); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (IntegrationType != null) + { + p.Add(new KeyValuePair("IntegrationType", IntegrationType.ToString())); + } + + if (IntegrationFlowSid != null) + { + p.Add(new KeyValuePair("Integration.FlowSid", IntegrationFlowSid.ToString())); + } + + if (IntegrationUrl != null) + { + p.Add(new KeyValuePair("Integration.Url", Serializers.Url(IntegrationUrl))); + } + + if (IntegrationWorkspaceSid != null) + { + p.Add(new KeyValuePair("Integration.WorkspaceSid", IntegrationWorkspaceSid.ToString())); + } + + if (IntegrationWorkflowSid != null) + { + p.Add(new KeyValuePair("Integration.WorkflowSid", IntegrationWorkflowSid.ToString())); + } + + if (IntegrationChannel != null) + { + p.Add(new KeyValuePair("Integration.Channel", IntegrationChannel)); + } + + if (IntegrationTimeout != null) + { + p.Add(new KeyValuePair("Integration.Timeout", IntegrationTimeout.ToString())); + } + + if (IntegrationPriority != null) + { + p.Add(new KeyValuePair("Integration.Priority", IntegrationPriority.ToString())); + } + + if (IntegrationCreationOnMessage != null) + { + p.Add(new KeyValuePair("Integration.CreationOnMessage", IntegrationCreationOnMessage.Value.ToString().ToLower())); + } + + if (LongLived != null) + { + p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); + } + + if (JanitorEnabled != null) + { + p.Add(new KeyValuePair("JanitorEnabled", JanitorEnabled.Value.ToString().ToLower())); + } + + if (IntegrationRetryCount != null) + { + p.Add(new KeyValuePair("Integration.RetryCount", IntegrationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// UpdateFlexFlowOptions + /// + public class UpdateFlexFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The SID of the chat service + /// + public string ChatServiceSid { get; set; } + /// + /// The channel type + /// + public FlexFlowResource.ChannelTypeEnum ChannelType { get; set; } + /// + /// The channel contact's Identity + /// + public string ContactIdentity { get; set; } + /// + /// Whether the new Flex Flow is enabled + /// + public bool? Enabled { get; set; } + /// + /// The software that will handle inbound messages. + /// + public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; set; } + /// + /// The SID of the Studio Flow + /// + public string IntegrationFlowSid { get; set; } + /// + /// The External Webhook URL + /// + public Uri IntegrationUrl { get; set; } + /// + /// The Workspace SID for a new Task + /// + public string IntegrationWorkspaceSid { get; set; } + /// + /// The Workflow SID for a new Task + /// + public string IntegrationWorkflowSid { get; set; } + /// + /// The Task Channel for a new Task + /// + public string IntegrationChannel { get; set; } + /// + /// The Task timeout in seconds for a new Task + /// + public int? IntegrationTimeout { get; set; } + /// + /// The Task priority of a new Task + /// + public int? IntegrationPriority { get; set; } + /// + /// Whether to create a Task when the first message arrives + /// + public bool? IntegrationCreationOnMessage { get; set; } + /// + /// Reuse this chat channel for future interactions with a contact + /// + public bool? LongLived { get; set; } + /// + /// Remove active Proxy sessions if the corresponding Task is deleted + /// + public bool? JanitorEnabled { get; set; } + /// + /// The number of times to retry the webhook if the first attempt fails + /// + public int? IntegrationRetryCount { get; set; } + + /// + /// Construct a new UpdateFlexFlowOptions + /// + /// The SID that identifies the resource to update + public UpdateFlexFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ChatServiceSid != null) + { + p.Add(new KeyValuePair("ChatServiceSid", ChatServiceSid.ToString())); + } + + if (ChannelType != null) + { + p.Add(new KeyValuePair("ChannelType", ChannelType.ToString())); + } + + if (ContactIdentity != null) + { + p.Add(new KeyValuePair("ContactIdentity", ContactIdentity)); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (IntegrationType != null) + { + p.Add(new KeyValuePair("IntegrationType", IntegrationType.ToString())); + } + + if (IntegrationFlowSid != null) + { + p.Add(new KeyValuePair("Integration.FlowSid", IntegrationFlowSid.ToString())); + } + + if (IntegrationUrl != null) + { + p.Add(new KeyValuePair("Integration.Url", Serializers.Url(IntegrationUrl))); + } + + if (IntegrationWorkspaceSid != null) + { + p.Add(new KeyValuePair("Integration.WorkspaceSid", IntegrationWorkspaceSid.ToString())); + } + + if (IntegrationWorkflowSid != null) + { + p.Add(new KeyValuePair("Integration.WorkflowSid", IntegrationWorkflowSid.ToString())); + } + + if (IntegrationChannel != null) + { + p.Add(new KeyValuePair("Integration.Channel", IntegrationChannel)); + } + + if (IntegrationTimeout != null) + { + p.Add(new KeyValuePair("Integration.Timeout", IntegrationTimeout.ToString())); + } + + if (IntegrationPriority != null) + { + p.Add(new KeyValuePair("Integration.Priority", IntegrationPriority.ToString())); + } + + if (IntegrationCreationOnMessage != null) + { + p.Add(new KeyValuePair("Integration.CreationOnMessage", IntegrationCreationOnMessage.Value.ToString().ToLower())); + } + + if (LongLived != null) + { + p.Add(new KeyValuePair("LongLived", LongLived.Value.ToString().ToLower())); + } + + if (JanitorEnabled != null) + { + p.Add(new KeyValuePair("JanitorEnabled", JanitorEnabled.Value.ToString().ToLower())); + } + + if (IntegrationRetryCount != null) + { + p.Add(new KeyValuePair("Integration.RetryCount", IntegrationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// DeleteFlexFlowOptions + /// + public class DeleteFlexFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFlexFlowOptions + /// + /// The SID that identifies the resource to delete + public DeleteFlexFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/FlexFlowResource.cs b/src/Twilio/Rest/FlexApi/V1/FlexFlowResource.cs index d92f16c5c..5d0209940 100644 --- a/src/Twilio/Rest/FlexApi/V1/FlexFlowResource.cs +++ b/src/Twilio/Rest/FlexApi/V1/FlexFlowResource.cs @@ -17,670 +17,670 @@ using Twilio.Types; namespace Twilio.Rest.FlexApi.V1 -{ - - public class FlexFlowResource : Resource - { - public sealed class ChannelTypeEnum : StringEnum - { - private ChannelTypeEnum(string value) : base(value) {} - public ChannelTypeEnum() {} - public static implicit operator ChannelTypeEnum(string value) - { - return new ChannelTypeEnum(value); - } - - public static readonly ChannelTypeEnum Web = new ChannelTypeEnum("web"); - public static readonly ChannelTypeEnum Sms = new ChannelTypeEnum("sms"); - public static readonly ChannelTypeEnum Facebook = new ChannelTypeEnum("facebook"); - public static readonly ChannelTypeEnum Whatsapp = new ChannelTypeEnum("whatsapp"); - public static readonly ChannelTypeEnum Line = new ChannelTypeEnum("line"); - public static readonly ChannelTypeEnum Custom = new ChannelTypeEnum("custom"); - } - - public sealed class IntegrationTypeEnum : StringEnum - { - private IntegrationTypeEnum(string value) : base(value) {} - public IntegrationTypeEnum() {} - public static implicit operator IntegrationTypeEnum(string value) - { - return new IntegrationTypeEnum(value); - } - - public static readonly IntegrationTypeEnum Studio = new IntegrationTypeEnum("studio"); - public static readonly IntegrationTypeEnum External = new IntegrationTypeEnum("external"); - public static readonly IntegrationTypeEnum Task = new IntegrationTypeEnum("task"); - } - - private static Request BuildReadRequest(ReadFlexFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/FlexFlows", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read FlexFlow parameters - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static ResourceSet Read(ReadFlexFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_flows", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read FlexFlow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task> ReadAsync(ReadFlexFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_flows", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The `friendly_name` of the Flex Flow resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static ResourceSet Read(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlexFlowOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The `friendly_name` of the Flex Flow resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlexFlowOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("flex_flows", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_flows", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_flows", response.Content); - } - - private static Request BuildFetchRequest(FetchFlexFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/FlexFlows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch FlexFlow parameters - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Fetch(FetchFlexFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch FlexFlow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task FetchAsync(FetchFlexFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFlexFlowOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFlexFlowOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateFlexFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/FlexFlows", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create FlexFlow parameters - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Create(CreateFlexFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create FlexFlow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task CreateAsync(CreateFlexFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The SID of the chat service - /// The channel type - /// The channel contact's Identity - /// Whether the new Flex Flow is enabled - /// The software that will handle inbound messages. - /// The SID of the Studio Flow - /// The External Webhook URL - /// The Workspace SID for a new Task - /// The Workflow SID for a new Task - /// The Task Channel for a new Task - /// The Task timeout in seconds for a new Task - /// The Task priority of a new Task - /// Whether to create a Task when the first message arrives - /// Reuse this chat channel for future interactions with a contact - /// Remove active Proxy sessions if the corresponding Task is deleted - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Create(string friendlyName, - string chatServiceSid, - FlexFlowResource.ChannelTypeEnum channelType, - string contactIdentity = null, - bool? enabled = null, - FlexFlowResource.IntegrationTypeEnum integrationType = null, - string integrationFlowSid = null, - Uri integrationUrl = null, - string integrationWorkspaceSid = null, - string integrationWorkflowSid = null, - string integrationChannel = null, - int? integrationTimeout = null, - int? integrationPriority = null, - bool? integrationCreationOnMessage = null, - bool? longLived = null, - bool? janitorEnabled = null, - int? integrationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateFlexFlowOptions(friendlyName, chatServiceSid, channelType){ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The SID of the chat service - /// The channel type - /// The channel contact's Identity - /// Whether the new Flex Flow is enabled - /// The software that will handle inbound messages. - /// The SID of the Studio Flow - /// The External Webhook URL - /// The Workspace SID for a new Task - /// The Workflow SID for a new Task - /// The Task Channel for a new Task - /// The Task timeout in seconds for a new Task - /// The Task priority of a new Task - /// Whether to create a Task when the first message arrives - /// Reuse this chat channel for future interactions with a contact - /// Remove active Proxy sessions if the corresponding Task is deleted - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string chatServiceSid, - FlexFlowResource.ChannelTypeEnum channelType, - string contactIdentity = null, - bool? enabled = null, - FlexFlowResource.IntegrationTypeEnum integrationType = null, - string integrationFlowSid = null, - Uri integrationUrl = null, - string integrationWorkspaceSid = null, - string integrationWorkflowSid = null, - string integrationChannel = null, - int? integrationTimeout = null, - int? integrationPriority = null, - bool? integrationCreationOnMessage = null, - bool? longLived = null, - bool? janitorEnabled = null, - int? integrationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateFlexFlowOptions(friendlyName, chatServiceSid, channelType){ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFlexFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/FlexFlows/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update FlexFlow parameters - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Update(UpdateFlexFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update FlexFlow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlexFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// A string to describe the resource - /// The SID of the chat service - /// The channel type - /// The channel contact's Identity - /// Whether the new Flex Flow is enabled - /// The software that will handle inbound messages. - /// The SID of the Studio Flow - /// The External Webhook URL - /// The Workspace SID for a new Task - /// The Workflow SID for a new Task - /// The Task Channel for a new Task - /// The Task timeout in seconds for a new Task - /// The Task priority of a new Task - /// Whether to create a Task when the first message arrives - /// Reuse this chat channel for future interactions with a contact - /// Remove active Proxy sessions if the corresponding Task is deleted - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static FlexFlowResource Update(string pathSid, - string friendlyName = null, - string chatServiceSid = null, - FlexFlowResource.ChannelTypeEnum channelType = null, - string contactIdentity = null, - bool? enabled = null, - FlexFlowResource.IntegrationTypeEnum integrationType = null, - string integrationFlowSid = null, - Uri integrationUrl = null, - string integrationWorkspaceSid = null, - string integrationWorkflowSid = null, - string integrationChannel = null, - int? integrationTimeout = null, - int? integrationPriority = null, - bool? integrationCreationOnMessage = null, - bool? longLived = null, - bool? janitorEnabled = null, - int? integrationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlexFlowOptions(pathSid){FriendlyName = friendlyName, ChatServiceSid = chatServiceSid, ChannelType = channelType, ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// A string to describe the resource - /// The SID of the chat service - /// The channel type - /// The channel contact's Identity - /// Whether the new Flex Flow is enabled - /// The software that will handle inbound messages. - /// The SID of the Studio Flow - /// The External Webhook URL - /// The Workspace SID for a new Task - /// The Workflow SID for a new Task - /// The Task Channel for a new Task - /// The Task timeout in seconds for a new Task - /// The Task priority of a new Task - /// Whether to create a Task when the first message arrives - /// Reuse this chat channel for future interactions with a contact - /// Remove active Proxy sessions if the corresponding Task is deleted - /// The number of times to retry the webhook if the first attempt fails - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string chatServiceSid = null, - FlexFlowResource.ChannelTypeEnum channelType = null, - string contactIdentity = null, - bool? enabled = null, - FlexFlowResource.IntegrationTypeEnum integrationType = null, - string integrationFlowSid = null, - Uri integrationUrl = null, - string integrationWorkspaceSid = null, - string integrationWorkflowSid = null, - string integrationChannel = null, - int? integrationTimeout = null, - int? integrationPriority = null, - bool? integrationCreationOnMessage = null, - bool? longLived = null, - bool? janitorEnabled = null, - int? integrationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlexFlowOptions(pathSid){FriendlyName = friendlyName, ChatServiceSid = chatServiceSid, ChannelType = channelType, ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFlexFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.FlexApi, - "/v1/FlexFlows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete FlexFlow parameters - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static bool Delete(DeleteFlexFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete FlexFlow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlexFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of FlexFlow - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlexFlowOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlexFlow - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlexFlowOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlexFlowResource object - /// - /// Raw JSON string - /// FlexFlowResource object represented by the provided JSON - public static FlexFlowResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the chat service - /// - [JsonProperty("chat_service_sid")] - public string ChatServiceSid { get; private set; } - /// - /// The channel type - /// - [JsonProperty("channel_type")] - [JsonConverter(typeof(StringEnumConverter))] - public FlexFlowResource.ChannelTypeEnum ChannelType { get; private set; } - /// - /// The channel contact's Identity - /// - [JsonProperty("contact_identity")] - public string ContactIdentity { get; private set; } - /// - /// Whether the Flex Flow is enabled - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The software that will handle inbound messages. - /// - [JsonProperty("integration_type")] - [JsonConverter(typeof(StringEnumConverter))] - public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; private set; } - /// - /// An object that contains specific parameters for the integration - /// - [JsonProperty("integration")] - public object Integration { get; private set; } - /// - /// Re-use this chat channel for future interactions with a contact - /// - [JsonProperty("long_lived")] - public bool? LongLived { get; private set; } - /// - /// Remove active Proxy sessions if the corresponding Task is deleted. - /// - [JsonProperty("janitor_enabled")] - public bool? JanitorEnabled { get; private set; } - /// - /// The absolute URL of the Flex Flow resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FlexFlowResource() - { - - } - } +{ + + public class FlexFlowResource : Resource + { + public sealed class ChannelTypeEnum : StringEnum + { + private ChannelTypeEnum(string value) : base(value) { } + public ChannelTypeEnum() { } + public static implicit operator ChannelTypeEnum(string value) + { + return new ChannelTypeEnum(value); + } + + public static readonly ChannelTypeEnum Web = new ChannelTypeEnum("web"); + public static readonly ChannelTypeEnum Sms = new ChannelTypeEnum("sms"); + public static readonly ChannelTypeEnum Facebook = new ChannelTypeEnum("facebook"); + public static readonly ChannelTypeEnum Whatsapp = new ChannelTypeEnum("whatsapp"); + public static readonly ChannelTypeEnum Line = new ChannelTypeEnum("line"); + public static readonly ChannelTypeEnum Custom = new ChannelTypeEnum("custom"); + } + + public sealed class IntegrationTypeEnum : StringEnum + { + private IntegrationTypeEnum(string value) : base(value) { } + public IntegrationTypeEnum() { } + public static implicit operator IntegrationTypeEnum(string value) + { + return new IntegrationTypeEnum(value); + } + + public static readonly IntegrationTypeEnum Studio = new IntegrationTypeEnum("studio"); + public static readonly IntegrationTypeEnum External = new IntegrationTypeEnum("external"); + public static readonly IntegrationTypeEnum Task = new IntegrationTypeEnum("task"); + } + + private static Request BuildReadRequest(ReadFlexFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/FlexFlows", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read FlexFlow parameters + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static ResourceSet Read(ReadFlexFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_flows", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read FlexFlow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task> ReadAsync(ReadFlexFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_flows", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The `friendly_name` of the Flex Flow resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static ResourceSet Read(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlexFlowOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The `friendly_name` of the Flex Flow resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlexFlowOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("flex_flows", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_flows", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_flows", response.Content); + } + + private static Request BuildFetchRequest(FetchFlexFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/FlexFlows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch FlexFlow parameters + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Fetch(FetchFlexFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch FlexFlow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task FetchAsync(FetchFlexFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFlexFlowOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFlexFlowOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateFlexFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/FlexFlows", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create FlexFlow parameters + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Create(CreateFlexFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create FlexFlow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task CreateAsync(CreateFlexFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The SID of the chat service + /// The channel type + /// The channel contact's Identity + /// Whether the new Flex Flow is enabled + /// The software that will handle inbound messages. + /// The SID of the Studio Flow + /// The External Webhook URL + /// The Workspace SID for a new Task + /// The Workflow SID for a new Task + /// The Task Channel for a new Task + /// The Task timeout in seconds for a new Task + /// The Task priority of a new Task + /// Whether to create a Task when the first message arrives + /// Reuse this chat channel for future interactions with a contact + /// Remove active Proxy sessions if the corresponding Task is deleted + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Create(string friendlyName, + string chatServiceSid, + FlexFlowResource.ChannelTypeEnum channelType, + string contactIdentity = null, + bool? enabled = null, + FlexFlowResource.IntegrationTypeEnum integrationType = null, + string integrationFlowSid = null, + Uri integrationUrl = null, + string integrationWorkspaceSid = null, + string integrationWorkflowSid = null, + string integrationChannel = null, + int? integrationTimeout = null, + int? integrationPriority = null, + bool? integrationCreationOnMessage = null, + bool? longLived = null, + bool? janitorEnabled = null, + int? integrationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateFlexFlowOptions(friendlyName, chatServiceSid, channelType) { ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The SID of the chat service + /// The channel type + /// The channel contact's Identity + /// Whether the new Flex Flow is enabled + /// The software that will handle inbound messages. + /// The SID of the Studio Flow + /// The External Webhook URL + /// The Workspace SID for a new Task + /// The Workflow SID for a new Task + /// The Task Channel for a new Task + /// The Task timeout in seconds for a new Task + /// The Task priority of a new Task + /// Whether to create a Task when the first message arrives + /// Reuse this chat channel for future interactions with a contact + /// Remove active Proxy sessions if the corresponding Task is deleted + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string chatServiceSid, + FlexFlowResource.ChannelTypeEnum channelType, + string contactIdentity = null, + bool? enabled = null, + FlexFlowResource.IntegrationTypeEnum integrationType = null, + string integrationFlowSid = null, + Uri integrationUrl = null, + string integrationWorkspaceSid = null, + string integrationWorkflowSid = null, + string integrationChannel = null, + int? integrationTimeout = null, + int? integrationPriority = null, + bool? integrationCreationOnMessage = null, + bool? longLived = null, + bool? janitorEnabled = null, + int? integrationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateFlexFlowOptions(friendlyName, chatServiceSid, channelType) { ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFlexFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/FlexFlows/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update FlexFlow parameters + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Update(UpdateFlexFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update FlexFlow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlexFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// A string to describe the resource + /// The SID of the chat service + /// The channel type + /// The channel contact's Identity + /// Whether the new Flex Flow is enabled + /// The software that will handle inbound messages. + /// The SID of the Studio Flow + /// The External Webhook URL + /// The Workspace SID for a new Task + /// The Workflow SID for a new Task + /// The Task Channel for a new Task + /// The Task timeout in seconds for a new Task + /// The Task priority of a new Task + /// Whether to create a Task when the first message arrives + /// Reuse this chat channel for future interactions with a contact + /// Remove active Proxy sessions if the corresponding Task is deleted + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static FlexFlowResource Update(string pathSid, + string friendlyName = null, + string chatServiceSid = null, + FlexFlowResource.ChannelTypeEnum channelType = null, + string contactIdentity = null, + bool? enabled = null, + FlexFlowResource.IntegrationTypeEnum integrationType = null, + string integrationFlowSid = null, + Uri integrationUrl = null, + string integrationWorkspaceSid = null, + string integrationWorkflowSid = null, + string integrationChannel = null, + int? integrationTimeout = null, + int? integrationPriority = null, + bool? integrationCreationOnMessage = null, + bool? longLived = null, + bool? janitorEnabled = null, + int? integrationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlexFlowOptions(pathSid) { FriendlyName = friendlyName, ChatServiceSid = chatServiceSid, ChannelType = channelType, ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// A string to describe the resource + /// The SID of the chat service + /// The channel type + /// The channel contact's Identity + /// Whether the new Flex Flow is enabled + /// The software that will handle inbound messages. + /// The SID of the Studio Flow + /// The External Webhook URL + /// The Workspace SID for a new Task + /// The Workflow SID for a new Task + /// The Task Channel for a new Task + /// The Task timeout in seconds for a new Task + /// The Task priority of a new Task + /// Whether to create a Task when the first message arrives + /// Reuse this chat channel for future interactions with a contact + /// Remove active Proxy sessions if the corresponding Task is deleted + /// The number of times to retry the webhook if the first attempt fails + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string chatServiceSid = null, + FlexFlowResource.ChannelTypeEnum channelType = null, + string contactIdentity = null, + bool? enabled = null, + FlexFlowResource.IntegrationTypeEnum integrationType = null, + string integrationFlowSid = null, + Uri integrationUrl = null, + string integrationWorkspaceSid = null, + string integrationWorkflowSid = null, + string integrationChannel = null, + int? integrationTimeout = null, + int? integrationPriority = null, + bool? integrationCreationOnMessage = null, + bool? longLived = null, + bool? janitorEnabled = null, + int? integrationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlexFlowOptions(pathSid) { FriendlyName = friendlyName, ChatServiceSid = chatServiceSid, ChannelType = channelType, ContactIdentity = contactIdentity, Enabled = enabled, IntegrationType = integrationType, IntegrationFlowSid = integrationFlowSid, IntegrationUrl = integrationUrl, IntegrationWorkspaceSid = integrationWorkspaceSid, IntegrationWorkflowSid = integrationWorkflowSid, IntegrationChannel = integrationChannel, IntegrationTimeout = integrationTimeout, IntegrationPriority = integrationPriority, IntegrationCreationOnMessage = integrationCreationOnMessage, LongLived = longLived, JanitorEnabled = janitorEnabled, IntegrationRetryCount = integrationRetryCount }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFlexFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.FlexApi, + "/v1/FlexFlows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete FlexFlow parameters + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static bool Delete(DeleteFlexFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete FlexFlow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlexFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of FlexFlow + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlexFlowOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlexFlow + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlexFlowOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlexFlowResource object + /// + /// Raw JSON string + /// FlexFlowResource object represented by the provided JSON + public static FlexFlowResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the chat service + /// + [JsonProperty("chat_service_sid")] + public string ChatServiceSid { get; private set; } + /// + /// The channel type + /// + [JsonProperty("channel_type")] + [JsonConverter(typeof(StringEnumConverter))] + public FlexFlowResource.ChannelTypeEnum ChannelType { get; private set; } + /// + /// The channel contact's Identity + /// + [JsonProperty("contact_identity")] + public string ContactIdentity { get; private set; } + /// + /// Whether the Flex Flow is enabled + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The software that will handle inbound messages. + /// + [JsonProperty("integration_type")] + [JsonConverter(typeof(StringEnumConverter))] + public FlexFlowResource.IntegrationTypeEnum IntegrationType { get; private set; } + /// + /// An object that contains specific parameters for the integration + /// + [JsonProperty("integration")] + public object Integration { get; private set; } + /// + /// Re-use this chat channel for future interactions with a contact + /// + [JsonProperty("long_lived")] + public bool? LongLived { get; private set; } + /// + /// Remove active Proxy sessions if the corresponding Task is deleted. + /// + [JsonProperty("janitor_enabled")] + public bool? JanitorEnabled { get; private set; } + /// + /// The absolute URL of the Flex Flow resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FlexFlowResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/WebChannelOptions.cs b/src/Twilio/Rest/FlexApi/V1/WebChannelOptions.cs index c57000349..12f2cb067 100644 --- a/src/Twilio/Rest/FlexApi/V1/WebChannelOptions.cs +++ b/src/Twilio/Rest/FlexApi/V1/WebChannelOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.FlexApi.V1 -{ - +{ + + /// + /// ReadWebChannelOptions + /// + public class ReadWebChannelOptions : ReadOptions + { /// - /// ReadWebChannelOptions - /// - public class ReadWebChannelOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchWebChannelOptions + /// + public class FetchWebChannelOptions : IOptions + { /// - /// FetchWebChannelOptions + /// The SID of the WebChannel resource to fetch /// - public class FetchWebChannelOptions : IOptions - { - /// - /// The SID of the WebChannel resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebChannelOptions - /// - /// The SID of the WebChannel resource to fetch - public FetchWebChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateWebChannelOptions - /// - public class CreateWebChannelOptions : IOptions - { - /// - /// The SID of the Flex Flow - /// - public string FlexFlowSid { get; } - /// - /// The chat identity - /// - public string Identity { get; } - /// - /// The chat participant's friendly name - /// - public string CustomerFriendlyName { get; } - /// - /// The chat channel's friendly name - /// - public string ChatFriendlyName { get; } - /// - /// The chat channel's unique name - /// - public string ChatUniqueName { get; set; } - /// - /// The pre-engagement data - /// - public string PreEngagementData { get; set; } - - /// - /// Construct a new CreateWebChannelOptions - /// - /// The SID of the Flex Flow - /// The chat identity - /// The chat participant's friendly name - /// The chat channel's friendly name - public CreateWebChannelOptions(string flexFlowSid, - string identity, - string customerFriendlyName, - string chatFriendlyName) - { - FlexFlowSid = flexFlowSid; - Identity = identity; - CustomerFriendlyName = customerFriendlyName; - ChatFriendlyName = chatFriendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FlexFlowSid != null) - { - p.Add(new KeyValuePair("FlexFlowSid", FlexFlowSid.ToString())); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (CustomerFriendlyName != null) - { - p.Add(new KeyValuePair("CustomerFriendlyName", CustomerFriendlyName)); - } - - if (ChatFriendlyName != null) - { - p.Add(new KeyValuePair("ChatFriendlyName", ChatFriendlyName)); - } - - if (ChatUniqueName != null) - { - p.Add(new KeyValuePair("ChatUniqueName", ChatUniqueName)); - } - - if (PreEngagementData != null) - { - p.Add(new KeyValuePair("PreEngagementData", PreEngagementData)); - } - - return p; - } - } - + /// Construct a new FetchWebChannelOptions + /// + /// The SID of the WebChannel resource to fetch + public FetchWebChannelOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// UpdateWebChannelOptions - /// - public class UpdateWebChannelOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The chat status - /// - public WebChannelResource.ChatStatusEnum ChatStatus { get; set; } - /// - /// The post-engagement data - /// - public string PostEngagementData { get; set; } - - /// - /// Construct a new UpdateWebChannelOptions - /// - /// The SID that identifies the resource to update - public UpdateWebChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ChatStatus != null) - { - p.Add(new KeyValuePair("ChatStatus", ChatStatus.ToString())); - } - - if (PostEngagementData != null) - { - p.Add(new KeyValuePair("PostEngagementData", PostEngagementData)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateWebChannelOptions + /// + public class CreateWebChannelOptions : IOptions + { /// - /// DeleteWebChannelOptions + /// The SID of the Flex Flow /// - public class DeleteWebChannelOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebChannelOptions - /// - /// The SID that identifies the resource to delete - public DeleteWebChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string FlexFlowSid { get; } + /// + /// The chat identity + /// + public string Identity { get; } + /// + /// The chat participant's friendly name + /// + public string CustomerFriendlyName { get; } + /// + /// The chat channel's friendly name + /// + public string ChatFriendlyName { get; } + /// + /// The chat channel's unique name + /// + public string ChatUniqueName { get; set; } + /// + /// The pre-engagement data + /// + public string PreEngagementData { get; set; } + + /// + /// Construct a new CreateWebChannelOptions + /// + /// The SID of the Flex Flow + /// The chat identity + /// The chat participant's friendly name + /// The chat channel's friendly name + public CreateWebChannelOptions(string flexFlowSid, + string identity, + string customerFriendlyName, + string chatFriendlyName) + { + FlexFlowSid = flexFlowSid; + Identity = identity; + CustomerFriendlyName = customerFriendlyName; + ChatFriendlyName = chatFriendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FlexFlowSid != null) + { + p.Add(new KeyValuePair("FlexFlowSid", FlexFlowSid.ToString())); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (CustomerFriendlyName != null) + { + p.Add(new KeyValuePair("CustomerFriendlyName", CustomerFriendlyName)); + } + + if (ChatFriendlyName != null) + { + p.Add(new KeyValuePair("ChatFriendlyName", ChatFriendlyName)); + } + + if (ChatUniqueName != null) + { + p.Add(new KeyValuePair("ChatUniqueName", ChatUniqueName)); + } + + if (PreEngagementData != null) + { + p.Add(new KeyValuePair("PreEngagementData", PreEngagementData)); + } + + return p; + } + } + + /// + /// UpdateWebChannelOptions + /// + public class UpdateWebChannelOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The chat status + /// + public WebChannelResource.ChatStatusEnum ChatStatus { get; set; } + /// + /// The post-engagement data + /// + public string PostEngagementData { get; set; } + + /// + /// Construct a new UpdateWebChannelOptions + /// + /// The SID that identifies the resource to update + public UpdateWebChannelOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ChatStatus != null) + { + p.Add(new KeyValuePair("ChatStatus", ChatStatus.ToString())); + } + + if (PostEngagementData != null) + { + p.Add(new KeyValuePair("PostEngagementData", PostEngagementData)); + } + + return p; + } + } + + /// + /// DeleteWebChannelOptions + /// + public class DeleteWebChannelOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebChannelOptions + /// + /// The SID that identifies the resource to delete + public DeleteWebChannelOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FlexApi/V1/WebChannelResource.cs b/src/Twilio/Rest/FlexApi/V1/WebChannelResource.cs index 4b4e941ee..7dddae7de 100644 --- a/src/Twilio/Rest/FlexApi/V1/WebChannelResource.cs +++ b/src/Twilio/Rest/FlexApi/V1/WebChannelResource.cs @@ -17,501 +17,501 @@ using Twilio.Types; namespace Twilio.Rest.FlexApi.V1 -{ - - public class WebChannelResource : Resource - { - public sealed class ChatStatusEnum : StringEnum - { - private ChatStatusEnum(string value) : base(value) {} - public ChatStatusEnum() {} - public static implicit operator ChatStatusEnum(string value) - { - return new ChatStatusEnum(value); - } - - public static readonly ChatStatusEnum Inactive = new ChatStatusEnum("inactive"); - } - - private static Request BuildReadRequest(ReadWebChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/WebChannels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read WebChannel parameters - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static ResourceSet Read(ReadWebChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_chat_channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read WebChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("flex_chat_channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebChannelOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebChannelOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.FlexApi) - ); - - var response = client.Request(request); - return Page.FromJson("flex_chat_channels", response.Content); - } - - private static Request BuildFetchRequest(FetchWebChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FlexApi, - "/v1/WebChannels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WebChannel parameters - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Fetch(FetchWebChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WebChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchWebChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the WebChannel resource to fetch - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWebChannelOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the WebChannel resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebChannelOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateWebChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/WebChannels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create WebChannel parameters - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Create(CreateWebChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create WebChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task CreateAsync(CreateWebChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Flex Flow - /// The chat identity - /// The chat participant's friendly name - /// The chat channel's friendly name - /// The chat channel's unique name - /// The pre-engagement data - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Create(string flexFlowSid, - string identity, - string customerFriendlyName, - string chatFriendlyName, - string chatUniqueName = null, - string preEngagementData = null, - ITwilioRestClient client = null) - { - var options = new CreateWebChannelOptions(flexFlowSid, identity, customerFriendlyName, chatFriendlyName){ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Flex Flow - /// The chat identity - /// The chat participant's friendly name - /// The chat channel's friendly name - /// The chat channel's unique name - /// The pre-engagement data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task CreateAsync(string flexFlowSid, - string identity, - string customerFriendlyName, - string chatFriendlyName, - string chatUniqueName = null, - string preEngagementData = null, - ITwilioRestClient client = null) - { - var options = new CreateWebChannelOptions(flexFlowSid, identity, customerFriendlyName, chatFriendlyName){ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FlexApi, - "/v1/WebChannels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update WebChannel parameters - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Update(UpdateWebChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update WebChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// The chat status - /// The post-engagement data - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static WebChannelResource Update(string pathSid, - WebChannelResource.ChatStatusEnum chatStatus = null, - string postEngagementData = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebChannelOptions(pathSid){ChatStatus = chatStatus, PostEngagementData = postEngagementData}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// The chat status - /// The post-engagement data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - WebChannelResource.ChatStatusEnum chatStatus = null, - string postEngagementData = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebChannelOptions(pathSid){ChatStatus = chatStatus, PostEngagementData = postEngagementData}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.FlexApi, - "/v1/WebChannels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete WebChannel parameters - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static bool Delete(DeleteWebChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete WebChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of WebChannel - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWebChannelOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WebChannel - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWebChannelOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebChannelResource object - /// - /// Raw JSON string - /// WebChannelResource object represented by the provided JSON - public static WebChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource and owns this Workflow - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flex Flow - /// - [JsonProperty("flex_flow_sid")] - public string FlexFlowSid { get; private set; } - /// - /// The unique string that identifies the WebChannel resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The absolute URL of the WebChannel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private WebChannelResource() - { - - } - } +{ + + public class WebChannelResource : Resource + { + public sealed class ChatStatusEnum : StringEnum + { + private ChatStatusEnum(string value) : base(value) { } + public ChatStatusEnum() { } + public static implicit operator ChatStatusEnum(string value) + { + return new ChatStatusEnum(value); + } + + public static readonly ChatStatusEnum Inactive = new ChatStatusEnum("inactive"); + } + + private static Request BuildReadRequest(ReadWebChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/WebChannels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read WebChannel parameters + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static ResourceSet Read(ReadWebChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_chat_channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read WebChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("flex_chat_channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebChannelOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebChannelOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.FlexApi) + ); + + var response = client.Request(request); + return Page.FromJson("flex_chat_channels", response.Content); + } + + private static Request BuildFetchRequest(FetchWebChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FlexApi, + "/v1/WebChannels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WebChannel parameters + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Fetch(FetchWebChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WebChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchWebChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the WebChannel resource to fetch + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWebChannelOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the WebChannel resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebChannelOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateWebChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/WebChannels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create WebChannel parameters + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Create(CreateWebChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create WebChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task CreateAsync(CreateWebChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Flex Flow + /// The chat identity + /// The chat participant's friendly name + /// The chat channel's friendly name + /// The chat channel's unique name + /// The pre-engagement data + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Create(string flexFlowSid, + string identity, + string customerFriendlyName, + string chatFriendlyName, + string chatUniqueName = null, + string preEngagementData = null, + ITwilioRestClient client = null) + { + var options = new CreateWebChannelOptions(flexFlowSid, identity, customerFriendlyName, chatFriendlyName) { ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Flex Flow + /// The chat identity + /// The chat participant's friendly name + /// The chat channel's friendly name + /// The chat channel's unique name + /// The pre-engagement data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task CreateAsync(string flexFlowSid, + string identity, + string customerFriendlyName, + string chatFriendlyName, + string chatUniqueName = null, + string preEngagementData = null, + ITwilioRestClient client = null) + { + var options = new CreateWebChannelOptions(flexFlowSid, identity, customerFriendlyName, chatFriendlyName) { ChatUniqueName = chatUniqueName, PreEngagementData = preEngagementData }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FlexApi, + "/v1/WebChannels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update WebChannel parameters + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Update(UpdateWebChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update WebChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// The chat status + /// The post-engagement data + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static WebChannelResource Update(string pathSid, + WebChannelResource.ChatStatusEnum chatStatus = null, + string postEngagementData = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebChannelOptions(pathSid) { ChatStatus = chatStatus, PostEngagementData = postEngagementData }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// The chat status + /// The post-engagement data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + WebChannelResource.ChatStatusEnum chatStatus = null, + string postEngagementData = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebChannelOptions(pathSid) { ChatStatus = chatStatus, PostEngagementData = postEngagementData }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.FlexApi, + "/v1/WebChannels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete WebChannel parameters + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static bool Delete(DeleteWebChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete WebChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of WebChannel + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWebChannelOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WebChannel + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWebChannelOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebChannelResource object + /// + /// Raw JSON string + /// WebChannelResource object represented by the provided JSON + public static WebChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource and owns this Workflow + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flex Flow + /// + [JsonProperty("flex_flow_sid")] + public string FlexFlowSid { get; private set; } + /// + /// The unique string that identifies the WebChannel resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The absolute URL of the WebChannel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private WebChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FrontlineApi/V1/UserOptions.cs b/src/Twilio/Rest/FrontlineApi/V1/UserOptions.cs index 2da04c279..393359b51 100644 --- a/src/Twilio/Rest/FrontlineApi/V1/UserOptions.cs +++ b/src/Twilio/Rest/FrontlineApi/V1/UserOptions.cs @@ -9,104 +9,104 @@ using Twilio.Converters; namespace Twilio.Rest.FrontlineApi.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a frontline user + /// + public class FetchUserOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a frontline user + /// The SID of the User resource to fetch /// - public class FetchUserOptions : IOptions - { - /// - /// The SID of the User resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The SID of the User resource to fetch - public FetchUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update an existing frontline user + /// Construct a new FetchUserOptions /// - public class UpdateUserOptions : IOptions - { - /// - /// The SID of the User resource to update - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the User - /// - public string FriendlyName { get; set; } - /// - /// The avatar URL which will be shown in Frontline application - /// - public string Avatar { get; set; } - /// - /// Current state of this user - /// - public UserResource.StateTypeEnum State { get; set; } - /// - /// Whether the User is available for new conversations - /// - public bool? IsAvailable { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The SID of the User resource to update - public UpdateUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Avatar != null) - { - p.Add(new KeyValuePair("Avatar", Avatar)); - } - - if (State != null) - { - p.Add(new KeyValuePair("State", State.ToString())); - } - - if (IsAvailable != null) - { - p.Add(new KeyValuePair("IsAvailable", IsAvailable.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the User resource to fetch + public FetchUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update an existing frontline user + /// + public class UpdateUserOptions : IOptions + { + /// + /// The SID of the User resource to update + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the User + /// + public string FriendlyName { get; set; } + /// + /// The avatar URL which will be shown in Frontline application + /// + public string Avatar { get; set; } + /// + /// Current state of this user + /// + public UserResource.StateTypeEnum State { get; set; } + /// + /// Whether the User is available for new conversations + /// + public bool? IsAvailable { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The SID of the User resource to update + public UpdateUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Avatar != null) + { + p.Add(new KeyValuePair("Avatar", Avatar)); + } + + if (State != null) + { + p.Add(new KeyValuePair("State", State.ToString())); + } + + if (IsAvailable != null) + { + p.Add(new KeyValuePair("IsAvailable", IsAvailable.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/FrontlineApi/V1/UserResource.cs b/src/Twilio/Rest/FrontlineApi/V1/UserResource.cs index 9d9d80c73..f388cf525 100644 --- a/src/Twilio/Rest/FrontlineApi/V1/UserResource.cs +++ b/src/Twilio/Rest/FrontlineApi/V1/UserResource.cs @@ -19,233 +19,233 @@ using Twilio.Types; namespace Twilio.Rest.FrontlineApi.V1 -{ - - public class UserResource : Resource - { - public sealed class StateTypeEnum : StringEnum - { - private StateTypeEnum(string value) : base(value) {} - public StateTypeEnum() {} - public static implicit operator StateTypeEnum(string value) - { - return new StateTypeEnum(value); - } - - public static readonly StateTypeEnum Active = new StateTypeEnum("active"); - public static readonly StateTypeEnum Deactivated = new StateTypeEnum("deactivated"); - } - - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.FrontlineApi, - "/v1/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a frontline user - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a frontline user - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a frontline user - /// - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a frontline user - /// - /// The SID of the User resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.FrontlineApi, - "/v1/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing frontline user - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing frontline user - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing frontline user - /// - /// The SID of the User resource to update - /// The string that you assigned to describe the User - /// The avatar URL which will be shown in Frontline application - /// Current state of this user - /// Whether the User is available for new conversations - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathSid, - string friendlyName = null, - string avatar = null, - UserResource.StateTypeEnum state = null, - bool? isAvailable = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathSid){FriendlyName = friendlyName, Avatar = avatar, State = state, IsAvailable = isAvailable}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing frontline user - /// - /// The SID of the User resource to update - /// The string that you assigned to describe the User - /// The avatar URL which will be shown in Frontline application - /// Current state of this user - /// Whether the User is available for new conversations - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string avatar = null, - UserResource.StateTypeEnum state = null, - bool? isAvailable = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathSid){FriendlyName = friendlyName, Avatar = avatar, State = state, IsAvailable = isAvailable}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The string that you assigned to describe the User - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The avatar URL which will be shown in Frontline application - /// - [JsonProperty("avatar")] - public string Avatar { get; private set; } - /// - /// Current state of this user - /// - [JsonProperty("state")] - [JsonConverter(typeof(StringEnumConverter))] - public UserResource.StateTypeEnum State { get; private set; } - /// - /// Whether the User is available for new conversations - /// - [JsonProperty("is_available")] - public bool? IsAvailable { get; private set; } - /// - /// An absolute URL for this user. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + public sealed class StateTypeEnum : StringEnum + { + private StateTypeEnum(string value) : base(value) { } + public StateTypeEnum() { } + public static implicit operator StateTypeEnum(string value) + { + return new StateTypeEnum(value); + } + + public static readonly StateTypeEnum Active = new StateTypeEnum("active"); + public static readonly StateTypeEnum Deactivated = new StateTypeEnum("deactivated"); + } + + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.FrontlineApi, + "/v1/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a frontline user + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a frontline user + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a frontline user + /// + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a frontline user + /// + /// The SID of the User resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.FrontlineApi, + "/v1/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing frontline user + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing frontline user + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing frontline user + /// + /// The SID of the User resource to update + /// The string that you assigned to describe the User + /// The avatar URL which will be shown in Frontline application + /// Current state of this user + /// Whether the User is available for new conversations + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathSid, + string friendlyName = null, + string avatar = null, + UserResource.StateTypeEnum state = null, + bool? isAvailable = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathSid) { FriendlyName = friendlyName, Avatar = avatar, State = state, IsAvailable = isAvailable }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing frontline user + /// + /// The SID of the User resource to update + /// The string that you assigned to describe the User + /// The avatar URL which will be shown in Frontline application + /// Current state of this user + /// Whether the User is available for new conversations + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string avatar = null, + UserResource.StateTypeEnum state = null, + bool? isAvailable = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathSid) { FriendlyName = friendlyName, Avatar = avatar, State = state, IsAvailable = isAvailable }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The string that you assigned to describe the User + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The avatar URL which will be shown in Frontline application + /// + [JsonProperty("avatar")] + public string Avatar { get; private set; } + /// + /// Current state of this user + /// + [JsonProperty("state")] + [JsonConverter(typeof(StringEnumConverter))] + public UserResource.StateTypeEnum State { get; private set; } + /// + /// Whether the User is available for new conversations + /// + [JsonProperty("is_available")] + public bool? IsAvailable { get; private set; } + /// + /// An absolute URL for this user. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/CallSummaryOptions.cs b/src/Twilio/Rest/Insights/V1/Call/CallSummaryOptions.cs index 080def3f1..64b739549 100644 --- a/src/Twilio/Rest/Insights/V1/Call/CallSummaryOptions.cs +++ b/src/Twilio/Rest/Insights/V1/Call/CallSummaryOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1.Call -{ - +{ + + /// + /// FetchCallSummaryOptions + /// + public class FetchCallSummaryOptions : IOptions + { /// - /// FetchCallSummaryOptions + /// The call_sid /// - public class FetchCallSummaryOptions : IOptions - { - /// - /// The call_sid - /// - public string PathCallSid { get; } - /// - /// The processing_state - /// - public CallSummaryResource.ProcessingStateEnum ProcessingState { get; set; } - - /// - /// Construct a new FetchCallSummaryOptions - /// - /// The call_sid - public FetchCallSummaryOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ProcessingState != null) - { - p.Add(new KeyValuePair("ProcessingState", ProcessingState.ToString())); - } - - return p; - } - } + public string PathCallSid { get; } + /// + /// The processing_state + /// + public CallSummaryResource.ProcessingStateEnum ProcessingState { get; set; } + + /// + /// Construct a new FetchCallSummaryOptions + /// + /// The call_sid + public FetchCallSummaryOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ProcessingState != null) + { + p.Add(new KeyValuePair("ProcessingState", ProcessingState.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/CallSummaryResource.cs b/src/Twilio/Rest/Insights/V1/Call/CallSummaryResource.cs index bd25cc803..dff6dc8e8 100644 --- a/src/Twilio/Rest/Insights/V1/Call/CallSummaryResource.cs +++ b/src/Twilio/Rest/Insights/V1/Call/CallSummaryResource.cs @@ -17,260 +17,260 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1.Call -{ - - public class CallSummaryResource : Resource - { - public sealed class CallTypeEnum : StringEnum - { - private CallTypeEnum(string value) : base(value) {} - public CallTypeEnum() {} - public static implicit operator CallTypeEnum(string value) - { - return new CallTypeEnum(value); - } - - public static readonly CallTypeEnum Carrier = new CallTypeEnum("carrier"); - public static readonly CallTypeEnum Sip = new CallTypeEnum("sip"); - public static readonly CallTypeEnum Trunking = new CallTypeEnum("trunking"); - public static readonly CallTypeEnum Client = new CallTypeEnum("client"); - } - - public sealed class CallStateEnum : StringEnum - { - private CallStateEnum(string value) : base(value) {} - public CallStateEnum() {} - public static implicit operator CallStateEnum(string value) - { - return new CallStateEnum(value); - } - - public static readonly CallStateEnum Ringing = new CallStateEnum("ringing"); - public static readonly CallStateEnum Completed = new CallStateEnum("completed"); - public static readonly CallStateEnum Busy = new CallStateEnum("busy"); - public static readonly CallStateEnum Fail = new CallStateEnum("fail"); - public static readonly CallStateEnum Noanswer = new CallStateEnum("noanswer"); - public static readonly CallStateEnum Canceled = new CallStateEnum("canceled"); - public static readonly CallStateEnum Answered = new CallStateEnum("answered"); - public static readonly CallStateEnum Undialed = new CallStateEnum("undialed"); - } - - public sealed class ProcessingStateEnum : StringEnum - { - private ProcessingStateEnum(string value) : base(value) {} - public ProcessingStateEnum() {} - public static implicit operator ProcessingStateEnum(string value) - { - return new ProcessingStateEnum(value); - } - - public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); - public static readonly ProcessingStateEnum Partial = new ProcessingStateEnum("partial"); - } - - private static Request BuildFetchRequest(FetchCallSummaryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/" + options.PathCallSid + "/Summary", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch CallSummary parameters - /// Client to make requests to Twilio - /// A single instance of CallSummary - public static CallSummaryResource Fetch(FetchCallSummaryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch CallSummary parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CallSummary - public static async System.Threading.Tasks.Task FetchAsync(FetchCallSummaryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The call_sid - /// The processing_state - /// Client to make requests to Twilio - /// A single instance of CallSummary - public static CallSummaryResource Fetch(string pathCallSid, - CallSummaryResource.ProcessingStateEnum processingState = null, - ITwilioRestClient client = null) - { - var options = new FetchCallSummaryOptions(pathCallSid){ProcessingState = processingState}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The call_sid - /// The processing_state - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CallSummary - public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, - CallSummaryResource.ProcessingStateEnum processingState = null, - ITwilioRestClient client = null) - { - var options = new FetchCallSummaryOptions(pathCallSid){ProcessingState = processingState}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CallSummaryResource object - /// - /// Raw JSON string - /// CallSummaryResource object represented by the provided JSON - public static CallSummaryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The call_sid - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The call_type - /// - [JsonProperty("call_type")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummaryResource.CallTypeEnum CallType { get; private set; } - /// - /// The call_state - /// - [JsonProperty("call_state")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummaryResource.CallStateEnum CallState { get; private set; } - /// - /// The processing_state - /// - [JsonProperty("processing_state")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummaryResource.ProcessingStateEnum ProcessingState { get; private set; } - /// - /// The created_time - /// - [JsonProperty("created_time")] - public DateTime? CreatedTime { get; private set; } - /// - /// The start_time - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end_time - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The duration - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The connect_duration - /// - [JsonProperty("connect_duration")] - public int? ConnectDuration { get; private set; } - /// - /// The from - /// - [JsonProperty("from")] - public object From { get; private set; } - /// - /// The to - /// - [JsonProperty("to")] - public object To { get; private set; } - /// - /// The carrier_edge - /// - [JsonProperty("carrier_edge")] - public object CarrierEdge { get; private set; } - /// - /// The client_edge - /// - [JsonProperty("client_edge")] - public object ClientEdge { get; private set; } - /// - /// The sdk_edge - /// - [JsonProperty("sdk_edge")] - public object SdkEdge { get; private set; } - /// - /// The sip_edge - /// - [JsonProperty("sip_edge")] - public object SipEdge { get; private set; } - /// - /// The tags - /// - [JsonProperty("tags")] - public List Tags { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The properties - /// - [JsonProperty("properties")] - public object Properties { get; private set; } - /// - /// The trust - /// - [JsonProperty("trust")] - public object Trust { get; private set; } - - private CallSummaryResource() - { - - } - } +{ + + public class CallSummaryResource : Resource + { + public sealed class CallTypeEnum : StringEnum + { + private CallTypeEnum(string value) : base(value) { } + public CallTypeEnum() { } + public static implicit operator CallTypeEnum(string value) + { + return new CallTypeEnum(value); + } + + public static readonly CallTypeEnum Carrier = new CallTypeEnum("carrier"); + public static readonly CallTypeEnum Sip = new CallTypeEnum("sip"); + public static readonly CallTypeEnum Trunking = new CallTypeEnum("trunking"); + public static readonly CallTypeEnum Client = new CallTypeEnum("client"); + } + + public sealed class CallStateEnum : StringEnum + { + private CallStateEnum(string value) : base(value) { } + public CallStateEnum() { } + public static implicit operator CallStateEnum(string value) + { + return new CallStateEnum(value); + } + + public static readonly CallStateEnum Ringing = new CallStateEnum("ringing"); + public static readonly CallStateEnum Completed = new CallStateEnum("completed"); + public static readonly CallStateEnum Busy = new CallStateEnum("busy"); + public static readonly CallStateEnum Fail = new CallStateEnum("fail"); + public static readonly CallStateEnum Noanswer = new CallStateEnum("noanswer"); + public static readonly CallStateEnum Canceled = new CallStateEnum("canceled"); + public static readonly CallStateEnum Answered = new CallStateEnum("answered"); + public static readonly CallStateEnum Undialed = new CallStateEnum("undialed"); + } + + public sealed class ProcessingStateEnum : StringEnum + { + private ProcessingStateEnum(string value) : base(value) { } + public ProcessingStateEnum() { } + public static implicit operator ProcessingStateEnum(string value) + { + return new ProcessingStateEnum(value); + } + + public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); + public static readonly ProcessingStateEnum Partial = new ProcessingStateEnum("partial"); + } + + private static Request BuildFetchRequest(FetchCallSummaryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/" + options.PathCallSid + "/Summary", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch CallSummary parameters + /// Client to make requests to Twilio + /// A single instance of CallSummary + public static CallSummaryResource Fetch(FetchCallSummaryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch CallSummary parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CallSummary + public static async System.Threading.Tasks.Task FetchAsync(FetchCallSummaryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The call_sid + /// The processing_state + /// Client to make requests to Twilio + /// A single instance of CallSummary + public static CallSummaryResource Fetch(string pathCallSid, + CallSummaryResource.ProcessingStateEnum processingState = null, + ITwilioRestClient client = null) + { + var options = new FetchCallSummaryOptions(pathCallSid) { ProcessingState = processingState }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The call_sid + /// The processing_state + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CallSummary + public static async System.Threading.Tasks.Task FetchAsync(string pathCallSid, + CallSummaryResource.ProcessingStateEnum processingState = null, + ITwilioRestClient client = null) + { + var options = new FetchCallSummaryOptions(pathCallSid) { ProcessingState = processingState }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CallSummaryResource object + /// + /// Raw JSON string + /// CallSummaryResource object represented by the provided JSON + public static CallSummaryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The call_sid + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The call_type + /// + [JsonProperty("call_type")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummaryResource.CallTypeEnum CallType { get; private set; } + /// + /// The call_state + /// + [JsonProperty("call_state")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummaryResource.CallStateEnum CallState { get; private set; } + /// + /// The processing_state + /// + [JsonProperty("processing_state")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummaryResource.ProcessingStateEnum ProcessingState { get; private set; } + /// + /// The created_time + /// + [JsonProperty("created_time")] + public DateTime? CreatedTime { get; private set; } + /// + /// The start_time + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end_time + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The duration + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The connect_duration + /// + [JsonProperty("connect_duration")] + public int? ConnectDuration { get; private set; } + /// + /// The from + /// + [JsonProperty("from")] + public object From { get; private set; } + /// + /// The to + /// + [JsonProperty("to")] + public object To { get; private set; } + /// + /// The carrier_edge + /// + [JsonProperty("carrier_edge")] + public object CarrierEdge { get; private set; } + /// + /// The client_edge + /// + [JsonProperty("client_edge")] + public object ClientEdge { get; private set; } + /// + /// The sdk_edge + /// + [JsonProperty("sdk_edge")] + public object SdkEdge { get; private set; } + /// + /// The sip_edge + /// + [JsonProperty("sip_edge")] + public object SipEdge { get; private set; } + /// + /// The tags + /// + [JsonProperty("tags")] + public List Tags { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The properties + /// + [JsonProperty("properties")] + public object Properties { get; private set; } + /// + /// The trust + /// + [JsonProperty("trust")] + public object Trust { get; private set; } + + private CallSummaryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/EventOptions.cs b/src/Twilio/Rest/Insights/V1/Call/EventOptions.cs index 15cefc67a..f44506070 100644 --- a/src/Twilio/Rest/Insights/V1/Call/EventOptions.cs +++ b/src/Twilio/Rest/Insights/V1/Call/EventOptions.cs @@ -9,52 +9,52 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1.Call -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadEventOptions + /// + public class ReadEventOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadEventOptions + /// The call_sid /// - public class ReadEventOptions : ReadOptions - { - /// - /// The call_sid - /// - public string PathCallSid { get; } - /// - /// The edge - /// - public EventResource.TwilioEdgeEnum Edge { get; set; } - - /// - /// Construct a new ReadEventOptions - /// - /// The call_sid - public ReadEventOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Edge != null) - { - p.Add(new KeyValuePair("Edge", Edge.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathCallSid { get; } + /// + /// The edge + /// + public EventResource.TwilioEdgeEnum Edge { get; set; } + + /// + /// Construct a new ReadEventOptions + /// + /// The call_sid + public ReadEventOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Edge != null) + { + p.Add(new KeyValuePair("Edge", Edge.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/EventResource.cs b/src/Twilio/Rest/Insights/V1/Call/EventResource.cs index 32fd30a35..09f595ed4 100644 --- a/src/Twilio/Rest/Insights/V1/Call/EventResource.cs +++ b/src/Twilio/Rest/Insights/V1/Call/EventResource.cs @@ -20,259 +20,259 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1.Call -{ - - public class EventResource : Resource - { - public sealed class TwilioEdgeEnum : StringEnum - { - private TwilioEdgeEnum(string value) : base(value) {} - public TwilioEdgeEnum() {} - public static implicit operator TwilioEdgeEnum(string value) - { - return new TwilioEdgeEnum(value); - } - - public static readonly TwilioEdgeEnum UnknownEdge = new TwilioEdgeEnum("unknown_edge"); - public static readonly TwilioEdgeEnum CarrierEdge = new TwilioEdgeEnum("carrier_edge"); - public static readonly TwilioEdgeEnum SipEdge = new TwilioEdgeEnum("sip_edge"); - public static readonly TwilioEdgeEnum SdkEdge = new TwilioEdgeEnum("sdk_edge"); - public static readonly TwilioEdgeEnum ClientEdge = new TwilioEdgeEnum("client_edge"); - } - - public sealed class LevelEnum : StringEnum - { - private LevelEnum(string value) : base(value) {} - public LevelEnum() {} - public static implicit operator LevelEnum(string value) - { - return new LevelEnum(value); - } - - public static readonly LevelEnum Unknown = new LevelEnum("UNKNOWN"); - public static readonly LevelEnum Debug = new LevelEnum("DEBUG"); - public static readonly LevelEnum Info = new LevelEnum("INFO"); - public static readonly LevelEnum Warning = new LevelEnum("WARNING"); - public static readonly LevelEnum Error = new LevelEnum("ERROR"); - } - - private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/" + options.PathCallSid + "/Events", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The call_sid - /// The edge - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(string pathCallSid, - EventResource.TwilioEdgeEnum edge = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathCallSid){Edge = edge, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The call_sid - /// The edge - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, - EventResource.TwilioEdgeEnum edge = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathCallSid){Edge = edge, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Converts a JSON string into a EventResource object - /// - /// Raw JSON string - /// EventResource object represented by the provided JSON - public static EventResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The timestamp - /// - [JsonProperty("timestamp")] - public string Timestamp { get; private set; } - /// - /// The call_sid - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The edge - /// - [JsonProperty("edge")] - [JsonConverter(typeof(StringEnumConverter))] - public EventResource.TwilioEdgeEnum Edge { get; private set; } - /// - /// The group - /// - [JsonProperty("group")] - public string Group { get; private set; } - /// - /// The level - /// - [JsonProperty("level")] - [JsonConverter(typeof(StringEnumConverter))] - public EventResource.LevelEnum Level { get; private set; } - /// - /// The name - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The carrier_edge - /// - [JsonProperty("carrier_edge")] - public object CarrierEdge { get; private set; } - /// - /// The sip_edge - /// - [JsonProperty("sip_edge")] - public object SipEdge { get; private set; } - /// - /// The sdk_edge - /// - [JsonProperty("sdk_edge")] - public object SdkEdge { get; private set; } - /// - /// The client_edge - /// - [JsonProperty("client_edge")] - public object ClientEdge { get; private set; } - - private EventResource() - { - - } - } +{ + + public class EventResource : Resource + { + public sealed class TwilioEdgeEnum : StringEnum + { + private TwilioEdgeEnum(string value) : base(value) { } + public TwilioEdgeEnum() { } + public static implicit operator TwilioEdgeEnum(string value) + { + return new TwilioEdgeEnum(value); + } + + public static readonly TwilioEdgeEnum UnknownEdge = new TwilioEdgeEnum("unknown_edge"); + public static readonly TwilioEdgeEnum CarrierEdge = new TwilioEdgeEnum("carrier_edge"); + public static readonly TwilioEdgeEnum SipEdge = new TwilioEdgeEnum("sip_edge"); + public static readonly TwilioEdgeEnum SdkEdge = new TwilioEdgeEnum("sdk_edge"); + public static readonly TwilioEdgeEnum ClientEdge = new TwilioEdgeEnum("client_edge"); + } + + public sealed class LevelEnum : StringEnum + { + private LevelEnum(string value) : base(value) { } + public LevelEnum() { } + public static implicit operator LevelEnum(string value) + { + return new LevelEnum(value); + } + + public static readonly LevelEnum Unknown = new LevelEnum("UNKNOWN"); + public static readonly LevelEnum Debug = new LevelEnum("DEBUG"); + public static readonly LevelEnum Info = new LevelEnum("INFO"); + public static readonly LevelEnum Warning = new LevelEnum("WARNING"); + public static readonly LevelEnum Error = new LevelEnum("ERROR"); + } + + private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/" + options.PathCallSid + "/Events", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The call_sid + /// The edge + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(string pathCallSid, + EventResource.TwilioEdgeEnum edge = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathCallSid) { Edge = edge, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The call_sid + /// The edge + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, + EventResource.TwilioEdgeEnum edge = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathCallSid) { Edge = edge, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Converts a JSON string into a EventResource object + /// + /// Raw JSON string + /// EventResource object represented by the provided JSON + public static EventResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The timestamp + /// + [JsonProperty("timestamp")] + public string Timestamp { get; private set; } + /// + /// The call_sid + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The edge + /// + [JsonProperty("edge")] + [JsonConverter(typeof(StringEnumConverter))] + public EventResource.TwilioEdgeEnum Edge { get; private set; } + /// + /// The group + /// + [JsonProperty("group")] + public string Group { get; private set; } + /// + /// The level + /// + [JsonProperty("level")] + [JsonConverter(typeof(StringEnumConverter))] + public EventResource.LevelEnum Level { get; private set; } + /// + /// The name + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The carrier_edge + /// + [JsonProperty("carrier_edge")] + public object CarrierEdge { get; private set; } + /// + /// The sip_edge + /// + [JsonProperty("sip_edge")] + public object SipEdge { get; private set; } + /// + /// The sdk_edge + /// + [JsonProperty("sdk_edge")] + public object SdkEdge { get; private set; } + /// + /// The client_edge + /// + [JsonProperty("client_edge")] + public object ClientEdge { get; private set; } + + private EventResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/MetricOptions.cs b/src/Twilio/Rest/Insights/V1/Call/MetricOptions.cs index 8d9dcb306..a4df63ae7 100644 --- a/src/Twilio/Rest/Insights/V1/Call/MetricOptions.cs +++ b/src/Twilio/Rest/Insights/V1/Call/MetricOptions.cs @@ -9,61 +9,61 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1.Call -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadMetricOptions + /// + public class ReadMetricOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadMetricOptions + /// The call_sid /// - public class ReadMetricOptions : ReadOptions - { - /// - /// The call_sid - /// - public string PathCallSid { get; } - /// - /// The edge - /// - public MetricResource.TwilioEdgeEnum Edge { get; set; } - /// - /// The direction - /// - public MetricResource.StreamDirectionEnum Direction { get; set; } - - /// - /// Construct a new ReadMetricOptions - /// - /// The call_sid - public ReadMetricOptions(string pathCallSid) - { - PathCallSid = pathCallSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Edge != null) - { - p.Add(new KeyValuePair("Edge", Edge.ToString())); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathCallSid { get; } + /// + /// The edge + /// + public MetricResource.TwilioEdgeEnum Edge { get; set; } + /// + /// The direction + /// + public MetricResource.StreamDirectionEnum Direction { get; set; } + + /// + /// Construct a new ReadMetricOptions + /// + /// The call_sid + public ReadMetricOptions(string pathCallSid) + { + PathCallSid = pathCallSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Edge != null) + { + p.Add(new KeyValuePair("Edge", Edge.ToString())); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Call/MetricResource.cs b/src/Twilio/Rest/Insights/V1/Call/MetricResource.cs index b48d3a62a..5e6014f7b 100644 --- a/src/Twilio/Rest/Insights/V1/Call/MetricResource.cs +++ b/src/Twilio/Rest/Insights/V1/Call/MetricResource.cs @@ -20,252 +20,252 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1.Call -{ - - public class MetricResource : Resource - { - public sealed class TwilioEdgeEnum : StringEnum - { - private TwilioEdgeEnum(string value) : base(value) {} - public TwilioEdgeEnum() {} - public static implicit operator TwilioEdgeEnum(string value) - { - return new TwilioEdgeEnum(value); - } - - public static readonly TwilioEdgeEnum UnknownEdge = new TwilioEdgeEnum("unknown_edge"); - public static readonly TwilioEdgeEnum CarrierEdge = new TwilioEdgeEnum("carrier_edge"); - public static readonly TwilioEdgeEnum SipEdge = new TwilioEdgeEnum("sip_edge"); - public static readonly TwilioEdgeEnum SdkEdge = new TwilioEdgeEnum("sdk_edge"); - public static readonly TwilioEdgeEnum ClientEdge = new TwilioEdgeEnum("client_edge"); - } - - public sealed class StreamDirectionEnum : StringEnum - { - private StreamDirectionEnum(string value) : base(value) {} - public StreamDirectionEnum() {} - public static implicit operator StreamDirectionEnum(string value) - { - return new StreamDirectionEnum(value); - } - - public static readonly StreamDirectionEnum Unknown = new StreamDirectionEnum("unknown"); - public static readonly StreamDirectionEnum Inbound = new StreamDirectionEnum("inbound"); - public static readonly StreamDirectionEnum Outbound = new StreamDirectionEnum("outbound"); - public static readonly StreamDirectionEnum Both = new StreamDirectionEnum("both"); - } - - private static Request BuildReadRequest(ReadMetricOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/" + options.PathCallSid + "/Metrics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Metric parameters - /// Client to make requests to Twilio - /// A single instance of Metric - public static ResourceSet Read(ReadMetricOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("metrics", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Metric parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Metric - public static async System.Threading.Tasks.Task> ReadAsync(ReadMetricOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("metrics", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The call_sid - /// The edge - /// The direction - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Metric - public static ResourceSet Read(string pathCallSid, - MetricResource.TwilioEdgeEnum edge = null, - MetricResource.StreamDirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMetricOptions(pathCallSid){Edge = edge, Direction = direction, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The call_sid - /// The edge - /// The direction - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Metric - public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, - MetricResource.TwilioEdgeEnum edge = null, - MetricResource.StreamDirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMetricOptions(pathCallSid){Edge = edge, Direction = direction, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("metrics", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("metrics", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("metrics", response.Content); - } - - /// - /// Converts a JSON string into a MetricResource object - /// - /// Raw JSON string - /// MetricResource object represented by the provided JSON - public static MetricResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The timestamp - /// - [JsonProperty("timestamp")] - public string Timestamp { get; private set; } - /// - /// The call_sid - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The edge - /// - [JsonProperty("edge")] - [JsonConverter(typeof(StringEnumConverter))] - public MetricResource.TwilioEdgeEnum Edge { get; private set; } - /// - /// The direction - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public MetricResource.StreamDirectionEnum Direction { get; private set; } - /// - /// The carrier_edge - /// - [JsonProperty("carrier_edge")] - public object CarrierEdge { get; private set; } - /// - /// The sip_edge - /// - [JsonProperty("sip_edge")] - public object SipEdge { get; private set; } - /// - /// The sdk_edge - /// - [JsonProperty("sdk_edge")] - public object SdkEdge { get; private set; } - /// - /// The client_edge - /// - [JsonProperty("client_edge")] - public object ClientEdge { get; private set; } - - private MetricResource() - { - - } - } +{ + + public class MetricResource : Resource + { + public sealed class TwilioEdgeEnum : StringEnum + { + private TwilioEdgeEnum(string value) : base(value) { } + public TwilioEdgeEnum() { } + public static implicit operator TwilioEdgeEnum(string value) + { + return new TwilioEdgeEnum(value); + } + + public static readonly TwilioEdgeEnum UnknownEdge = new TwilioEdgeEnum("unknown_edge"); + public static readonly TwilioEdgeEnum CarrierEdge = new TwilioEdgeEnum("carrier_edge"); + public static readonly TwilioEdgeEnum SipEdge = new TwilioEdgeEnum("sip_edge"); + public static readonly TwilioEdgeEnum SdkEdge = new TwilioEdgeEnum("sdk_edge"); + public static readonly TwilioEdgeEnum ClientEdge = new TwilioEdgeEnum("client_edge"); + } + + public sealed class StreamDirectionEnum : StringEnum + { + private StreamDirectionEnum(string value) : base(value) { } + public StreamDirectionEnum() { } + public static implicit operator StreamDirectionEnum(string value) + { + return new StreamDirectionEnum(value); + } + + public static readonly StreamDirectionEnum Unknown = new StreamDirectionEnum("unknown"); + public static readonly StreamDirectionEnum Inbound = new StreamDirectionEnum("inbound"); + public static readonly StreamDirectionEnum Outbound = new StreamDirectionEnum("outbound"); + public static readonly StreamDirectionEnum Both = new StreamDirectionEnum("both"); + } + + private static Request BuildReadRequest(ReadMetricOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/" + options.PathCallSid + "/Metrics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Metric parameters + /// Client to make requests to Twilio + /// A single instance of Metric + public static ResourceSet Read(ReadMetricOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("metrics", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Metric parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Metric + public static async System.Threading.Tasks.Task> ReadAsync(ReadMetricOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("metrics", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The call_sid + /// The edge + /// The direction + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Metric + public static ResourceSet Read(string pathCallSid, + MetricResource.TwilioEdgeEnum edge = null, + MetricResource.StreamDirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMetricOptions(pathCallSid) { Edge = edge, Direction = direction, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The call_sid + /// The edge + /// The direction + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Metric + public static async System.Threading.Tasks.Task> ReadAsync(string pathCallSid, + MetricResource.TwilioEdgeEnum edge = null, + MetricResource.StreamDirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMetricOptions(pathCallSid) { Edge = edge, Direction = direction, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("metrics", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("metrics", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("metrics", response.Content); + } + + /// + /// Converts a JSON string into a MetricResource object + /// + /// Raw JSON string + /// MetricResource object represented by the provided JSON + public static MetricResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The timestamp + /// + [JsonProperty("timestamp")] + public string Timestamp { get; private set; } + /// + /// The call_sid + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The edge + /// + [JsonProperty("edge")] + [JsonConverter(typeof(StringEnumConverter))] + public MetricResource.TwilioEdgeEnum Edge { get; private set; } + /// + /// The direction + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public MetricResource.StreamDirectionEnum Direction { get; private set; } + /// + /// The carrier_edge + /// + [JsonProperty("carrier_edge")] + public object CarrierEdge { get; private set; } + /// + /// The sip_edge + /// + [JsonProperty("sip_edge")] + public object SipEdge { get; private set; } + /// + /// The sdk_edge + /// + [JsonProperty("sdk_edge")] + public object SdkEdge { get; private set; } + /// + /// The client_edge + /// + [JsonProperty("client_edge")] + public object ClientEdge { get; private set; } + + private MetricResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/CallOptions.cs b/src/Twilio/Rest/Insights/V1/CallOptions.cs index 3dd23d2f7..8fc440cb8 100644 --- a/src/Twilio/Rest/Insights/V1/CallOptions.cs +++ b/src/Twilio/Rest/Insights/V1/CallOptions.cs @@ -9,38 +9,38 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchCallOptions + /// + public class FetchCallOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchCallOptions + /// The sid /// - public class FetchCallOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCallOptions - /// - /// The sid - public FetchCallOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchCallOptions + /// + /// The sid + public FetchCallOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/CallResource.cs b/src/Twilio/Rest/Insights/V1/CallResource.cs index d02c8f2b4..4a9ed89a0 100644 --- a/src/Twilio/Rest/Insights/V1/CallResource.cs +++ b/src/Twilio/Rest/Insights/V1/CallResource.cs @@ -19,115 +19,115 @@ using Twilio.Http; namespace Twilio.Rest.Insights.V1 -{ - - public class CallResource : Resource - { - private static Request BuildFetchRequest(FetchCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Call parameters - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Call parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Call - public static CallResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCallOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCallOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CallResource object - /// - /// Raw JSON string - /// CallResource object represented by the provided JSON - public static CallResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private CallResource() - { - - } - } +{ + + public class CallResource : Resource + { + private static Request BuildFetchRequest(FetchCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Call parameters + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Call parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Call + public static CallResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCallOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Call + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCallOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CallResource object + /// + /// Raw JSON string + /// CallResource object represented by the provided JSON + public static CallResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private CallResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/CallSummariesOptions.cs b/src/Twilio/Rest/Insights/V1/CallSummariesOptions.cs index a483cfac1..f7c15ad2f 100644 --- a/src/Twilio/Rest/Insights/V1/CallSummariesOptions.cs +++ b/src/Twilio/Rest/Insights/V1/CallSummariesOptions.cs @@ -9,189 +9,189 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1 -{ - +{ + + /// + /// ReadCallSummariesOptions + /// + public class ReadCallSummariesOptions : ReadOptions + { /// - /// ReadCallSummariesOptions - /// - public class ReadCallSummariesOptions : ReadOptions - { - /// - /// The from - /// - public string From { get; set; } - /// - /// The to - /// - public string To { get; set; } - /// - /// The from_carrier - /// - public string FromCarrier { get; set; } - /// - /// The to_carrier - /// - public string ToCarrier { get; set; } - /// - /// The from_country_code - /// - public string FromCountryCode { get; set; } - /// - /// The to_country_code - /// - public string ToCountryCode { get; set; } - /// - /// The branded - /// - public bool? Branded { get; set; } - /// - /// The verified_caller - /// - public bool? VerifiedCaller { get; set; } - /// - /// The has_tag - /// - public bool? HasTag { get; set; } - /// - /// The start_time - /// - public string StartTime { get; set; } - /// - /// The end_time - /// - public string EndTime { get; set; } - /// - /// The call_type - /// - public string CallType { get; set; } - /// - /// The call_state - /// - public string CallState { get; set; } - /// - /// The direction - /// - public string Direction { get; set; } - /// - /// The processing_state - /// - public CallSummariesResource.ProcessingStateRequestEnum ProcessingState { get; set; } - /// - /// The sort_by - /// - public CallSummariesResource.SortByEnum SortBy { get; set; } - /// - /// The subaccount - /// - public string Subaccount { get; set; } - /// - /// The abnormal_session - /// - public bool? AbnormalSession { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (FromCarrier != null) - { - p.Add(new KeyValuePair("FromCarrier", FromCarrier)); - } - - if (ToCarrier != null) - { - p.Add(new KeyValuePair("ToCarrier", ToCarrier)); - } - - if (FromCountryCode != null) - { - p.Add(new KeyValuePair("FromCountryCode", FromCountryCode)); - } - - if (ToCountryCode != null) - { - p.Add(new KeyValuePair("ToCountryCode", ToCountryCode)); - } - - if (Branded != null) - { - p.Add(new KeyValuePair("Branded", Branded.Value.ToString().ToLower())); - } - - if (VerifiedCaller != null) - { - p.Add(new KeyValuePair("VerifiedCaller", VerifiedCaller.Value.ToString().ToLower())); - } - - if (HasTag != null) - { - p.Add(new KeyValuePair("HasTag", HasTag.Value.ToString().ToLower())); - } - - if (StartTime != null) - { - p.Add(new KeyValuePair("StartTime", StartTime)); - } - - if (EndTime != null) - { - p.Add(new KeyValuePair("EndTime", EndTime)); - } - - if (CallType != null) - { - p.Add(new KeyValuePair("CallType", CallType)); - } - - if (CallState != null) - { - p.Add(new KeyValuePair("CallState", CallState)); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction)); - } - - if (ProcessingState != null) - { - p.Add(new KeyValuePair("ProcessingState", ProcessingState.ToString())); - } - - if (SortBy != null) - { - p.Add(new KeyValuePair("SortBy", SortBy.ToString())); - } - - if (Subaccount != null) - { - p.Add(new KeyValuePair("Subaccount", Subaccount.ToString())); - } - - if (AbnormalSession != null) - { - p.Add(new KeyValuePair("AbnormalSession", AbnormalSession.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The from + /// + public string From { get; set; } + /// + /// The to + /// + public string To { get; set; } + /// + /// The from_carrier + /// + public string FromCarrier { get; set; } + /// + /// The to_carrier + /// + public string ToCarrier { get; set; } + /// + /// The from_country_code + /// + public string FromCountryCode { get; set; } + /// + /// The to_country_code + /// + public string ToCountryCode { get; set; } + /// + /// The branded + /// + public bool? Branded { get; set; } + /// + /// The verified_caller + /// + public bool? VerifiedCaller { get; set; } + /// + /// The has_tag + /// + public bool? HasTag { get; set; } + /// + /// The start_time + /// + public string StartTime { get; set; } + /// + /// The end_time + /// + public string EndTime { get; set; } + /// + /// The call_type + /// + public string CallType { get; set; } + /// + /// The call_state + /// + public string CallState { get; set; } + /// + /// The direction + /// + public string Direction { get; set; } + /// + /// The processing_state + /// + public CallSummariesResource.ProcessingStateRequestEnum ProcessingState { get; set; } + /// + /// The sort_by + /// + public CallSummariesResource.SortByEnum SortBy { get; set; } + /// + /// The subaccount + /// + public string Subaccount { get; set; } + /// + /// The abnormal_session + /// + public bool? AbnormalSession { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (FromCarrier != null) + { + p.Add(new KeyValuePair("FromCarrier", FromCarrier)); + } + + if (ToCarrier != null) + { + p.Add(new KeyValuePair("ToCarrier", ToCarrier)); + } + + if (FromCountryCode != null) + { + p.Add(new KeyValuePair("FromCountryCode", FromCountryCode)); + } + + if (ToCountryCode != null) + { + p.Add(new KeyValuePair("ToCountryCode", ToCountryCode)); + } + + if (Branded != null) + { + p.Add(new KeyValuePair("Branded", Branded.Value.ToString().ToLower())); + } + + if (VerifiedCaller != null) + { + p.Add(new KeyValuePair("VerifiedCaller", VerifiedCaller.Value.ToString().ToLower())); + } + + if (HasTag != null) + { + p.Add(new KeyValuePair("HasTag", HasTag.Value.ToString().ToLower())); + } + + if (StartTime != null) + { + p.Add(new KeyValuePair("StartTime", StartTime)); + } + + if (EndTime != null) + { + p.Add(new KeyValuePair("EndTime", EndTime)); + } + + if (CallType != null) + { + p.Add(new KeyValuePair("CallType", CallType)); + } + + if (CallState != null) + { + p.Add(new KeyValuePair("CallState", CallState)); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction)); + } + + if (ProcessingState != null) + { + p.Add(new KeyValuePair("ProcessingState", ProcessingState.ToString())); + } + + if (SortBy != null) + { + p.Add(new KeyValuePair("SortBy", SortBy.ToString())); + } + + if (Subaccount != null) + { + p.Add(new KeyValuePair("Subaccount", Subaccount.ToString())); + } + + if (AbnormalSession != null) + { + p.Add(new KeyValuePair("AbnormalSession", AbnormalSession.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/CallSummariesResource.cs b/src/Twilio/Rest/Insights/V1/CallSummariesResource.cs index a10072418..1f789637d 100644 --- a/src/Twilio/Rest/Insights/V1/CallSummariesResource.cs +++ b/src/Twilio/Rest/Insights/V1/CallSummariesResource.cs @@ -17,434 +17,434 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1 -{ - - public class CallSummariesResource : Resource - { - public sealed class CallTypeEnum : StringEnum - { - private CallTypeEnum(string value) : base(value) {} - public CallTypeEnum() {} - public static implicit operator CallTypeEnum(string value) - { - return new CallTypeEnum(value); - } - - public static readonly CallTypeEnum Carrier = new CallTypeEnum("carrier"); - public static readonly CallTypeEnum Sip = new CallTypeEnum("sip"); - public static readonly CallTypeEnum Trunking = new CallTypeEnum("trunking"); - public static readonly CallTypeEnum Client = new CallTypeEnum("client"); - } - - public sealed class CallStateEnum : StringEnum - { - private CallStateEnum(string value) : base(value) {} - public CallStateEnum() {} - public static implicit operator CallStateEnum(string value) - { - return new CallStateEnum(value); - } - - public static readonly CallStateEnum Ringing = new CallStateEnum("ringing"); - public static readonly CallStateEnum Completed = new CallStateEnum("completed"); - public static readonly CallStateEnum Busy = new CallStateEnum("busy"); - public static readonly CallStateEnum Fail = new CallStateEnum("fail"); - public static readonly CallStateEnum Noanswer = new CallStateEnum("noanswer"); - public static readonly CallStateEnum Canceled = new CallStateEnum("canceled"); - public static readonly CallStateEnum Answered = new CallStateEnum("answered"); - public static readonly CallStateEnum Undialed = new CallStateEnum("undialed"); - } - - public sealed class ProcessingStateEnum : StringEnum - { - private ProcessingStateEnum(string value) : base(value) {} - public ProcessingStateEnum() {} - public static implicit operator ProcessingStateEnum(string value) - { - return new ProcessingStateEnum(value); - } - - public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); - public static readonly ProcessingStateEnum Partial = new ProcessingStateEnum("partial"); - } - - public sealed class CallDirectionEnum : StringEnum - { - private CallDirectionEnum(string value) : base(value) {} - public CallDirectionEnum() {} - public static implicit operator CallDirectionEnum(string value) - { - return new CallDirectionEnum(value); - } - - public static readonly CallDirectionEnum OutboundApi = new CallDirectionEnum("outbound_api"); - public static readonly CallDirectionEnum OutboundDial = new CallDirectionEnum("outbound_dial"); - public static readonly CallDirectionEnum Inbound = new CallDirectionEnum("inbound"); - public static readonly CallDirectionEnum TrunkingOriginating = new CallDirectionEnum("trunking_originating"); - public static readonly CallDirectionEnum TrunkingTerminating = new CallDirectionEnum("trunking_terminating"); - } - - public sealed class SortByEnum : StringEnum - { - private SortByEnum(string value) : base(value) {} - public SortByEnum() {} - public static implicit operator SortByEnum(string value) - { - return new SortByEnum(value); - } - - public static readonly SortByEnum StartTime = new SortByEnum("start_time"); - public static readonly SortByEnum EndTime = new SortByEnum("end_time"); - } - - public sealed class ProcessingStateRequestEnum : StringEnum - { - private ProcessingStateRequestEnum(string value) : base(value) {} - public ProcessingStateRequestEnum() {} - public static implicit operator ProcessingStateRequestEnum(string value) - { - return new ProcessingStateRequestEnum(value); - } - - public static readonly ProcessingStateRequestEnum Completed = new ProcessingStateRequestEnum("completed"); - public static readonly ProcessingStateRequestEnum Started = new ProcessingStateRequestEnum("started"); - public static readonly ProcessingStateRequestEnum Partial = new ProcessingStateRequestEnum("partial"); - public static readonly ProcessingStateRequestEnum All = new ProcessingStateRequestEnum("all"); - } - - private static Request BuildReadRequest(ReadCallSummariesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/Summaries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read CallSummaries parameters - /// Client to make requests to Twilio - /// A single instance of CallSummaries - public static ResourceSet Read(ReadCallSummariesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("call_summaries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read CallSummaries parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CallSummaries - public static async System.Threading.Tasks.Task> ReadAsync(ReadCallSummariesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("call_summaries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The from - /// The to - /// The from_carrier - /// The to_carrier - /// The from_country_code - /// The to_country_code - /// The branded - /// The verified_caller - /// The has_tag - /// The start_time - /// The end_time - /// The call_type - /// The call_state - /// The direction - /// The processing_state - /// The sort_by - /// The subaccount - /// The abnormal_session - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CallSummaries - public static ResourceSet Read(string from = null, - string to = null, - string fromCarrier = null, - string toCarrier = null, - string fromCountryCode = null, - string toCountryCode = null, - bool? branded = null, - bool? verifiedCaller = null, - bool? hasTag = null, - string startTime = null, - string endTime = null, - string callType = null, - string callState = null, - string direction = null, - CallSummariesResource.ProcessingStateRequestEnum processingState = null, - CallSummariesResource.SortByEnum sortBy = null, - string subaccount = null, - bool? abnormalSession = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCallSummariesOptions(){From = from, To = to, FromCarrier = fromCarrier, ToCarrier = toCarrier, FromCountryCode = fromCountryCode, ToCountryCode = toCountryCode, Branded = branded, VerifiedCaller = verifiedCaller, HasTag = hasTag, StartTime = startTime, EndTime = endTime, CallType = callType, CallState = callState, Direction = direction, ProcessingState = processingState, SortBy = sortBy, Subaccount = subaccount, AbnormalSession = abnormalSession, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The from - /// The to - /// The from_carrier - /// The to_carrier - /// The from_country_code - /// The to_country_code - /// The branded - /// The verified_caller - /// The has_tag - /// The start_time - /// The end_time - /// The call_type - /// The call_state - /// The direction - /// The processing_state - /// The sort_by - /// The subaccount - /// The abnormal_session - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CallSummaries - public static async System.Threading.Tasks.Task> ReadAsync(string from = null, - string to = null, - string fromCarrier = null, - string toCarrier = null, - string fromCountryCode = null, - string toCountryCode = null, - bool? branded = null, - bool? verifiedCaller = null, - bool? hasTag = null, - string startTime = null, - string endTime = null, - string callType = null, - string callState = null, - string direction = null, - CallSummariesResource.ProcessingStateRequestEnum processingState = null, - CallSummariesResource.SortByEnum sortBy = null, - string subaccount = null, - bool? abnormalSession = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCallSummariesOptions(){From = from, To = to, FromCarrier = fromCarrier, ToCarrier = toCarrier, FromCountryCode = fromCountryCode, ToCountryCode = toCountryCode, Branded = branded, VerifiedCaller = verifiedCaller, HasTag = hasTag, StartTime = startTime, EndTime = endTime, CallType = callType, CallState = callState, Direction = direction, ProcessingState = processingState, SortBy = sortBy, Subaccount = subaccount, AbnormalSession = abnormalSession, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("call_summaries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("call_summaries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("call_summaries", response.Content); - } - - /// - /// Converts a JSON string into a CallSummariesResource object - /// - /// Raw JSON string - /// CallSummariesResource object represented by the provided JSON - public static CallSummariesResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The call_sid - /// - [JsonProperty("call_sid")] - public string CallSid { get; private set; } - /// - /// The call_type - /// - [JsonProperty("call_type")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummariesResource.CallTypeEnum CallType { get; private set; } - /// - /// The call_state - /// - [JsonProperty("call_state")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummariesResource.CallStateEnum CallState { get; private set; } - /// - /// The processing_state - /// - [JsonProperty("processing_state")] - [JsonConverter(typeof(StringEnumConverter))] - public CallSummariesResource.ProcessingStateEnum ProcessingState { get; private set; } - /// - /// The created_time - /// - [JsonProperty("created_time")] - public DateTime? CreatedTime { get; private set; } - /// - /// The start_time - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end_time - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The duration - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The connect_duration - /// - [JsonProperty("connect_duration")] - public int? ConnectDuration { get; private set; } - /// - /// The from - /// - [JsonProperty("from")] - public object From { get; private set; } - /// - /// The to - /// - [JsonProperty("to")] - public object To { get; private set; } - /// - /// The carrier_edge - /// - [JsonProperty("carrier_edge")] - public object CarrierEdge { get; private set; } - /// - /// The client_edge - /// - [JsonProperty("client_edge")] - public object ClientEdge { get; private set; } - /// - /// The sdk_edge - /// - [JsonProperty("sdk_edge")] - public object SdkEdge { get; private set; } - /// - /// The sip_edge - /// - [JsonProperty("sip_edge")] - public object SipEdge { get; private set; } - /// - /// The tags - /// - [JsonProperty("tags")] - public List Tags { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The properties - /// - [JsonProperty("properties")] - public object Properties { get; private set; } - /// - /// The trust - /// - [JsonProperty("trust")] - public object Trust { get; private set; } - - private CallSummariesResource() - { - - } - } +{ + + public class CallSummariesResource : Resource + { + public sealed class CallTypeEnum : StringEnum + { + private CallTypeEnum(string value) : base(value) { } + public CallTypeEnum() { } + public static implicit operator CallTypeEnum(string value) + { + return new CallTypeEnum(value); + } + + public static readonly CallTypeEnum Carrier = new CallTypeEnum("carrier"); + public static readonly CallTypeEnum Sip = new CallTypeEnum("sip"); + public static readonly CallTypeEnum Trunking = new CallTypeEnum("trunking"); + public static readonly CallTypeEnum Client = new CallTypeEnum("client"); + } + + public sealed class CallStateEnum : StringEnum + { + private CallStateEnum(string value) : base(value) { } + public CallStateEnum() { } + public static implicit operator CallStateEnum(string value) + { + return new CallStateEnum(value); + } + + public static readonly CallStateEnum Ringing = new CallStateEnum("ringing"); + public static readonly CallStateEnum Completed = new CallStateEnum("completed"); + public static readonly CallStateEnum Busy = new CallStateEnum("busy"); + public static readonly CallStateEnum Fail = new CallStateEnum("fail"); + public static readonly CallStateEnum Noanswer = new CallStateEnum("noanswer"); + public static readonly CallStateEnum Canceled = new CallStateEnum("canceled"); + public static readonly CallStateEnum Answered = new CallStateEnum("answered"); + public static readonly CallStateEnum Undialed = new CallStateEnum("undialed"); + } + + public sealed class ProcessingStateEnum : StringEnum + { + private ProcessingStateEnum(string value) : base(value) { } + public ProcessingStateEnum() { } + public static implicit operator ProcessingStateEnum(string value) + { + return new ProcessingStateEnum(value); + } + + public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); + public static readonly ProcessingStateEnum Partial = new ProcessingStateEnum("partial"); + } + + public sealed class CallDirectionEnum : StringEnum + { + private CallDirectionEnum(string value) : base(value) { } + public CallDirectionEnum() { } + public static implicit operator CallDirectionEnum(string value) + { + return new CallDirectionEnum(value); + } + + public static readonly CallDirectionEnum OutboundApi = new CallDirectionEnum("outbound_api"); + public static readonly CallDirectionEnum OutboundDial = new CallDirectionEnum("outbound_dial"); + public static readonly CallDirectionEnum Inbound = new CallDirectionEnum("inbound"); + public static readonly CallDirectionEnum TrunkingOriginating = new CallDirectionEnum("trunking_originating"); + public static readonly CallDirectionEnum TrunkingTerminating = new CallDirectionEnum("trunking_terminating"); + } + + public sealed class SortByEnum : StringEnum + { + private SortByEnum(string value) : base(value) { } + public SortByEnum() { } + public static implicit operator SortByEnum(string value) + { + return new SortByEnum(value); + } + + public static readonly SortByEnum StartTime = new SortByEnum("start_time"); + public static readonly SortByEnum EndTime = new SortByEnum("end_time"); + } + + public sealed class ProcessingStateRequestEnum : StringEnum + { + private ProcessingStateRequestEnum(string value) : base(value) { } + public ProcessingStateRequestEnum() { } + public static implicit operator ProcessingStateRequestEnum(string value) + { + return new ProcessingStateRequestEnum(value); + } + + public static readonly ProcessingStateRequestEnum Completed = new ProcessingStateRequestEnum("completed"); + public static readonly ProcessingStateRequestEnum Started = new ProcessingStateRequestEnum("started"); + public static readonly ProcessingStateRequestEnum Partial = new ProcessingStateRequestEnum("partial"); + public static readonly ProcessingStateRequestEnum All = new ProcessingStateRequestEnum("all"); + } + + private static Request BuildReadRequest(ReadCallSummariesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/Summaries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read CallSummaries parameters + /// Client to make requests to Twilio + /// A single instance of CallSummaries + public static ResourceSet Read(ReadCallSummariesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("call_summaries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read CallSummaries parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CallSummaries + public static async System.Threading.Tasks.Task> ReadAsync(ReadCallSummariesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("call_summaries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The from + /// The to + /// The from_carrier + /// The to_carrier + /// The from_country_code + /// The to_country_code + /// The branded + /// The verified_caller + /// The has_tag + /// The start_time + /// The end_time + /// The call_type + /// The call_state + /// The direction + /// The processing_state + /// The sort_by + /// The subaccount + /// The abnormal_session + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CallSummaries + public static ResourceSet Read(string from = null, + string to = null, + string fromCarrier = null, + string toCarrier = null, + string fromCountryCode = null, + string toCountryCode = null, + bool? branded = null, + bool? verifiedCaller = null, + bool? hasTag = null, + string startTime = null, + string endTime = null, + string callType = null, + string callState = null, + string direction = null, + CallSummariesResource.ProcessingStateRequestEnum processingState = null, + CallSummariesResource.SortByEnum sortBy = null, + string subaccount = null, + bool? abnormalSession = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCallSummariesOptions() { From = from, To = to, FromCarrier = fromCarrier, ToCarrier = toCarrier, FromCountryCode = fromCountryCode, ToCountryCode = toCountryCode, Branded = branded, VerifiedCaller = verifiedCaller, HasTag = hasTag, StartTime = startTime, EndTime = endTime, CallType = callType, CallState = callState, Direction = direction, ProcessingState = processingState, SortBy = sortBy, Subaccount = subaccount, AbnormalSession = abnormalSession, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The from + /// The to + /// The from_carrier + /// The to_carrier + /// The from_country_code + /// The to_country_code + /// The branded + /// The verified_caller + /// The has_tag + /// The start_time + /// The end_time + /// The call_type + /// The call_state + /// The direction + /// The processing_state + /// The sort_by + /// The subaccount + /// The abnormal_session + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CallSummaries + public static async System.Threading.Tasks.Task> ReadAsync(string from = null, + string to = null, + string fromCarrier = null, + string toCarrier = null, + string fromCountryCode = null, + string toCountryCode = null, + bool? branded = null, + bool? verifiedCaller = null, + bool? hasTag = null, + string startTime = null, + string endTime = null, + string callType = null, + string callState = null, + string direction = null, + CallSummariesResource.ProcessingStateRequestEnum processingState = null, + CallSummariesResource.SortByEnum sortBy = null, + string subaccount = null, + bool? abnormalSession = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCallSummariesOptions() { From = from, To = to, FromCarrier = fromCarrier, ToCarrier = toCarrier, FromCountryCode = fromCountryCode, ToCountryCode = toCountryCode, Branded = branded, VerifiedCaller = verifiedCaller, HasTag = hasTag, StartTime = startTime, EndTime = endTime, CallType = callType, CallState = callState, Direction = direction, ProcessingState = processingState, SortBy = sortBy, Subaccount = subaccount, AbnormalSession = abnormalSession, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("call_summaries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("call_summaries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("call_summaries", response.Content); + } + + /// + /// Converts a JSON string into a CallSummariesResource object + /// + /// Raw JSON string + /// CallSummariesResource object represented by the provided JSON + public static CallSummariesResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The call_sid + /// + [JsonProperty("call_sid")] + public string CallSid { get; private set; } + /// + /// The call_type + /// + [JsonProperty("call_type")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummariesResource.CallTypeEnum CallType { get; private set; } + /// + /// The call_state + /// + [JsonProperty("call_state")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummariesResource.CallStateEnum CallState { get; private set; } + /// + /// The processing_state + /// + [JsonProperty("processing_state")] + [JsonConverter(typeof(StringEnumConverter))] + public CallSummariesResource.ProcessingStateEnum ProcessingState { get; private set; } + /// + /// The created_time + /// + [JsonProperty("created_time")] + public DateTime? CreatedTime { get; private set; } + /// + /// The start_time + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end_time + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The duration + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The connect_duration + /// + [JsonProperty("connect_duration")] + public int? ConnectDuration { get; private set; } + /// + /// The from + /// + [JsonProperty("from")] + public object From { get; private set; } + /// + /// The to + /// + [JsonProperty("to")] + public object To { get; private set; } + /// + /// The carrier_edge + /// + [JsonProperty("carrier_edge")] + public object CarrierEdge { get; private set; } + /// + /// The client_edge + /// + [JsonProperty("client_edge")] + public object ClientEdge { get; private set; } + /// + /// The sdk_edge + /// + [JsonProperty("sdk_edge")] + public object SdkEdge { get; private set; } + /// + /// The sip_edge + /// + [JsonProperty("sip_edge")] + public object SipEdge { get; private set; } + /// + /// The tags + /// + [JsonProperty("tags")] + public List Tags { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The properties + /// + [JsonProperty("properties")] + public object Properties { get; private set; } + /// + /// The trust + /// + [JsonProperty("trust")] + public object Trust { get; private set; } + + private CallSummariesResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Room/ParticipantOptions.cs b/src/Twilio/Rest/Insights/V1/Room/ParticipantOptions.cs index 794656502..e6975fded 100644 --- a/src/Twilio/Rest/Insights/V1/Room/ParticipantOptions.cs +++ b/src/Twilio/Rest/Insights/V1/Room/ParticipantOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1.Room -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Get Video Log Analyzer data for a Room Participant. + /// + public class FetchParticipantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Get Video Log Analyzer data for a Room Participant. + /// The SID of the Room resource. /// - public class FetchParticipantOptions : IOptions - { - /// - /// The SID of the Room resource. - /// - public string PathRoomSid { get; } - /// - /// The SID of the Participant resource. - /// - public string PathParticipantSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The SID of the Room resource. - /// The SID of the Participant resource. - public FetchParticipantOptions(string pathRoomSid, string pathParticipantSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Get a list of room participants. + /// The SID of the Participant resource. /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The SID of the Room resource. - /// - public string PathRoomSid { get; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The SID of the Room resource. - public ReadParticipantOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathParticipantSid { get; } + + /// + /// Construct a new FetchParticipantOptions + /// + /// The SID of the Room resource. + /// The SID of the Participant resource. + public FetchParticipantOptions(string pathRoomSid, string pathParticipantSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Get a list of room participants. + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The SID of the Room resource. + /// + public string PathRoomSid { get; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The SID of the Room resource. + public ReadParticipantOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/Room/ParticipantResource.cs b/src/Twilio/Rest/Insights/V1/Room/ParticipantResource.cs index 1b1856963..acc61a0c3 100644 --- a/src/Twilio/Rest/Insights/V1/Room/ParticipantResource.cs +++ b/src/Twilio/Rest/Insights/V1/Room/ParticipantResource.cs @@ -19,395 +19,395 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1.Room -{ - - public class ParticipantResource : Resource - { - public sealed class RoomStatusEnum : StringEnum - { - private RoomStatusEnum(string value) : base(value) {} - public RoomStatusEnum() {} - public static implicit operator RoomStatusEnum(string value) - { - return new RoomStatusEnum(value); - } - - public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in_progress"); - public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); - } - - public sealed class CodecEnum : StringEnum - { - private CodecEnum(string value) : base(value) {} - public CodecEnum() {} - public static implicit operator CodecEnum(string value) - { - return new CodecEnum(value); - } - - public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); - public static readonly CodecEnum H264 = new CodecEnum("H264"); - public static readonly CodecEnum Vp9 = new CodecEnum("VP9"); - } - - public sealed class TwilioRealmEnum : StringEnum - { - private TwilioRealmEnum(string value) : base(value) {} - public TwilioRealmEnum() {} - public static implicit operator TwilioRealmEnum(string value) - { - return new TwilioRealmEnum(value); - } - - public static readonly TwilioRealmEnum Us1 = new TwilioRealmEnum("us1"); - public static readonly TwilioRealmEnum Us2 = new TwilioRealmEnum("us2"); - public static readonly TwilioRealmEnum Au1 = new TwilioRealmEnum("au1"); - public static readonly TwilioRealmEnum Br1 = new TwilioRealmEnum("br1"); - public static readonly TwilioRealmEnum Ie1 = new TwilioRealmEnum("ie1"); - public static readonly TwilioRealmEnum Jp1 = new TwilioRealmEnum("jp1"); - public static readonly TwilioRealmEnum Sg1 = new TwilioRealmEnum("sg1"); - public static readonly TwilioRealmEnum In1 = new TwilioRealmEnum("in1"); - public static readonly TwilioRealmEnum De1 = new TwilioRealmEnum("de1"); - public static readonly TwilioRealmEnum Gll = new TwilioRealmEnum("gll"); - } - - public sealed class EdgeLocationEnum : StringEnum - { - private EdgeLocationEnum(string value) : base(value) {} - public EdgeLocationEnum() {} - public static implicit operator EdgeLocationEnum(string value) - { - return new EdgeLocationEnum(value); - } - - public static readonly EdgeLocationEnum Ashburn = new EdgeLocationEnum("ashburn"); - public static readonly EdgeLocationEnum Dublin = new EdgeLocationEnum("dublin"); - public static readonly EdgeLocationEnum Frankfurt = new EdgeLocationEnum("frankfurt"); - public static readonly EdgeLocationEnum Singapore = new EdgeLocationEnum("singapore"); - public static readonly EdgeLocationEnum Sydney = new EdgeLocationEnum("sydney"); - public static readonly EdgeLocationEnum SaoPaulo = new EdgeLocationEnum("sao_paulo"); - public static readonly EdgeLocationEnum Roaming = new EdgeLocationEnum("roaming"); - public static readonly EdgeLocationEnum Umatilla = new EdgeLocationEnum("umatilla"); - public static readonly EdgeLocationEnum Tokyo = new EdgeLocationEnum("tokyo"); - } - - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Video/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get Video Log Analyzer data for a Room Participant. - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Get Video Log Analyzer data for a Room Participant. - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Get Video Log Analyzer data for a Room Participant. - /// - /// The SID of the Room resource. - /// The SID of the Participant resource. - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathRoomSid, - string pathParticipantSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathRoomSid, pathParticipantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Get Video Log Analyzer data for a Room Participant. - /// - /// The SID of the Room resource. - /// The SID of the Participant resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathParticipantSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathRoomSid, pathParticipantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Video/Rooms/" + options.PathRoomSid + "/Participants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get a list of room participants. - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Get a list of room participants. - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Get a list of room participants. - /// - /// The SID of the Room resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathRoomSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathRoomSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Get a list of room participants. - /// - /// The SID of the Room resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathRoomSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Unique identifier for the participant. - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The application-defined string that uniquely identifies the participant within a Room. - /// - [JsonProperty("participant_identity")] - public string ParticipantIdentity { get; private set; } - /// - /// When the participant joined the room. - /// - [JsonProperty("join_time")] - public DateTime? JoinTime { get; private set; } - /// - /// When the participant left the room - /// - [JsonProperty("leave_time")] - public DateTime? LeaveTime { get; private set; } - /// - /// Amount of time in seconds the participant was in the room. - /// - [JsonProperty("duration_sec")] - public long? DurationSec { get; private set; } - /// - /// Account SID associated with the room. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Unique identifier for the room. - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// Status of the room. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantResource.RoomStatusEnum Status { get; private set; } - /// - /// Codecs detected from the participant. - /// - [JsonProperty("codecs")] - [JsonConverter(typeof(StringEnumConverter))] - public List Codecs { get; private set; } - /// - /// Reason the participant left the room. - /// - [JsonProperty("end_reason")] - public string EndReason { get; private set; } - /// - /// Errors encountered by the participant. - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - /// - /// Twilio error code dictionary link. - /// - [JsonProperty("error_code_url")] - public string ErrorCodeUrl { get; private set; } - /// - /// Twilio media region the participant connected to. - /// - [JsonProperty("media_region")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantResource.TwilioRealmEnum MediaRegion { get; private set; } - /// - /// Object containing information about the participant's data from the room. - /// - [JsonProperty("properties")] - public object Properties { get; private set; } - /// - /// Name of the edge location the participant connected to. - /// - [JsonProperty("edge_location")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantResource.EdgeLocationEnum EdgeLocation { get; private set; } - /// - /// Object containing information about the SDK name and version. - /// - [JsonProperty("publisher_info")] - public object PublisherInfo { get; private set; } - /// - /// URL of the participant resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + public sealed class RoomStatusEnum : StringEnum + { + private RoomStatusEnum(string value) : base(value) { } + public RoomStatusEnum() { } + public static implicit operator RoomStatusEnum(string value) + { + return new RoomStatusEnum(value); + } + + public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in_progress"); + public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); + } + + public sealed class CodecEnum : StringEnum + { + private CodecEnum(string value) : base(value) { } + public CodecEnum() { } + public static implicit operator CodecEnum(string value) + { + return new CodecEnum(value); + } + + public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); + public static readonly CodecEnum H264 = new CodecEnum("H264"); + public static readonly CodecEnum Vp9 = new CodecEnum("VP9"); + } + + public sealed class TwilioRealmEnum : StringEnum + { + private TwilioRealmEnum(string value) : base(value) { } + public TwilioRealmEnum() { } + public static implicit operator TwilioRealmEnum(string value) + { + return new TwilioRealmEnum(value); + } + + public static readonly TwilioRealmEnum Us1 = new TwilioRealmEnum("us1"); + public static readonly TwilioRealmEnum Us2 = new TwilioRealmEnum("us2"); + public static readonly TwilioRealmEnum Au1 = new TwilioRealmEnum("au1"); + public static readonly TwilioRealmEnum Br1 = new TwilioRealmEnum("br1"); + public static readonly TwilioRealmEnum Ie1 = new TwilioRealmEnum("ie1"); + public static readonly TwilioRealmEnum Jp1 = new TwilioRealmEnum("jp1"); + public static readonly TwilioRealmEnum Sg1 = new TwilioRealmEnum("sg1"); + public static readonly TwilioRealmEnum In1 = new TwilioRealmEnum("in1"); + public static readonly TwilioRealmEnum De1 = new TwilioRealmEnum("de1"); + public static readonly TwilioRealmEnum Gll = new TwilioRealmEnum("gll"); + } + + public sealed class EdgeLocationEnum : StringEnum + { + private EdgeLocationEnum(string value) : base(value) { } + public EdgeLocationEnum() { } + public static implicit operator EdgeLocationEnum(string value) + { + return new EdgeLocationEnum(value); + } + + public static readonly EdgeLocationEnum Ashburn = new EdgeLocationEnum("ashburn"); + public static readonly EdgeLocationEnum Dublin = new EdgeLocationEnum("dublin"); + public static readonly EdgeLocationEnum Frankfurt = new EdgeLocationEnum("frankfurt"); + public static readonly EdgeLocationEnum Singapore = new EdgeLocationEnum("singapore"); + public static readonly EdgeLocationEnum Sydney = new EdgeLocationEnum("sydney"); + public static readonly EdgeLocationEnum SaoPaulo = new EdgeLocationEnum("sao_paulo"); + public static readonly EdgeLocationEnum Roaming = new EdgeLocationEnum("roaming"); + public static readonly EdgeLocationEnum Umatilla = new EdgeLocationEnum("umatilla"); + public static readonly EdgeLocationEnum Tokyo = new EdgeLocationEnum("tokyo"); + } + + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Video/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get Video Log Analyzer data for a Room Participant. + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Get Video Log Analyzer data for a Room Participant. + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Get Video Log Analyzer data for a Room Participant. + /// + /// The SID of the Room resource. + /// The SID of the Participant resource. + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathRoomSid, + string pathParticipantSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathRoomSid, pathParticipantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Get Video Log Analyzer data for a Room Participant. + /// + /// The SID of the Room resource. + /// The SID of the Participant resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathParticipantSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathRoomSid, pathParticipantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Video/Rooms/" + options.PathRoomSid + "/Participants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get a list of room participants. + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Get a list of room participants. + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Get a list of room participants. + /// + /// The SID of the Room resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathRoomSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathRoomSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Get a list of room participants. + /// + /// The SID of the Room resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathRoomSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Unique identifier for the participant. + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The application-defined string that uniquely identifies the participant within a Room. + /// + [JsonProperty("participant_identity")] + public string ParticipantIdentity { get; private set; } + /// + /// When the participant joined the room. + /// + [JsonProperty("join_time")] + public DateTime? JoinTime { get; private set; } + /// + /// When the participant left the room + /// + [JsonProperty("leave_time")] + public DateTime? LeaveTime { get; private set; } + /// + /// Amount of time in seconds the participant was in the room. + /// + [JsonProperty("duration_sec")] + public long? DurationSec { get; private set; } + /// + /// Account SID associated with the room. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Unique identifier for the room. + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// Status of the room. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantResource.RoomStatusEnum Status { get; private set; } + /// + /// Codecs detected from the participant. + /// + [JsonProperty("codecs")] + [JsonConverter(typeof(StringEnumConverter))] + public List Codecs { get; private set; } + /// + /// Reason the participant left the room. + /// + [JsonProperty("end_reason")] + public string EndReason { get; private set; } + /// + /// Errors encountered by the participant. + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + /// + /// Twilio error code dictionary link. + /// + [JsonProperty("error_code_url")] + public string ErrorCodeUrl { get; private set; } + /// + /// Twilio media region the participant connected to. + /// + [JsonProperty("media_region")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantResource.TwilioRealmEnum MediaRegion { get; private set; } + /// + /// Object containing information about the participant's data from the room. + /// + [JsonProperty("properties")] + public object Properties { get; private set; } + /// + /// Name of the edge location the participant connected to. + /// + [JsonProperty("edge_location")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantResource.EdgeLocationEnum EdgeLocation { get; private set; } + /// + /// Object containing information about the SDK name and version. + /// + [JsonProperty("publisher_info")] + public object PublisherInfo { get; private set; } + /// + /// URL of the participant resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/RoomOptions.cs b/src/Twilio/Rest/Insights/V1/RoomOptions.cs index 31c2d705e..281a3fd9c 100644 --- a/src/Twilio/Rest/Insights/V1/RoomOptions.cs +++ b/src/Twilio/Rest/Insights/V1/RoomOptions.cs @@ -10,114 +10,114 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Get Video Log Analyzer data for a Room. + /// + public class FetchRoomOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Get Video Log Analyzer data for a Room. + /// The SID of the Room resource. /// - public class FetchRoomOptions : IOptions - { - /// - /// The SID of the Room resource. - /// - public string PathRoomSid { get; } - - /// - /// Construct a new FetchRoomOptions - /// - /// The SID of the Room resource. - public FetchRoomOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Get a list of Programmable Video Rooms. + /// Construct a new FetchRoomOptions /// - public class ReadRoomOptions : ReadOptions - { - /// - /// Type of room. - /// - public List RoomType { get; set; } - /// - /// Codecs used by participants in the room. - /// - public List Codec { get; set; } - /// - /// Room friendly name. - /// - public string RoomName { get; set; } - /// - /// Only read rooms that started on or after this ISO 8601 timestamp. - /// - public DateTime? CreatedAfter { get; set; } - /// - /// Only read rooms that started before this ISO 8601 timestamp. - /// - public DateTime? CreatedBefore { get; set; } - - /// - /// Construct a new ReadRoomOptions - /// - public ReadRoomOptions() - { - RoomType = new List(); - Codec = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (RoomType != null) - { - p.AddRange(RoomType.Select(prop => new KeyValuePair("RoomType", prop.ToString()))); - } - - if (Codec != null) - { - p.AddRange(Codec.Select(prop => new KeyValuePair("Codec", prop.ToString()))); - } - - if (RoomName != null) - { - p.Add(new KeyValuePair("RoomName", RoomName)); - } - - if (CreatedAfter != null) - { - p.Add(new KeyValuePair("CreatedAfter", Serializers.DateTimeIso8601(CreatedAfter))); - } - - if (CreatedBefore != null) - { - p.Add(new KeyValuePair("CreatedBefore", Serializers.DateTimeIso8601(CreatedBefore))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Room resource. + public FetchRoomOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Get a list of Programmable Video Rooms. + /// + public class ReadRoomOptions : ReadOptions + { + /// + /// Type of room. + /// + public List RoomType { get; set; } + /// + /// Codecs used by participants in the room. + /// + public List Codec { get; set; } + /// + /// Room friendly name. + /// + public string RoomName { get; set; } + /// + /// Only read rooms that started on or after this ISO 8601 timestamp. + /// + public DateTime? CreatedAfter { get; set; } + /// + /// Only read rooms that started before this ISO 8601 timestamp. + /// + public DateTime? CreatedBefore { get; set; } + + /// + /// Construct a new ReadRoomOptions + /// + public ReadRoomOptions() + { + RoomType = new List(); + Codec = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (RoomType != null) + { + p.AddRange(RoomType.Select(prop => new KeyValuePair("RoomType", prop.ToString()))); + } + + if (Codec != null) + { + p.AddRange(Codec.Select(prop => new KeyValuePair("Codec", prop.ToString()))); + } + + if (RoomName != null) + { + p.Add(new KeyValuePair("RoomName", RoomName)); + } + + if (CreatedAfter != null) + { + p.Add(new KeyValuePair("CreatedAfter", Serializers.DateTimeIso8601(CreatedAfter))); + } + + if (CreatedBefore != null) + { + p.Add(new KeyValuePair("CreatedBefore", Serializers.DateTimeIso8601(CreatedBefore))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/RoomResource.cs b/src/Twilio/Rest/Insights/V1/RoomResource.cs index 1d2d4ae73..8549ee6eb 100644 --- a/src/Twilio/Rest/Insights/V1/RoomResource.cs +++ b/src/Twilio/Rest/Insights/V1/RoomResource.cs @@ -19,511 +19,511 @@ using Twilio.Types; namespace Twilio.Rest.Insights.V1 -{ - - public class RoomResource : Resource - { - public sealed class RoomTypeEnum : StringEnum - { - private RoomTypeEnum(string value) : base(value) {} - public RoomTypeEnum() {} - public static implicit operator RoomTypeEnum(string value) - { - return new RoomTypeEnum(value); - } - - public static readonly RoomTypeEnum Go = new RoomTypeEnum("go"); - public static readonly RoomTypeEnum PeerToPeer = new RoomTypeEnum("peer_to_peer"); - public static readonly RoomTypeEnum Group = new RoomTypeEnum("group"); - public static readonly RoomTypeEnum GroupSmall = new RoomTypeEnum("group_small"); - } - - public sealed class RoomStatusEnum : StringEnum - { - private RoomStatusEnum(string value) : base(value) {} - public RoomStatusEnum() {} - public static implicit operator RoomStatusEnum(string value) - { - return new RoomStatusEnum(value); - } - - public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in_progress"); - public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); - } - - public sealed class CreatedMethodEnum : StringEnum - { - private CreatedMethodEnum(string value) : base(value) {} - public CreatedMethodEnum() {} - public static implicit operator CreatedMethodEnum(string value) - { - return new CreatedMethodEnum(value); - } - - public static readonly CreatedMethodEnum Sdk = new CreatedMethodEnum("sdk"); - public static readonly CreatedMethodEnum AdHoc = new CreatedMethodEnum("ad_hoc"); - public static readonly CreatedMethodEnum Api = new CreatedMethodEnum("api"); - } - - public sealed class EndReasonEnum : StringEnum - { - private EndReasonEnum(string value) : base(value) {} - public EndReasonEnum() {} - public static implicit operator EndReasonEnum(string value) - { - return new EndReasonEnum(value); - } - - public static readonly EndReasonEnum RoomEndedViaApi = new EndReasonEnum("room_ended_via_api"); - public static readonly EndReasonEnum Timeout = new EndReasonEnum("timeout"); - } - - public sealed class CodecEnum : StringEnum - { - private CodecEnum(string value) : base(value) {} - public CodecEnum() {} - public static implicit operator CodecEnum(string value) - { - return new CodecEnum(value); - } - - public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); - public static readonly CodecEnum H264 = new CodecEnum("H264"); - public static readonly CodecEnum Vp9 = new CodecEnum("VP9"); - } - - public sealed class TwilioRealmEnum : StringEnum - { - private TwilioRealmEnum(string value) : base(value) {} - public TwilioRealmEnum() {} - public static implicit operator TwilioRealmEnum(string value) - { - return new TwilioRealmEnum(value); - } - - public static readonly TwilioRealmEnum Us1 = new TwilioRealmEnum("us1"); - public static readonly TwilioRealmEnum Us2 = new TwilioRealmEnum("us2"); - public static readonly TwilioRealmEnum Au1 = new TwilioRealmEnum("au1"); - public static readonly TwilioRealmEnum Br1 = new TwilioRealmEnum("br1"); - public static readonly TwilioRealmEnum Ie1 = new TwilioRealmEnum("ie1"); - public static readonly TwilioRealmEnum Jp1 = new TwilioRealmEnum("jp1"); - public static readonly TwilioRealmEnum Sg1 = new TwilioRealmEnum("sg1"); - public static readonly TwilioRealmEnum In1 = new TwilioRealmEnum("in1"); - public static readonly TwilioRealmEnum De1 = new TwilioRealmEnum("de1"); - public static readonly TwilioRealmEnum Gll = new TwilioRealmEnum("gll"); - } - - public sealed class ProcessingStateEnum : StringEnum - { - private ProcessingStateEnum(string value) : base(value) {} - public ProcessingStateEnum() {} - public static implicit operator ProcessingStateEnum(string value) - { - return new ProcessingStateEnum(value); - } - - public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); - public static readonly ProcessingStateEnum InProgress = new ProcessingStateEnum("in_progress"); - } - - public sealed class EdgeLocationEnum : StringEnum - { - private EdgeLocationEnum(string value) : base(value) {} - public EdgeLocationEnum() {} - public static implicit operator EdgeLocationEnum(string value) - { - return new EdgeLocationEnum(value); - } - - public static readonly EdgeLocationEnum Ashburn = new EdgeLocationEnum("ashburn"); - public static readonly EdgeLocationEnum Dublin = new EdgeLocationEnum("dublin"); - public static readonly EdgeLocationEnum Frankfurt = new EdgeLocationEnum("frankfurt"); - public static readonly EdgeLocationEnum Singapore = new EdgeLocationEnum("singapore"); - public static readonly EdgeLocationEnum Sydney = new EdgeLocationEnum("sydney"); - public static readonly EdgeLocationEnum SaoPaulo = new EdgeLocationEnum("sao_paulo"); - public static readonly EdgeLocationEnum Roaming = new EdgeLocationEnum("roaming"); - public static readonly EdgeLocationEnum Umatilla = new EdgeLocationEnum("umatilla"); - public static readonly EdgeLocationEnum Tokyo = new EdgeLocationEnum("tokyo"); - } - - private static Request BuildFetchRequest(FetchRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Video/Rooms/" + options.PathRoomSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get Video Log Analyzer data for a Room. - /// - /// Fetch Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Fetch(FetchRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Get Video Log Analyzer data for a Room. - /// - /// Fetch Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task FetchAsync(FetchRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Get Video Log Analyzer data for a Room. - /// - /// The SID of the Room resource. - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Fetch(string pathRoomSid, ITwilioRestClient client = null) - { - var options = new FetchRoomOptions(pathRoomSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Get Video Log Analyzer data for a Room. - /// - /// The SID of the Room resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - ITwilioRestClient client = null) - { - var options = new FetchRoomOptions(pathRoomSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Video/Rooms", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Get a list of Programmable Video Rooms. - /// - /// Read Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static ResourceSet Read(ReadRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("rooms", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Get a list of Programmable Video Rooms. - /// - /// Read Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("rooms", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Get a list of Programmable Video Rooms. - /// - /// Type of room. - /// Codecs used by participants in the room. - /// Room friendly name. - /// Only read rooms that started on or after this ISO 8601 timestamp. - /// Only read rooms that started before this ISO 8601 timestamp. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Room - public static ResourceSet Read(List roomType = null, - List codec = null, - string roomName = null, - DateTime? createdAfter = null, - DateTime? createdBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomOptions(){RoomType = roomType, Codec = codec, RoomName = roomName, CreatedAfter = createdAfter, CreatedBefore = createdBefore, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Get a list of Programmable Video Rooms. - /// - /// Type of room. - /// Codecs used by participants in the room. - /// Room friendly name. - /// Only read rooms that started on or after this ISO 8601 timestamp. - /// Only read rooms that started before this ISO 8601 timestamp. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task> ReadAsync(List roomType = null, - List codec = null, - string roomName = null, - DateTime? createdAfter = null, - DateTime? createdBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomOptions(){RoomType = roomType, Codec = codec, RoomName = roomName, CreatedAfter = createdAfter, CreatedBefore = createdBefore, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Insights) - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - /// - /// Converts a JSON string into a RoomResource object - /// - /// Raw JSON string - /// RoomResource object represented by the provided JSON - public static RoomResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account SID associated with this room. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Unique identifier for the room. - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// room friendly name. - /// - [JsonProperty("room_name")] - public string RoomName { get; private set; } - /// - /// Creation time of the room. - /// - [JsonProperty("create_time")] - public DateTime? CreateTime { get; private set; } - /// - /// End time for the room. - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// Type of room. - /// - [JsonProperty("room_type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.RoomTypeEnum RoomType { get; private set; } - /// - /// Status of the room. - /// - [JsonProperty("room_status")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.RoomStatusEnum RoomStatus { get; private set; } - /// - /// Webhook provided for status callbacks. - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// HTTP method provided for status callback URL. - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// How the room was created. - /// - [JsonProperty("created_method")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.CreatedMethodEnum CreatedMethod { get; private set; } - /// - /// Reason the room ended. - /// - [JsonProperty("end_reason")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.EndReasonEnum EndReason { get; private set; } - /// - /// Max number of total participants allowed by the application settings. - /// - [JsonProperty("max_participants")] - public int? MaxParticipants { get; private set; } - /// - /// Number of participants. May include duplicate identities for participants who left and rejoined. - /// - [JsonProperty("unique_participants")] - public int? UniqueParticipants { get; private set; } - /// - /// Unique number of participant identities. - /// - [JsonProperty("unique_participant_identities")] - public int? UniqueParticipantIdentities { get; private set; } - /// - /// Actual number of concurrent participants. - /// - [JsonProperty("concurrent_participants")] - public int? ConcurrentParticipants { get; private set; } - /// - /// Maximum number of participants allowed in the room at the same time allowed by the application settings. - /// - [JsonProperty("max_concurrent_participants")] - public int? MaxConcurrentParticipants { get; private set; } - /// - /// Codecs used by participants in the room. - /// - [JsonProperty("codecs")] - [JsonConverter(typeof(StringEnumConverter))] - public List Codecs { get; private set; } - /// - /// Region of Twilio media servers for the room. - /// - [JsonProperty("media_region")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.TwilioRealmEnum MediaRegion { get; private set; } - /// - /// Total room duration from create time to end time. - /// - [JsonProperty("duration_sec")] - public long? DurationSec { get; private set; } - /// - /// Combined amount of participant time in the room. - /// - [JsonProperty("total_participant_duration_sec")] - public long? TotalParticipantDurationSec { get; private set; } - /// - /// Combined amount of recorded seconds for participants in the room. - /// - [JsonProperty("total_recording_duration_sec")] - public long? TotalRecordingDurationSec { get; private set; } - /// - /// Video Log Analyzer resource state. Will be either `in-progress` or `complete`. - /// - [JsonProperty("processing_state")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.ProcessingStateEnum ProcessingState { get; private set; } - /// - /// Boolean indicating if recording is enabled for the room. - /// - [JsonProperty("recording_enabled")] - public bool? RecordingEnabled { get; private set; } - /// - /// Edge location of Twilio media servers for the room. - /// - [JsonProperty("edge_location")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.EdgeLocationEnum EdgeLocation { get; private set; } - /// - /// URL for the room resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Room subresources. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private RoomResource() - { - - } - } +{ + + public class RoomResource : Resource + { + public sealed class RoomTypeEnum : StringEnum + { + private RoomTypeEnum(string value) : base(value) { } + public RoomTypeEnum() { } + public static implicit operator RoomTypeEnum(string value) + { + return new RoomTypeEnum(value); + } + + public static readonly RoomTypeEnum Go = new RoomTypeEnum("go"); + public static readonly RoomTypeEnum PeerToPeer = new RoomTypeEnum("peer_to_peer"); + public static readonly RoomTypeEnum Group = new RoomTypeEnum("group"); + public static readonly RoomTypeEnum GroupSmall = new RoomTypeEnum("group_small"); + } + + public sealed class RoomStatusEnum : StringEnum + { + private RoomStatusEnum(string value) : base(value) { } + public RoomStatusEnum() { } + public static implicit operator RoomStatusEnum(string value) + { + return new RoomStatusEnum(value); + } + + public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in_progress"); + public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); + } + + public sealed class CreatedMethodEnum : StringEnum + { + private CreatedMethodEnum(string value) : base(value) { } + public CreatedMethodEnum() { } + public static implicit operator CreatedMethodEnum(string value) + { + return new CreatedMethodEnum(value); + } + + public static readonly CreatedMethodEnum Sdk = new CreatedMethodEnum("sdk"); + public static readonly CreatedMethodEnum AdHoc = new CreatedMethodEnum("ad_hoc"); + public static readonly CreatedMethodEnum Api = new CreatedMethodEnum("api"); + } + + public sealed class EndReasonEnum : StringEnum + { + private EndReasonEnum(string value) : base(value) { } + public EndReasonEnum() { } + public static implicit operator EndReasonEnum(string value) + { + return new EndReasonEnum(value); + } + + public static readonly EndReasonEnum RoomEndedViaApi = new EndReasonEnum("room_ended_via_api"); + public static readonly EndReasonEnum Timeout = new EndReasonEnum("timeout"); + } + + public sealed class CodecEnum : StringEnum + { + private CodecEnum(string value) : base(value) { } + public CodecEnum() { } + public static implicit operator CodecEnum(string value) + { + return new CodecEnum(value); + } + + public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); + public static readonly CodecEnum H264 = new CodecEnum("H264"); + public static readonly CodecEnum Vp9 = new CodecEnum("VP9"); + } + + public sealed class TwilioRealmEnum : StringEnum + { + private TwilioRealmEnum(string value) : base(value) { } + public TwilioRealmEnum() { } + public static implicit operator TwilioRealmEnum(string value) + { + return new TwilioRealmEnum(value); + } + + public static readonly TwilioRealmEnum Us1 = new TwilioRealmEnum("us1"); + public static readonly TwilioRealmEnum Us2 = new TwilioRealmEnum("us2"); + public static readonly TwilioRealmEnum Au1 = new TwilioRealmEnum("au1"); + public static readonly TwilioRealmEnum Br1 = new TwilioRealmEnum("br1"); + public static readonly TwilioRealmEnum Ie1 = new TwilioRealmEnum("ie1"); + public static readonly TwilioRealmEnum Jp1 = new TwilioRealmEnum("jp1"); + public static readonly TwilioRealmEnum Sg1 = new TwilioRealmEnum("sg1"); + public static readonly TwilioRealmEnum In1 = new TwilioRealmEnum("in1"); + public static readonly TwilioRealmEnum De1 = new TwilioRealmEnum("de1"); + public static readonly TwilioRealmEnum Gll = new TwilioRealmEnum("gll"); + } + + public sealed class ProcessingStateEnum : StringEnum + { + private ProcessingStateEnum(string value) : base(value) { } + public ProcessingStateEnum() { } + public static implicit operator ProcessingStateEnum(string value) + { + return new ProcessingStateEnum(value); + } + + public static readonly ProcessingStateEnum Complete = new ProcessingStateEnum("complete"); + public static readonly ProcessingStateEnum InProgress = new ProcessingStateEnum("in_progress"); + } + + public sealed class EdgeLocationEnum : StringEnum + { + private EdgeLocationEnum(string value) : base(value) { } + public EdgeLocationEnum() { } + public static implicit operator EdgeLocationEnum(string value) + { + return new EdgeLocationEnum(value); + } + + public static readonly EdgeLocationEnum Ashburn = new EdgeLocationEnum("ashburn"); + public static readonly EdgeLocationEnum Dublin = new EdgeLocationEnum("dublin"); + public static readonly EdgeLocationEnum Frankfurt = new EdgeLocationEnum("frankfurt"); + public static readonly EdgeLocationEnum Singapore = new EdgeLocationEnum("singapore"); + public static readonly EdgeLocationEnum Sydney = new EdgeLocationEnum("sydney"); + public static readonly EdgeLocationEnum SaoPaulo = new EdgeLocationEnum("sao_paulo"); + public static readonly EdgeLocationEnum Roaming = new EdgeLocationEnum("roaming"); + public static readonly EdgeLocationEnum Umatilla = new EdgeLocationEnum("umatilla"); + public static readonly EdgeLocationEnum Tokyo = new EdgeLocationEnum("tokyo"); + } + + private static Request BuildFetchRequest(FetchRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Video/Rooms/" + options.PathRoomSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get Video Log Analyzer data for a Room. + /// + /// Fetch Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Fetch(FetchRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Get Video Log Analyzer data for a Room. + /// + /// Fetch Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task FetchAsync(FetchRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Get Video Log Analyzer data for a Room. + /// + /// The SID of the Room resource. + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Fetch(string pathRoomSid, ITwilioRestClient client = null) + { + var options = new FetchRoomOptions(pathRoomSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Get Video Log Analyzer data for a Room. + /// + /// The SID of the Room resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + ITwilioRestClient client = null) + { + var options = new FetchRoomOptions(pathRoomSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Video/Rooms", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Get a list of Programmable Video Rooms. + /// + /// Read Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static ResourceSet Read(ReadRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("rooms", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Get a list of Programmable Video Rooms. + /// + /// Read Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("rooms", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Get a list of Programmable Video Rooms. + /// + /// Type of room. + /// Codecs used by participants in the room. + /// Room friendly name. + /// Only read rooms that started on or after this ISO 8601 timestamp. + /// Only read rooms that started before this ISO 8601 timestamp. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Room + public static ResourceSet Read(List roomType = null, + List codec = null, + string roomName = null, + DateTime? createdAfter = null, + DateTime? createdBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomOptions() { RoomType = roomType, Codec = codec, RoomName = roomName, CreatedAfter = createdAfter, CreatedBefore = createdBefore, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Get a list of Programmable Video Rooms. + /// + /// Type of room. + /// Codecs used by participants in the room. + /// Room friendly name. + /// Only read rooms that started on or after this ISO 8601 timestamp. + /// Only read rooms that started before this ISO 8601 timestamp. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task> ReadAsync(List roomType = null, + List codec = null, + string roomName = null, + DateTime? createdAfter = null, + DateTime? createdBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomOptions() { RoomType = roomType, Codec = codec, RoomName = roomName, CreatedAfter = createdAfter, CreatedBefore = createdBefore, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Insights) + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + /// + /// Converts a JSON string into a RoomResource object + /// + /// Raw JSON string + /// RoomResource object represented by the provided JSON + public static RoomResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account SID associated with this room. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Unique identifier for the room. + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// room friendly name. + /// + [JsonProperty("room_name")] + public string RoomName { get; private set; } + /// + /// Creation time of the room. + /// + [JsonProperty("create_time")] + public DateTime? CreateTime { get; private set; } + /// + /// End time for the room. + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// Type of room. + /// + [JsonProperty("room_type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.RoomTypeEnum RoomType { get; private set; } + /// + /// Status of the room. + /// + [JsonProperty("room_status")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.RoomStatusEnum RoomStatus { get; private set; } + /// + /// Webhook provided for status callbacks. + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// HTTP method provided for status callback URL. + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// How the room was created. + /// + [JsonProperty("created_method")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.CreatedMethodEnum CreatedMethod { get; private set; } + /// + /// Reason the room ended. + /// + [JsonProperty("end_reason")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.EndReasonEnum EndReason { get; private set; } + /// + /// Max number of total participants allowed by the application settings. + /// + [JsonProperty("max_participants")] + public int? MaxParticipants { get; private set; } + /// + /// Number of participants. May include duplicate identities for participants who left and rejoined. + /// + [JsonProperty("unique_participants")] + public int? UniqueParticipants { get; private set; } + /// + /// Unique number of participant identities. + /// + [JsonProperty("unique_participant_identities")] + public int? UniqueParticipantIdentities { get; private set; } + /// + /// Actual number of concurrent participants. + /// + [JsonProperty("concurrent_participants")] + public int? ConcurrentParticipants { get; private set; } + /// + /// Maximum number of participants allowed in the room at the same time allowed by the application settings. + /// + [JsonProperty("max_concurrent_participants")] + public int? MaxConcurrentParticipants { get; private set; } + /// + /// Codecs used by participants in the room. + /// + [JsonProperty("codecs")] + [JsonConverter(typeof(StringEnumConverter))] + public List Codecs { get; private set; } + /// + /// Region of Twilio media servers for the room. + /// + [JsonProperty("media_region")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.TwilioRealmEnum MediaRegion { get; private set; } + /// + /// Total room duration from create time to end time. + /// + [JsonProperty("duration_sec")] + public long? DurationSec { get; private set; } + /// + /// Combined amount of participant time in the room. + /// + [JsonProperty("total_participant_duration_sec")] + public long? TotalParticipantDurationSec { get; private set; } + /// + /// Combined amount of recorded seconds for participants in the room. + /// + [JsonProperty("total_recording_duration_sec")] + public long? TotalRecordingDurationSec { get; private set; } + /// + /// Video Log Analyzer resource state. Will be either `in-progress` or `complete`. + /// + [JsonProperty("processing_state")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.ProcessingStateEnum ProcessingState { get; private set; } + /// + /// Boolean indicating if recording is enabled for the room. + /// + [JsonProperty("recording_enabled")] + public bool? RecordingEnabled { get; private set; } + /// + /// Edge location of Twilio media servers for the room. + /// + [JsonProperty("edge_location")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.EdgeLocationEnum EdgeLocation { get; private set; } + /// + /// URL for the room resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Room subresources. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private RoomResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/SettingOptions.cs b/src/Twilio/Rest/Insights/V1/SettingOptions.cs index 84acf5461..a37cd2dbe 100644 --- a/src/Twilio/Rest/Insights/V1/SettingOptions.cs +++ b/src/Twilio/Rest/Insights/V1/SettingOptions.cs @@ -9,74 +9,74 @@ using Twilio.Converters; namespace Twilio.Rest.Insights.V1 -{ - +{ + + /// + /// FetchSettingOptions + /// + public class FetchSettingOptions : IOptions + { /// - /// FetchSettingOptions + /// The subaccount_sid /// - public class FetchSettingOptions : IOptions - { - /// - /// The subaccount_sid - /// - public string SubaccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (SubaccountSid != null) - { - p.Add(new KeyValuePair("SubaccountSid", SubaccountSid.ToString())); - } - - return p; - } - } - + public string SubaccountSid { get; set; } + /// - /// UpdateSettingOptions + /// Generate the necessary parameters /// - public class UpdateSettingOptions : IOptions - { - /// - /// The advanced_features - /// - public bool? AdvancedFeatures { get; set; } - /// - /// The voice_trace - /// - public bool? VoiceTrace { get; set; } - /// - /// The subaccount_sid - /// - public string SubaccountSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AdvancedFeatures != null) - { - p.Add(new KeyValuePair("AdvancedFeatures", AdvancedFeatures.Value.ToString().ToLower())); - } - - if (VoiceTrace != null) - { - p.Add(new KeyValuePair("VoiceTrace", VoiceTrace.Value.ToString().ToLower())); - } - - if (SubaccountSid != null) - { - p.Add(new KeyValuePair("SubaccountSid", SubaccountSid.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (SubaccountSid != null) + { + p.Add(new KeyValuePair("SubaccountSid", SubaccountSid.ToString())); + } + + return p; + } + } + + /// + /// UpdateSettingOptions + /// + public class UpdateSettingOptions : IOptions + { + /// + /// The advanced_features + /// + public bool? AdvancedFeatures { get; set; } + /// + /// The voice_trace + /// + public bool? VoiceTrace { get; set; } + /// + /// The subaccount_sid + /// + public string SubaccountSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AdvancedFeatures != null) + { + p.Add(new KeyValuePair("AdvancedFeatures", AdvancedFeatures.Value.ToString().ToLower())); + } + + if (VoiceTrace != null) + { + p.Add(new KeyValuePair("VoiceTrace", VoiceTrace.Value.ToString().ToLower())); + } + + if (SubaccountSid != null) + { + p.Add(new KeyValuePair("SubaccountSid", SubaccountSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Insights/V1/SettingResource.cs b/src/Twilio/Rest/Insights/V1/SettingResource.cs index 8c11b4394..b6e483046 100644 --- a/src/Twilio/Rest/Insights/V1/SettingResource.cs +++ b/src/Twilio/Rest/Insights/V1/SettingResource.cs @@ -16,196 +16,196 @@ using Twilio.Http; namespace Twilio.Rest.Insights.V1 -{ - - public class SettingResource : Resource - { - private static Request BuildFetchRequest(FetchSettingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Insights, - "/v1/Voice/Settings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Setting parameters - /// Client to make requests to Twilio - /// A single instance of Setting - public static SettingResource Fetch(FetchSettingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Setting parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Setting - public static async System.Threading.Tasks.Task FetchAsync(FetchSettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The subaccount_sid - /// Client to make requests to Twilio - /// A single instance of Setting - public static SettingResource Fetch(string subaccountSid = null, ITwilioRestClient client = null) - { - var options = new FetchSettingOptions(){SubaccountSid = subaccountSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The subaccount_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Setting - public static async System.Threading.Tasks.Task FetchAsync(string subaccountSid = null, - ITwilioRestClient client = null) - { - var options = new FetchSettingOptions(){SubaccountSid = subaccountSid}; - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSettingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Insights, - "/v1/Voice/Settings", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Setting parameters - /// Client to make requests to Twilio - /// A single instance of Setting - public static SettingResource Update(UpdateSettingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Setting parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Setting - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The advanced_features - /// The voice_trace - /// The subaccount_sid - /// Client to make requests to Twilio - /// A single instance of Setting - public static SettingResource Update(bool? advancedFeatures = null, - bool? voiceTrace = null, - string subaccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSettingOptions(){AdvancedFeatures = advancedFeatures, VoiceTrace = voiceTrace, SubaccountSid = subaccountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The advanced_features - /// The voice_trace - /// The subaccount_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Setting - public static async System.Threading.Tasks.Task UpdateAsync(bool? advancedFeatures = null, - bool? voiceTrace = null, - string subaccountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSettingOptions(){AdvancedFeatures = advancedFeatures, VoiceTrace = voiceTrace, SubaccountSid = subaccountSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SettingResource object - /// - /// Raw JSON string - /// SettingResource object represented by the provided JSON - public static SettingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The advanced_features - /// - [JsonProperty("advanced_features")] - public bool? AdvancedFeatures { get; private set; } - /// - /// The voice_trace - /// - [JsonProperty("voice_trace")] - public bool? VoiceTrace { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SettingResource() - { - - } - } +{ + + public class SettingResource : Resource + { + private static Request BuildFetchRequest(FetchSettingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Insights, + "/v1/Voice/Settings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Setting parameters + /// Client to make requests to Twilio + /// A single instance of Setting + public static SettingResource Fetch(FetchSettingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Setting parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Setting + public static async System.Threading.Tasks.Task FetchAsync(FetchSettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The subaccount_sid + /// Client to make requests to Twilio + /// A single instance of Setting + public static SettingResource Fetch(string subaccountSid = null, ITwilioRestClient client = null) + { + var options = new FetchSettingOptions() { SubaccountSid = subaccountSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The subaccount_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Setting + public static async System.Threading.Tasks.Task FetchAsync(string subaccountSid = null, + ITwilioRestClient client = null) + { + var options = new FetchSettingOptions() { SubaccountSid = subaccountSid }; + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSettingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Insights, + "/v1/Voice/Settings", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Setting parameters + /// Client to make requests to Twilio + /// A single instance of Setting + public static SettingResource Update(UpdateSettingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Setting parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Setting + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The advanced_features + /// The voice_trace + /// The subaccount_sid + /// Client to make requests to Twilio + /// A single instance of Setting + public static SettingResource Update(bool? advancedFeatures = null, + bool? voiceTrace = null, + string subaccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSettingOptions() { AdvancedFeatures = advancedFeatures, VoiceTrace = voiceTrace, SubaccountSid = subaccountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The advanced_features + /// The voice_trace + /// The subaccount_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Setting + public static async System.Threading.Tasks.Task UpdateAsync(bool? advancedFeatures = null, + bool? voiceTrace = null, + string subaccountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSettingOptions() { AdvancedFeatures = advancedFeatures, VoiceTrace = voiceTrace, SubaccountSid = subaccountSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SettingResource object + /// + /// Raw JSON string + /// SettingResource object represented by the provided JSON + public static SettingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The advanced_features + /// + [JsonProperty("advanced_features")] + public bool? AdvancedFeatures { get; private set; } + /// + /// The voice_trace + /// + [JsonProperty("voice_trace")] + public bool? VoiceTrace { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SettingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/CredentialOptions.cs b/src/Twilio/Rest/IpMessaging/V1/CredentialOptions.cs index d6a85723b..42cbe7a26 100644 --- a/src/Twilio/Rest/IpMessaging/V1/CredentialOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/CredentialOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1 -{ - +{ + + /// + /// ReadCredentialOptions + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// ReadCredentialOptions + /// Generate the necessary parameters /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateCredentialOptions + /// + public class CreateCredentialOptions : IOptions + { /// - /// CreateCredentialOptions + /// The type /// - public class CreateCredentialOptions : IOptions - { - /// - /// The type - /// - public CredentialResource.PushServiceEnum Type { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The certificate - /// - public string Certificate { get; set; } - /// - /// The private_key - /// - public string PrivateKey { get; set; } - /// - /// The sandbox - /// - public bool? Sandbox { get; set; } - /// - /// The api_key - /// - public string ApiKey { get; set; } - /// - /// The secret - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The type - public CreateCredentialOptions(CredentialResource.PushServiceEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushServiceEnum Type { get; } /// - /// FetchCredentialOptions + /// The friendly_name /// - public class FetchCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The sid - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// UpdateCredentialOptions + /// The certificate /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The certificate - /// - public string Certificate { get; set; } - /// - /// The private_key - /// - public string PrivateKey { get; set; } - /// - /// The sandbox - /// - public bool? Sandbox { get; set; } - /// - /// The api_key - /// - public string ApiKey { get; set; } - /// - /// The secret - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The sid - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string Certificate { get; set; } /// - /// DeleteCredentialOptions + /// The private_key /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The sid - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PrivateKey { get; set; } + /// + /// The sandbox + /// + public bool? Sandbox { get; set; } + /// + /// The api_key + /// + public string ApiKey { get; set; } + /// + /// The secret + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The type + public CreateCredentialOptions(CredentialResource.PushServiceEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// FetchCredentialOptions + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The sid + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateCredentialOptions + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The certificate + /// + public string Certificate { get; set; } + /// + /// The private_key + /// + public string PrivateKey { get; set; } + /// + /// The sandbox + /// + public bool? Sandbox { get; set; } + /// + /// The api_key + /// + public string ApiKey { get; set; } + /// + /// The secret + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The sid + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// DeleteCredentialOptions + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The sid + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/CredentialResource.cs b/src/Twilio/Rest/IpMessaging/V1/CredentialResource.cs index 84eed309f..b6e06e27d 100644 --- a/src/Twilio/Rest/IpMessaging/V1/CredentialResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/CredentialResource.cs @@ -17,534 +17,534 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V1 -{ - - public class CredentialResource : Resource - { - public sealed class PushServiceEnum : StringEnum - { - private PushServiceEnum(string value) : base(value) {} - public PushServiceEnum() {} - public static implicit operator PushServiceEnum(string value) - { - return new PushServiceEnum(value); - } - - public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); - public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); - public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); - } - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushServiceEnum Type { get; private set; } - /// - /// The sandbox - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushServiceEnum : StringEnum + { + private PushServiceEnum(string value) : base(value) { } + public PushServiceEnum() { } + public static implicit operator PushServiceEnum(string value) + { + return new PushServiceEnum(value); + } + + public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); + public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); + public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); + } + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushServiceEnum Type { get; private set; } + /// + /// The sandbox + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteOptions.cs index 5605a2cb0..a1c14fb0f 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteOptions.cs @@ -10,193 +10,193 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - +{ + + /// + /// FetchInviteOptions + /// + public class FetchInviteOptions : IOptions + { /// - /// FetchInviteOptions - /// - public class FetchInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// CreateInviteOptions - /// - public class CreateInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The identity - public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + /// The channel_sid + /// + public string PathChannelSid { get; } /// - /// ReadInviteOptions - /// - public class ReadInviteOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadInviteOptions - /// - /// The service_sid - /// The channel_sid - public ReadInviteOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// DeleteInviteOptions - /// - public class DeleteInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateInviteOptions + /// + public class CreateInviteOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The identity + public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadInviteOptions + /// + public class ReadInviteOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadInviteOptions + /// + /// The service_sid + /// The channel_sid + public ReadInviteOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteInviteOptions + /// + public class DeleteInviteOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteResource.cs index 16890102e..f7c8650ea 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/InviteResource.cs @@ -16,456 +16,456 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - - public class InviteResource : Resource - { - private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a InviteResource object - /// - /// Raw JSON string - /// InviteResource object represented by the provided JSON - public static InviteResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InviteResource() - { - - } - } +{ + + public class InviteResource : Resource + { + private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a InviteResource object + /// + /// Raw JSON string + /// InviteResource object represented by the provided JSON + public static InviteResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InviteResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberOptions.cs index 3e0320713..32617a5e5 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberOptions.cs @@ -10,252 +10,252 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - +{ + + /// + /// FetchMemberOptions + /// + public class FetchMemberOptions : IOptions + { /// - /// FetchMemberOptions + /// The service_sid /// - public class FetchMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// CreateMemberOptions + /// The channel_sid /// - public class CreateMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The identity - public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + public string PathChannelSid { get; } /// - /// ReadMemberOptions + /// The sid /// - public class ReadMemberOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadMemberOptions - /// - /// The service_sid - /// The channel_sid - public ReadMemberOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteMemberOptions + /// Construct a new FetchMemberOptions /// - public class DeleteMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// The channel_sid + /// The sid + public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMemberOptions + /// Generate the necessary parameters /// - public class UpdateMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The last_consumed_message_index - /// - public int? LastConsumedMessageIndex { get; set; } - - /// - /// Construct a new UpdateMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMemberOptions + /// + public class CreateMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The identity + public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadMemberOptions + /// + public class ReadMemberOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadMemberOptions + /// + /// The service_sid + /// The channel_sid + public ReadMemberOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMemberOptions + /// + public class DeleteMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateMemberOptions + /// + public class UpdateMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The last_consumed_message_index + /// + public int? LastConsumedMessageIndex { get; set; } + + /// + /// Construct a new UpdateMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberResource.cs index 49e3dc61e..8d095b9ed 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MemberResource.cs @@ -16,545 +16,545 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - - public class MemberResource : Resource - { - private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The role_sid - /// The last_consumed_message_index - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The role_sid - /// The last_consumed_message_index - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MemberResource object - /// - /// Raw JSON string - /// MemberResource object represented by the provided JSON - public static MemberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The last_consumed_message_index - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The last_consumption_timestamp - /// - [JsonProperty("last_consumption_timestamp")] - public DateTime? LastConsumptionTimestamp { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MemberResource() - { - - } - } +{ + + public class MemberResource : Resource + { + private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The role_sid + /// The last_consumed_message_index + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The role_sid + /// The last_consumed_message_index + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MemberResource object + /// + /// Raw JSON string + /// MemberResource object represented by the provided JSON + public static MemberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The last_consumed_message_index + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The last_consumption_timestamp + /// + [JsonProperty("last_consumption_timestamp")] + public DateTime? LastConsumptionTimestamp { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MemberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageOptions.cs index f32c292b1..2fab09996 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageOptions.cs @@ -9,260 +9,260 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - +{ + + /// + /// FetchMessageOptions + /// + public class FetchMessageOptions : IOptions + { /// - /// FetchMessageOptions + /// The service_sid /// - public class FetchMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// CreateMessageOptions + /// The channel_sid /// - public class CreateMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The body - /// - public string Body { get; } - /// - /// The from - /// - public string From { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The body - public CreateMessageOptions(string pathServiceSid, string pathChannelSid, string body) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Body = body; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } - + public string PathChannelSid { get; } /// - /// ReadMessageOptions + /// The sid /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The order - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The service_sid - /// The channel_sid - public ReadMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteMessageOptions + /// Construct a new FetchMessageOptions /// - public class DeleteMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// The channel_sid + /// The sid + public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMessageOptions + /// Generate the necessary parameters /// - public class UpdateMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The body - /// - public string Body { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMessageOptions + /// + public class CreateMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The body + /// + public string Body { get; } + /// + /// The from + /// + public string From { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The body + public CreateMessageOptions(string pathServiceSid, string pathChannelSid, string body) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Body = body; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } + + /// + /// ReadMessageOptions + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The order + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The service_sid + /// The channel_sid + public ReadMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMessageOptions + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateMessageOptions + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The body + /// + public string Body { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageResource.cs index 150256c8b..fe350c55c 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/Channel/MessageResource.cs @@ -17,572 +17,572 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V1.Service.Channel -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The body - /// The from - /// The attributes - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathServiceSid, - string pathChannelSid, - string body, - string from = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body){From = from, Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The body - /// The from - /// The attributes - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string body, - string from = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body){From = from, Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The order - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The order - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The body - /// The attributes - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The body - /// The attributes - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The to - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The was_edited - /// - [JsonProperty("was_edited")] - public bool? WasEdited { get; private set; } - /// - /// The from - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The body - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The index - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The body + /// The from + /// The attributes + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathServiceSid, + string pathChannelSid, + string body, + string from = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body) { From = from, Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The body + /// The from + /// The attributes + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string body, + string from = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid, body) { From = from, Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The order + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The order + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The body + /// The attributes + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The body + /// The attributes + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The to + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The was_edited + /// + [JsonProperty("was_edited")] + public bool? WasEdited { get; private set; } + /// + /// The from + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The body + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The index + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/ChannelOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/ChannelOptions.cs index 831ea7932..2ce8e8dce 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/ChannelOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/ChannelOptions.cs @@ -10,247 +10,247 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service -{ - +{ + + /// + /// FetchChannelOptions + /// + public class FetchChannelOptions : IOptions + { /// - /// FetchChannelOptions + /// The service_sid /// - public class FetchChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChannelOptions - /// - /// The service_sid - /// The sid - public FetchChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// DeleteChannelOptions + /// The sid /// - public class DeleteChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteChannelOptions - /// - /// The service_sid - /// The sid - public DeleteChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateChannelOptions + /// Construct a new FetchChannelOptions /// - public class CreateChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The type - /// - public ChannelResource.ChannelTypeEnum Type { get; set; } - - /// - /// Construct a new CreateChannelOptions - /// - /// The service_sid - public CreateChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - return p; - } - } - + /// The service_sid + /// The sid + public FetchChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadChannelOptions + /// Generate the necessary parameters /// - public class ReadChannelOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The type - /// - public List Type { get; set; } - - /// - /// Construct a new ReadChannelOptions - /// - /// The service_sid - public ReadChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Type = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteChannelOptions + /// + public class DeleteChannelOptions : IOptions + { /// - /// UpdateChannelOptions + /// The service_sid /// - public class UpdateChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - - /// - /// Construct a new UpdateChannelOptions - /// - /// The service_sid - /// The sid - public UpdateChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteChannelOptions + /// + /// The service_sid + /// The sid + public DeleteChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateChannelOptions + /// + public class CreateChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The type + /// + public ChannelResource.ChannelTypeEnum Type { get; set; } + + /// + /// Construct a new CreateChannelOptions + /// + /// The service_sid + public CreateChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + return p; + } + } + + /// + /// ReadChannelOptions + /// + public class ReadChannelOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The type + /// + public List Type { get; set; } + + /// + /// Construct a new ReadChannelOptions + /// + /// The service_sid + public ReadChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Type = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateChannelOptions + /// + public class UpdateChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + + /// + /// Construct a new UpdateChannelOptions + /// + /// The service_sid + /// The sid + public UpdateChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/ChannelResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/ChannelResource.cs index 39c2f1564..eac1ab6ad 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/ChannelResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/ChannelResource.cs @@ -17,562 +17,562 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V1.Service -{ - - public class ChannelResource : Resource - { - public sealed class ChannelTypeEnum : StringEnum - { - private ChannelTypeEnum(string value) : base(value) {} - public ChannelTypeEnum() {} - public static implicit operator ChannelTypeEnum(string value) - { - return new ChannelTypeEnum(value); - } - - public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); - public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); - } - - private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The type - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The type - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The friendly_name - /// The unique_name - /// The attributes - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The friendly_name - /// The unique_name - /// The attributes - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public ChannelResource.ChannelTypeEnum Type { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The members_count - /// - [JsonProperty("members_count")] - public int? MembersCount { get; private set; } - /// - /// The messages_count - /// - [JsonProperty("messages_count")] - public int? MessagesCount { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + public sealed class ChannelTypeEnum : StringEnum + { + private ChannelTypeEnum(string value) : base(value) { } + public ChannelTypeEnum() { } + public static implicit operator ChannelTypeEnum(string value) + { + return new ChannelTypeEnum(value); + } + + public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); + public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); + } + + private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The type + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The type + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The friendly_name + /// The unique_name + /// The attributes + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The friendly_name + /// The unique_name + /// The attributes + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public ChannelResource.ChannelTypeEnum Type { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The members_count + /// + [JsonProperty("members_count")] + public int? MembersCount { get; private set; } + /// + /// The messages_count + /// + [JsonProperty("messages_count")] + public int? MessagesCount { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/RoleOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/RoleOptions.cs index 42afd2aab..d249b6405 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/RoleOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/RoleOptions.cs @@ -10,221 +10,221 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service -{ - +{ + + /// + /// FetchRoleOptions + /// + public class FetchRoleOptions : IOptions + { /// - /// FetchRoleOptions - /// - public class FetchRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The service_sid - /// The sid - public FetchRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// DeleteRoleOptions - /// - public class DeleteRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The service_sid - /// The sid - public DeleteRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// CreateRoleOptions - /// - public class CreateRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; } - /// - /// The type - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// The permission - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - public CreateRoleOptions(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// Construct a new FetchRoleOptions + /// + /// The service_sid + /// The sid + public FetchRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadRoleOptions + /// Generate the necessary parameters /// - public class ReadRoleOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadRoleOptions - /// - /// The service_sid - public ReadRoleOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteRoleOptions + /// + public class DeleteRoleOptions : IOptions + { /// - /// UpdateRoleOptions - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The permission - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The service_sid - /// The sid - /// The permission - public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The service_sid + /// The sid + public DeleteRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRoleOptions + /// + public class CreateRoleOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; } + /// + /// The type + /// + public RoleResource.RoleTypeEnum Type { get; } + /// + /// The permission + /// + public List Permission { get; } + + /// + /// Construct a new CreateRoleOptions + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + public CreateRoleOptions(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// ReadRoleOptions + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadRoleOptions + /// + /// The service_sid + public ReadRoleOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateRoleOptions + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The permission + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The service_sid + /// The sid + /// The permission + public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/RoleResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/RoleResource.cs index 8afad6e43..e6629bc60 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/RoleResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/RoleResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V1.Service -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); - public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); - } - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The permission - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The permission - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// The permissions - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); + public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); + } + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The permission + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The permission + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// The permissions + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelOptions.cs index c0e7dc6a0..1e6af5475 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelOptions.cs @@ -9,46 +9,46 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service.User -{ - +{ + + /// + /// ReadUserChannelOptions + /// + public class ReadUserChannelOptions : ReadOptions + { /// - /// ReadUserChannelOptions + /// The service_sid /// - public class ReadUserChannelOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserChannelOptions - /// - /// The service_sid - /// The user_sid - public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + + /// + /// Construct a new ReadUserChannelOptions + /// + /// The service_sid + /// The user_sid + public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelResource.cs index 7bc13347d..22779cce6 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/User/UserChannelResource.cs @@ -17,225 +17,225 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V1.Service.User -{ - - public class UserChannelResource : Resource - { - public sealed class ChannelStatusEnum : StringEnum - { - private ChannelStatusEnum(string value) : base(value) {} - public ChannelStatusEnum() {} - public static implicit operator ChannelStatusEnum(string value) - { - return new ChannelStatusEnum(value); - } - - public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); - public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); - public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); - } - - private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The user_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The user_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Converts a JSON string into a UserChannelResource object - /// - /// Raw JSON string - /// UserChannelResource object represented by the provided JSON - public static UserChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The member_sid - /// - [JsonProperty("member_sid")] - public string MemberSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.ChannelStatusEnum Status { get; private set; } - /// - /// The last_consumed_message_index - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The unread_messages_count - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private UserChannelResource() - { - - } - } +{ + + public class UserChannelResource : Resource + { + public sealed class ChannelStatusEnum : StringEnum + { + private ChannelStatusEnum(string value) : base(value) { } + public ChannelStatusEnum() { } + public static implicit operator ChannelStatusEnum(string value) + { + return new ChannelStatusEnum(value); + } + + public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); + public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); + public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); + } + + private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The user_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The user_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Converts a JSON string into a UserChannelResource object + /// + /// Raw JSON string + /// UserChannelResource object represented by the provided JSON + public static UserChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The member_sid + /// + [JsonProperty("member_sid")] + public string MemberSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.ChannelStatusEnum Status { get; private set; } + /// + /// The last_consumed_message_index + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The unread_messages_count + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private UserChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/UserOptions.cs b/src/Twilio/Rest/IpMessaging/V1/Service/UserOptions.cs index 23e88c5fa..5ab744222 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/UserOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/UserOptions.cs @@ -9,239 +9,239 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1.Service -{ - +{ + + /// + /// FetchUserOptions + /// + public class FetchUserOptions : IOptions + { /// - /// FetchUserOptions - /// - public class FetchUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The service_sid - /// The sid - public FetchUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// DeleteUserOptions - /// - public class DeleteUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The service_sid - /// The sid - public DeleteUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// CreateUserOptions - /// - public class CreateUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The service_sid - /// The identity - public CreateUserOptions(string pathServiceSid, string identity) - { - PathServiceSid = pathServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Construct a new FetchUserOptions + /// + /// The service_sid + /// The sid + public FetchUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadUserOptions + /// Generate the necessary parameters /// - public class ReadUserOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadUserOptions - /// - /// The service_sid - public ReadUserOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserOptions + /// + public class DeleteUserOptions : IOptions + { /// - /// UpdateUserOptions - /// - public class UpdateUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The service_sid - /// The sid - public UpdateUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The service_sid + /// The sid + public DeleteUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateUserOptions + /// + public class CreateUserOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The service_sid + /// The identity + public CreateUserOptions(string pathServiceSid, string identity) + { + PathServiceSid = pathServiceSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadUserOptions + /// + public class ReadUserOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadUserOptions + /// + /// The service_sid + public ReadUserOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateUserOptions + /// + public class UpdateUserOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The service_sid + /// The sid + public UpdateUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/Service/UserResource.cs b/src/Twilio/Rest/IpMessaging/V1/Service/UserResource.cs index fbb79eedf..904945ccd 100644 --- a/src/Twilio/Rest/IpMessaging/V1/Service/UserResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/Service/UserResource.cs @@ -16,544 +16,544 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V1.Service -{ - - public class UserResource : Resource - { - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The identity - /// The role_sid - /// The attributes - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The identity - /// The role_sid - /// The attributes - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The role_sid - /// The attributes - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The role_sid - /// The attributes - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The is_online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// The is_notifiable - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The joined_channels_count - /// - [JsonProperty("joined_channels_count")] - public int? JoinedChannelsCount { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The identity + /// The role_sid + /// The attributes + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The identity + /// The role_sid + /// The attributes + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The role_sid + /// The attributes + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The role_sid + /// The attributes + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The is_online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// The is_notifiable + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The joined_channels_count + /// + [JsonProperty("joined_channels_count")] + public int? JoinedChannelsCount { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/ServiceOptions.cs b/src/Twilio/Rest/IpMessaging/V1/ServiceOptions.cs index 15c15c292..84f828f41 100644 --- a/src/Twilio/Rest/IpMessaging/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V1/ServiceOptions.cs @@ -10,634 +10,634 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V1 -{ - +{ + + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// FetchServiceOptions + /// The sid /// - public class FetchServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The sid - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteServiceOptions + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The sid - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateServiceOptions + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// The friendly_name - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateServiceOptions - /// - /// The friendly_name - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The default_service_role_sid - /// - public string DefaultServiceRoleSid { get; set; } - /// - /// The default_channel_role_sid - /// - public string DefaultChannelRoleSid { get; set; } - /// - /// The default_channel_creator_role_sid - /// - public string DefaultChannelCreatorRoleSid { get; set; } - /// - /// The read_status_enabled - /// - public bool? ReadStatusEnabled { get; set; } - /// - /// The reachability_enabled - /// - public bool? ReachabilityEnabled { get; set; } - /// - /// The typing_indicator_timeout - /// - public int? TypingIndicatorTimeout { get; set; } - /// - /// The consumption_report_interval - /// - public int? ConsumptionReportInterval { get; set; } - /// - /// The notifications.new_message.enabled - /// - public bool? NotificationsNewMessageEnabled { get; set; } - /// - /// The notifications.new_message.template - /// - public string NotificationsNewMessageTemplate { get; set; } - /// - /// The notifications.added_to_channel.enabled - /// - public bool? NotificationsAddedToChannelEnabled { get; set; } - /// - /// The notifications.added_to_channel.template - /// - public string NotificationsAddedToChannelTemplate { get; set; } - /// - /// The notifications.removed_from_channel.enabled - /// - public bool? NotificationsRemovedFromChannelEnabled { get; set; } - /// - /// The notifications.removed_from_channel.template - /// - public string NotificationsRemovedFromChannelTemplate { get; set; } - /// - /// The notifications.invited_to_channel.enabled - /// - public bool? NotificationsInvitedToChannelEnabled { get; set; } - /// - /// The notifications.invited_to_channel.template - /// - public string NotificationsInvitedToChannelTemplate { get; set; } - /// - /// The pre_webhook_url - /// - public Uri PreWebhookUrl { get; set; } - /// - /// The post_webhook_url - /// - public Uri PostWebhookUrl { get; set; } - /// - /// The webhook_method - /// - public Twilio.Http.HttpMethod WebhookMethod { get; set; } - /// - /// The webhook_filters - /// - public List WebhookFilters { get; set; } - /// - /// The webhooks.on_message_send.url - /// - public Uri WebhooksOnMessageSendUrl { get; set; } - /// - /// The webhooks.on_message_send.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageSendMethod { get; set; } - /// - /// The webhooks.on_message_update.url - /// - public Uri WebhooksOnMessageUpdateUrl { get; set; } - /// - /// The webhooks.on_message_update.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageUpdateMethod { get; set; } - /// - /// The webhooks.on_message_remove.url - /// - public Uri WebhooksOnMessageRemoveUrl { get; set; } - /// - /// The webhooks.on_message_remove.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageRemoveMethod { get; set; } - /// - /// The webhooks.on_channel_add.url - /// - public Uri WebhooksOnChannelAddUrl { get; set; } - /// - /// The webhooks.on_channel_add.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelAddMethod { get; set; } - /// - /// The webhooks.on_channel_destroy.url - /// - public Uri WebhooksOnChannelDestroyUrl { get; set; } - /// - /// The webhooks.on_channel_destroy.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelDestroyMethod { get; set; } - /// - /// The webhooks.on_channel_update.url - /// - public Uri WebhooksOnChannelUpdateUrl { get; set; } - /// - /// The webhooks.on_channel_update.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelUpdateMethod { get; set; } - /// - /// The webhooks.on_member_add.url - /// - public Uri WebhooksOnMemberAddUrl { get; set; } - /// - /// The webhooks.on_member_add.method - /// - public Twilio.Http.HttpMethod WebhooksOnMemberAddMethod { get; set; } - /// - /// The webhooks.on_member_remove.url - /// - public Uri WebhooksOnMemberRemoveUrl { get; set; } - /// - /// The webhooks.on_member_remove.method - /// - public Twilio.Http.HttpMethod WebhooksOnMemberRemoveMethod { get; set; } - /// - /// The webhooks.on_message_sent.url - /// - public Uri WebhooksOnMessageSentUrl { get; set; } - /// - /// The webhooks.on_message_sent.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageSentMethod { get; set; } - /// - /// The webhooks.on_message_updated.url - /// - public Uri WebhooksOnMessageUpdatedUrl { get; set; } - /// - /// The webhooks.on_message_updated.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageUpdatedMethod { get; set; } - /// - /// The webhooks.on_message_removed.url - /// - public Uri WebhooksOnMessageRemovedUrl { get; set; } - /// - /// The webhooks.on_message_removed.method - /// - public Twilio.Http.HttpMethod WebhooksOnMessageRemovedMethod { get; set; } - /// - /// The webhooks.on_channel_added.url - /// - public Uri WebhooksOnChannelAddedUrl { get; set; } - /// - /// The webhooks.on_channel_added.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelAddedMethod { get; set; } - /// - /// The webhooks.on_channel_destroyed.url - /// - public Uri WebhooksOnChannelDestroyedUrl { get; set; } - /// - /// The webhooks.on_channel_destroyed.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelDestroyedMethod { get; set; } - /// - /// The webhooks.on_channel_updated.url - /// - public Uri WebhooksOnChannelUpdatedUrl { get; set; } - /// - /// The webhooks.on_channel_updated.method - /// - public Twilio.Http.HttpMethod WebhooksOnChannelUpdatedMethod { get; set; } - /// - /// The webhooks.on_member_added.url - /// - public Uri WebhooksOnMemberAddedUrl { get; set; } - /// - /// The webhooks.on_member_added.method - /// - public Twilio.Http.HttpMethod WebhooksOnMemberAddedMethod { get; set; } - /// - /// The webhooks.on_member_removed.url - /// - public Uri WebhooksOnMemberRemovedUrl { get; set; } - /// - /// The webhooks.on_member_removed.method - /// - public Twilio.Http.HttpMethod WebhooksOnMemberRemovedMethod { get; set; } - /// - /// The limits.channel_members - /// - public int? LimitsChannelMembers { get; set; } - /// - /// The limits.user_channels - /// - public int? LimitsUserChannels { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The sid - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - WebhookFilters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DefaultServiceRoleSid != null) - { - p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); - } - - if (DefaultChannelRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); - } - - if (DefaultChannelCreatorRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); - } - - if (ReadStatusEnabled != null) - { - p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); - } - - if (TypingIndicatorTimeout != null) - { - p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); - } - - if (ConsumptionReportInterval != null) - { - p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); - } - - if (NotificationsNewMessageEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); - } - - if (NotificationsNewMessageTemplate != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); - } - - if (NotificationsAddedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); - } - - if (NotificationsRemovedFromChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsRemovedFromChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); - } - - if (NotificationsInvitedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsInvitedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); - } - - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); - } - - if (WebhookFilters != null) - { - p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); - } - - if (WebhooksOnMessageSendUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSend.Url", Serializers.Url(WebhooksOnMessageSendUrl))); - } - - if (WebhooksOnMessageSendMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSend.Method", WebhooksOnMessageSendMethod.ToString())); - } - - if (WebhooksOnMessageUpdateUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Url", Serializers.Url(WebhooksOnMessageUpdateUrl))); - } - - if (WebhooksOnMessageUpdateMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Method", WebhooksOnMessageUpdateMethod.ToString())); - } - - if (WebhooksOnMessageRemoveUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Url", Serializers.Url(WebhooksOnMessageRemoveUrl))); - } - - if (WebhooksOnMessageRemoveMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Method", WebhooksOnMessageRemoveMethod.ToString())); - } - - if (WebhooksOnChannelAddUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Url", Serializers.Url(WebhooksOnChannelAddUrl))); - } - - if (WebhooksOnChannelAddMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Method", WebhooksOnChannelAddMethod.ToString())); - } - - if (WebhooksOnChannelDestroyUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Url", Serializers.Url(WebhooksOnChannelDestroyUrl))); - } - - if (WebhooksOnChannelDestroyMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Method", WebhooksOnChannelDestroyMethod.ToString())); - } - - if (WebhooksOnChannelUpdateUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Url", Serializers.Url(WebhooksOnChannelUpdateUrl))); - } - - if (WebhooksOnChannelUpdateMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Method", WebhooksOnChannelUpdateMethod.ToString())); - } - - if (WebhooksOnMemberAddUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Url", Serializers.Url(WebhooksOnMemberAddUrl))); - } - - if (WebhooksOnMemberAddMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Method", WebhooksOnMemberAddMethod.ToString())); - } - - if (WebhooksOnMemberRemoveUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Url", Serializers.Url(WebhooksOnMemberRemoveUrl))); - } - - if (WebhooksOnMemberRemoveMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Method", WebhooksOnMemberRemoveMethod.ToString())); - } - - if (WebhooksOnMessageSentUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSent.Url", Serializers.Url(WebhooksOnMessageSentUrl))); - } - - if (WebhooksOnMessageSentMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageSent.Method", WebhooksOnMessageSentMethod.ToString())); - } - - if (WebhooksOnMessageUpdatedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Url", Serializers.Url(WebhooksOnMessageUpdatedUrl))); - } - - if (WebhooksOnMessageUpdatedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Method", WebhooksOnMessageUpdatedMethod.ToString())); - } - - if (WebhooksOnMessageRemovedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Url", Serializers.Url(WebhooksOnMessageRemovedUrl))); - } - - if (WebhooksOnMessageRemovedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Method", WebhooksOnMessageRemovedMethod.ToString())); - } - - if (WebhooksOnChannelAddedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Url", Serializers.Url(WebhooksOnChannelAddedUrl))); - } - - if (WebhooksOnChannelAddedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Method", WebhooksOnChannelAddedMethod.ToString())); - } - - if (WebhooksOnChannelDestroyedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Url", Serializers.Url(WebhooksOnChannelDestroyedUrl))); - } - - if (WebhooksOnChannelDestroyedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Method", WebhooksOnChannelDestroyedMethod.ToString())); - } - - if (WebhooksOnChannelUpdatedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Url", Serializers.Url(WebhooksOnChannelUpdatedUrl))); - } - - if (WebhooksOnChannelUpdatedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Method", WebhooksOnChannelUpdatedMethod.ToString())); - } - - if (WebhooksOnMemberAddedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Url", Serializers.Url(WebhooksOnMemberAddedUrl))); - } - - if (WebhooksOnMemberAddedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Method", WebhooksOnMemberAddedMethod.ToString())); - } - - if (WebhooksOnMemberRemovedUrl != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Url", Serializers.Url(WebhooksOnMemberRemovedUrl))); - } - - if (WebhooksOnMemberRemovedMethod != null) - { - p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Method", WebhooksOnMemberRemovedMethod.ToString())); - } - - if (LimitsChannelMembers != null) - { - p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); - } - - if (LimitsUserChannels != null) - { - p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); - } - - return p; - } - } + /// Construct a new DeleteServiceOptions + /// + /// The sid + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// The friendly_name + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateServiceOptions + /// + /// The friendly_name + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The default_service_role_sid + /// + public string DefaultServiceRoleSid { get; set; } + /// + /// The default_channel_role_sid + /// + public string DefaultChannelRoleSid { get; set; } + /// + /// The default_channel_creator_role_sid + /// + public string DefaultChannelCreatorRoleSid { get; set; } + /// + /// The read_status_enabled + /// + public bool? ReadStatusEnabled { get; set; } + /// + /// The reachability_enabled + /// + public bool? ReachabilityEnabled { get; set; } + /// + /// The typing_indicator_timeout + /// + public int? TypingIndicatorTimeout { get; set; } + /// + /// The consumption_report_interval + /// + public int? ConsumptionReportInterval { get; set; } + /// + /// The notifications.new_message.enabled + /// + public bool? NotificationsNewMessageEnabled { get; set; } + /// + /// The notifications.new_message.template + /// + public string NotificationsNewMessageTemplate { get; set; } + /// + /// The notifications.added_to_channel.enabled + /// + public bool? NotificationsAddedToChannelEnabled { get; set; } + /// + /// The notifications.added_to_channel.template + /// + public string NotificationsAddedToChannelTemplate { get; set; } + /// + /// The notifications.removed_from_channel.enabled + /// + public bool? NotificationsRemovedFromChannelEnabled { get; set; } + /// + /// The notifications.removed_from_channel.template + /// + public string NotificationsRemovedFromChannelTemplate { get; set; } + /// + /// The notifications.invited_to_channel.enabled + /// + public bool? NotificationsInvitedToChannelEnabled { get; set; } + /// + /// The notifications.invited_to_channel.template + /// + public string NotificationsInvitedToChannelTemplate { get; set; } + /// + /// The pre_webhook_url + /// + public Uri PreWebhookUrl { get; set; } + /// + /// The post_webhook_url + /// + public Uri PostWebhookUrl { get; set; } + /// + /// The webhook_method + /// + public Twilio.Http.HttpMethod WebhookMethod { get; set; } + /// + /// The webhook_filters + /// + public List WebhookFilters { get; set; } + /// + /// The webhooks.on_message_send.url + /// + public Uri WebhooksOnMessageSendUrl { get; set; } + /// + /// The webhooks.on_message_send.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageSendMethod { get; set; } + /// + /// The webhooks.on_message_update.url + /// + public Uri WebhooksOnMessageUpdateUrl { get; set; } + /// + /// The webhooks.on_message_update.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageUpdateMethod { get; set; } + /// + /// The webhooks.on_message_remove.url + /// + public Uri WebhooksOnMessageRemoveUrl { get; set; } + /// + /// The webhooks.on_message_remove.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageRemoveMethod { get; set; } + /// + /// The webhooks.on_channel_add.url + /// + public Uri WebhooksOnChannelAddUrl { get; set; } + /// + /// The webhooks.on_channel_add.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelAddMethod { get; set; } + /// + /// The webhooks.on_channel_destroy.url + /// + public Uri WebhooksOnChannelDestroyUrl { get; set; } + /// + /// The webhooks.on_channel_destroy.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelDestroyMethod { get; set; } + /// + /// The webhooks.on_channel_update.url + /// + public Uri WebhooksOnChannelUpdateUrl { get; set; } + /// + /// The webhooks.on_channel_update.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelUpdateMethod { get; set; } + /// + /// The webhooks.on_member_add.url + /// + public Uri WebhooksOnMemberAddUrl { get; set; } + /// + /// The webhooks.on_member_add.method + /// + public Twilio.Http.HttpMethod WebhooksOnMemberAddMethod { get; set; } + /// + /// The webhooks.on_member_remove.url + /// + public Uri WebhooksOnMemberRemoveUrl { get; set; } + /// + /// The webhooks.on_member_remove.method + /// + public Twilio.Http.HttpMethod WebhooksOnMemberRemoveMethod { get; set; } + /// + /// The webhooks.on_message_sent.url + /// + public Uri WebhooksOnMessageSentUrl { get; set; } + /// + /// The webhooks.on_message_sent.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageSentMethod { get; set; } + /// + /// The webhooks.on_message_updated.url + /// + public Uri WebhooksOnMessageUpdatedUrl { get; set; } + /// + /// The webhooks.on_message_updated.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageUpdatedMethod { get; set; } + /// + /// The webhooks.on_message_removed.url + /// + public Uri WebhooksOnMessageRemovedUrl { get; set; } + /// + /// The webhooks.on_message_removed.method + /// + public Twilio.Http.HttpMethod WebhooksOnMessageRemovedMethod { get; set; } + /// + /// The webhooks.on_channel_added.url + /// + public Uri WebhooksOnChannelAddedUrl { get; set; } + /// + /// The webhooks.on_channel_added.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelAddedMethod { get; set; } + /// + /// The webhooks.on_channel_destroyed.url + /// + public Uri WebhooksOnChannelDestroyedUrl { get; set; } + /// + /// The webhooks.on_channel_destroyed.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelDestroyedMethod { get; set; } + /// + /// The webhooks.on_channel_updated.url + /// + public Uri WebhooksOnChannelUpdatedUrl { get; set; } + /// + /// The webhooks.on_channel_updated.method + /// + public Twilio.Http.HttpMethod WebhooksOnChannelUpdatedMethod { get; set; } + /// + /// The webhooks.on_member_added.url + /// + public Uri WebhooksOnMemberAddedUrl { get; set; } + /// + /// The webhooks.on_member_added.method + /// + public Twilio.Http.HttpMethod WebhooksOnMemberAddedMethod { get; set; } + /// + /// The webhooks.on_member_removed.url + /// + public Uri WebhooksOnMemberRemovedUrl { get; set; } + /// + /// The webhooks.on_member_removed.method + /// + public Twilio.Http.HttpMethod WebhooksOnMemberRemovedMethod { get; set; } + /// + /// The limits.channel_members + /// + public int? LimitsChannelMembers { get; set; } + /// + /// The limits.user_channels + /// + public int? LimitsUserChannels { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The sid + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + WebhookFilters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DefaultServiceRoleSid != null) + { + p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); + } + + if (DefaultChannelRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); + } + + if (DefaultChannelCreatorRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); + } + + if (ReadStatusEnabled != null) + { + p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); + } + + if (TypingIndicatorTimeout != null) + { + p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); + } + + if (ConsumptionReportInterval != null) + { + p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); + } + + if (NotificationsNewMessageEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); + } + + if (NotificationsNewMessageTemplate != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); + } + + if (NotificationsAddedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); + } + + if (NotificationsRemovedFromChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsRemovedFromChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); + } + + if (NotificationsInvitedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsInvitedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); + } + + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); + } + + if (WebhookFilters != null) + { + p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); + } + + if (WebhooksOnMessageSendUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSend.Url", Serializers.Url(WebhooksOnMessageSendUrl))); + } + + if (WebhooksOnMessageSendMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSend.Method", WebhooksOnMessageSendMethod.ToString())); + } + + if (WebhooksOnMessageUpdateUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Url", Serializers.Url(WebhooksOnMessageUpdateUrl))); + } + + if (WebhooksOnMessageUpdateMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdate.Method", WebhooksOnMessageUpdateMethod.ToString())); + } + + if (WebhooksOnMessageRemoveUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Url", Serializers.Url(WebhooksOnMessageRemoveUrl))); + } + + if (WebhooksOnMessageRemoveMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemove.Method", WebhooksOnMessageRemoveMethod.ToString())); + } + + if (WebhooksOnChannelAddUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Url", Serializers.Url(WebhooksOnChannelAddUrl))); + } + + if (WebhooksOnChannelAddMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdd.Method", WebhooksOnChannelAddMethod.ToString())); + } + + if (WebhooksOnChannelDestroyUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Url", Serializers.Url(WebhooksOnChannelDestroyUrl))); + } + + if (WebhooksOnChannelDestroyMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroy.Method", WebhooksOnChannelDestroyMethod.ToString())); + } + + if (WebhooksOnChannelUpdateUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Url", Serializers.Url(WebhooksOnChannelUpdateUrl))); + } + + if (WebhooksOnChannelUpdateMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdate.Method", WebhooksOnChannelUpdateMethod.ToString())); + } + + if (WebhooksOnMemberAddUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Url", Serializers.Url(WebhooksOnMemberAddUrl))); + } + + if (WebhooksOnMemberAddMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdd.Method", WebhooksOnMemberAddMethod.ToString())); + } + + if (WebhooksOnMemberRemoveUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Url", Serializers.Url(WebhooksOnMemberRemoveUrl))); + } + + if (WebhooksOnMemberRemoveMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemove.Method", WebhooksOnMemberRemoveMethod.ToString())); + } + + if (WebhooksOnMessageSentUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSent.Url", Serializers.Url(WebhooksOnMessageSentUrl))); + } + + if (WebhooksOnMessageSentMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageSent.Method", WebhooksOnMessageSentMethod.ToString())); + } + + if (WebhooksOnMessageUpdatedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Url", Serializers.Url(WebhooksOnMessageUpdatedUrl))); + } + + if (WebhooksOnMessageUpdatedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageUpdated.Method", WebhooksOnMessageUpdatedMethod.ToString())); + } + + if (WebhooksOnMessageRemovedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Url", Serializers.Url(WebhooksOnMessageRemovedUrl))); + } + + if (WebhooksOnMessageRemovedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMessageRemoved.Method", WebhooksOnMessageRemovedMethod.ToString())); + } + + if (WebhooksOnChannelAddedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Url", Serializers.Url(WebhooksOnChannelAddedUrl))); + } + + if (WebhooksOnChannelAddedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelAdded.Method", WebhooksOnChannelAddedMethod.ToString())); + } + + if (WebhooksOnChannelDestroyedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Url", Serializers.Url(WebhooksOnChannelDestroyedUrl))); + } + + if (WebhooksOnChannelDestroyedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelDestroyed.Method", WebhooksOnChannelDestroyedMethod.ToString())); + } + + if (WebhooksOnChannelUpdatedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Url", Serializers.Url(WebhooksOnChannelUpdatedUrl))); + } + + if (WebhooksOnChannelUpdatedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnChannelUpdated.Method", WebhooksOnChannelUpdatedMethod.ToString())); + } + + if (WebhooksOnMemberAddedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Url", Serializers.Url(WebhooksOnMemberAddedUrl))); + } + + if (WebhooksOnMemberAddedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberAdded.Method", WebhooksOnMemberAddedMethod.ToString())); + } + + if (WebhooksOnMemberRemovedUrl != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Url", Serializers.Url(WebhooksOnMemberRemovedUrl))); + } + + if (WebhooksOnMemberRemovedMethod != null) + { + p.Add(new KeyValuePair("Webhooks.OnMemberRemoved.Method", WebhooksOnMemberRemovedMethod.ToString())); + } + + if (LimitsChannelMembers != null) + { + p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); + } + + if (LimitsUserChannels != null) + { + p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V1/ServiceResource.cs b/src/Twilio/Rest/IpMessaging/V1/ServiceResource.cs index 16ef0036f..37485669e 100644 --- a/src/Twilio/Rest/IpMessaging/V1/ServiceResource.cs +++ b/src/Twilio/Rest/IpMessaging/V1/ServiceResource.cs @@ -16,751 +16,751 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The friendly_name - /// The default_service_role_sid - /// The default_channel_role_sid - /// The default_channel_creator_role_sid - /// The read_status_enabled - /// The reachability_enabled - /// The typing_indicator_timeout - /// The consumption_report_interval - /// The notifications.new_message.enabled - /// The notifications.new_message.template - /// The notifications.added_to_channel.enabled - /// The notifications.added_to_channel.template - /// The notifications.removed_from_channel.enabled - /// The notifications.removed_from_channel.template - /// The notifications.invited_to_channel.enabled - /// The notifications.invited_to_channel.template - /// The pre_webhook_url - /// The post_webhook_url - /// The webhook_method - /// The webhook_filters - /// The webhooks.on_message_send.url - /// The webhooks.on_message_send.method - /// The webhooks.on_message_update.url - /// The webhooks.on_message_update.method - /// The webhooks.on_message_remove.url - /// The webhooks.on_message_remove.method - /// The webhooks.on_channel_add.url - /// The webhooks.on_channel_add.method - /// The webhooks.on_channel_destroy.url - /// The webhooks.on_channel_destroy.method - /// The webhooks.on_channel_update.url - /// The webhooks.on_channel_update.method - /// The webhooks.on_member_add.url - /// The webhooks.on_member_add.method - /// The webhooks.on_member_remove.url - /// The webhooks.on_member_remove.method - /// The webhooks.on_message_sent.url - /// The webhooks.on_message_sent.method - /// The webhooks.on_message_updated.url - /// The webhooks.on_message_updated.method - /// The webhooks.on_message_removed.url - /// The webhooks.on_message_removed.method - /// The webhooks.on_channel_added.url - /// The webhooks.on_channel_added.method - /// The webhooks.on_channel_destroyed.url - /// The webhooks.on_channel_destroyed.method - /// The webhooks.on_channel_updated.url - /// The webhooks.on_channel_updated.method - /// The webhooks.on_member_added.url - /// The webhooks.on_member_added.method - /// The webhooks.on_member_removed.url - /// The webhooks.on_member_removed.method - /// The limits.channel_members - /// The limits.user_channels - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - Uri webhooksOnMessageSendUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, - Uri webhooksOnMessageUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, - Uri webhooksOnMessageRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, - Uri webhooksOnChannelAddUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, - Uri webhooksOnChannelDestroyUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, - Uri webhooksOnChannelUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, - Uri webhooksOnMemberAddUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, - Uri webhooksOnMemberRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, - Uri webhooksOnMessageSentUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, - Uri webhooksOnMessageUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, - Uri webhooksOnMessageRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, - Uri webhooksOnChannelAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, - Uri webhooksOnChannelDestroyedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, - Uri webhooksOnChannelUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, - Uri webhooksOnMemberAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, - Uri webhooksOnMemberRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The friendly_name - /// The default_service_role_sid - /// The default_channel_role_sid - /// The default_channel_creator_role_sid - /// The read_status_enabled - /// The reachability_enabled - /// The typing_indicator_timeout - /// The consumption_report_interval - /// The notifications.new_message.enabled - /// The notifications.new_message.template - /// The notifications.added_to_channel.enabled - /// The notifications.added_to_channel.template - /// The notifications.removed_from_channel.enabled - /// The notifications.removed_from_channel.template - /// The notifications.invited_to_channel.enabled - /// The notifications.invited_to_channel.template - /// The pre_webhook_url - /// The post_webhook_url - /// The webhook_method - /// The webhook_filters - /// The webhooks.on_message_send.url - /// The webhooks.on_message_send.method - /// The webhooks.on_message_update.url - /// The webhooks.on_message_update.method - /// The webhooks.on_message_remove.url - /// The webhooks.on_message_remove.method - /// The webhooks.on_channel_add.url - /// The webhooks.on_channel_add.method - /// The webhooks.on_channel_destroy.url - /// The webhooks.on_channel_destroy.method - /// The webhooks.on_channel_update.url - /// The webhooks.on_channel_update.method - /// The webhooks.on_member_add.url - /// The webhooks.on_member_add.method - /// The webhooks.on_member_remove.url - /// The webhooks.on_member_remove.method - /// The webhooks.on_message_sent.url - /// The webhooks.on_message_sent.method - /// The webhooks.on_message_updated.url - /// The webhooks.on_message_updated.method - /// The webhooks.on_message_removed.url - /// The webhooks.on_message_removed.method - /// The webhooks.on_channel_added.url - /// The webhooks.on_channel_added.method - /// The webhooks.on_channel_destroyed.url - /// The webhooks.on_channel_destroyed.method - /// The webhooks.on_channel_updated.url - /// The webhooks.on_channel_updated.method - /// The webhooks.on_member_added.url - /// The webhooks.on_member_added.method - /// The webhooks.on_member_removed.url - /// The webhooks.on_member_removed.method - /// The limits.channel_members - /// The limits.user_channels - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - Uri webhooksOnMessageSendUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, - Uri webhooksOnMessageUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, - Uri webhooksOnMessageRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, - Uri webhooksOnChannelAddUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, - Uri webhooksOnChannelDestroyUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, - Uri webhooksOnChannelUpdateUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, - Uri webhooksOnMemberAddUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, - Uri webhooksOnMemberRemoveUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, - Uri webhooksOnMessageSentUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, - Uri webhooksOnMessageUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, - Uri webhooksOnMessageRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, - Uri webhooksOnChannelAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, - Uri webhooksOnChannelDestroyedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, - Uri webhooksOnChannelUpdatedUrl = null, - Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, - Uri webhooksOnMemberAddedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, - Uri webhooksOnMemberRemovedUrl = null, - Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The default_service_role_sid - /// - [JsonProperty("default_service_role_sid")] - public string DefaultServiceRoleSid { get; private set; } - /// - /// The default_channel_role_sid - /// - [JsonProperty("default_channel_role_sid")] - public string DefaultChannelRoleSid { get; private set; } - /// - /// The default_channel_creator_role_sid - /// - [JsonProperty("default_channel_creator_role_sid")] - public string DefaultChannelCreatorRoleSid { get; private set; } - /// - /// The read_status_enabled - /// - [JsonProperty("read_status_enabled")] - public bool? ReadStatusEnabled { get; private set; } - /// - /// The reachability_enabled - /// - [JsonProperty("reachability_enabled")] - public bool? ReachabilityEnabled { get; private set; } - /// - /// The typing_indicator_timeout - /// - [JsonProperty("typing_indicator_timeout")] - public int? TypingIndicatorTimeout { get; private set; } - /// - /// The consumption_report_interval - /// - [JsonProperty("consumption_report_interval")] - public int? ConsumptionReportInterval { get; private set; } - /// - /// The limits - /// - [JsonProperty("limits")] - public object Limits { get; private set; } - /// - /// The webhooks - /// - [JsonProperty("webhooks")] - public object Webhooks { get; private set; } - /// - /// The pre_webhook_url - /// - [JsonProperty("pre_webhook_url")] - public string PreWebhookUrl { get; private set; } - /// - /// The post_webhook_url - /// - [JsonProperty("post_webhook_url")] - public string PostWebhookUrl { get; private set; } - /// - /// The webhook_method - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The webhook_filters - /// - [JsonProperty("webhook_filters")] - public List WebhookFilters { get; private set; } - /// - /// The notifications - /// - [JsonProperty("notifications")] - public object Notifications { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The friendly_name + /// The default_service_role_sid + /// The default_channel_role_sid + /// The default_channel_creator_role_sid + /// The read_status_enabled + /// The reachability_enabled + /// The typing_indicator_timeout + /// The consumption_report_interval + /// The notifications.new_message.enabled + /// The notifications.new_message.template + /// The notifications.added_to_channel.enabled + /// The notifications.added_to_channel.template + /// The notifications.removed_from_channel.enabled + /// The notifications.removed_from_channel.template + /// The notifications.invited_to_channel.enabled + /// The notifications.invited_to_channel.template + /// The pre_webhook_url + /// The post_webhook_url + /// The webhook_method + /// The webhook_filters + /// The webhooks.on_message_send.url + /// The webhooks.on_message_send.method + /// The webhooks.on_message_update.url + /// The webhooks.on_message_update.method + /// The webhooks.on_message_remove.url + /// The webhooks.on_message_remove.method + /// The webhooks.on_channel_add.url + /// The webhooks.on_channel_add.method + /// The webhooks.on_channel_destroy.url + /// The webhooks.on_channel_destroy.method + /// The webhooks.on_channel_update.url + /// The webhooks.on_channel_update.method + /// The webhooks.on_member_add.url + /// The webhooks.on_member_add.method + /// The webhooks.on_member_remove.url + /// The webhooks.on_member_remove.method + /// The webhooks.on_message_sent.url + /// The webhooks.on_message_sent.method + /// The webhooks.on_message_updated.url + /// The webhooks.on_message_updated.method + /// The webhooks.on_message_removed.url + /// The webhooks.on_message_removed.method + /// The webhooks.on_channel_added.url + /// The webhooks.on_channel_added.method + /// The webhooks.on_channel_destroyed.url + /// The webhooks.on_channel_destroyed.method + /// The webhooks.on_channel_updated.url + /// The webhooks.on_channel_updated.method + /// The webhooks.on_member_added.url + /// The webhooks.on_member_added.method + /// The webhooks.on_member_removed.url + /// The webhooks.on_member_removed.method + /// The limits.channel_members + /// The limits.user_channels + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + Uri webhooksOnMessageSendUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, + Uri webhooksOnMessageUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, + Uri webhooksOnMessageRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, + Uri webhooksOnChannelAddUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, + Uri webhooksOnChannelDestroyUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, + Uri webhooksOnChannelUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, + Uri webhooksOnMemberAddUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, + Uri webhooksOnMemberRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, + Uri webhooksOnMessageSentUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, + Uri webhooksOnMessageUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, + Uri webhooksOnMessageRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, + Uri webhooksOnChannelAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, + Uri webhooksOnChannelDestroyedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, + Uri webhooksOnChannelUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, + Uri webhooksOnMemberAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, + Uri webhooksOnMemberRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The friendly_name + /// The default_service_role_sid + /// The default_channel_role_sid + /// The default_channel_creator_role_sid + /// The read_status_enabled + /// The reachability_enabled + /// The typing_indicator_timeout + /// The consumption_report_interval + /// The notifications.new_message.enabled + /// The notifications.new_message.template + /// The notifications.added_to_channel.enabled + /// The notifications.added_to_channel.template + /// The notifications.removed_from_channel.enabled + /// The notifications.removed_from_channel.template + /// The notifications.invited_to_channel.enabled + /// The notifications.invited_to_channel.template + /// The pre_webhook_url + /// The post_webhook_url + /// The webhook_method + /// The webhook_filters + /// The webhooks.on_message_send.url + /// The webhooks.on_message_send.method + /// The webhooks.on_message_update.url + /// The webhooks.on_message_update.method + /// The webhooks.on_message_remove.url + /// The webhooks.on_message_remove.method + /// The webhooks.on_channel_add.url + /// The webhooks.on_channel_add.method + /// The webhooks.on_channel_destroy.url + /// The webhooks.on_channel_destroy.method + /// The webhooks.on_channel_update.url + /// The webhooks.on_channel_update.method + /// The webhooks.on_member_add.url + /// The webhooks.on_member_add.method + /// The webhooks.on_member_remove.url + /// The webhooks.on_member_remove.method + /// The webhooks.on_message_sent.url + /// The webhooks.on_message_sent.method + /// The webhooks.on_message_updated.url + /// The webhooks.on_message_updated.method + /// The webhooks.on_message_removed.url + /// The webhooks.on_message_removed.method + /// The webhooks.on_channel_added.url + /// The webhooks.on_channel_added.method + /// The webhooks.on_channel_destroyed.url + /// The webhooks.on_channel_destroyed.method + /// The webhooks.on_channel_updated.url + /// The webhooks.on_channel_updated.method + /// The webhooks.on_member_added.url + /// The webhooks.on_member_added.method + /// The webhooks.on_member_removed.url + /// The webhooks.on_member_removed.method + /// The limits.channel_members + /// The limits.user_channels + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + Uri webhooksOnMessageSendUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSendMethod = null, + Uri webhooksOnMessageUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdateMethod = null, + Uri webhooksOnMessageRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemoveMethod = null, + Uri webhooksOnChannelAddUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddMethod = null, + Uri webhooksOnChannelDestroyUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyMethod = null, + Uri webhooksOnChannelUpdateUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdateMethod = null, + Uri webhooksOnMemberAddUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddMethod = null, + Uri webhooksOnMemberRemoveUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemoveMethod = null, + Uri webhooksOnMessageSentUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageSentMethod = null, + Uri webhooksOnMessageUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageUpdatedMethod = null, + Uri webhooksOnMessageRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMessageRemovedMethod = null, + Uri webhooksOnChannelAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelAddedMethod = null, + Uri webhooksOnChannelDestroyedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelDestroyedMethod = null, + Uri webhooksOnChannelUpdatedUrl = null, + Twilio.Http.HttpMethod webhooksOnChannelUpdatedMethod = null, + Uri webhooksOnMemberAddedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberAddedMethod = null, + Uri webhooksOnMemberRemovedUrl = null, + Twilio.Http.HttpMethod webhooksOnMemberRemovedMethod = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, WebhooksOnMessageSendUrl = webhooksOnMessageSendUrl, WebhooksOnMessageSendMethod = webhooksOnMessageSendMethod, WebhooksOnMessageUpdateUrl = webhooksOnMessageUpdateUrl, WebhooksOnMessageUpdateMethod = webhooksOnMessageUpdateMethod, WebhooksOnMessageRemoveUrl = webhooksOnMessageRemoveUrl, WebhooksOnMessageRemoveMethod = webhooksOnMessageRemoveMethod, WebhooksOnChannelAddUrl = webhooksOnChannelAddUrl, WebhooksOnChannelAddMethod = webhooksOnChannelAddMethod, WebhooksOnChannelDestroyUrl = webhooksOnChannelDestroyUrl, WebhooksOnChannelDestroyMethod = webhooksOnChannelDestroyMethod, WebhooksOnChannelUpdateUrl = webhooksOnChannelUpdateUrl, WebhooksOnChannelUpdateMethod = webhooksOnChannelUpdateMethod, WebhooksOnMemberAddUrl = webhooksOnMemberAddUrl, WebhooksOnMemberAddMethod = webhooksOnMemberAddMethod, WebhooksOnMemberRemoveUrl = webhooksOnMemberRemoveUrl, WebhooksOnMemberRemoveMethod = webhooksOnMemberRemoveMethod, WebhooksOnMessageSentUrl = webhooksOnMessageSentUrl, WebhooksOnMessageSentMethod = webhooksOnMessageSentMethod, WebhooksOnMessageUpdatedUrl = webhooksOnMessageUpdatedUrl, WebhooksOnMessageUpdatedMethod = webhooksOnMessageUpdatedMethod, WebhooksOnMessageRemovedUrl = webhooksOnMessageRemovedUrl, WebhooksOnMessageRemovedMethod = webhooksOnMessageRemovedMethod, WebhooksOnChannelAddedUrl = webhooksOnChannelAddedUrl, WebhooksOnChannelAddedMethod = webhooksOnChannelAddedMethod, WebhooksOnChannelDestroyedUrl = webhooksOnChannelDestroyedUrl, WebhooksOnChannelDestroyedMethod = webhooksOnChannelDestroyedMethod, WebhooksOnChannelUpdatedUrl = webhooksOnChannelUpdatedUrl, WebhooksOnChannelUpdatedMethod = webhooksOnChannelUpdatedMethod, WebhooksOnMemberAddedUrl = webhooksOnMemberAddedUrl, WebhooksOnMemberAddedMethod = webhooksOnMemberAddedMethod, WebhooksOnMemberRemovedUrl = webhooksOnMemberRemovedUrl, WebhooksOnMemberRemovedMethod = webhooksOnMemberRemovedMethod, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The default_service_role_sid + /// + [JsonProperty("default_service_role_sid")] + public string DefaultServiceRoleSid { get; private set; } + /// + /// The default_channel_role_sid + /// + [JsonProperty("default_channel_role_sid")] + public string DefaultChannelRoleSid { get; private set; } + /// + /// The default_channel_creator_role_sid + /// + [JsonProperty("default_channel_creator_role_sid")] + public string DefaultChannelCreatorRoleSid { get; private set; } + /// + /// The read_status_enabled + /// + [JsonProperty("read_status_enabled")] + public bool? ReadStatusEnabled { get; private set; } + /// + /// The reachability_enabled + /// + [JsonProperty("reachability_enabled")] + public bool? ReachabilityEnabled { get; private set; } + /// + /// The typing_indicator_timeout + /// + [JsonProperty("typing_indicator_timeout")] + public int? TypingIndicatorTimeout { get; private set; } + /// + /// The consumption_report_interval + /// + [JsonProperty("consumption_report_interval")] + public int? ConsumptionReportInterval { get; private set; } + /// + /// The limits + /// + [JsonProperty("limits")] + public object Limits { get; private set; } + /// + /// The webhooks + /// + [JsonProperty("webhooks")] + public object Webhooks { get; private set; } + /// + /// The pre_webhook_url + /// + [JsonProperty("pre_webhook_url")] + public string PreWebhookUrl { get; private set; } + /// + /// The post_webhook_url + /// + [JsonProperty("post_webhook_url")] + public string PostWebhookUrl { get; private set; } + /// + /// The webhook_method + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The webhook_filters + /// + [JsonProperty("webhook_filters")] + public List WebhookFilters { get; private set; } + /// + /// The notifications + /// + [JsonProperty("notifications")] + public object Notifications { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/CredentialOptions.cs b/src/Twilio/Rest/IpMessaging/V2/CredentialOptions.cs index 23d963ee5..31b7fddf3 100644 --- a/src/Twilio/Rest/IpMessaging/V2/CredentialOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/CredentialOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2 -{ - +{ + + /// + /// ReadCredentialOptions + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// ReadCredentialOptions + /// Generate the necessary parameters /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateCredentialOptions + /// + public class CreateCredentialOptions : IOptions + { /// - /// CreateCredentialOptions + /// The type /// - public class CreateCredentialOptions : IOptions - { - /// - /// The type - /// - public CredentialResource.PushServiceEnum Type { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The certificate - /// - public string Certificate { get; set; } - /// - /// The private_key - /// - public string PrivateKey { get; set; } - /// - /// The sandbox - /// - public bool? Sandbox { get; set; } - /// - /// The api_key - /// - public string ApiKey { get; set; } - /// - /// The secret - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The type - public CreateCredentialOptions(CredentialResource.PushServiceEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushServiceEnum Type { get; } /// - /// FetchCredentialOptions + /// The friendly_name /// - public class FetchCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The sid - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// UpdateCredentialOptions + /// The certificate /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The certificate - /// - public string Certificate { get; set; } - /// - /// The private_key - /// - public string PrivateKey { get; set; } - /// - /// The sandbox - /// - public bool? Sandbox { get; set; } - /// - /// The api_key - /// - public string ApiKey { get; set; } - /// - /// The secret - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The sid - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string Certificate { get; set; } /// - /// DeleteCredentialOptions + /// The private_key /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The sid - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PrivateKey { get; set; } + /// + /// The sandbox + /// + public bool? Sandbox { get; set; } + /// + /// The api_key + /// + public string ApiKey { get; set; } + /// + /// The secret + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The type + public CreateCredentialOptions(CredentialResource.PushServiceEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// FetchCredentialOptions + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The sid + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateCredentialOptions + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The certificate + /// + public string Certificate { get; set; } + /// + /// The private_key + /// + public string PrivateKey { get; set; } + /// + /// The sandbox + /// + public bool? Sandbox { get; set; } + /// + /// The api_key + /// + public string ApiKey { get; set; } + /// + /// The secret + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The sid + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// DeleteCredentialOptions + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The sid + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/CredentialResource.cs b/src/Twilio/Rest/IpMessaging/V2/CredentialResource.cs index 156dfadd0..5c0322e86 100644 --- a/src/Twilio/Rest/IpMessaging/V2/CredentialResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/CredentialResource.cs @@ -17,534 +17,534 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2 -{ - - public class CredentialResource : Resource - { - public sealed class PushServiceEnum : StringEnum - { - private PushServiceEnum(string value) : base(value) {} - public PushServiceEnum() {} - public static implicit operator PushServiceEnum(string value) - { - return new PushServiceEnum(value); - } - - public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); - public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); - public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); - } - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The friendly_name - /// The certificate - /// The private_key - /// The sandbox - /// The api_key - /// The secret - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushServiceEnum Type { get; private set; } - /// - /// The sandbox - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushServiceEnum : StringEnum + { + private PushServiceEnum(string value) : base(value) { } + public PushServiceEnum() { } + public static implicit operator PushServiceEnum(string value) + { + return new PushServiceEnum(value); + } + + public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); + public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); + public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); + } + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The friendly_name + /// The certificate + /// The private_key + /// The sandbox + /// The api_key + /// The secret + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushServiceEnum Type { get; private set; } + /// + /// The sandbox + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/BindingOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/BindingOptions.cs index 1e978ee27..be30f44d4 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/BindingOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/BindingOptions.cs @@ -10,130 +10,130 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service -{ - +{ + + /// + /// ReadBindingOptions + /// + public class ReadBindingOptions : ReadOptions + { /// - /// ReadBindingOptions + /// The service_sid /// - public class ReadBindingOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The binding_type - /// - public List BindingType { get; set; } - /// - /// The identity - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadBindingOptions - /// - /// The service_sid - public ReadBindingOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - BindingType = new List(); - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (BindingType != null) - { - p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); - } - - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// FetchBindingOptions + /// The binding_type /// - public class FetchBindingOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBindingOptions - /// - /// The service_sid - /// The sid - public FetchBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List BindingType { get; set; } /// - /// DeleteBindingOptions + /// The identity /// - public class DeleteBindingOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBindingOptions - /// - /// The service_sid - /// The sid - public DeleteBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List Identity { get; set; } + + /// + /// Construct a new ReadBindingOptions + /// + /// The service_sid + public ReadBindingOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + BindingType = new List(); + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (BindingType != null) + { + p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); + } + + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchBindingOptions + /// + public class FetchBindingOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBindingOptions + /// + /// The service_sid + /// The sid + public FetchBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteBindingOptions + /// + public class DeleteBindingOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBindingOptions + /// + /// The service_sid + /// The sid + public DeleteBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/BindingResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/BindingResource.cs index 65811ce62..ab0775384 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/BindingResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/BindingResource.cs @@ -17,389 +17,389 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service -{ - - public class BindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - } - - private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The binding_type - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(string pathServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The binding_type - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List bindingType = null, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BindingResource object - /// - /// Raw JSON string - /// BindingResource object represented by the provided JSON - public static BindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The endpoint - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The credential_sid - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The binding_type - /// - [JsonProperty("binding_type")] - [JsonConverter(typeof(StringEnumConverter))] - public BindingResource.BindingTypeEnum BindingType { get; private set; } - /// - /// The message_types - /// - [JsonProperty("message_types")] - public List MessageTypes { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BindingResource() - { - - } - } +{ + + public class BindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + } + + private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The binding_type + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(string pathServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The binding_type + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List bindingType = null, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { BindingType = bindingType, Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BindingResource object + /// + /// Raw JSON string + /// BindingResource object represented by the provided JSON + public static BindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The endpoint + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The credential_sid + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The binding_type + /// + [JsonProperty("binding_type")] + [JsonConverter(typeof(StringEnumConverter))] + public BindingResource.BindingTypeEnum BindingType { get; private set; } + /// + /// The message_types + /// + [JsonProperty("message_types")] + public List MessageTypes { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteOptions.cs index 3e43515b8..46e2412f9 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteOptions.cs @@ -10,193 +10,193 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - +{ + + /// + /// FetchInviteOptions + /// + public class FetchInviteOptions : IOptions + { /// - /// FetchInviteOptions - /// - public class FetchInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// CreateInviteOptions - /// - public class CreateInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - - /// - /// Construct a new CreateInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The identity - public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - return p; - } - } - + /// The channel_sid + /// + public string PathChannelSid { get; } /// - /// ReadInviteOptions - /// - public class ReadInviteOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadInviteOptions - /// - /// The service_sid - /// The channel_sid - public ReadInviteOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// DeleteInviteOptions - /// - public class DeleteInviteOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInviteOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public FetchInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateInviteOptions + /// + public class CreateInviteOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + + /// + /// Construct a new CreateInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The identity + public CreateInviteOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + return p; + } + } + + /// + /// ReadInviteOptions + /// + public class ReadInviteOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadInviteOptions + /// + /// The service_sid + /// The channel_sid + public ReadInviteOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteInviteOptions + /// + public class DeleteInviteOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInviteOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteInviteOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteResource.cs index e2b262eea..78a8b8e51 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/InviteResource.cs @@ -16,456 +16,456 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - - public class InviteResource : Resource - { - private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static InviteResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - ITwilioRestClient client = null) - { - var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("invites", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Invite - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInviteOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("invites", response.Content); - } - - private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Invite parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Invite - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Invite - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a InviteResource object - /// - /// Raw JSON string - /// InviteResource object represented by the provided JSON - public static InviteResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InviteResource() - { - - } - } +{ + + public class InviteResource : Resource + { + private static Request BuildFetchRequest(FetchInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(FetchInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(FetchInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(CreateInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(CreateInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static InviteResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + ITwilioRestClient client = null) + { + var options = new CreateInviteOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(ReadInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(ReadInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("invites", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Invite + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInviteOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("invites", response.Content); + } + + private static Request BuildDeleteRequest(DeleteInviteOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Invites/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(DeleteInviteOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Invite parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInviteOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Invite + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Invite + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a InviteResource object + /// + /// Raw JSON string + /// InviteResource object represented by the provided JSON + public static InviteResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InviteResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberOptions.cs index eeca6d9ba..3478f8f53 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberOptions.cs @@ -10,387 +10,387 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - +{ + + /// + /// FetchMemberOptions + /// + public class FetchMemberOptions : IOptions + { /// - /// FetchMemberOptions - /// - public class FetchMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// CreateMemberOptions - /// - public class CreateMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The last_consumed_message_index - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The last_consumption_timestamp - /// - public DateTime? LastConsumptionTimestamp { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The identity - public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The channel_sid + /// + public string PathChannelSid { get; } /// - /// ReadMemberOptions - /// - public class ReadMemberOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The identity - /// - public List Identity { get; set; } - - /// - /// Construct a new ReadMemberOptions - /// - /// The service_sid - /// The channel_sid - public ReadMemberOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Identity = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// DeleteMemberOptions - /// - public class DeleteMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public FetchMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMemberOptions - /// - public class UpdateMemberOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The last_consumed_message_index - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The last_consumption_timestamp - /// - public DateTime? LastConsumptionTimestamp { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMemberOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMemberOptions + /// + public class CreateMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The last_consumed_message_index + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The last_consumption_timestamp + /// + public DateTime? LastConsumptionTimestamp { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The identity + public CreateMemberOptions(string pathServiceSid, string pathChannelSid, string identity) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadMemberOptions + /// + public class ReadMemberOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The identity + /// + public List Identity { get; set; } + + /// + /// Construct a new ReadMemberOptions + /// + /// The service_sid + /// The channel_sid + public ReadMemberOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Identity = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMemberOptions + /// + public class DeleteMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// UpdateMemberOptions + /// + public class UpdateMemberOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The last_consumed_message_index + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The last_consumption_timestamp + /// + public DateTime? LastConsumptionTimestamp { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MemberResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMemberOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public UpdateMemberOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberResource.cs index 03c1f58d9..a847e5019 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MemberResource.cs @@ -17,611 +17,611 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - - public class MemberResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// The date_created - /// The date_updated - /// The attributes - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Create(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The identity - /// The role_sid - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// The date_created - /// The date_updated - /// The attributes - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string identity, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("members", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Member - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The identity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - List identity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMemberOptions(pathServiceSid, pathChannelSid){Identity = identity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("members", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Member parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The role_sid - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// The date_created - /// The date_updated - /// The attributes - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Member - public static MemberResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The role_sid - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// The date_created - /// The date_updated - /// The attributes - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Member - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string roleSid = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string attributes = null, - MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid){RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MemberResource object - /// - /// Raw JSON string - /// MemberResource object represented by the provided JSON - public static MemberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The last_consumed_message_index - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The last_consumption_timestamp - /// - [JsonProperty("last_consumption_timestamp")] - public DateTime? LastConsumptionTimestamp { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - - private MemberResource() - { - - } - } +{ + + public class MemberResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(FetchMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(FetchMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMemberOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(CreateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(CreateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// The date_created + /// The date_updated + /// The attributes + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Create(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The identity + /// The role_sid + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// The date_created + /// The date_updated + /// The attributes + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string identity, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMemberOptions(pathServiceSid, pathChannelSid, identity) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(ReadMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(ReadMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("members", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Member + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The identity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + List identity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMemberOptions(pathServiceSid, pathChannelSid) { Identity = identity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("members", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(DeleteMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMemberOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMemberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Members/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(UpdateMemberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Member parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMemberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The role_sid + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// The date_created + /// The date_updated + /// The attributes + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Member + public static MemberResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The role_sid + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// The date_created + /// The date_updated + /// The attributes + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Member + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string roleSid = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string attributes = null, + MemberResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMemberOptions(pathServiceSid, pathChannelSid, pathSid) { RoleSid = roleSid, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MemberResource object + /// + /// Raw JSON string + /// MemberResource object represented by the provided JSON + public static MemberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The last_consumed_message_index + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The last_consumption_timestamp + /// + [JsonProperty("last_consumption_timestamp")] + public DateTime? LastConsumptionTimestamp { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + + private MemberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageOptions.cs index 7cc37cd2a..088b02c00 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageOptions.cs @@ -9,384 +9,384 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - +{ + + /// + /// FetchMessageOptions + /// + public class FetchMessageOptions : IOptions + { /// - /// FetchMessageOptions - /// - public class FetchMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// CreateMessageOptions - /// - public class CreateMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The from - /// - public string From { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The last_updated_by - /// - public string LastUpdatedBy { get; set; } - /// - /// The body - /// - public string Body { get; set; } - /// - /// The media_sid - /// - public string MediaSid { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateMessageOptions - /// - /// The service_sid - /// The channel_sid - public CreateMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (LastUpdatedBy != null) - { - p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (MediaSid != null) - { - p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The channel_sid + /// + public string PathChannelSid { get; } /// - /// ReadMessageOptions - /// - public class ReadMessageOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The order - /// - public MessageResource.OrderTypeEnum Order { get; set; } - - /// - /// Construct a new ReadMessageOptions - /// - /// The service_sid - /// The channel_sid - public ReadMessageOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// DeleteMessageOptions - /// - public class DeleteMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public FetchMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + /// - /// UpdateMessageOptions - /// - public class UpdateMessageOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The body - /// - public string Body { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The last_updated_by - /// - public string LastUpdatedBy { get; set; } - /// - /// The from - /// - public string From { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateMessageOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (LastUpdatedBy != null) - { - p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateMessageOptions + /// + public class CreateMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The from + /// + public string From { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The last_updated_by + /// + public string LastUpdatedBy { get; set; } + /// + /// The body + /// + public string Body { get; set; } + /// + /// The media_sid + /// + public string MediaSid { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateMessageOptions + /// + /// The service_sid + /// The channel_sid + public CreateMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (LastUpdatedBy != null) + { + p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (MediaSid != null) + { + p.Add(new KeyValuePair("MediaSid", MediaSid.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadMessageOptions + /// + public class ReadMessageOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The order + /// + public MessageResource.OrderTypeEnum Order { get; set; } + + /// + /// Construct a new ReadMessageOptions + /// + /// The service_sid + /// The channel_sid + public ReadMessageOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteMessageOptions + /// + public class DeleteMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// UpdateMessageOptions + /// + public class UpdateMessageOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The body + /// + public string Body { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The last_updated_by + /// + public string LastUpdatedBy { get; set; } + /// + /// The from + /// + public string From { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public MessageResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateMessageOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public UpdateMessageOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (LastUpdatedBy != null) + { + p.Add(new KeyValuePair("LastUpdatedBy", LastUpdatedBy)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageResource.cs index 1519d93c3..e6a668ba7 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/MessageResource.cs @@ -17,644 +17,644 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - - public class MessageResource : Resource - { - public sealed class OrderTypeEnum : StringEnum - { - private OrderTypeEnum(string value) : base(value) {} - public OrderTypeEnum() {} - public static implicit operator OrderTypeEnum(string value) - { - return new OrderTypeEnum(value); - } - - public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); - public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The from - /// The attributes - /// The date_created - /// The date_updated - /// The last_updated_by - /// The body - /// The media_sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Create(string pathServiceSid, - string pathChannelSid, - string from = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string body = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid){From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The from - /// The attributes - /// The date_created - /// The date_updated - /// The last_updated_by - /// The body - /// The media_sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - string from = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string body = null, - string mediaSid = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageOptions(pathServiceSid, pathChannelSid){From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messages", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The order - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Message - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// The order - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - MessageResource.OrderTypeEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageOptions(pathServiceSid, pathChannelSid){Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("messages", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Message parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The body - /// The attributes - /// The date_created - /// The date_updated - /// The last_updated_by - /// The from - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Message - public static MessageResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string from = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The body - /// The attributes - /// The date_created - /// The date_updated - /// The last_updated_by - /// The from - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Message - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string body = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string lastUpdatedBy = null, - string from = null, - MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid){Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessageResource object - /// - /// Raw JSON string - /// MessageResource object represented by the provided JSON - public static MessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The to - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The last_updated_by - /// - [JsonProperty("last_updated_by")] - public string LastUpdatedBy { get; private set; } - /// - /// The was_edited - /// - [JsonProperty("was_edited")] - public bool? WasEdited { get; private set; } - /// - /// The from - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// The body - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The index - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The media - /// - [JsonProperty("media")] - public object Media { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessageResource() - { - - } - } +{ + + public class MessageResource : Resource + { + public sealed class OrderTypeEnum : StringEnum + { + private OrderTypeEnum(string value) : base(value) { } + public OrderTypeEnum() { } + public static implicit operator OrderTypeEnum(string value) + { + return new OrderTypeEnum(value); + } + + public static readonly OrderTypeEnum Asc = new OrderTypeEnum("asc"); + public static readonly OrderTypeEnum Desc = new OrderTypeEnum("desc"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(FetchMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The from + /// The attributes + /// The date_created + /// The date_updated + /// The last_updated_by + /// The body + /// The media_sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Create(string pathServiceSid, + string pathChannelSid, + string from = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string body = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid) { From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The from + /// The attributes + /// The date_created + /// The date_updated + /// The last_updated_by + /// The body + /// The media_sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + string from = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string body = null, + string mediaSid = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageOptions(pathServiceSid, pathChannelSid) { From = from, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, Body = body, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(ReadMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messages", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The order + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Message + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// The order + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + MessageResource.OrderTypeEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageOptions(pathServiceSid, pathChannelSid) { Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("messages", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(DeleteMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteMessageOptions(pathServiceSid, pathChannelSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Messages/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(UpdateMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Message parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The body + /// The attributes + /// The date_created + /// The date_updated + /// The last_updated_by + /// The from + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Message + public static MessageResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string from = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The body + /// The attributes + /// The date_created + /// The date_updated + /// The last_updated_by + /// The from + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Message + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string body = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string lastUpdatedBy = null, + string from = null, + MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateMessageOptions(pathServiceSid, pathChannelSid, pathSid) { Body = body, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, LastUpdatedBy = lastUpdatedBy, From = from, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessageResource object + /// + /// Raw JSON string + /// MessageResource object represented by the provided JSON + public static MessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The to + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The last_updated_by + /// + [JsonProperty("last_updated_by")] + public string LastUpdatedBy { get; private set; } + /// + /// The was_edited + /// + [JsonProperty("was_edited")] + public bool? WasEdited { get; private set; } + /// + /// The from + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// The body + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The index + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The media + /// + [JsonProperty("media")] + public object Media { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookOptions.cs index 285961423..a2de4e3bd 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookOptions.cs @@ -10,327 +10,327 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - +{ + + /// + /// ReadWebhookOptions + /// + public class ReadWebhookOptions : ReadOptions + { /// - /// ReadWebhookOptions - /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// The service_sid - /// The channel_sid - public ReadWebhookOptions(string pathServiceSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// FetchWebhookOptions - /// - public class FetchWebhookOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public FetchWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The channel_sid + /// + public string PathChannelSid { get; } + /// - /// CreateWebhookOptions - /// - public class CreateWebhookOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The type - /// - public WebhookResource.TypeEnum Type { get; } - /// - /// The configuration.url - /// - public string ConfigurationUrl { get; set; } - /// - /// The configuration.method - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The configuration.filters - /// - public List ConfigurationFilters { get; set; } - /// - /// The configuration.triggers - /// - public List ConfigurationTriggers { get; set; } - /// - /// The configuration.flow_sid - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The configuration.retry_count - /// - public int? ConfigurationRetryCount { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// The service_sid - /// The channel_sid - /// The type - public CreateWebhookOptions(string pathServiceSid, string pathChannelSid, WebhookResource.TypeEnum type) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - Type = type; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationRetryCount != null) - { - p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); - } - - return p; - } - } - + /// Construct a new ReadWebhookOptions + /// + /// The service_sid + /// The channel_sid + public ReadWebhookOptions(string pathServiceSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + } + /// - /// UpdateWebhookOptions - /// - public class UpdateWebhookOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The configuration.url - /// - public string ConfigurationUrl { get; set; } - /// - /// The configuration.method - /// - public WebhookResource.MethodEnum ConfigurationMethod { get; set; } - /// - /// The configuration.filters - /// - public List ConfigurationFilters { get; set; } - /// - /// The configuration.triggers - /// - public List ConfigurationTriggers { get; set; } - /// - /// The configuration.flow_sid - /// - public string ConfigurationFlowSid { get; set; } - /// - /// The configuration.retry_count - /// - public int? ConfigurationRetryCount { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public UpdateWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - ConfigurationFilters = new List(); - ConfigurationTriggers = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ConfigurationUrl != null) - { - p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); - } - - if (ConfigurationMethod != null) - { - p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); - } - - if (ConfigurationFilters != null) - { - p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); - } - - if (ConfigurationTriggers != null) - { - p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); - } - - if (ConfigurationFlowSid != null) - { - p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); - } - - if (ConfigurationRetryCount != null) - { - p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchWebhookOptions + /// + public class FetchWebhookOptions : IOptions + { /// - /// DeleteWebhookOptions - /// - public class DeleteWebhookOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// The service_sid - /// The channel_sid - /// The sid - public DeleteWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathChannelSid = pathChannelSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public FetchWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateWebhookOptions + /// + public class CreateWebhookOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The type + /// + public WebhookResource.TypeEnum Type { get; } + /// + /// The configuration.url + /// + public string ConfigurationUrl { get; set; } + /// + /// The configuration.method + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The configuration.filters + /// + public List ConfigurationFilters { get; set; } + /// + /// The configuration.triggers + /// + public List ConfigurationTriggers { get; set; } + /// + /// The configuration.flow_sid + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The configuration.retry_count + /// + public int? ConfigurationRetryCount { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// The service_sid + /// The channel_sid + /// The type + public CreateWebhookOptions(string pathServiceSid, string pathChannelSid, WebhookResource.TypeEnum type) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + Type = type; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationRetryCount != null) + { + p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// UpdateWebhookOptions + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The configuration.url + /// + public string ConfigurationUrl { get; set; } + /// + /// The configuration.method + /// + public WebhookResource.MethodEnum ConfigurationMethod { get; set; } + /// + /// The configuration.filters + /// + public List ConfigurationFilters { get; set; } + /// + /// The configuration.triggers + /// + public List ConfigurationTriggers { get; set; } + /// + /// The configuration.flow_sid + /// + public string ConfigurationFlowSid { get; set; } + /// + /// The configuration.retry_count + /// + public int? ConfigurationRetryCount { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public UpdateWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + ConfigurationFilters = new List(); + ConfigurationTriggers = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ConfigurationUrl != null) + { + p.Add(new KeyValuePair("Configuration.Url", ConfigurationUrl)); + } + + if (ConfigurationMethod != null) + { + p.Add(new KeyValuePair("Configuration.Method", ConfigurationMethod.ToString())); + } + + if (ConfigurationFilters != null) + { + p.AddRange(ConfigurationFilters.Select(prop => new KeyValuePair("Configuration.Filters", prop))); + } + + if (ConfigurationTriggers != null) + { + p.AddRange(ConfigurationTriggers.Select(prop => new KeyValuePair("Configuration.Triggers", prop))); + } + + if (ConfigurationFlowSid != null) + { + p.Add(new KeyValuePair("Configuration.FlowSid", ConfigurationFlowSid.ToString())); + } + + if (ConfigurationRetryCount != null) + { + p.Add(new KeyValuePair("Configuration.RetryCount", ConfigurationRetryCount.ToString())); + } + + return p; + } + } + + /// + /// DeleteWebhookOptions + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// The service_sid + /// The channel_sid + /// The sid + public DeleteWebhookOptions(string pathServiceSid, string pathChannelSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathChannelSid = pathChannelSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookResource.cs index ad98559df..ac41ea09e 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/Channel/WebhookResource.cs @@ -17,594 +17,594 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service.Channel -{ - - public class WebhookResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Webhook = new TypeEnum("webhook"); - public static readonly TypeEnum Trigger = new TypeEnum("trigger"); - public static readonly TypeEnum Studio = new TypeEnum("studio"); - } - - public sealed class MethodEnum : StringEnum - { - private MethodEnum(string value) : base(value) {} - public MethodEnum() {} - public static implicit operator MethodEnum(string value) - { - return new MethodEnum(value); - } - - public static readonly MethodEnum Get = new MethodEnum("GET"); - public static readonly MethodEnum Post = new MethodEnum("POST"); - } - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathServiceSid, - string pathChannelSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The channel_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathChannelSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The type - /// The configuration.url - /// The configuration.method - /// The configuration.filters - /// The configuration.triggers - /// The configuration.flow_sid - /// The configuration.retry_count - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathServiceSid, - string pathChannelSid, - WebhookResource.TypeEnum type, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The channel_sid - /// The type - /// The configuration.url - /// The configuration.method - /// The configuration.filters - /// The configuration.triggers - /// The configuration.flow_sid - /// The configuration.retry_count - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathChannelSid, - WebhookResource.TypeEnum type, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The configuration.url - /// The configuration.method - /// The configuration.filters - /// The configuration.triggers - /// The configuration.flow_sid - /// The configuration.retry_count - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathServiceSid, - string pathChannelSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The channel_sid - /// The sid - /// The configuration.url - /// The configuration.method - /// The configuration.filters - /// The configuration.triggers - /// The configuration.flow_sid - /// The configuration.retry_count - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - string configurationUrl = null, - WebhookResource.MethodEnum configurationMethod = null, - List configurationFilters = null, - List configurationTriggers = null, - string configurationFlowSid = null, - int? configurationRetryCount = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid){ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The channel_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathChannelSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The configuration - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Webhook = new TypeEnum("webhook"); + public static readonly TypeEnum Trigger = new TypeEnum("trigger"); + public static readonly TypeEnum Studio = new TypeEnum("studio"); + } + + public sealed class MethodEnum : StringEnum + { + private MethodEnum(string value) : base(value) { } + public MethodEnum() { } + public static implicit operator MethodEnum(string value) + { + return new MethodEnum(value); + } + + public static readonly MethodEnum Get = new MethodEnum("GET"); + public static readonly MethodEnum Post = new MethodEnum("POST"); + } + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathServiceSid, + string pathChannelSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The channel_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathChannelSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid, pathChannelSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The type + /// The configuration.url + /// The configuration.method + /// The configuration.filters + /// The configuration.triggers + /// The configuration.flow_sid + /// The configuration.retry_count + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathServiceSid, + string pathChannelSid, + WebhookResource.TypeEnum type, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The channel_sid + /// The type + /// The configuration.url + /// The configuration.method + /// The configuration.filters + /// The configuration.triggers + /// The configuration.flow_sid + /// The configuration.retry_count + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathChannelSid, + WebhookResource.TypeEnum type, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, pathChannelSid, type) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The configuration.url + /// The configuration.method + /// The configuration.filters + /// The configuration.triggers + /// The configuration.flow_sid + /// The configuration.retry_count + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathServiceSid, + string pathChannelSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The channel_sid + /// The sid + /// The configuration.url + /// The configuration.method + /// The configuration.filters + /// The configuration.triggers + /// The configuration.flow_sid + /// The configuration.retry_count + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + string configurationUrl = null, + WebhookResource.MethodEnum configurationMethod = null, + List configurationFilters = null, + List configurationTriggers = null, + string configurationFlowSid = null, + int? configurationRetryCount = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathChannelSid, pathSid) { ConfigurationUrl = configurationUrl, ConfigurationMethod = configurationMethod, ConfigurationFilters = configurationFilters, ConfigurationTriggers = configurationTriggers, ConfigurationFlowSid = configurationFlowSid, ConfigurationRetryCount = configurationRetryCount }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathChannelSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The channel_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathChannelSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathChannelSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The configuration + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/ChannelOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/ChannelOptions.cs index 3f6f4db61..e15afcf7e 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/ChannelOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/ChannelOptions.cs @@ -10,355 +10,355 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service -{ - +{ + + /// + /// FetchChannelOptions + /// + public class FetchChannelOptions : IOptions + { /// - /// FetchChannelOptions - /// - public class FetchChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChannelOptions - /// - /// The service_sid - /// The sid - public FetchChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// DeleteChannelOptions - /// - public class DeleteChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new DeleteChannelOptions - /// - /// The service_sid - /// The sid - public DeleteChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// CreateChannelOptions - /// - public class CreateChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The type - /// - public ChannelResource.ChannelTypeEnum Type { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The created_by - /// - public string CreatedBy { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateChannelOptions - /// - /// The service_sid - public CreateChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (CreatedBy != null) - { - p.Add(new KeyValuePair("CreatedBy", CreatedBy)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// Construct a new FetchChannelOptions + /// + /// The service_sid + /// The sid + public FetchChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadChannelOptions - /// - public class ReadChannelOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The type - /// - public List Type { get; set; } - - /// - /// Construct a new ReadChannelOptions - /// - /// The service_sid - public ReadChannelOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Type = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteChannelOptions + /// + public class DeleteChannelOptions : IOptions + { /// - /// UpdateChannelOptions - /// - public class UpdateChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The date_created - /// - public DateTime? DateCreated { get; set; } - /// - /// The date_updated - /// - public DateTime? DateUpdated { get; set; } - /// - /// The created_by - /// - public string CreatedBy { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateChannelOptions - /// - /// The service_sid - /// The sid - public UpdateChannelOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (DateCreated != null) - { - p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); - } - - if (DateUpdated != null) - { - p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); - } - - if (CreatedBy != null) - { - p.Add(new KeyValuePair("CreatedBy", CreatedBy)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new DeleteChannelOptions + /// + /// The service_sid + /// The sid + public DeleteChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// CreateChannelOptions + /// + public class CreateChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The type + /// + public ChannelResource.ChannelTypeEnum Type { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The created_by + /// + public string CreatedBy { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateChannelOptions + /// + /// The service_sid + public CreateChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (CreatedBy != null) + { + p.Add(new KeyValuePair("CreatedBy", CreatedBy)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadChannelOptions + /// + public class ReadChannelOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The type + /// + public List Type { get; set; } + + /// + /// Construct a new ReadChannelOptions + /// + /// The service_sid + public ReadChannelOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Type = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateChannelOptions + /// + public class UpdateChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The date_created + /// + public DateTime? DateCreated { get; set; } + /// + /// The date_updated + /// + public DateTime? DateUpdated { get; set; } + /// + /// The created_by + /// + public string CreatedBy { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public ChannelResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateChannelOptions + /// + /// The service_sid + /// The sid + public UpdateChannelOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (DateCreated != null) + { + p.Add(new KeyValuePair("DateCreated", Serializers.DateTimeIso8601(DateCreated))); + } + + if (DateUpdated != null) + { + p.Add(new KeyValuePair("DateUpdated", Serializers.DateTimeIso8601(DateUpdated))); + } + + if (CreatedBy != null) + { + p.Add(new KeyValuePair("CreatedBy", CreatedBy)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/ChannelResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/ChannelResource.cs index a1fd3c843..ace403061 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/ChannelResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/ChannelResource.cs @@ -17,613 +17,613 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service -{ - - public class ChannelResource : Resource - { - public sealed class ChannelTypeEnum : StringEnum - { - private ChannelTypeEnum(string value) : base(value) {} - public ChannelTypeEnum() {} - public static implicit operator ChannelTypeEnum(string value) - { - return new ChannelTypeEnum(value); - } - - public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); - public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); - } - - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChannelOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static bool Delete(string pathServiceSid, - string pathSid, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new DeleteChannelOptions(pathServiceSid, pathSid){XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The type - /// The date_created - /// The date_updated - /// The created_by - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The type - /// The date_created - /// The date_updated - /// The created_by - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - ChannelResource.ChannelTypeEnum type = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathServiceSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Channel - public static ResourceSet Read(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - List type = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChannelOptions(pathServiceSid){Type = type, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The date_created - /// The date_updated - /// The created_by - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Update(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The friendly_name - /// The unique_name - /// The attributes - /// The date_created - /// The date_updated - /// The created_by - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - string attributes = null, - DateTime? dateCreated = null, - DateTime? dateUpdated = null, - string createdBy = null, - ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateChannelOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public ChannelResource.ChannelTypeEnum Type { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - /// - /// The members_count - /// - [JsonProperty("members_count")] - public int? MembersCount { get; private set; } - /// - /// The messages_count - /// - [JsonProperty("messages_count")] - public int? MessagesCount { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + public sealed class ChannelTypeEnum : StringEnum + { + private ChannelTypeEnum(string value) : base(value) { } + public ChannelTypeEnum() { } + public static implicit operator ChannelTypeEnum(string value) + { + return new ChannelTypeEnum(value); + } + + public static readonly ChannelTypeEnum Public = new ChannelTypeEnum("public"); + public static readonly ChannelTypeEnum Private = new ChannelTypeEnum("private"); + } + + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(FetchChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(FetchChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChannelOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(DeleteChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static bool Delete(string pathServiceSid, + string pathSid, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new DeleteChannelOptions(pathServiceSid, pathSid) { XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The type + /// The date_created + /// The date_updated + /// The created_by + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The type + /// The date_created + /// The date_updated + /// The created_by + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + ChannelResource.ChannelTypeEnum type = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathServiceSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, Type = type, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(ReadChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(ReadChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Channel + public static ResourceSet Read(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + List type = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChannelOptions(pathServiceSid) { Type = type, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildUpdateRequest(UpdateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Channels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(UpdateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The date_created + /// The date_updated + /// The created_by + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Update(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The friendly_name + /// The unique_name + /// The attributes + /// The date_created + /// The date_updated + /// The created_by + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + string attributes = null, + DateTime? dateCreated = null, + DateTime? dateUpdated = null, + string createdBy = null, + ChannelResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateChannelOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Attributes = attributes, DateCreated = dateCreated, DateUpdated = dateUpdated, CreatedBy = createdBy, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public ChannelResource.ChannelTypeEnum Type { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + /// + /// The members_count + /// + [JsonProperty("members_count")] + public int? MembersCount { get; private set; } + /// + /// The messages_count + /// + [JsonProperty("messages_count")] + public int? MessagesCount { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/RoleOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/RoleOptions.cs index 040b999f1..a860ee16e 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/RoleOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/RoleOptions.cs @@ -10,221 +10,221 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service -{ - +{ + + /// + /// FetchRoleOptions + /// + public class FetchRoleOptions : IOptions + { /// - /// FetchRoleOptions - /// - public class FetchRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoleOptions - /// - /// The service_sid - /// The sid - public FetchRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// DeleteRoleOptions - /// - public class DeleteRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoleOptions - /// - /// The service_sid - /// The sid - public DeleteRoleOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// CreateRoleOptions - /// - public class CreateRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; } - /// - /// The type - /// - public RoleResource.RoleTypeEnum Type { get; } - /// - /// The permission - /// - public List Permission { get; } - - /// - /// Construct a new CreateRoleOptions - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - public CreateRoleOptions(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - Type = type; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } - + /// Construct a new FetchRoleOptions + /// + /// The service_sid + /// The sid + public FetchRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadRoleOptions + /// Generate the necessary parameters /// - public class ReadRoleOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadRoleOptions - /// - /// The service_sid - public ReadRoleOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteRoleOptions + /// + public class DeleteRoleOptions : IOptions + { /// - /// UpdateRoleOptions - /// - public class UpdateRoleOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The permission - /// - public List Permission { get; } - - /// - /// Construct a new UpdateRoleOptions - /// - /// The service_sid - /// The sid - /// The permission - public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Permission = permission; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Permission != null) - { - p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); - } - - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoleOptions + /// + /// The service_sid + /// The sid + public DeleteRoleOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRoleOptions + /// + public class CreateRoleOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; } + /// + /// The type + /// + public RoleResource.RoleTypeEnum Type { get; } + /// + /// The permission + /// + public List Permission { get; } + + /// + /// Construct a new CreateRoleOptions + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + public CreateRoleOptions(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + Type = type; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } + + /// + /// ReadRoleOptions + /// + public class ReadRoleOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadRoleOptions + /// + /// The service_sid + public ReadRoleOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateRoleOptions + /// + public class UpdateRoleOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The permission + /// + public List Permission { get; } + + /// + /// Construct a new UpdateRoleOptions + /// + /// The service_sid + /// The sid + /// The permission + public UpdateRoleOptions(string pathServiceSid, string pathSid, List permission) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Permission = permission; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Permission != null) + { + p.AddRange(Permission.Select(prop => new KeyValuePair("Permission", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/RoleResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/RoleResource.cs index 63571b644..b06602631 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/RoleResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/RoleResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service -{ - - public class RoleResource : Resource - { - public sealed class RoleTypeEnum : StringEnum - { - private RoleTypeEnum(string value) : base(value) {} - public RoleTypeEnum() {} - public static implicit operator RoleTypeEnum(string value) - { - return new RoleTypeEnum(value); - } - - public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); - public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); - } - - private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoleOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Role - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoleOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Roles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Create(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The friendly_name - /// The type - /// The permission - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - RoleResource.RoleTypeEnum type, - List permission, - ITwilioRestClient client = null) - { - var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Roles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("roles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Role - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoleOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("roles", response.Content); - } - - private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Role parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The permission - /// Client to make requests to Twilio - /// A single instance of Role - public static RoleResource Update(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The permission - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Role - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - List permission, - ITwilioRestClient client = null) - { - var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoleResource object - /// - /// Raw JSON string - /// RoleResource object represented by the provided JSON - public static RoleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoleResource.RoleTypeEnum Type { get; private set; } - /// - /// The permissions - /// - [JsonProperty("permissions")] - public List Permissions { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RoleResource() - { - - } - } +{ + + public class RoleResource : Resource + { + public sealed class RoleTypeEnum : StringEnum + { + private RoleTypeEnum(string value) : base(value) { } + public RoleTypeEnum() { } + public static implicit operator RoleTypeEnum(string value) + { + return new RoleTypeEnum(value); + } + + public static readonly RoleTypeEnum Channel = new RoleTypeEnum("channel"); + public static readonly RoleTypeEnum Deployment = new RoleTypeEnum("deployment"); + } + + private static Request BuildFetchRequest(FetchRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(FetchRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(FetchRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoleOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(DeleteRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Role + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoleOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Roles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(CreateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(CreateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Create(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The friendly_name + /// The type + /// The permission + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + RoleResource.RoleTypeEnum type, + List permission, + ITwilioRestClient client = null) + { + var options = new CreateRoleOptions(pathServiceSid, friendlyName, type, permission); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Roles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(ReadRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("roles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Role + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoleOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("roles", response.Content); + } + + private static Request BuildUpdateRequest(UpdateRoleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Roles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(UpdateRoleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Role parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The permission + /// Client to make requests to Twilio + /// A single instance of Role + public static RoleResource Update(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The permission + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Role + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + List permission, + ITwilioRestClient client = null) + { + var options = new UpdateRoleOptions(pathServiceSid, pathSid, permission); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoleResource object + /// + /// Raw JSON string + /// RoleResource object represented by the provided JSON + public static RoleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoleResource.RoleTypeEnum Type { get; private set; } + /// + /// The permissions + /// + [JsonProperty("permissions")] + public List Permissions { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RoleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingOptions.cs index 98bf3f0f6..5530e0f6e 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingOptions.cs @@ -10,138 +10,138 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.User -{ - +{ + + /// + /// ReadUserBindingOptions + /// + public class ReadUserBindingOptions : ReadOptions + { /// - /// ReadUserBindingOptions + /// The service_sid /// - public class ReadUserBindingOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The binding_type - /// - public List BindingType { get; set; } - - /// - /// Construct a new ReadUserBindingOptions - /// - /// The service_sid - /// The user_sid - public ReadUserBindingOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - BindingType = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (BindingType != null) - { - p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// FetchUserBindingOptions + /// The user_sid /// - public class FetchUserBindingOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserBindingOptions - /// - /// The service_sid - /// The user_sid - /// The sid - public FetchUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathUserSid { get; } /// - /// DeleteUserBindingOptions + /// The binding_type /// - public class DeleteUserBindingOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserBindingOptions - /// - /// The service_sid - /// The user_sid - /// The sid - public DeleteUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List BindingType { get; set; } + + /// + /// Construct a new ReadUserBindingOptions + /// + /// The service_sid + /// The user_sid + public ReadUserBindingOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + BindingType = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (BindingType != null) + { + p.AddRange(BindingType.Select(prop => new KeyValuePair("BindingType", prop.ToString()))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchUserBindingOptions + /// + public class FetchUserBindingOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchUserBindingOptions + /// + /// The service_sid + /// The user_sid + /// The sid + public FetchUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserBindingOptions + /// + public class DeleteUserBindingOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserBindingOptions + /// + /// The service_sid + /// The user_sid + /// The sid + public DeleteUserBindingOptions(string pathServiceSid, string pathUserSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingResource.cs index 5ceafb141..ad753d397 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserBindingResource.cs @@ -17,398 +17,398 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service.User -{ - - public class UserBindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - } - - private static Request BuildReadRequest(ReadUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static ResourceSet Read(ReadUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The user_sid - /// The binding_type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - List bindingType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid){BindingType = bindingType, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The user_sid - /// The binding_type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - List bindingType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid){BindingType = bindingType, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - private static Request BuildFetchRequest(FetchUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static UserBindingResource Fetch(FetchUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task FetchAsync(FetchUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The user_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static UserBindingResource Fetch(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The user_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete UserBinding parameters - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static bool Delete(DeleteUserBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete UserBinding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The user_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of UserBinding - public static bool Delete(string pathServiceSid, string pathUserSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The user_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserBinding - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathUserSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserBindingResource object - /// - /// Raw JSON string - /// UserBindingResource object represented by the provided JSON - public static UserBindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The endpoint - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The user_sid - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The credential_sid - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The binding_type - /// - [JsonProperty("binding_type")] - [JsonConverter(typeof(StringEnumConverter))] - public UserBindingResource.BindingTypeEnum BindingType { get; private set; } - /// - /// The message_types - /// - [JsonProperty("message_types")] - public List MessageTypes { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserBindingResource() - { - - } - } +{ + + public class UserBindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + } + + private static Request BuildReadRequest(ReadUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static ResourceSet Read(ReadUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The user_sid + /// The binding_type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + List bindingType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid) { BindingType = bindingType, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The user_sid + /// The binding_type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + List bindingType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserBindingOptions(pathServiceSid, pathUserSid) { BindingType = bindingType, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + private static Request BuildFetchRequest(FetchUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static UserBindingResource Fetch(FetchUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task FetchAsync(FetchUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The user_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static UserBindingResource Fetch(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The user_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete UserBinding parameters + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static bool Delete(DeleteUserBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete UserBinding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The user_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of UserBinding + public static bool Delete(string pathServiceSid, string pathUserSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The user_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserBinding + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathUserSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserBindingOptions(pathServiceSid, pathUserSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserBindingResource object + /// + /// Raw JSON string + /// UserBindingResource object represented by the provided JSON + public static UserBindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The endpoint + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The user_sid + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The credential_sid + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The binding_type + /// + [JsonProperty("binding_type")] + [JsonConverter(typeof(StringEnumConverter))] + public UserBindingResource.BindingTypeEnum BindingType { get; private set; } + /// + /// The message_types + /// + [JsonProperty("message_types")] + public List MessageTypes { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserBindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelOptions.cs index a97ab39fa..7afcac94d 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelOptions.cs @@ -9,196 +9,196 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service.User -{ - +{ + + /// + /// ReadUserChannelOptions + /// + public class ReadUserChannelOptions : ReadOptions + { /// - /// ReadUserChannelOptions - /// - public class ReadUserChannelOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - - /// - /// Construct a new ReadUserChannelOptions - /// - /// The service_sid - /// The user_sid - public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// FetchUserChannelOptions - /// - public class FetchUserChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - - /// - /// Construct a new FetchUserChannelOptions - /// - /// The service_sid - /// The user_sid - /// The channel_sid - public FetchUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The user_sid + /// + public string PathUserSid { get; } + /// - /// DeleteUserChannelOptions - /// - public class DeleteUserChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - - /// - /// Construct a new DeleteUserChannelOptions - /// - /// The service_sid - /// The user_sid - /// The channel_sid - public DeleteUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadUserChannelOptions + /// + /// The service_sid + /// The user_sid + public ReadUserChannelOptions(string pathServiceSid, string pathUserSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + } + /// - /// UpdateUserChannelOptions - /// - public class UpdateUserChannelOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The user_sid - /// - public string PathUserSid { get; } - /// - /// The channel_sid - /// - public string PathChannelSid { get; } - /// - /// The notification_level - /// - public UserChannelResource.NotificationLevelEnum NotificationLevel { get; set; } - /// - /// The last_consumed_message_index - /// - public int? LastConsumedMessageIndex { get; set; } - /// - /// The last_consumption_timestamp - /// - public DateTime? LastConsumptionTimestamp { get; set; } - - /// - /// Construct a new UpdateUserChannelOptions - /// - /// The service_sid - /// The user_sid - /// The channel_sid - public UpdateUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) - { - PathServiceSid = pathServiceSid; - PathUserSid = pathUserSid; - PathChannelSid = pathChannelSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (NotificationLevel != null) - { - p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); - } - - if (LastConsumedMessageIndex != null) - { - p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); - } - - if (LastConsumptionTimestamp != null) - { - p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchUserChannelOptions + /// + public class FetchUserChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + + /// + /// Construct a new FetchUserChannelOptions + /// + /// The service_sid + /// The user_sid + /// The channel_sid + public FetchUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserChannelOptions + /// + public class DeleteUserChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + + /// + /// Construct a new DeleteUserChannelOptions + /// + /// The service_sid + /// The user_sid + /// The channel_sid + public DeleteUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateUserChannelOptions + /// + public class UpdateUserChannelOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The user_sid + /// + public string PathUserSid { get; } + /// + /// The channel_sid + /// + public string PathChannelSid { get; } + /// + /// The notification_level + /// + public UserChannelResource.NotificationLevelEnum NotificationLevel { get; set; } + /// + /// The last_consumed_message_index + /// + public int? LastConsumedMessageIndex { get; set; } + /// + /// The last_consumption_timestamp + /// + public DateTime? LastConsumptionTimestamp { get; set; } + + /// + /// Construct a new UpdateUserChannelOptions + /// + /// The service_sid + /// The user_sid + /// The channel_sid + public UpdateUserChannelOptions(string pathServiceSid, string pathUserSid, string pathChannelSid) + { + PathServiceSid = pathServiceSid; + PathUserSid = pathUserSid; + PathChannelSid = pathChannelSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (NotificationLevel != null) + { + p.Add(new KeyValuePair("NotificationLevel", NotificationLevel.ToString())); + } + + if (LastConsumedMessageIndex != null) + { + p.Add(new KeyValuePair("LastConsumedMessageIndex", LastConsumedMessageIndex.ToString())); + } + + if (LastConsumptionTimestamp != null) + { + p.Add(new KeyValuePair("LastConsumptionTimestamp", Serializers.DateTimeIso8601(LastConsumptionTimestamp))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelResource.cs index d13fb1912..e3a188789 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/User/UserChannelResource.cs @@ -17,494 +17,494 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service.User -{ - - public class UserChannelResource : Resource - { - public sealed class ChannelStatusEnum : StringEnum - { - private ChannelStatusEnum(string value) : base(value) {} - public ChannelStatusEnum() {} - public static implicit operator ChannelStatusEnum(string value) - { - return new ChannelStatusEnum(value); - } - - public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); - public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); - public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); - } - - public sealed class NotificationLevelEnum : StringEnum - { - private NotificationLevelEnum(string value) : base(value) {} - public NotificationLevelEnum() {} - public static implicit operator NotificationLevelEnum(string value) - { - return new NotificationLevelEnum(value); - } - - public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); - public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); - } - - private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The user_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static ResourceSet Read(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The user_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathUserSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildFetchRequest(FetchUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Fetch(FetchUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Fetch(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static bool Delete(DeleteUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static bool Delete(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateUserChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update UserChannel parameters - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Update(UpdateUserChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update UserChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// The notification_level - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// Client to make requests to Twilio - /// A single instance of UserChannel - public static UserChannelResource Update(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - UserChannelResource.NotificationLevelEnum notificationLevel = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid){NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The user_sid - /// The channel_sid - /// The notification_level - /// The last_consumed_message_index - /// The last_consumption_timestamp - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UserChannel - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathUserSid, - string pathChannelSid, - UserChannelResource.NotificationLevelEnum notificationLevel = null, - int? lastConsumedMessageIndex = null, - DateTime? lastConsumptionTimestamp = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid){NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserChannelResource object - /// - /// Raw JSON string - /// UserChannelResource object represented by the provided JSON - public static UserChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The channel_sid - /// - [JsonProperty("channel_sid")] - public string ChannelSid { get; private set; } - /// - /// The user_sid - /// - [JsonProperty("user_sid")] - public string UserSid { get; private set; } - /// - /// The member_sid - /// - [JsonProperty("member_sid")] - public string MemberSid { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.ChannelStatusEnum Status { get; private set; } - /// - /// The last_consumed_message_index - /// - [JsonProperty("last_consumed_message_index")] - public int? LastConsumedMessageIndex { get; private set; } - /// - /// The unread_messages_count - /// - [JsonProperty("unread_messages_count")] - public int? UnreadMessagesCount { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The notification_level - /// - [JsonProperty("notification_level")] - [JsonConverter(typeof(StringEnumConverter))] - public UserChannelResource.NotificationLevelEnum NotificationLevel { get; private set; } - - private UserChannelResource() - { - - } - } +{ + + public class UserChannelResource : Resource + { + public sealed class ChannelStatusEnum : StringEnum + { + private ChannelStatusEnum(string value) : base(value) { } + public ChannelStatusEnum() { } + public static implicit operator ChannelStatusEnum(string value) + { + return new ChannelStatusEnum(value); + } + + public static readonly ChannelStatusEnum Joined = new ChannelStatusEnum("joined"); + public static readonly ChannelStatusEnum Invited = new ChannelStatusEnum("invited"); + public static readonly ChannelStatusEnum NotParticipating = new ChannelStatusEnum("not_participating"); + } + + public sealed class NotificationLevelEnum : StringEnum + { + private NotificationLevelEnum(string value) : base(value) { } + public NotificationLevelEnum() { } + public static implicit operator NotificationLevelEnum(string value) + { + return new NotificationLevelEnum(value); + } + + public static readonly NotificationLevelEnum Default = new NotificationLevelEnum("default"); + public static readonly NotificationLevelEnum Muted = new NotificationLevelEnum("muted"); + } + + private static Request BuildReadRequest(ReadUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(ReadUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The user_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static ResourceSet Read(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The user_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathUserSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserChannelOptions(pathServiceSid, pathUserSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildFetchRequest(FetchUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Fetch(FetchUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Fetch(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new FetchUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static bool Delete(DeleteUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static bool Delete(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateUserChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathUserSid + "/Channels/" + options.PathChannelSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update UserChannel parameters + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Update(UpdateUserChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update UserChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// The notification_level + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// Client to make requests to Twilio + /// A single instance of UserChannel + public static UserChannelResource Update(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + UserChannelResource.NotificationLevelEnum notificationLevel = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid) { NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The user_sid + /// The channel_sid + /// The notification_level + /// The last_consumed_message_index + /// The last_consumption_timestamp + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UserChannel + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathUserSid, + string pathChannelSid, + UserChannelResource.NotificationLevelEnum notificationLevel = null, + int? lastConsumedMessageIndex = null, + DateTime? lastConsumptionTimestamp = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserChannelOptions(pathServiceSid, pathUserSid, pathChannelSid) { NotificationLevel = notificationLevel, LastConsumedMessageIndex = lastConsumedMessageIndex, LastConsumptionTimestamp = lastConsumptionTimestamp }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserChannelResource object + /// + /// Raw JSON string + /// UserChannelResource object represented by the provided JSON + public static UserChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The channel_sid + /// + [JsonProperty("channel_sid")] + public string ChannelSid { get; private set; } + /// + /// The user_sid + /// + [JsonProperty("user_sid")] + public string UserSid { get; private set; } + /// + /// The member_sid + /// + [JsonProperty("member_sid")] + public string MemberSid { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.ChannelStatusEnum Status { get; private set; } + /// + /// The last_consumed_message_index + /// + [JsonProperty("last_consumed_message_index")] + public int? LastConsumedMessageIndex { get; private set; } + /// + /// The unread_messages_count + /// + [JsonProperty("unread_messages_count")] + public int? UnreadMessagesCount { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The notification_level + /// + [JsonProperty("notification_level")] + [JsonConverter(typeof(StringEnumConverter))] + public UserChannelResource.NotificationLevelEnum NotificationLevel { get; private set; } + + private UserChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/UserOptions.cs b/src/Twilio/Rest/IpMessaging/V2/Service/UserOptions.cs index 23cefdf76..6cb164b7d 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/UserOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/UserOptions.cs @@ -9,275 +9,275 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2.Service -{ - +{ + + /// + /// FetchUserOptions + /// + public class FetchUserOptions : IOptions + { /// - /// FetchUserOptions + /// The service_sid /// - public class FetchUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUserOptions - /// - /// The service_sid - /// The sid - public FetchUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// DeleteUserOptions + /// The sid /// - public class DeleteUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUserOptions - /// - /// The service_sid - /// The sid - public DeleteUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateUserOptions + /// Construct a new FetchUserOptions /// - public class CreateUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The identity - /// - public string Identity { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new CreateUserOptions - /// - /// The service_sid - /// The identity - public CreateUserOptions(string pathServiceSid, string identity) - { - PathServiceSid = pathServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } - + /// The service_sid + /// The sid + public FetchUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadUserOptions + /// Generate the necessary parameters /// - public class ReadUserOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadUserOptions - /// - /// The service_sid - public ReadUserOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteUserOptions + /// + public class DeleteUserOptions : IOptions + { /// - /// UpdateUserOptions + /// The service_sid /// - public class UpdateUserOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The role_sid - /// - public string RoleSid { get; set; } - /// - /// The attributes - /// - public string Attributes { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The X-Twilio-Webhook-Enabled HTTP request header - /// - public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } - - /// - /// Construct a new UpdateUserOptions - /// - /// The service_sid - /// The sid - public UpdateUserOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoleSid != null) - { - p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XTwilioWebhookEnabled != null) - { - p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUserOptions + /// + /// The service_sid + /// The sid + public DeleteUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateUserOptions + /// + public class CreateUserOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The identity + /// + public string Identity { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new CreateUserOptions + /// + /// The service_sid + /// The identity + public CreateUserOptions(string pathServiceSid, string identity) + { + PathServiceSid = pathServiceSid; + Identity = identity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } + + /// + /// ReadUserOptions + /// + public class ReadUserOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadUserOptions + /// + /// The service_sid + public ReadUserOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateUserOptions + /// + public class UpdateUserOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The role_sid + /// + public string RoleSid { get; set; } + /// + /// The attributes + /// + public string Attributes { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The X-Twilio-Webhook-Enabled HTTP request header + /// + public UserResource.WebhookEnabledTypeEnum XTwilioWebhookEnabled { get; set; } + + /// + /// Construct a new UpdateUserOptions + /// + /// The service_sid + /// The sid + public UpdateUserOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoleSid != null) + { + p.Add(new KeyValuePair("RoleSid", RoleSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XTwilioWebhookEnabled != null) + { + p.Add(new KeyValuePair("X-Twilio-Webhook-Enabled", XTwilioWebhookEnabled.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/Service/UserResource.cs b/src/Twilio/Rest/IpMessaging/V2/Service/UserResource.cs index 3aa09733b..44cb4df62 100644 --- a/src/Twilio/Rest/IpMessaging/V2/Service/UserResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/Service/UserResource.cs @@ -17,565 +17,565 @@ using Twilio.Types; namespace Twilio.Rest.IpMessaging.V2.Service -{ - - public class UserResource : Resource - { - public sealed class WebhookEnabledTypeEnum : StringEnum - { - private WebhookEnabledTypeEnum(string value) : base(value) {} - public WebhookEnabledTypeEnum() {} - public static implicit operator WebhookEnabledTypeEnum(string value) - { - return new WebhookEnabledTypeEnum(value); - } - - public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); - public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); - } - - private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUserOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of User - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUserOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The identity - /// The role_sid - /// The attributes - /// The friendly_name - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Create(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The identity - /// The role_sid - /// The attributes - /// The friendly_name - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateUserOptions(pathServiceSid, identity){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("users", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of User - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUserOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("users", response.Content); - } - - private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update User parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The role_sid - /// The attributes - /// The friendly_name - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// A single instance of User - public static UserResource Update(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The role_sid - /// The attributes - /// The friendly_name - /// The X-Twilio-Webhook-Enabled HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of User - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string roleSid = null, - string attributes = null, - string friendlyName = null, - UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateUserOptions(pathServiceSid, pathSid){RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UserResource object - /// - /// Raw JSON string - /// UserResource object represented by the provided JSON - public static UserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The attributes - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The role_sid - /// - [JsonProperty("role_sid")] - public string RoleSid { get; private set; } - /// - /// The identity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The is_online - /// - [JsonProperty("is_online")] - public bool? IsOnline { get; private set; } - /// - /// The is_notifiable - /// - [JsonProperty("is_notifiable")] - public bool? IsNotifiable { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The joined_channels_count - /// - [JsonProperty("joined_channels_count")] - public int? JoinedChannelsCount { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UserResource() - { - - } - } +{ + + public class UserResource : Resource + { + public sealed class WebhookEnabledTypeEnum : StringEnum + { + private WebhookEnabledTypeEnum(string value) : base(value) { } + public WebhookEnabledTypeEnum() { } + public static implicit operator WebhookEnabledTypeEnum(string value) + { + return new WebhookEnabledTypeEnum(value); + } + + public static readonly WebhookEnabledTypeEnum True = new WebhookEnabledTypeEnum("true"); + public static readonly WebhookEnabledTypeEnum False = new WebhookEnabledTypeEnum("false"); + } + + private static Request BuildFetchRequest(FetchUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUserOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUserOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The identity + /// The role_sid + /// The attributes + /// The friendly_name + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The identity + /// The role_sid + /// The attributes + /// The friendly_name + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateUserOptions(pathServiceSid, identity) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(ReadUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("users", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUserOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("users", response.Content); + } + + private static Request BuildUpdateRequest(UpdateUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathServiceSid + "/Users/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The role_sid + /// The attributes + /// The friendly_name + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The role_sid + /// The attributes + /// The friendly_name + /// The X-Twilio-Webhook-Enabled HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string roleSid = null, + string attributes = null, + string friendlyName = null, + UserResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateUserOptions(pathServiceSid, pathSid) { RoleSid = roleSid, Attributes = attributes, FriendlyName = friendlyName, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The attributes + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The role_sid + /// + [JsonProperty("role_sid")] + public string RoleSid { get; private set; } + /// + /// The identity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The is_online + /// + [JsonProperty("is_online")] + public bool? IsOnline { get; private set; } + /// + /// The is_notifiable + /// + [JsonProperty("is_notifiable")] + public bool? IsNotifiable { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The joined_channels_count + /// + [JsonProperty("joined_channels_count")] + public int? JoinedChannelsCount { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/ServiceOptions.cs b/src/Twilio/Rest/IpMessaging/V2/ServiceOptions.cs index e6ae62a60..c7d452d64 100644 --- a/src/Twilio/Rest/IpMessaging/V2/ServiceOptions.cs +++ b/src/Twilio/Rest/IpMessaging/V2/ServiceOptions.cs @@ -10,427 +10,427 @@ using Twilio.Converters; namespace Twilio.Rest.IpMessaging.V2 -{ - +{ + + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// FetchServiceOptions + /// The sid /// - public class FetchServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The sid - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteServiceOptions + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The sid - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateServiceOptions + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// The friendly_name - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateServiceOptions - /// - /// The friendly_name - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The default_service_role_sid - /// - public string DefaultServiceRoleSid { get; set; } - /// - /// The default_channel_role_sid - /// - public string DefaultChannelRoleSid { get; set; } - /// - /// The default_channel_creator_role_sid - /// - public string DefaultChannelCreatorRoleSid { get; set; } - /// - /// The read_status_enabled - /// - public bool? ReadStatusEnabled { get; set; } - /// - /// The reachability_enabled - /// - public bool? ReachabilityEnabled { get; set; } - /// - /// The typing_indicator_timeout - /// - public int? TypingIndicatorTimeout { get; set; } - /// - /// The consumption_report_interval - /// - public int? ConsumptionReportInterval { get; set; } - /// - /// The notifications.new_message.enabled - /// - public bool? NotificationsNewMessageEnabled { get; set; } - /// - /// The notifications.new_message.template - /// - public string NotificationsNewMessageTemplate { get; set; } - /// - /// The notifications.new_message.sound - /// - public string NotificationsNewMessageSound { get; set; } - /// - /// The notifications.new_message.badge_count_enabled - /// - public bool? NotificationsNewMessageBadgeCountEnabled { get; set; } - /// - /// The notifications.added_to_channel.enabled - /// - public bool? NotificationsAddedToChannelEnabled { get; set; } - /// - /// The notifications.added_to_channel.template - /// - public string NotificationsAddedToChannelTemplate { get; set; } - /// - /// The notifications.added_to_channel.sound - /// - public string NotificationsAddedToChannelSound { get; set; } - /// - /// The notifications.removed_from_channel.enabled - /// - public bool? NotificationsRemovedFromChannelEnabled { get; set; } - /// - /// The notifications.removed_from_channel.template - /// - public string NotificationsRemovedFromChannelTemplate { get; set; } - /// - /// The notifications.removed_from_channel.sound - /// - public string NotificationsRemovedFromChannelSound { get; set; } - /// - /// The notifications.invited_to_channel.enabled - /// - public bool? NotificationsInvitedToChannelEnabled { get; set; } - /// - /// The notifications.invited_to_channel.template - /// - public string NotificationsInvitedToChannelTemplate { get; set; } - /// - /// The notifications.invited_to_channel.sound - /// - public string NotificationsInvitedToChannelSound { get; set; } - /// - /// The pre_webhook_url - /// - public Uri PreWebhookUrl { get; set; } - /// - /// The post_webhook_url - /// - public Uri PostWebhookUrl { get; set; } - /// - /// The webhook_method - /// - public Twilio.Http.HttpMethod WebhookMethod { get; set; } - /// - /// The webhook_filters - /// - public List WebhookFilters { get; set; } - /// - /// The limits.channel_members - /// - public int? LimitsChannelMembers { get; set; } - /// - /// The limits.user_channels - /// - public int? LimitsUserChannels { get; set; } - /// - /// The media.compatibility_message - /// - public string MediaCompatibilityMessage { get; set; } - /// - /// The pre_webhook_retry_count - /// - public int? PreWebhookRetryCount { get; set; } - /// - /// The post_webhook_retry_count - /// - public int? PostWebhookRetryCount { get; set; } - /// - /// The notifications.log_enabled - /// - public bool? NotificationsLogEnabled { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The sid - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - WebhookFilters = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DefaultServiceRoleSid != null) - { - p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); - } - - if (DefaultChannelRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); - } - - if (DefaultChannelCreatorRoleSid != null) - { - p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); - } - - if (ReadStatusEnabled != null) - { - p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); - } - - if (TypingIndicatorTimeout != null) - { - p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); - } - - if (ConsumptionReportInterval != null) - { - p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); - } - - if (NotificationsNewMessageEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); - } - - if (NotificationsNewMessageTemplate != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); - } - - if (NotificationsNewMessageSound != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.Sound", NotificationsNewMessageSound)); - } - - if (NotificationsNewMessageBadgeCountEnabled != null) - { - p.Add(new KeyValuePair("Notifications.NewMessage.BadgeCountEnabled", NotificationsNewMessageBadgeCountEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsAddedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); - } - - if (NotificationsAddedToChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.AddedToChannel.Sound", NotificationsAddedToChannelSound)); - } - - if (NotificationsRemovedFromChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsRemovedFromChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); - } - - if (NotificationsRemovedFromChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Sound", NotificationsRemovedFromChannelSound)); - } - - if (NotificationsInvitedToChannelEnabled != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); - } - - if (NotificationsInvitedToChannelTemplate != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); - } - - if (NotificationsInvitedToChannelSound != null) - { - p.Add(new KeyValuePair("Notifications.InvitedToChannel.Sound", NotificationsInvitedToChannelSound)); - } - - if (PreWebhookUrl != null) - { - p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); - } - - if (PostWebhookUrl != null) - { - p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); - } - - if (WebhookFilters != null) - { - p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); - } - - if (LimitsChannelMembers != null) - { - p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); - } - - if (LimitsUserChannels != null) - { - p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); - } - - if (MediaCompatibilityMessage != null) - { - p.Add(new KeyValuePair("Media.CompatibilityMessage", MediaCompatibilityMessage)); - } - - if (PreWebhookRetryCount != null) - { - p.Add(new KeyValuePair("PreWebhookRetryCount", PreWebhookRetryCount.ToString())); - } - - if (PostWebhookRetryCount != null) - { - p.Add(new KeyValuePair("PostWebhookRetryCount", PostWebhookRetryCount.ToString())); - } - - if (NotificationsLogEnabled != null) - { - p.Add(new KeyValuePair("Notifications.LogEnabled", NotificationsLogEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new DeleteServiceOptions + /// + /// The sid + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// The friendly_name + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateServiceOptions + /// + /// The friendly_name + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The default_service_role_sid + /// + public string DefaultServiceRoleSid { get; set; } + /// + /// The default_channel_role_sid + /// + public string DefaultChannelRoleSid { get; set; } + /// + /// The default_channel_creator_role_sid + /// + public string DefaultChannelCreatorRoleSid { get; set; } + /// + /// The read_status_enabled + /// + public bool? ReadStatusEnabled { get; set; } + /// + /// The reachability_enabled + /// + public bool? ReachabilityEnabled { get; set; } + /// + /// The typing_indicator_timeout + /// + public int? TypingIndicatorTimeout { get; set; } + /// + /// The consumption_report_interval + /// + public int? ConsumptionReportInterval { get; set; } + /// + /// The notifications.new_message.enabled + /// + public bool? NotificationsNewMessageEnabled { get; set; } + /// + /// The notifications.new_message.template + /// + public string NotificationsNewMessageTemplate { get; set; } + /// + /// The notifications.new_message.sound + /// + public string NotificationsNewMessageSound { get; set; } + /// + /// The notifications.new_message.badge_count_enabled + /// + public bool? NotificationsNewMessageBadgeCountEnabled { get; set; } + /// + /// The notifications.added_to_channel.enabled + /// + public bool? NotificationsAddedToChannelEnabled { get; set; } + /// + /// The notifications.added_to_channel.template + /// + public string NotificationsAddedToChannelTemplate { get; set; } + /// + /// The notifications.added_to_channel.sound + /// + public string NotificationsAddedToChannelSound { get; set; } + /// + /// The notifications.removed_from_channel.enabled + /// + public bool? NotificationsRemovedFromChannelEnabled { get; set; } + /// + /// The notifications.removed_from_channel.template + /// + public string NotificationsRemovedFromChannelTemplate { get; set; } + /// + /// The notifications.removed_from_channel.sound + /// + public string NotificationsRemovedFromChannelSound { get; set; } + /// + /// The notifications.invited_to_channel.enabled + /// + public bool? NotificationsInvitedToChannelEnabled { get; set; } + /// + /// The notifications.invited_to_channel.template + /// + public string NotificationsInvitedToChannelTemplate { get; set; } + /// + /// The notifications.invited_to_channel.sound + /// + public string NotificationsInvitedToChannelSound { get; set; } + /// + /// The pre_webhook_url + /// + public Uri PreWebhookUrl { get; set; } + /// + /// The post_webhook_url + /// + public Uri PostWebhookUrl { get; set; } + /// + /// The webhook_method + /// + public Twilio.Http.HttpMethod WebhookMethod { get; set; } + /// + /// The webhook_filters + /// + public List WebhookFilters { get; set; } + /// + /// The limits.channel_members + /// + public int? LimitsChannelMembers { get; set; } + /// + /// The limits.user_channels + /// + public int? LimitsUserChannels { get; set; } + /// + /// The media.compatibility_message + /// + public string MediaCompatibilityMessage { get; set; } + /// + /// The pre_webhook_retry_count + /// + public int? PreWebhookRetryCount { get; set; } + /// + /// The post_webhook_retry_count + /// + public int? PostWebhookRetryCount { get; set; } + /// + /// The notifications.log_enabled + /// + public bool? NotificationsLogEnabled { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The sid + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + WebhookFilters = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DefaultServiceRoleSid != null) + { + p.Add(new KeyValuePair("DefaultServiceRoleSid", DefaultServiceRoleSid.ToString())); + } + + if (DefaultChannelRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelRoleSid", DefaultChannelRoleSid.ToString())); + } + + if (DefaultChannelCreatorRoleSid != null) + { + p.Add(new KeyValuePair("DefaultChannelCreatorRoleSid", DefaultChannelCreatorRoleSid.ToString())); + } + + if (ReadStatusEnabled != null) + { + p.Add(new KeyValuePair("ReadStatusEnabled", ReadStatusEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityEnabled", ReachabilityEnabled.Value.ToString().ToLower())); + } + + if (TypingIndicatorTimeout != null) + { + p.Add(new KeyValuePair("TypingIndicatorTimeout", TypingIndicatorTimeout.ToString())); + } + + if (ConsumptionReportInterval != null) + { + p.Add(new KeyValuePair("ConsumptionReportInterval", ConsumptionReportInterval.ToString())); + } + + if (NotificationsNewMessageEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Enabled", NotificationsNewMessageEnabled.Value.ToString().ToLower())); + } + + if (NotificationsNewMessageTemplate != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Template", NotificationsNewMessageTemplate)); + } + + if (NotificationsNewMessageSound != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.Sound", NotificationsNewMessageSound)); + } + + if (NotificationsNewMessageBadgeCountEnabled != null) + { + p.Add(new KeyValuePair("Notifications.NewMessage.BadgeCountEnabled", NotificationsNewMessageBadgeCountEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Enabled", NotificationsAddedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsAddedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Template", NotificationsAddedToChannelTemplate)); + } + + if (NotificationsAddedToChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.AddedToChannel.Sound", NotificationsAddedToChannelSound)); + } + + if (NotificationsRemovedFromChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Enabled", NotificationsRemovedFromChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsRemovedFromChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Template", NotificationsRemovedFromChannelTemplate)); + } + + if (NotificationsRemovedFromChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.RemovedFromChannel.Sound", NotificationsRemovedFromChannelSound)); + } + + if (NotificationsInvitedToChannelEnabled != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Enabled", NotificationsInvitedToChannelEnabled.Value.ToString().ToLower())); + } + + if (NotificationsInvitedToChannelTemplate != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Template", NotificationsInvitedToChannelTemplate)); + } + + if (NotificationsInvitedToChannelSound != null) + { + p.Add(new KeyValuePair("Notifications.InvitedToChannel.Sound", NotificationsInvitedToChannelSound)); + } + + if (PreWebhookUrl != null) + { + p.Add(new KeyValuePair("PreWebhookUrl", Serializers.Url(PreWebhookUrl))); + } + + if (PostWebhookUrl != null) + { + p.Add(new KeyValuePair("PostWebhookUrl", Serializers.Url(PostWebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod.ToString())); + } + + if (WebhookFilters != null) + { + p.AddRange(WebhookFilters.Select(prop => new KeyValuePair("WebhookFilters", prop))); + } + + if (LimitsChannelMembers != null) + { + p.Add(new KeyValuePair("Limits.ChannelMembers", LimitsChannelMembers.ToString())); + } + + if (LimitsUserChannels != null) + { + p.Add(new KeyValuePair("Limits.UserChannels", LimitsUserChannels.ToString())); + } + + if (MediaCompatibilityMessage != null) + { + p.Add(new KeyValuePair("Media.CompatibilityMessage", MediaCompatibilityMessage)); + } + + if (PreWebhookRetryCount != null) + { + p.Add(new KeyValuePair("PreWebhookRetryCount", PreWebhookRetryCount.ToString())); + } + + if (PostWebhookRetryCount != null) + { + p.Add(new KeyValuePair("PostWebhookRetryCount", PostWebhookRetryCount.ToString())); + } + + if (NotificationsLogEnabled != null) + { + p.Add(new KeyValuePair("Notifications.LogEnabled", NotificationsLogEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/IpMessaging/V2/ServiceResource.cs b/src/Twilio/Rest/IpMessaging/V2/ServiceResource.cs index 0e334c6ca..d20ecdcd7 100644 --- a/src/Twilio/Rest/IpMessaging/V2/ServiceResource.cs +++ b/src/Twilio/Rest/IpMessaging/V2/ServiceResource.cs @@ -16,669 +16,669 @@ using Twilio.Http; namespace Twilio.Rest.IpMessaging.V2 -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.IpMessaging, - "/v2/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.IpMessaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.IpMessaging, - "/v2/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The friendly_name - /// The default_service_role_sid - /// The default_channel_role_sid - /// The default_channel_creator_role_sid - /// The read_status_enabled - /// The reachability_enabled - /// The typing_indicator_timeout - /// The consumption_report_interval - /// The notifications.new_message.enabled - /// The notifications.new_message.template - /// The notifications.new_message.sound - /// The notifications.new_message.badge_count_enabled - /// The notifications.added_to_channel.enabled - /// The notifications.added_to_channel.template - /// The notifications.added_to_channel.sound - /// The notifications.removed_from_channel.enabled - /// The notifications.removed_from_channel.template - /// The notifications.removed_from_channel.sound - /// The notifications.invited_to_channel.enabled - /// The notifications.invited_to_channel.template - /// The notifications.invited_to_channel.sound - /// The pre_webhook_url - /// The post_webhook_url - /// The webhook_method - /// The webhook_filters - /// The limits.channel_members - /// The limits.user_channels - /// The media.compatibility_message - /// The pre_webhook_retry_count - /// The post_webhook_retry_count - /// The notifications.log_enabled - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - string notificationsNewMessageSound = null, - bool? notificationsNewMessageBadgeCountEnabled = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - string notificationsAddedToChannelSound = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - string notificationsRemovedFromChannelSound = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - string notificationsInvitedToChannelSound = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - string mediaCompatibilityMessage = null, - int? preWebhookRetryCount = null, - int? postWebhookRetryCount = null, - bool? notificationsLogEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The friendly_name - /// The default_service_role_sid - /// The default_channel_role_sid - /// The default_channel_creator_role_sid - /// The read_status_enabled - /// The reachability_enabled - /// The typing_indicator_timeout - /// The consumption_report_interval - /// The notifications.new_message.enabled - /// The notifications.new_message.template - /// The notifications.new_message.sound - /// The notifications.new_message.badge_count_enabled - /// The notifications.added_to_channel.enabled - /// The notifications.added_to_channel.template - /// The notifications.added_to_channel.sound - /// The notifications.removed_from_channel.enabled - /// The notifications.removed_from_channel.template - /// The notifications.removed_from_channel.sound - /// The notifications.invited_to_channel.enabled - /// The notifications.invited_to_channel.template - /// The notifications.invited_to_channel.sound - /// The pre_webhook_url - /// The post_webhook_url - /// The webhook_method - /// The webhook_filters - /// The limits.channel_members - /// The limits.user_channels - /// The media.compatibility_message - /// The pre_webhook_retry_count - /// The post_webhook_retry_count - /// The notifications.log_enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string defaultServiceRoleSid = null, - string defaultChannelRoleSid = null, - string defaultChannelCreatorRoleSid = null, - bool? readStatusEnabled = null, - bool? reachabilityEnabled = null, - int? typingIndicatorTimeout = null, - int? consumptionReportInterval = null, - bool? notificationsNewMessageEnabled = null, - string notificationsNewMessageTemplate = null, - string notificationsNewMessageSound = null, - bool? notificationsNewMessageBadgeCountEnabled = null, - bool? notificationsAddedToChannelEnabled = null, - string notificationsAddedToChannelTemplate = null, - string notificationsAddedToChannelSound = null, - bool? notificationsRemovedFromChannelEnabled = null, - string notificationsRemovedFromChannelTemplate = null, - string notificationsRemovedFromChannelSound = null, - bool? notificationsInvitedToChannelEnabled = null, - string notificationsInvitedToChannelTemplate = null, - string notificationsInvitedToChannelSound = null, - Uri preWebhookUrl = null, - Uri postWebhookUrl = null, - Twilio.Http.HttpMethod webhookMethod = null, - List webhookFilters = null, - int? limitsChannelMembers = null, - int? limitsUserChannels = null, - string mediaCompatibilityMessage = null, - int? preWebhookRetryCount = null, - int? postWebhookRetryCount = null, - bool? notificationsLogEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The default_service_role_sid - /// - [JsonProperty("default_service_role_sid")] - public string DefaultServiceRoleSid { get; private set; } - /// - /// The default_channel_role_sid - /// - [JsonProperty("default_channel_role_sid")] - public string DefaultChannelRoleSid { get; private set; } - /// - /// The default_channel_creator_role_sid - /// - [JsonProperty("default_channel_creator_role_sid")] - public string DefaultChannelCreatorRoleSid { get; private set; } - /// - /// The read_status_enabled - /// - [JsonProperty("read_status_enabled")] - public bool? ReadStatusEnabled { get; private set; } - /// - /// The reachability_enabled - /// - [JsonProperty("reachability_enabled")] - public bool? ReachabilityEnabled { get; private set; } - /// - /// The typing_indicator_timeout - /// - [JsonProperty("typing_indicator_timeout")] - public int? TypingIndicatorTimeout { get; private set; } - /// - /// The consumption_report_interval - /// - [JsonProperty("consumption_report_interval")] - public int? ConsumptionReportInterval { get; private set; } - /// - /// The limits - /// - [JsonProperty("limits")] - public object Limits { get; private set; } - /// - /// The pre_webhook_url - /// - [JsonProperty("pre_webhook_url")] - public string PreWebhookUrl { get; private set; } - /// - /// The post_webhook_url - /// - [JsonProperty("post_webhook_url")] - public string PostWebhookUrl { get; private set; } - /// - /// The webhook_method - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The webhook_filters - /// - [JsonProperty("webhook_filters")] - public List WebhookFilters { get; private set; } - /// - /// The pre_webhook_retry_count - /// - [JsonProperty("pre_webhook_retry_count")] - public int? PreWebhookRetryCount { get; private set; } - /// - /// The post_webhook_retry_count - /// - [JsonProperty("post_webhook_retry_count")] - public int? PostWebhookRetryCount { get; private set; } - /// - /// The notifications - /// - [JsonProperty("notifications")] - public object Notifications { get; private set; } - /// - /// The media - /// - [JsonProperty("media")] - public object Media { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.IpMessaging, + "/v2/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.IpMessaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.IpMessaging, + "/v2/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The friendly_name + /// The default_service_role_sid + /// The default_channel_role_sid + /// The default_channel_creator_role_sid + /// The read_status_enabled + /// The reachability_enabled + /// The typing_indicator_timeout + /// The consumption_report_interval + /// The notifications.new_message.enabled + /// The notifications.new_message.template + /// The notifications.new_message.sound + /// The notifications.new_message.badge_count_enabled + /// The notifications.added_to_channel.enabled + /// The notifications.added_to_channel.template + /// The notifications.added_to_channel.sound + /// The notifications.removed_from_channel.enabled + /// The notifications.removed_from_channel.template + /// The notifications.removed_from_channel.sound + /// The notifications.invited_to_channel.enabled + /// The notifications.invited_to_channel.template + /// The notifications.invited_to_channel.sound + /// The pre_webhook_url + /// The post_webhook_url + /// The webhook_method + /// The webhook_filters + /// The limits.channel_members + /// The limits.user_channels + /// The media.compatibility_message + /// The pre_webhook_retry_count + /// The post_webhook_retry_count + /// The notifications.log_enabled + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + string notificationsNewMessageSound = null, + bool? notificationsNewMessageBadgeCountEnabled = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + string notificationsAddedToChannelSound = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + string notificationsRemovedFromChannelSound = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + string notificationsInvitedToChannelSound = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + string mediaCompatibilityMessage = null, + int? preWebhookRetryCount = null, + int? postWebhookRetryCount = null, + bool? notificationsLogEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The friendly_name + /// The default_service_role_sid + /// The default_channel_role_sid + /// The default_channel_creator_role_sid + /// The read_status_enabled + /// The reachability_enabled + /// The typing_indicator_timeout + /// The consumption_report_interval + /// The notifications.new_message.enabled + /// The notifications.new_message.template + /// The notifications.new_message.sound + /// The notifications.new_message.badge_count_enabled + /// The notifications.added_to_channel.enabled + /// The notifications.added_to_channel.template + /// The notifications.added_to_channel.sound + /// The notifications.removed_from_channel.enabled + /// The notifications.removed_from_channel.template + /// The notifications.removed_from_channel.sound + /// The notifications.invited_to_channel.enabled + /// The notifications.invited_to_channel.template + /// The notifications.invited_to_channel.sound + /// The pre_webhook_url + /// The post_webhook_url + /// The webhook_method + /// The webhook_filters + /// The limits.channel_members + /// The limits.user_channels + /// The media.compatibility_message + /// The pre_webhook_retry_count + /// The post_webhook_retry_count + /// The notifications.log_enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string defaultServiceRoleSid = null, + string defaultChannelRoleSid = null, + string defaultChannelCreatorRoleSid = null, + bool? readStatusEnabled = null, + bool? reachabilityEnabled = null, + int? typingIndicatorTimeout = null, + int? consumptionReportInterval = null, + bool? notificationsNewMessageEnabled = null, + string notificationsNewMessageTemplate = null, + string notificationsNewMessageSound = null, + bool? notificationsNewMessageBadgeCountEnabled = null, + bool? notificationsAddedToChannelEnabled = null, + string notificationsAddedToChannelTemplate = null, + string notificationsAddedToChannelSound = null, + bool? notificationsRemovedFromChannelEnabled = null, + string notificationsRemovedFromChannelTemplate = null, + string notificationsRemovedFromChannelSound = null, + bool? notificationsInvitedToChannelEnabled = null, + string notificationsInvitedToChannelTemplate = null, + string notificationsInvitedToChannelSound = null, + Uri preWebhookUrl = null, + Uri postWebhookUrl = null, + Twilio.Http.HttpMethod webhookMethod = null, + List webhookFilters = null, + int? limitsChannelMembers = null, + int? limitsUserChannels = null, + string mediaCompatibilityMessage = null, + int? preWebhookRetryCount = null, + int? postWebhookRetryCount = null, + bool? notificationsLogEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, DefaultServiceRoleSid = defaultServiceRoleSid, DefaultChannelRoleSid = defaultChannelRoleSid, DefaultChannelCreatorRoleSid = defaultChannelCreatorRoleSid, ReadStatusEnabled = readStatusEnabled, ReachabilityEnabled = reachabilityEnabled, TypingIndicatorTimeout = typingIndicatorTimeout, ConsumptionReportInterval = consumptionReportInterval, NotificationsNewMessageEnabled = notificationsNewMessageEnabled, NotificationsNewMessageTemplate = notificationsNewMessageTemplate, NotificationsNewMessageSound = notificationsNewMessageSound, NotificationsNewMessageBadgeCountEnabled = notificationsNewMessageBadgeCountEnabled, NotificationsAddedToChannelEnabled = notificationsAddedToChannelEnabled, NotificationsAddedToChannelTemplate = notificationsAddedToChannelTemplate, NotificationsAddedToChannelSound = notificationsAddedToChannelSound, NotificationsRemovedFromChannelEnabled = notificationsRemovedFromChannelEnabled, NotificationsRemovedFromChannelTemplate = notificationsRemovedFromChannelTemplate, NotificationsRemovedFromChannelSound = notificationsRemovedFromChannelSound, NotificationsInvitedToChannelEnabled = notificationsInvitedToChannelEnabled, NotificationsInvitedToChannelTemplate = notificationsInvitedToChannelTemplate, NotificationsInvitedToChannelSound = notificationsInvitedToChannelSound, PreWebhookUrl = preWebhookUrl, PostWebhookUrl = postWebhookUrl, WebhookMethod = webhookMethod, WebhookFilters = webhookFilters, LimitsChannelMembers = limitsChannelMembers, LimitsUserChannels = limitsUserChannels, MediaCompatibilityMessage = mediaCompatibilityMessage, PreWebhookRetryCount = preWebhookRetryCount, PostWebhookRetryCount = postWebhookRetryCount, NotificationsLogEnabled = notificationsLogEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The default_service_role_sid + /// + [JsonProperty("default_service_role_sid")] + public string DefaultServiceRoleSid { get; private set; } + /// + /// The default_channel_role_sid + /// + [JsonProperty("default_channel_role_sid")] + public string DefaultChannelRoleSid { get; private set; } + /// + /// The default_channel_creator_role_sid + /// + [JsonProperty("default_channel_creator_role_sid")] + public string DefaultChannelCreatorRoleSid { get; private set; } + /// + /// The read_status_enabled + /// + [JsonProperty("read_status_enabled")] + public bool? ReadStatusEnabled { get; private set; } + /// + /// The reachability_enabled + /// + [JsonProperty("reachability_enabled")] + public bool? ReachabilityEnabled { get; private set; } + /// + /// The typing_indicator_timeout + /// + [JsonProperty("typing_indicator_timeout")] + public int? TypingIndicatorTimeout { get; private set; } + /// + /// The consumption_report_interval + /// + [JsonProperty("consumption_report_interval")] + public int? ConsumptionReportInterval { get; private set; } + /// + /// The limits + /// + [JsonProperty("limits")] + public object Limits { get; private set; } + /// + /// The pre_webhook_url + /// + [JsonProperty("pre_webhook_url")] + public string PreWebhookUrl { get; private set; } + /// + /// The post_webhook_url + /// + [JsonProperty("post_webhook_url")] + public string PostWebhookUrl { get; private set; } + /// + /// The webhook_method + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The webhook_filters + /// + [JsonProperty("webhook_filters")] + public List WebhookFilters { get; private set; } + /// + /// The pre_webhook_retry_count + /// + [JsonProperty("pre_webhook_retry_count")] + public int? PreWebhookRetryCount { get; private set; } + /// + /// The post_webhook_retry_count + /// + [JsonProperty("post_webhook_retry_count")] + public int? PostWebhookRetryCount { get; private set; } + /// + /// The notifications + /// + [JsonProperty("notifications")] + public object Notifications { get; private set; } + /// + /// The media + /// + [JsonProperty("media")] + public object Media { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Lookups/V1/PhoneNumberOptions.cs b/src/Twilio/Rest/Lookups/V1/PhoneNumberOptions.cs index 21c13d411..eb4c7d07d 100644 --- a/src/Twilio/Rest/Lookups/V1/PhoneNumberOptions.cs +++ b/src/Twilio/Rest/Lookups/V1/PhoneNumberOptions.cs @@ -10,73 +10,73 @@ using Twilio.Converters; namespace Twilio.Rest.Lookups.V1 -{ - +{ + + /// + /// FetchPhoneNumberOptions + /// + public class FetchPhoneNumberOptions : IOptions + { /// - /// FetchPhoneNumberOptions + /// The phone number to fetch in E.164 format /// - public class FetchPhoneNumberOptions : IOptions - { - /// - /// The phone number to fetch in E.164 format - /// - public Types.PhoneNumber PathPhoneNumber { get; } - /// - /// The ISO country code of the phone number - /// - public string CountryCode { get; set; } - /// - /// The type of information to return - /// - public List Type { get; set; } - /// - /// The unique_name of an Add-on you would like to invoke - /// - public List AddOns { get; set; } - /// - /// Data specific to the add-on you would like to invoke - /// - public Dictionary AddOnsData { get; set; } - - /// - /// Construct a new FetchPhoneNumberOptions - /// - /// The phone number to fetch in E.164 format - public FetchPhoneNumberOptions(Types.PhoneNumber pathPhoneNumber) - { - PathPhoneNumber = pathPhoneNumber; - Type = new List(); - AddOns = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CountryCode != null) - { - p.Add(new KeyValuePair("CountryCode", CountryCode)); - } - - if (Type != null) - { - p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop))); - } - - if (AddOns != null) - { - p.AddRange(AddOns.Select(prop => new KeyValuePair("AddOns", prop))); - } - - if (AddOnsData != null) - { - p.AddRange(PrefixedCollapsibleMap.Serialize(AddOnsData, "AddOns")); - } - - return p; - } - } + public Types.PhoneNumber PathPhoneNumber { get; } + /// + /// The ISO country code of the phone number + /// + public string CountryCode { get; set; } + /// + /// The type of information to return + /// + public List Type { get; set; } + /// + /// The unique_name of an Add-on you would like to invoke + /// + public List AddOns { get; set; } + /// + /// Data specific to the add-on you would like to invoke + /// + public Dictionary AddOnsData { get; set; } + + /// + /// Construct a new FetchPhoneNumberOptions + /// + /// The phone number to fetch in E.164 format + public FetchPhoneNumberOptions(Types.PhoneNumber pathPhoneNumber) + { + PathPhoneNumber = pathPhoneNumber; + Type = new List(); + AddOns = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CountryCode != null) + { + p.Add(new KeyValuePair("CountryCode", CountryCode)); + } + + if (Type != null) + { + p.AddRange(Type.Select(prop => new KeyValuePair("Type", prop))); + } + + if (AddOns != null) + { + p.AddRange(AddOns.Select(prop => new KeyValuePair("AddOns", prop))); + } + + if (AddOnsData != null) + { + p.AddRange(PrefixedCollapsibleMap.Serialize(AddOnsData, "AddOns")); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Lookups/V1/PhoneNumberResource.cs b/src/Twilio/Rest/Lookups/V1/PhoneNumberResource.cs index 5c85cf3df..17eafcff9 100644 --- a/src/Twilio/Rest/Lookups/V1/PhoneNumberResource.cs +++ b/src/Twilio/Rest/Lookups/V1/PhoneNumberResource.cs @@ -17,167 +17,167 @@ using Twilio.Types; namespace Twilio.Rest.Lookups.V1 -{ - - public class PhoneNumberResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Landline = new TypeEnum("landline"); - public static readonly TypeEnum Mobile = new TypeEnum("mobile"); - public static readonly TypeEnum Voip = new TypeEnum("voip"); - } - - private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Lookups, - "/v1/PhoneNumbers/" + options.PathPhoneNumber + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The phone number to fetch in E.164 format - /// The ISO country code of the phone number - /// The type of information to return - /// The unique_name of an Add-on you would like to invoke - /// Data specific to the add-on you would like to invoke - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(Types.PhoneNumber pathPhoneNumber, - string countryCode = null, - List type = null, - List addOns = null, - Dictionary addOnsData = null, - ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathPhoneNumber){CountryCode = countryCode, Type = type, AddOns = addOns, AddOnsData = addOnsData}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The phone number to fetch in E.164 format - /// The ISO country code of the phone number - /// The type of information to return - /// The unique_name of an Add-on you would like to invoke - /// Data specific to the add-on you would like to invoke - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathPhoneNumber, - string countryCode = null, - List type = null, - List addOns = null, - Dictionary addOnsData = null, - ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathPhoneNumber){CountryCode = countryCode, Type = type, AddOns = addOns, AddOnsData = addOnsData}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PhoneNumberResource object - /// - /// Raw JSON string - /// PhoneNumberResource object represented by the provided JSON - public static PhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the phone number's owner - /// - [JsonProperty("caller_name")] - public object CallerName { get; private set; } - /// - /// The ISO country code for the phone number - /// - [JsonProperty("country_code")] - public string CountryCode { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The phone number, in national format - /// - [JsonProperty("national_format")] - public string NationalFormat { get; private set; } - /// - /// The telecom company that provides the phone number - /// - [JsonProperty("carrier")] - public object Carrier { get; private set; } - /// - /// A JSON string with the results of the Add-ons you specified - /// - [JsonProperty("add_ons")] - public object AddOns { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private PhoneNumberResource() - { - - } - } +{ + + public class PhoneNumberResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Landline = new TypeEnum("landline"); + public static readonly TypeEnum Mobile = new TypeEnum("mobile"); + public static readonly TypeEnum Voip = new TypeEnum("voip"); + } + + private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Lookups, + "/v1/PhoneNumbers/" + options.PathPhoneNumber + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The phone number to fetch in E.164 format + /// The ISO country code of the phone number + /// The type of information to return + /// The unique_name of an Add-on you would like to invoke + /// Data specific to the add-on you would like to invoke + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(Types.PhoneNumber pathPhoneNumber, + string countryCode = null, + List type = null, + List addOns = null, + Dictionary addOnsData = null, + ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathPhoneNumber) { CountryCode = countryCode, Type = type, AddOns = addOns, AddOnsData = addOnsData }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The phone number to fetch in E.164 format + /// The ISO country code of the phone number + /// The type of information to return + /// The unique_name of an Add-on you would like to invoke + /// Data specific to the add-on you would like to invoke + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathPhoneNumber, + string countryCode = null, + List type = null, + List addOns = null, + Dictionary addOnsData = null, + ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathPhoneNumber) { CountryCode = countryCode, Type = type, AddOns = addOns, AddOnsData = addOnsData }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PhoneNumberResource object + /// + /// Raw JSON string + /// PhoneNumberResource object represented by the provided JSON + public static PhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the phone number's owner + /// + [JsonProperty("caller_name")] + public object CallerName { get; private set; } + /// + /// The ISO country code for the phone number + /// + [JsonProperty("country_code")] + public string CountryCode { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The phone number, in national format + /// + [JsonProperty("national_format")] + public string NationalFormat { get; private set; } + /// + /// The telecom company that provides the phone number + /// + [JsonProperty("carrier")] + public object Carrier { get; private set; } + /// + /// A JSON string with the results of the Add-ons you specified + /// + [JsonProperty("add_ons")] + public object AddOns { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private PhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/MediaProcessorOptions.cs b/src/Twilio/Rest/Media/V1/MediaProcessorOptions.cs index 94c99fdf5..31d74fba4 100644 --- a/src/Twilio/Rest/Media/V1/MediaProcessorOptions.cs +++ b/src/Twilio/Rest/Media/V1/MediaProcessorOptions.cs @@ -9,195 +9,195 @@ using Twilio.Converters; namespace Twilio.Rest.Media.V1 -{ - +{ + + /// + /// CreateMediaProcessorOptions + /// + public class CreateMediaProcessorOptions : IOptions + { /// - /// CreateMediaProcessorOptions - /// - public class CreateMediaProcessorOptions : IOptions - { - /// - /// The Media Extension name or URL - /// - public string Extension { get; } - /// - /// The Media Extension context - /// - public string ExtensionContext { get; } - /// - /// The Media Extension environment - /// - public object ExtensionEnvironment { get; set; } - /// - /// The URL to send MediaProcessor event updates to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method Twilio should use to call the `status_callback` URL - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Maximum MediaProcessor duration in minutes - /// - public int? MaxDuration { get; set; } - - /// - /// Construct a new CreateMediaProcessorOptions - /// - /// The Media Extension name or URL - /// The Media Extension context - public CreateMediaProcessorOptions(string extension, string extensionContext) - { - Extension = extension; - ExtensionContext = extensionContext; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Extension != null) - { - p.Add(new KeyValuePair("Extension", Extension)); - } - - if (ExtensionContext != null) - { - p.Add(new KeyValuePair("ExtensionContext", ExtensionContext)); - } - - if (ExtensionEnvironment != null) - { - p.Add(new KeyValuePair("ExtensionEnvironment", Serializers.JsonObject(ExtensionEnvironment))); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (MaxDuration != null) - { - p.Add(new KeyValuePair("MaxDuration", MaxDuration.ToString())); - } - - return p; - } - } - + /// The Media Extension name or URL + /// + public string Extension { get; } /// - /// Returns a single MediaProcessor resource identified by a SID. + /// The Media Extension context /// - public class FetchMediaProcessorOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMediaProcessorOptions - /// - /// The SID that identifies the resource to fetch - public FetchMediaProcessorOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string ExtensionContext { get; } /// - /// Updates a MediaProcessor resource identified by a SID. - /// - public class UpdateMediaProcessorOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The status of the MediaProcessor - /// - public MediaProcessorResource.UpdateStatusEnum Status { get; } - - /// - /// Construct a new UpdateMediaProcessorOptions - /// - /// The SID that identifies the resource to update - /// The status of the MediaProcessor - public UpdateMediaProcessorOptions(string pathSid, MediaProcessorResource.UpdateStatusEnum status) - { - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } - + /// The Media Extension environment + /// + public object ExtensionEnvironment { get; set; } /// - /// Returns a list of MediaProcessors. - /// - public class ReadMediaProcessorOptions : ReadOptions - { - /// - /// The sort order of the list - /// - public MediaProcessorResource.OrderEnum Order { get; set; } - /// - /// Status to filter by - /// - public MediaProcessorResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The URL to send MediaProcessor event updates to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method Twilio should use to call the `status_callback` URL + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Maximum MediaProcessor duration in minutes + /// + public int? MaxDuration { get; set; } + + /// + /// Construct a new CreateMediaProcessorOptions + /// + /// The Media Extension name or URL + /// The Media Extension context + public CreateMediaProcessorOptions(string extension, string extensionContext) + { + Extension = extension; + ExtensionContext = extensionContext; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Extension != null) + { + p.Add(new KeyValuePair("Extension", Extension)); + } + + if (ExtensionContext != null) + { + p.Add(new KeyValuePair("ExtensionContext", ExtensionContext)); + } + + if (ExtensionEnvironment != null) + { + p.Add(new KeyValuePair("ExtensionEnvironment", Serializers.JsonObject(ExtensionEnvironment))); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (MaxDuration != null) + { + p.Add(new KeyValuePair("MaxDuration", MaxDuration.ToString())); + } + + return p; + } + } + + /// + /// Returns a single MediaProcessor resource identified by a SID. + /// + public class FetchMediaProcessorOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMediaProcessorOptions + /// + /// The SID that identifies the resource to fetch + public FetchMediaProcessorOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Updates a MediaProcessor resource identified by a SID. + /// + public class UpdateMediaProcessorOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The status of the MediaProcessor + /// + public MediaProcessorResource.UpdateStatusEnum Status { get; } + + /// + /// Construct a new UpdateMediaProcessorOptions + /// + /// The SID that identifies the resource to update + /// The status of the MediaProcessor + public UpdateMediaProcessorOptions(string pathSid, MediaProcessorResource.UpdateStatusEnum status) + { + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } + + /// + /// Returns a list of MediaProcessors. + /// + public class ReadMediaProcessorOptions : ReadOptions + { + /// + /// The sort order of the list + /// + public MediaProcessorResource.OrderEnum Order { get; set; } + /// + /// Status to filter by + /// + public MediaProcessorResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/MediaProcessorResource.cs b/src/Twilio/Rest/Media/V1/MediaProcessorResource.cs index 0bec9d4be..1b47c9a0c 100644 --- a/src/Twilio/Rest/Media/V1/MediaProcessorResource.cs +++ b/src/Twilio/Rest/Media/V1/MediaProcessorResource.cs @@ -17,499 +17,499 @@ using Twilio.Types; namespace Twilio.Rest.Media.V1 -{ - - public class MediaProcessorResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Started = new StatusEnum("started"); - public static readonly StatusEnum Ended = new StatusEnum("ended"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Ended = new UpdateStatusEnum("ended"); - } - - public sealed class OrderEnum : StringEnum - { - private OrderEnum(string value) : base(value) {} - public OrderEnum() {} - public static implicit operator OrderEnum(string value) - { - return new OrderEnum(value); - } - - public static readonly OrderEnum Asc = new OrderEnum("asc"); - public static readonly OrderEnum Desc = new OrderEnum("desc"); - } - - private static Request BuildCreateRequest(CreateMediaProcessorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Media, - "/v1/MediaProcessors", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create MediaProcessor parameters - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Create(CreateMediaProcessorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create MediaProcessor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task CreateAsync(CreateMediaProcessorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The Media Extension name or URL - /// The Media Extension context - /// The Media Extension environment - /// The URL to send MediaProcessor event updates to your application - /// The HTTP method Twilio should use to call the `status_callback` URL - /// Maximum MediaProcessor duration in minutes - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Create(string extension, - string extensionContext, - object extensionEnvironment = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - int? maxDuration = null, - ITwilioRestClient client = null) - { - var options = new CreateMediaProcessorOptions(extension, extensionContext){ExtensionEnvironment = extensionEnvironment, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxDuration = maxDuration}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The Media Extension name or URL - /// The Media Extension context - /// The Media Extension environment - /// The URL to send MediaProcessor event updates to your application - /// The HTTP method Twilio should use to call the `status_callback` URL - /// Maximum MediaProcessor duration in minutes - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task CreateAsync(string extension, - string extensionContext, - object extensionEnvironment = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - int? maxDuration = null, - ITwilioRestClient client = null) - { - var options = new CreateMediaProcessorOptions(extension, extensionContext){ExtensionEnvironment = extensionEnvironment, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxDuration = maxDuration}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMediaProcessorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Media, - "/v1/MediaProcessors/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single MediaProcessor resource identified by a SID. - /// - /// Fetch MediaProcessor parameters - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Fetch(FetchMediaProcessorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single MediaProcessor resource identified by a SID. - /// - /// Fetch MediaProcessor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task FetchAsync(FetchMediaProcessorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single MediaProcessor resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchMediaProcessorOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single MediaProcessor resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMediaProcessorOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMediaProcessorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Media, - "/v1/MediaProcessors/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a MediaProcessor resource identified by a SID. - /// - /// Update MediaProcessor parameters - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Update(UpdateMediaProcessorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a MediaProcessor resource identified by a SID. - /// - /// Update MediaProcessor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMediaProcessorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a MediaProcessor resource identified by a SID. - /// - /// The SID that identifies the resource to update - /// The status of the MediaProcessor - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static MediaProcessorResource Update(string pathSid, - MediaProcessorResource.UpdateStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateMediaProcessorOptions(pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a MediaProcessor resource identified by a SID. - /// - /// The SID that identifies the resource to update - /// The status of the MediaProcessor - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - MediaProcessorResource.UpdateStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateMediaProcessorOptions(pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMediaProcessorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Media, - "/v1/MediaProcessors", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of MediaProcessors. - /// - /// Read MediaProcessor parameters - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static ResourceSet Read(ReadMediaProcessorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("media_processors", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Returns a list of MediaProcessors. - /// - /// Read MediaProcessor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task> ReadAsync(ReadMediaProcessorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("media_processors", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Returns a list of MediaProcessors. - /// - /// The sort order of the list - /// Status to filter by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of MediaProcessor - public static ResourceSet Read(MediaProcessorResource.OrderEnum order = null, - MediaProcessorResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMediaProcessorOptions(){Order = order, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Returns a list of MediaProcessors. - /// - /// The sort order of the list - /// Status to filter by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MediaProcessor - public static async System.Threading.Tasks.Task> ReadAsync(MediaProcessorResource.OrderEnum order = null, - MediaProcessorResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMediaProcessorOptions(){Order = order, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("media_processors", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Media) - ); - - var response = client.Request(request); - return Page.FromJson("media_processors", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Media) - ); - - var response = client.Request(request); - return Page.FromJson("media_processors", response.Content); - } - - /// - /// Converts a JSON string into a MediaProcessorResource object - /// - /// Raw JSON string - /// MediaProcessorResource object represented by the provided JSON - public static MediaProcessorResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Media Extension name or URL - /// - [JsonProperty("extension")] - public string Extension { get; private set; } - /// - /// The Media Extension context - /// - [JsonProperty("extension_context")] - public string ExtensionContext { get; private set; } - /// - /// The status of the MediaProcessor - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public MediaProcessorResource.StatusEnum Status { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The reason why a MediaProcessor ended - /// - [JsonProperty("ended_reason")] - public string EndedReason { get; private set; } - /// - /// The URL to which Twilio will send MediaProcessor event updates - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method Twilio should use to call the `status_callback` URL - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// Maximum MediaProcessor duration in minutes - /// - [JsonProperty("max_duration")] - public int? MaxDuration { get; private set; } - - private MediaProcessorResource() - { - - } - } +{ + + public class MediaProcessorResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Started = new StatusEnum("started"); + public static readonly StatusEnum Ended = new StatusEnum("ended"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Ended = new UpdateStatusEnum("ended"); + } + + public sealed class OrderEnum : StringEnum + { + private OrderEnum(string value) : base(value) { } + public OrderEnum() { } + public static implicit operator OrderEnum(string value) + { + return new OrderEnum(value); + } + + public static readonly OrderEnum Asc = new OrderEnum("asc"); + public static readonly OrderEnum Desc = new OrderEnum("desc"); + } + + private static Request BuildCreateRequest(CreateMediaProcessorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Media, + "/v1/MediaProcessors", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create MediaProcessor parameters + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Create(CreateMediaProcessorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create MediaProcessor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task CreateAsync(CreateMediaProcessorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The Media Extension name or URL + /// The Media Extension context + /// The Media Extension environment + /// The URL to send MediaProcessor event updates to your application + /// The HTTP method Twilio should use to call the `status_callback` URL + /// Maximum MediaProcessor duration in minutes + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Create(string extension, + string extensionContext, + object extensionEnvironment = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + int? maxDuration = null, + ITwilioRestClient client = null) + { + var options = new CreateMediaProcessorOptions(extension, extensionContext) { ExtensionEnvironment = extensionEnvironment, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxDuration = maxDuration }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The Media Extension name or URL + /// The Media Extension context + /// The Media Extension environment + /// The URL to send MediaProcessor event updates to your application + /// The HTTP method Twilio should use to call the `status_callback` URL + /// Maximum MediaProcessor duration in minutes + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task CreateAsync(string extension, + string extensionContext, + object extensionEnvironment = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + int? maxDuration = null, + ITwilioRestClient client = null) + { + var options = new CreateMediaProcessorOptions(extension, extensionContext) { ExtensionEnvironment = extensionEnvironment, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxDuration = maxDuration }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMediaProcessorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Media, + "/v1/MediaProcessors/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single MediaProcessor resource identified by a SID. + /// + /// Fetch MediaProcessor parameters + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Fetch(FetchMediaProcessorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single MediaProcessor resource identified by a SID. + /// + /// Fetch MediaProcessor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task FetchAsync(FetchMediaProcessorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single MediaProcessor resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchMediaProcessorOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single MediaProcessor resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMediaProcessorOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMediaProcessorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Media, + "/v1/MediaProcessors/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a MediaProcessor resource identified by a SID. + /// + /// Update MediaProcessor parameters + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Update(UpdateMediaProcessorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a MediaProcessor resource identified by a SID. + /// + /// Update MediaProcessor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMediaProcessorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a MediaProcessor resource identified by a SID. + /// + /// The SID that identifies the resource to update + /// The status of the MediaProcessor + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static MediaProcessorResource Update(string pathSid, + MediaProcessorResource.UpdateStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateMediaProcessorOptions(pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a MediaProcessor resource identified by a SID. + /// + /// The SID that identifies the resource to update + /// The status of the MediaProcessor + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + MediaProcessorResource.UpdateStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateMediaProcessorOptions(pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMediaProcessorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Media, + "/v1/MediaProcessors", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of MediaProcessors. + /// + /// Read MediaProcessor parameters + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static ResourceSet Read(ReadMediaProcessorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("media_processors", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Returns a list of MediaProcessors. + /// + /// Read MediaProcessor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task> ReadAsync(ReadMediaProcessorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("media_processors", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Returns a list of MediaProcessors. + /// + /// The sort order of the list + /// Status to filter by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of MediaProcessor + public static ResourceSet Read(MediaProcessorResource.OrderEnum order = null, + MediaProcessorResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMediaProcessorOptions() { Order = order, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Returns a list of MediaProcessors. + /// + /// The sort order of the list + /// Status to filter by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MediaProcessor + public static async System.Threading.Tasks.Task> ReadAsync(MediaProcessorResource.OrderEnum order = null, + MediaProcessorResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMediaProcessorOptions() { Order = order, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("media_processors", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Media) + ); + + var response = client.Request(request); + return Page.FromJson("media_processors", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Media) + ); + + var response = client.Request(request); + return Page.FromJson("media_processors", response.Content); + } + + /// + /// Converts a JSON string into a MediaProcessorResource object + /// + /// Raw JSON string + /// MediaProcessorResource object represented by the provided JSON + public static MediaProcessorResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Media Extension name or URL + /// + [JsonProperty("extension")] + public string Extension { get; private set; } + /// + /// The Media Extension context + /// + [JsonProperty("extension_context")] + public string ExtensionContext { get; private set; } + /// + /// The status of the MediaProcessor + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public MediaProcessorResource.StatusEnum Status { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The reason why a MediaProcessor ended + /// + [JsonProperty("ended_reason")] + public string EndedReason { get; private set; } + /// + /// The URL to which Twilio will send MediaProcessor event updates + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method Twilio should use to call the `status_callback` URL + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// Maximum MediaProcessor duration in minutes + /// + [JsonProperty("max_duration")] + public int? MaxDuration { get; private set; } + + private MediaProcessorResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantOptions.cs b/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantOptions.cs index 4554c4e48..212170fc2 100644 --- a/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantOptions.cs +++ b/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantOptions.cs @@ -9,83 +9,83 @@ using Twilio.Converters; namespace Twilio.Rest.Media.V1.PlayerStreamer -{ - +{ + + /// + /// CreatePlaybackGrantOptions + /// + public class CreatePlaybackGrantOptions : IOptions + { /// - /// CreatePlaybackGrantOptions + /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. /// - public class CreatePlaybackGrantOptions : IOptions - { - /// - /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. - /// - public string PathSid { get; } - /// - /// The time to live of the PlaybackGrant - /// - public int? Ttl { get; set; } - /// - /// The full URL that is authorized to play back the livestream - /// - public string AccessControlAllowOrigin { get; set; } - - /// - /// Construct a new CreatePlaybackGrantOptions - /// - /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. - /// - public CreatePlaybackGrantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (AccessControlAllowOrigin != null) - { - p.Add(new KeyValuePair("AccessControlAllowOrigin", AccessControlAllowOrigin)); - } - - return p; - } - } - + public string PathSid { get; } /// - /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// The time to live of the PlaybackGrant /// - public class FetchPlaybackGrantOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPlaybackGrantOptions - /// - /// The SID that identifies the resource to fetch - public FetchPlaybackGrantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public int? Ttl { get; set; } + /// + /// The full URL that is authorized to play back the livestream + /// + public string AccessControlAllowOrigin { get; set; } + + /// + /// Construct a new CreatePlaybackGrantOptions + /// + /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. + /// + public CreatePlaybackGrantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (AccessControlAllowOrigin != null) + { + p.Add(new KeyValuePair("AccessControlAllowOrigin", AccessControlAllowOrigin)); + } + + return p; + } + } + + /// + /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// + public class FetchPlaybackGrantOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPlaybackGrantOptions + /// + /// The SID that identifies the resource to fetch + public FetchPlaybackGrantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantResource.cs b/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantResource.cs index 16b89547a..78e326059 100644 --- a/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantResource.cs +++ b/src/Twilio/Rest/Media/V1/PlayerStreamer/PlaybackGrantResource.cs @@ -16,203 +16,203 @@ using Twilio.Http; namespace Twilio.Rest.Media.V1.PlayerStreamer -{ - - public class PlaybackGrantResource : Resource - { - private static Request BuildCreateRequest(CreatePlaybackGrantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Media, - "/v1/PlayerStreamers/" + options.PathSid + "/PlaybackGrant", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create PlaybackGrant parameters - /// Client to make requests to Twilio - /// A single instance of PlaybackGrant - public static PlaybackGrantResource Create(CreatePlaybackGrantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create PlaybackGrant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlaybackGrant - public static async System.Threading.Tasks.Task CreateAsync(CreatePlaybackGrantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. - /// - /// The time to live of the PlaybackGrant - /// The full URL that is authorized to play back the livestream - /// Client to make requests to Twilio - /// A single instance of PlaybackGrant - public static PlaybackGrantResource Create(string pathSid, - int? ttl = null, - string accessControlAllowOrigin = null, - ITwilioRestClient client = null) - { - var options = new CreatePlaybackGrantOptions(pathSid){Ttl = ttl, AccessControlAllowOrigin = accessControlAllowOrigin}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. - /// - /// The time to live of the PlaybackGrant - /// The full URL that is authorized to play back the livestream - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlaybackGrant - public static async System.Threading.Tasks.Task CreateAsync(string pathSid, - int? ttl = null, - string accessControlAllowOrigin = null, - ITwilioRestClient client = null) - { - var options = new CreatePlaybackGrantOptions(pathSid){Ttl = ttl, AccessControlAllowOrigin = accessControlAllowOrigin}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchPlaybackGrantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Media, - "/v1/PlayerStreamers/" + options.PathSid + "/PlaybackGrant", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. - /// - /// Fetch PlaybackGrant parameters - /// Client to make requests to Twilio - /// A single instance of PlaybackGrant - public static PlaybackGrantResource Fetch(FetchPlaybackGrantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. - /// - /// Fetch PlaybackGrant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlaybackGrant - public static async System.Threading.Tasks.Task FetchAsync(FetchPlaybackGrantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of PlaybackGrant - public static PlaybackGrantResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPlaybackGrantOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlaybackGrant - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPlaybackGrantOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PlaybackGrantResource object - /// - /// Raw JSON string - /// PlaybackGrantResource object represented by the provided JSON - public static PlaybackGrantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The grant that authorizes the player sdk to connect to the livestream - /// - [JsonProperty("grant")] - public object Grant { get; private set; } - - private PlaybackGrantResource() - { - - } - } +{ + + public class PlaybackGrantResource : Resource + { + private static Request BuildCreateRequest(CreatePlaybackGrantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Media, + "/v1/PlayerStreamers/" + options.PathSid + "/PlaybackGrant", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create PlaybackGrant parameters + /// Client to make requests to Twilio + /// A single instance of PlaybackGrant + public static PlaybackGrantResource Create(CreatePlaybackGrantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create PlaybackGrant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlaybackGrant + public static async System.Threading.Tasks.Task CreateAsync(CreatePlaybackGrantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. + /// + /// The time to live of the PlaybackGrant + /// The full URL that is authorized to play back the livestream + /// Client to make requests to Twilio + /// A single instance of PlaybackGrant + public static PlaybackGrantResource Create(string pathSid, + int? ttl = null, + string accessControlAllowOrigin = null, + ITwilioRestClient client = null) + { + var options = new CreatePlaybackGrantOptions(pathSid) { Ttl = ttl, AccessControlAllowOrigin = accessControlAllowOrigin }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. + /// + /// The time to live of the PlaybackGrant + /// The full URL that is authorized to play back the livestream + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlaybackGrant + public static async System.Threading.Tasks.Task CreateAsync(string pathSid, + int? ttl = null, + string accessControlAllowOrigin = null, + ITwilioRestClient client = null) + { + var options = new CreatePlaybackGrantOptions(pathSid) { Ttl = ttl, AccessControlAllowOrigin = accessControlAllowOrigin }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchPlaybackGrantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Media, + "/v1/PlayerStreamers/" + options.PathSid + "/PlaybackGrant", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// + /// Fetch PlaybackGrant parameters + /// Client to make requests to Twilio + /// A single instance of PlaybackGrant + public static PlaybackGrantResource Fetch(FetchPlaybackGrantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// + /// Fetch PlaybackGrant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlaybackGrant + public static async System.Threading.Tasks.Task FetchAsync(FetchPlaybackGrantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of PlaybackGrant + public static PlaybackGrantResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPlaybackGrantOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// **This method is not enabled.** Returns a single PlaybackGrant resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlaybackGrant + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPlaybackGrantOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PlaybackGrantResource object + /// + /// Raw JSON string + /// PlaybackGrantResource object represented by the provided JSON + public static PlaybackGrantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the PlayerStreamer associated with this PlaybackGrant. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The grant that authorizes the player sdk to connect to the livestream + /// + [JsonProperty("grant")] + public object Grant { get; private set; } + + private PlaybackGrantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/PlayerStreamerOptions.cs b/src/Twilio/Rest/Media/V1/PlayerStreamerOptions.cs index 948836538..17a1923d4 100644 --- a/src/Twilio/Rest/Media/V1/PlayerStreamerOptions.cs +++ b/src/Twilio/Rest/Media/V1/PlayerStreamerOptions.cs @@ -9,157 +9,157 @@ using Twilio.Converters; namespace Twilio.Rest.Media.V1 -{ - +{ + + /// + /// Returns a single PlayerStreamer resource identified by a SID. + /// + public class FetchPlayerStreamerOptions : IOptions + { /// - /// Returns a single PlayerStreamer resource identified by a SID. + /// The SID that identifies the resource to fetch /// - public class FetchPlayerStreamerOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPlayerStreamerOptions - /// - /// The SID that identifies the resource to fetch - public FetchPlayerStreamerOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreatePlayerStreamerOptions + /// Construct a new FetchPlayerStreamerOptions /// - public class CreatePlayerStreamerOptions : IOptions - { - /// - /// Whether the PlayerStreamer is configured to stream video - /// - public bool? Video { get; set; } - /// - /// The URL to which Twilio will send PlayerStreamer event updates - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method Twilio should use to call the `status_callback` URL - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Video != null) - { - p.Add(new KeyValuePair("Video", Video.Value.ToString().ToLower())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + public FetchPlayerStreamerOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Updates a PlayerStreamer resource identified by a SID. + /// Generate the necessary parameters /// - public class UpdatePlayerStreamerOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The status the PlayerStreamer should be transitioned to - /// - public PlayerStreamerResource.UpdateStatusEnum Status { get; } - - /// - /// Construct a new UpdatePlayerStreamerOptions - /// - /// The SID that identifies the resource to update - /// The status the PlayerStreamer should be transitioned to - public UpdatePlayerStreamerOptions(string pathSid, PlayerStreamerResource.UpdateStatusEnum status) - { - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreatePlayerStreamerOptions + /// + public class CreatePlayerStreamerOptions : IOptions + { /// - /// Returns a list of PlayerStreamers. + /// Whether the PlayerStreamer is configured to stream video /// - public class ReadPlayerStreamerOptions : ReadOptions - { - /// - /// The sort order of the list - /// - public PlayerStreamerResource.OrderEnum Order { get; set; } - /// - /// Status to filter by - /// - public PlayerStreamerResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public bool? Video { get; set; } + /// + /// The URL to which Twilio will send PlayerStreamer event updates + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method Twilio should use to call the `status_callback` URL + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Video != null) + { + p.Add(new KeyValuePair("Video", Video.Value.ToString().ToLower())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + return p; + } + } + + /// + /// Updates a PlayerStreamer resource identified by a SID. + /// + public class UpdatePlayerStreamerOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The status the PlayerStreamer should be transitioned to + /// + public PlayerStreamerResource.UpdateStatusEnum Status { get; } + + /// + /// Construct a new UpdatePlayerStreamerOptions + /// + /// The SID that identifies the resource to update + /// The status the PlayerStreamer should be transitioned to + public UpdatePlayerStreamerOptions(string pathSid, PlayerStreamerResource.UpdateStatusEnum status) + { + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } + + /// + /// Returns a list of PlayerStreamers. + /// + public class ReadPlayerStreamerOptions : ReadOptions + { + /// + /// The sort order of the list + /// + public PlayerStreamerResource.OrderEnum Order { get; set; } + /// + /// Status to filter by + /// + public PlayerStreamerResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Media/V1/PlayerStreamerResource.cs b/src/Twilio/Rest/Media/V1/PlayerStreamerResource.cs index a730536e1..b4054bc59 100644 --- a/src/Twilio/Rest/Media/V1/PlayerStreamerResource.cs +++ b/src/Twilio/Rest/Media/V1/PlayerStreamerResource.cs @@ -17,499 +17,499 @@ using Twilio.Types; namespace Twilio.Rest.Media.V1 -{ - - public class PlayerStreamerResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Created = new StatusEnum("created"); - public static readonly StatusEnum Started = new StatusEnum("started"); - public static readonly StatusEnum Ended = new StatusEnum("ended"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class UpdateStatusEnum : StringEnum - { - private UpdateStatusEnum(string value) : base(value) {} - public UpdateStatusEnum() {} - public static implicit operator UpdateStatusEnum(string value) - { - return new UpdateStatusEnum(value); - } - - public static readonly UpdateStatusEnum Ended = new UpdateStatusEnum("ended"); - } - - public sealed class OrderEnum : StringEnum - { - private OrderEnum(string value) : base(value) {} - public OrderEnum() {} - public static implicit operator OrderEnum(string value) - { - return new OrderEnum(value); - } - - public static readonly OrderEnum Asc = new OrderEnum("asc"); - public static readonly OrderEnum Desc = new OrderEnum("desc"); - } - - public sealed class EndedReasonEnum : StringEnum - { - private EndedReasonEnum(string value) : base(value) {} - public EndedReasonEnum() {} - public static implicit operator EndedReasonEnum(string value) - { - return new EndedReasonEnum(value); - } - - public static readonly EndedReasonEnum EndedViaApi = new EndedReasonEnum("ended-via-api"); - public static readonly EndedReasonEnum MaxDurationExceeded = new EndedReasonEnum("max-duration-exceeded"); - public static readonly EndedReasonEnum StreamDisconnectedBySource = new EndedReasonEnum("stream-disconnected-by-source"); - public static readonly EndedReasonEnum UnexpectedFailure = new EndedReasonEnum("unexpected-failure"); - } - - private static Request BuildFetchRequest(FetchPlayerStreamerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Media, - "/v1/PlayerStreamers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single PlayerStreamer resource identified by a SID. - /// - /// Fetch PlayerStreamer parameters - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Fetch(FetchPlayerStreamerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single PlayerStreamer resource identified by a SID. - /// - /// Fetch PlayerStreamer parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task FetchAsync(FetchPlayerStreamerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single PlayerStreamer resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPlayerStreamerOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single PlayerStreamer resource identified by a SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPlayerStreamerOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreatePlayerStreamerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Media, - "/v1/PlayerStreamers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create PlayerStreamer parameters - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Create(CreatePlayerStreamerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create PlayerStreamer parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task CreateAsync(CreatePlayerStreamerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// Whether the PlayerStreamer is configured to stream video - /// The URL to which Twilio will send PlayerStreamer event updates - /// The HTTP method Twilio should use to call the `status_callback` URL - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Create(bool? video = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreatePlayerStreamerOptions(){Video = video, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// Whether the PlayerStreamer is configured to stream video - /// The URL to which Twilio will send PlayerStreamer event updates - /// The HTTP method Twilio should use to call the `status_callback` URL - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task CreateAsync(bool? video = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreatePlayerStreamerOptions(){Video = video, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdatePlayerStreamerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Media, - "/v1/PlayerStreamers/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a PlayerStreamer resource identified by a SID. - /// - /// Update PlayerStreamer parameters - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Update(UpdatePlayerStreamerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a PlayerStreamer resource identified by a SID. - /// - /// Update PlayerStreamer parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task UpdateAsync(UpdatePlayerStreamerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a PlayerStreamer resource identified by a SID. - /// - /// The SID that identifies the resource to update - /// The status the PlayerStreamer should be transitioned to - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static PlayerStreamerResource Update(string pathSid, - PlayerStreamerResource.UpdateStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdatePlayerStreamerOptions(pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a PlayerStreamer resource identified by a SID. - /// - /// The SID that identifies the resource to update - /// The status the PlayerStreamer should be transitioned to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - PlayerStreamerResource.UpdateStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdatePlayerStreamerOptions(pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPlayerStreamerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Media, - "/v1/PlayerStreamers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of PlayerStreamers. - /// - /// Read PlayerStreamer parameters - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static ResourceSet Read(ReadPlayerStreamerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("player_streamers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Returns a list of PlayerStreamers. - /// - /// Read PlayerStreamer parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task> ReadAsync(ReadPlayerStreamerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("player_streamers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Returns a list of PlayerStreamers. - /// - /// The sort order of the list - /// Status to filter by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PlayerStreamer - public static ResourceSet Read(PlayerStreamerResource.OrderEnum order = null, - PlayerStreamerResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPlayerStreamerOptions(){Order = order, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Returns a list of PlayerStreamers. - /// - /// The sort order of the list - /// Status to filter by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PlayerStreamer - public static async System.Threading.Tasks.Task> ReadAsync(PlayerStreamerResource.OrderEnum order = null, - PlayerStreamerResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPlayerStreamerOptions(){Order = order, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("player_streamers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Media) - ); - - var response = client.Request(request); - return Page.FromJson("player_streamers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Media) - ); - - var response = client.Request(request); - return Page.FromJson("player_streamers", response.Content); - } - - /// - /// Converts a JSON string into a PlayerStreamerResource object - /// - /// Raw JSON string - /// PlayerStreamerResource object represented by the provided JSON - public static PlayerStreamerResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Whether the PlayerStreamer is configured to stream video - /// - [JsonProperty("video")] - public bool? Video { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the PlayerStreamer - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public PlayerStreamerResource.StatusEnum Status { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URL to which Twilio will send PlayerStreamer event updates - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method Twilio should use to call the `status_callback` URL - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The reason why a PlayerStreamer ended - /// - [JsonProperty("ended_reason")] - [JsonConverter(typeof(StringEnumConverter))] - public PlayerStreamerResource.EndedReasonEnum EndedReason { get; private set; } - - private PlayerStreamerResource() - { - - } - } +{ + + public class PlayerStreamerResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Created = new StatusEnum("created"); + public static readonly StatusEnum Started = new StatusEnum("started"); + public static readonly StatusEnum Ended = new StatusEnum("ended"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class UpdateStatusEnum : StringEnum + { + private UpdateStatusEnum(string value) : base(value) { } + public UpdateStatusEnum() { } + public static implicit operator UpdateStatusEnum(string value) + { + return new UpdateStatusEnum(value); + } + + public static readonly UpdateStatusEnum Ended = new UpdateStatusEnum("ended"); + } + + public sealed class OrderEnum : StringEnum + { + private OrderEnum(string value) : base(value) { } + public OrderEnum() { } + public static implicit operator OrderEnum(string value) + { + return new OrderEnum(value); + } + + public static readonly OrderEnum Asc = new OrderEnum("asc"); + public static readonly OrderEnum Desc = new OrderEnum("desc"); + } + + public sealed class EndedReasonEnum : StringEnum + { + private EndedReasonEnum(string value) : base(value) { } + public EndedReasonEnum() { } + public static implicit operator EndedReasonEnum(string value) + { + return new EndedReasonEnum(value); + } + + public static readonly EndedReasonEnum EndedViaApi = new EndedReasonEnum("ended-via-api"); + public static readonly EndedReasonEnum MaxDurationExceeded = new EndedReasonEnum("max-duration-exceeded"); + public static readonly EndedReasonEnum StreamDisconnectedBySource = new EndedReasonEnum("stream-disconnected-by-source"); + public static readonly EndedReasonEnum UnexpectedFailure = new EndedReasonEnum("unexpected-failure"); + } + + private static Request BuildFetchRequest(FetchPlayerStreamerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Media, + "/v1/PlayerStreamers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single PlayerStreamer resource identified by a SID. + /// + /// Fetch PlayerStreamer parameters + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Fetch(FetchPlayerStreamerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single PlayerStreamer resource identified by a SID. + /// + /// Fetch PlayerStreamer parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task FetchAsync(FetchPlayerStreamerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single PlayerStreamer resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPlayerStreamerOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single PlayerStreamer resource identified by a SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPlayerStreamerOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreatePlayerStreamerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Media, + "/v1/PlayerStreamers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create PlayerStreamer parameters + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Create(CreatePlayerStreamerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create PlayerStreamer parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task CreateAsync(CreatePlayerStreamerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// Whether the PlayerStreamer is configured to stream video + /// The URL to which Twilio will send PlayerStreamer event updates + /// The HTTP method Twilio should use to call the `status_callback` URL + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Create(bool? video = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreatePlayerStreamerOptions() { Video = video, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// Whether the PlayerStreamer is configured to stream video + /// The URL to which Twilio will send PlayerStreamer event updates + /// The HTTP method Twilio should use to call the `status_callback` URL + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task CreateAsync(bool? video = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreatePlayerStreamerOptions() { Video = video, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdatePlayerStreamerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Media, + "/v1/PlayerStreamers/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a PlayerStreamer resource identified by a SID. + /// + /// Update PlayerStreamer parameters + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Update(UpdatePlayerStreamerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a PlayerStreamer resource identified by a SID. + /// + /// Update PlayerStreamer parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task UpdateAsync(UpdatePlayerStreamerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a PlayerStreamer resource identified by a SID. + /// + /// The SID that identifies the resource to update + /// The status the PlayerStreamer should be transitioned to + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static PlayerStreamerResource Update(string pathSid, + PlayerStreamerResource.UpdateStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdatePlayerStreamerOptions(pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a PlayerStreamer resource identified by a SID. + /// + /// The SID that identifies the resource to update + /// The status the PlayerStreamer should be transitioned to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + PlayerStreamerResource.UpdateStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdatePlayerStreamerOptions(pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPlayerStreamerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Media, + "/v1/PlayerStreamers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of PlayerStreamers. + /// + /// Read PlayerStreamer parameters + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static ResourceSet Read(ReadPlayerStreamerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("player_streamers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Returns a list of PlayerStreamers. + /// + /// Read PlayerStreamer parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task> ReadAsync(ReadPlayerStreamerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("player_streamers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Returns a list of PlayerStreamers. + /// + /// The sort order of the list + /// Status to filter by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PlayerStreamer + public static ResourceSet Read(PlayerStreamerResource.OrderEnum order = null, + PlayerStreamerResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPlayerStreamerOptions() { Order = order, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Returns a list of PlayerStreamers. + /// + /// The sort order of the list + /// Status to filter by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PlayerStreamer + public static async System.Threading.Tasks.Task> ReadAsync(PlayerStreamerResource.OrderEnum order = null, + PlayerStreamerResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPlayerStreamerOptions() { Order = order, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("player_streamers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Media) + ); + + var response = client.Request(request); + return Page.FromJson("player_streamers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Media) + ); + + var response = client.Request(request); + return Page.FromJson("player_streamers", response.Content); + } + + /// + /// Converts a JSON string into a PlayerStreamerResource object + /// + /// Raw JSON string + /// PlayerStreamerResource object represented by the provided JSON + public static PlayerStreamerResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Whether the PlayerStreamer is configured to stream video + /// + [JsonProperty("video")] + public bool? Video { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the PlayerStreamer + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public PlayerStreamerResource.StatusEnum Status { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URL to which Twilio will send PlayerStreamer event updates + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method Twilio should use to call the `status_callback` URL + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The reason why a PlayerStreamer ended + /// + [JsonProperty("ended_reason")] + [JsonConverter(typeof(StringEnumConverter))] + public PlayerStreamerResource.EndedReasonEnum EndedReason { get; private set; } + + private PlayerStreamerResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingOptions.cs b/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingOptions.cs index 335bf0225..9913d3f9a 100644 --- a/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingOptions.cs @@ -9,139 +9,139 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.BrandRegistration -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateBrandVettingOptions + /// + public class CreateBrandVettingOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateBrandVettingOptions + /// A2P BrandRegistration Sid /// - public class CreateBrandVettingOptions : IOptions - { - /// - /// A2P BrandRegistration Sid - /// - public string PathBrandSid { get; } - /// - /// Third-party provider of the vettings to create - /// - public BrandVettingResource.VettingProviderEnum VettingProvider { get; } - /// - /// The unique ID of the vetting - /// - public string VettingId { get; set; } - - /// - /// Construct a new CreateBrandVettingOptions - /// - /// A2P BrandRegistration Sid - /// Third-party provider of the vettings to create - public CreateBrandVettingOptions(string pathBrandSid, BrandVettingResource.VettingProviderEnum vettingProvider) - { - PathBrandSid = pathBrandSid; - VettingProvider = vettingProvider; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (VettingProvider != null) - { - p.Add(new KeyValuePair("VettingProvider", VettingProvider.ToString())); - } - - if (VettingId != null) - { - p.Add(new KeyValuePair("VettingId", VettingId)); - } - - return p; - } - } - + public string PathBrandSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadBrandVettingOptions + /// Third-party provider of the vettings to create /// - public class ReadBrandVettingOptions : ReadOptions - { - /// - /// A2P BrandRegistration Sid - /// - public string PathBrandSid { get; } - /// - /// Third-party provider of the vettings to create - /// - public BrandVettingResource.VettingProviderEnum VettingProvider { get; set; } - - /// - /// Construct a new ReadBrandVettingOptions - /// - /// A2P BrandRegistration Sid - public ReadBrandVettingOptions(string pathBrandSid) - { - PathBrandSid = pathBrandSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (VettingProvider != null) - { - p.Add(new KeyValuePair("VettingProvider", VettingProvider.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public BrandVettingResource.VettingProviderEnum VettingProvider { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchBrandVettingOptions + /// The unique ID of the vetting /// - public class FetchBrandVettingOptions : IOptions - { - /// - /// A2P BrandRegistration Sid - /// - public string PathBrandSid { get; } - /// - /// SID for third-party vetting record - /// - public string PathBrandVettingSid { get; } - - /// - /// Construct a new FetchBrandVettingOptions - /// - /// A2P BrandRegistration Sid - /// SID for third-party vetting record - public FetchBrandVettingOptions(string pathBrandSid, string pathBrandVettingSid) - { - PathBrandSid = pathBrandSid; - PathBrandVettingSid = pathBrandVettingSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string VettingId { get; set; } + + /// + /// Construct a new CreateBrandVettingOptions + /// + /// A2P BrandRegistration Sid + /// Third-party provider of the vettings to create + public CreateBrandVettingOptions(string pathBrandSid, BrandVettingResource.VettingProviderEnum vettingProvider) + { + PathBrandSid = pathBrandSid; + VettingProvider = vettingProvider; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (VettingProvider != null) + { + p.Add(new KeyValuePair("VettingProvider", VettingProvider.ToString())); + } + + if (VettingId != null) + { + p.Add(new KeyValuePair("VettingId", VettingId)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadBrandVettingOptions + /// + public class ReadBrandVettingOptions : ReadOptions + { + /// + /// A2P BrandRegistration Sid + /// + public string PathBrandSid { get; } + /// + /// Third-party provider of the vettings to create + /// + public BrandVettingResource.VettingProviderEnum VettingProvider { get; set; } + + /// + /// Construct a new ReadBrandVettingOptions + /// + /// A2P BrandRegistration Sid + public ReadBrandVettingOptions(string pathBrandSid) + { + PathBrandSid = pathBrandSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (VettingProvider != null) + { + p.Add(new KeyValuePair("VettingProvider", VettingProvider.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchBrandVettingOptions + /// + public class FetchBrandVettingOptions : IOptions + { + /// + /// A2P BrandRegistration Sid + /// + public string PathBrandSid { get; } + /// + /// SID for third-party vetting record + /// + public string PathBrandVettingSid { get; } + + /// + /// Construct a new FetchBrandVettingOptions + /// + /// A2P BrandRegistration Sid + /// SID for third-party vetting record + public FetchBrandVettingOptions(string pathBrandSid, string pathBrandVettingSid) + { + PathBrandSid = pathBrandSid; + PathBrandVettingSid = pathBrandVettingSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingResource.cs b/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingResource.cs index 25e680912..b40ba68b2 100644 --- a/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingResource.cs +++ b/src/Twilio/Rest/Messaging/V1/BrandRegistration/BrandVettingResource.cs @@ -19,382 +19,382 @@ using Twilio.Types; namespace Twilio.Rest.Messaging.V1.BrandRegistration -{ - - public class BrandVettingResource : Resource - { - public sealed class VettingProviderEnum : StringEnum - { - private VettingProviderEnum(string value) : base(value) {} - public VettingProviderEnum() {} - public static implicit operator VettingProviderEnum(string value) - { - return new VettingProviderEnum(value); - } - - public static readonly VettingProviderEnum CampaignVerify = new VettingProviderEnum("campaign-verify"); - } - - private static Request BuildCreateRequest(CreateBrandVettingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create BrandVetting parameters - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static BrandVettingResource Create(CreateBrandVettingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create BrandVetting parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task CreateAsync(CreateBrandVettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A2P BrandRegistration Sid - /// Third-party provider of the vettings to create - /// The unique ID of the vetting - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static BrandVettingResource Create(string pathBrandSid, - BrandVettingResource.VettingProviderEnum vettingProvider, - string vettingId = null, - ITwilioRestClient client = null) - { - var options = new CreateBrandVettingOptions(pathBrandSid, vettingProvider){VettingId = vettingId}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A2P BrandRegistration Sid - /// Third-party provider of the vettings to create - /// The unique ID of the vetting - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task CreateAsync(string pathBrandSid, - BrandVettingResource.VettingProviderEnum vettingProvider, - string vettingId = null, - ITwilioRestClient client = null) - { - var options = new CreateBrandVettingOptions(pathBrandSid, vettingProvider){VettingId = vettingId}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBrandVettingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read BrandVetting parameters - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static ResourceSet Read(ReadBrandVettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("data", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read BrandVetting parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task> ReadAsync(ReadBrandVettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("data", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// A2P BrandRegistration Sid - /// Third-party provider of the vettings to create - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static ResourceSet Read(string pathBrandSid, - BrandVettingResource.VettingProviderEnum vettingProvider = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBrandVettingOptions(pathBrandSid){VettingProvider = vettingProvider, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// A2P BrandRegistration Sid - /// Third-party provider of the vettings to create - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task> ReadAsync(string pathBrandSid, - BrandVettingResource.VettingProviderEnum vettingProvider = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBrandVettingOptions(pathBrandSid){VettingProvider = vettingProvider, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - private static Request BuildFetchRequest(FetchBrandVettingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings/" + options.PathBrandVettingSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch BrandVetting parameters - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static BrandVettingResource Fetch(FetchBrandVettingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch BrandVetting parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task FetchAsync(FetchBrandVettingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// A2P BrandRegistration Sid - /// SID for third-party vetting record - /// Client to make requests to Twilio - /// A single instance of BrandVetting - public static BrandVettingResource Fetch(string pathBrandSid, - string pathBrandVettingSid, - ITwilioRestClient client = null) - { - var options = new FetchBrandVettingOptions(pathBrandSid, pathBrandVettingSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// A2P BrandRegistration Sid - /// SID for third-party vetting record - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandVetting - public static async System.Threading.Tasks.Task FetchAsync(string pathBrandSid, - string pathBrandVettingSid, - ITwilioRestClient client = null) - { - var options = new FetchBrandVettingOptions(pathBrandSid, pathBrandVettingSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BrandVettingResource object - /// - /// Raw JSON string - /// BrandVettingResource object represented by the provided JSON - public static BrandVettingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the vetting - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A2P BrandRegistration Sid - /// - [JsonProperty("brand_sid")] - public string BrandSid { get; private set; } - /// - /// SID for third-party vetting record - /// - [JsonProperty("brand_vetting_sid")] - public string BrandVettingSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The unique ID of the vetting - /// - [JsonProperty("vetting_id")] - public string VettingId { get; private set; } - /// - /// The type of vetting - /// - [JsonProperty("vetting_class")] - public string VettingClass { get; private set; } - /// - /// Status of vetting attempt - /// - [JsonProperty("vetting_status")] - public string VettingStatus { get; private set; } - /// - /// Third-party provider that has conducted the vetting - /// - [JsonProperty("vetting_provider")] - [JsonConverter(typeof(StringEnumConverter))] - public BrandVettingResource.VettingProviderEnum VettingProvider { get; private set; } - /// - /// The absolute URL of the Brand Vetting - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private BrandVettingResource() - { - - } - } +{ + + public class BrandVettingResource : Resource + { + public sealed class VettingProviderEnum : StringEnum + { + private VettingProviderEnum(string value) : base(value) { } + public VettingProviderEnum() { } + public static implicit operator VettingProviderEnum(string value) + { + return new VettingProviderEnum(value); + } + + public static readonly VettingProviderEnum CampaignVerify = new VettingProviderEnum("campaign-verify"); + } + + private static Request BuildCreateRequest(CreateBrandVettingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create BrandVetting parameters + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static BrandVettingResource Create(CreateBrandVettingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create BrandVetting parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task CreateAsync(CreateBrandVettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A2P BrandRegistration Sid + /// Third-party provider of the vettings to create + /// The unique ID of the vetting + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static BrandVettingResource Create(string pathBrandSid, + BrandVettingResource.VettingProviderEnum vettingProvider, + string vettingId = null, + ITwilioRestClient client = null) + { + var options = new CreateBrandVettingOptions(pathBrandSid, vettingProvider) { VettingId = vettingId }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A2P BrandRegistration Sid + /// Third-party provider of the vettings to create + /// The unique ID of the vetting + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task CreateAsync(string pathBrandSid, + BrandVettingResource.VettingProviderEnum vettingProvider, + string vettingId = null, + ITwilioRestClient client = null) + { + var options = new CreateBrandVettingOptions(pathBrandSid, vettingProvider) { VettingId = vettingId }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBrandVettingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read BrandVetting parameters + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static ResourceSet Read(ReadBrandVettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("data", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read BrandVetting parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task> ReadAsync(ReadBrandVettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("data", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// A2P BrandRegistration Sid + /// Third-party provider of the vettings to create + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static ResourceSet Read(string pathBrandSid, + BrandVettingResource.VettingProviderEnum vettingProvider = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBrandVettingOptions(pathBrandSid) { VettingProvider = vettingProvider, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// A2P BrandRegistration Sid + /// Third-party provider of the vettings to create + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task> ReadAsync(string pathBrandSid, + BrandVettingResource.VettingProviderEnum vettingProvider = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBrandVettingOptions(pathBrandSid) { VettingProvider = vettingProvider, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + private static Request BuildFetchRequest(FetchBrandVettingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations/" + options.PathBrandSid + "/Vettings/" + options.PathBrandVettingSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch BrandVetting parameters + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static BrandVettingResource Fetch(FetchBrandVettingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch BrandVetting parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task FetchAsync(FetchBrandVettingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// A2P BrandRegistration Sid + /// SID for third-party vetting record + /// Client to make requests to Twilio + /// A single instance of BrandVetting + public static BrandVettingResource Fetch(string pathBrandSid, + string pathBrandVettingSid, + ITwilioRestClient client = null) + { + var options = new FetchBrandVettingOptions(pathBrandSid, pathBrandVettingSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// A2P BrandRegistration Sid + /// SID for third-party vetting record + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandVetting + public static async System.Threading.Tasks.Task FetchAsync(string pathBrandSid, + string pathBrandVettingSid, + ITwilioRestClient client = null) + { + var options = new FetchBrandVettingOptions(pathBrandSid, pathBrandVettingSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BrandVettingResource object + /// + /// Raw JSON string + /// BrandVettingResource object represented by the provided JSON + public static BrandVettingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the vetting + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A2P BrandRegistration Sid + /// + [JsonProperty("brand_sid")] + public string BrandSid { get; private set; } + /// + /// SID for third-party vetting record + /// + [JsonProperty("brand_vetting_sid")] + public string BrandVettingSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The unique ID of the vetting + /// + [JsonProperty("vetting_id")] + public string VettingId { get; private set; } + /// + /// The type of vetting + /// + [JsonProperty("vetting_class")] + public string VettingClass { get; private set; } + /// + /// Status of vetting attempt + /// + [JsonProperty("vetting_status")] + public string VettingStatus { get; private set; } + /// + /// Third-party provider that has conducted the vetting + /// + [JsonProperty("vetting_provider")] + [JsonConverter(typeof(StringEnumConverter))] + public BrandVettingResource.VettingProviderEnum VettingProvider { get; private set; } + /// + /// The absolute URL of the Brand Vetting + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private BrandVettingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/BrandRegistrationOptions.cs b/src/Twilio/Rest/Messaging/V1/BrandRegistrationOptions.cs index c873f3102..a0a1e226f 100644 --- a/src/Twilio/Rest/Messaging/V1/BrandRegistrationOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/BrandRegistrationOptions.cs @@ -9,133 +9,133 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchBrandRegistrationOptions + /// + public class FetchBrandRegistrationOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchBrandRegistrationOptions + /// The SID that identifies the resource to fetch /// - public class FetchBrandRegistrationOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBrandRegistrationOptions - /// - /// The SID that identifies the resource to fetch - public FetchBrandRegistrationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadBrandRegistrationOptions + /// Construct a new FetchBrandRegistrationOptions /// - public class ReadBrandRegistrationOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + public FetchBrandRegistrationOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateBrandRegistrationOptions + /// Generate the necessary parameters /// - public class CreateBrandRegistrationOptions : IOptions - { - /// - /// Customer Profile Bundle Sid - /// - public string CustomerProfileBundleSid { get; } - /// - /// A2P Messaging Profile Bundle Sid - /// - public string A2PProfileBundleSid { get; } - /// - /// Type of brand being created. One of: "STANDARD", "STARTER". - /// - public string BrandType { get; set; } - /// - /// A boolean that specifies whether brand should be a mock or not. If true, brand will be registered as a mock brand. Defaults to false if no value is provided. - /// - public bool? Mock { get; set; } - /// - /// Skip Automatic Secondary Vetting - /// - public bool? SkipAutomaticSecVet { get; set; } - - /// - /// Construct a new CreateBrandRegistrationOptions - /// - /// Customer Profile Bundle Sid - /// A2P Messaging Profile Bundle Sid - public CreateBrandRegistrationOptions(string customerProfileBundleSid, string a2PProfileBundleSid) - { - CustomerProfileBundleSid = customerProfileBundleSid; - A2PProfileBundleSid = a2PProfileBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CustomerProfileBundleSid != null) - { - p.Add(new KeyValuePair("CustomerProfileBundleSid", CustomerProfileBundleSid.ToString())); - } - - if (A2PProfileBundleSid != null) - { - p.Add(new KeyValuePair("A2PProfileBundleSid", A2PProfileBundleSid.ToString())); - } - - if (BrandType != null) - { - p.Add(new KeyValuePair("BrandType", BrandType)); - } - - if (Mock != null) - { - p.Add(new KeyValuePair("Mock", Mock.Value.ToString().ToLower())); - } - - if (SkipAutomaticSecVet != null) - { - p.Add(new KeyValuePair("SkipAutomaticSecVet", SkipAutomaticSecVet.Value.ToString().ToLower())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadBrandRegistrationOptions + /// + public class ReadBrandRegistrationOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateBrandRegistrationOptions + /// + public class CreateBrandRegistrationOptions : IOptions + { + /// + /// Customer Profile Bundle Sid + /// + public string CustomerProfileBundleSid { get; } + /// + /// A2P Messaging Profile Bundle Sid + /// + public string A2PProfileBundleSid { get; } + /// + /// Type of brand being created. One of: "STANDARD", "STARTER". + /// + public string BrandType { get; set; } + /// + /// A boolean that specifies whether brand should be a mock or not. If true, brand will be registered as a mock brand. Defaults to false if no value is provided. + /// + public bool? Mock { get; set; } + /// + /// Skip Automatic Secondary Vetting + /// + public bool? SkipAutomaticSecVet { get; set; } + + /// + /// Construct a new CreateBrandRegistrationOptions + /// + /// Customer Profile Bundle Sid + /// A2P Messaging Profile Bundle Sid + public CreateBrandRegistrationOptions(string customerProfileBundleSid, string a2PProfileBundleSid) + { + CustomerProfileBundleSid = customerProfileBundleSid; + A2PProfileBundleSid = a2PProfileBundleSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CustomerProfileBundleSid != null) + { + p.Add(new KeyValuePair("CustomerProfileBundleSid", CustomerProfileBundleSid.ToString())); + } + + if (A2PProfileBundleSid != null) + { + p.Add(new KeyValuePair("A2PProfileBundleSid", A2PProfileBundleSid.ToString())); + } + + if (BrandType != null) + { + p.Add(new KeyValuePair("BrandType", BrandType)); + } + + if (Mock != null) + { + p.Add(new KeyValuePair("Mock", Mock.Value.ToString().ToLower())); + } + + if (SkipAutomaticSecVet != null) + { + p.Add(new KeyValuePair("SkipAutomaticSecVet", SkipAutomaticSecVet.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/BrandRegistrationResource.cs b/src/Twilio/Rest/Messaging/V1/BrandRegistrationResource.cs index 5ff183184..6e7445d49 100644 --- a/src/Twilio/Rest/Messaging/V1/BrandRegistrationResource.cs +++ b/src/Twilio/Rest/Messaging/V1/BrandRegistrationResource.cs @@ -19,464 +19,464 @@ using Twilio.Types; namespace Twilio.Rest.Messaging.V1 -{ - - public class BrandRegistrationResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Pending = new StatusEnum("PENDING"); - public static readonly StatusEnum Approved = new StatusEnum("APPROVED"); - public static readonly StatusEnum Failed = new StatusEnum("FAILED"); - public static readonly StatusEnum InReview = new StatusEnum("IN_REVIEW"); - public static readonly StatusEnum Deleted = new StatusEnum("DELETED"); - } - - public sealed class IdentityStatusEnum : StringEnum - { - private IdentityStatusEnum(string value) : base(value) {} - public IdentityStatusEnum() {} - public static implicit operator IdentityStatusEnum(string value) - { - return new IdentityStatusEnum(value); - } - - public static readonly IdentityStatusEnum SelfDeclared = new IdentityStatusEnum("SELF_DECLARED"); - public static readonly IdentityStatusEnum Unverified = new IdentityStatusEnum("UNVERIFIED"); - public static readonly IdentityStatusEnum Verified = new IdentityStatusEnum("VERIFIED"); - public static readonly IdentityStatusEnum VettedVerified = new IdentityStatusEnum("VETTED_VERIFIED"); - } - - public sealed class BrandFeedbackEnum : StringEnum - { - private BrandFeedbackEnum(string value) : base(value) {} - public BrandFeedbackEnum() {} - public static implicit operator BrandFeedbackEnum(string value) - { - return new BrandFeedbackEnum(value); - } - - public static readonly BrandFeedbackEnum TaxId = new BrandFeedbackEnum("TAX_ID"); - public static readonly BrandFeedbackEnum StockSymbol = new BrandFeedbackEnum("STOCK_SYMBOL"); - public static readonly BrandFeedbackEnum Nonprofit = new BrandFeedbackEnum("NONPROFIT"); - public static readonly BrandFeedbackEnum GovernmentEntity = new BrandFeedbackEnum("GOVERNMENT_ENTITY"); - public static readonly BrandFeedbackEnum Others = new BrandFeedbackEnum("OTHERS"); - } - - private static Request BuildFetchRequest(FetchBrandRegistrationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch BrandRegistration parameters - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static BrandRegistrationResource Fetch(FetchBrandRegistrationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch BrandRegistration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task FetchAsync(FetchBrandRegistrationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static BrandRegistrationResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBrandRegistrationOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBrandRegistrationOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBrandRegistrationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read BrandRegistration parameters - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static ResourceSet Read(ReadBrandRegistrationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("data", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read BrandRegistration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task> ReadAsync(ReadBrandRegistrationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("data", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBrandRegistrationOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBrandRegistrationOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("data", response.Content); - } - - private static Request BuildCreateRequest(CreateBrandRegistrationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/a2p/BrandRegistrations", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create BrandRegistration parameters - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static BrandRegistrationResource Create(CreateBrandRegistrationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create BrandRegistration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task CreateAsync(CreateBrandRegistrationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// Customer Profile Bundle Sid - /// A2P Messaging Profile Bundle Sid - /// Type of brand being created. One of: "STANDARD", "STARTER". - /// A boolean that specifies whether brand should be a mock or not. If true, brand will be - /// registered as a mock brand. Defaults to false if no value is provided. - /// Skip Automatic Secondary Vetting - /// Client to make requests to Twilio - /// A single instance of BrandRegistration - public static BrandRegistrationResource Create(string customerProfileBundleSid, - string a2PProfileBundleSid, - string brandType = null, - bool? mock = null, - bool? skipAutomaticSecVet = null, - ITwilioRestClient client = null) - { - var options = new CreateBrandRegistrationOptions(customerProfileBundleSid, a2PProfileBundleSid){BrandType = brandType, Mock = mock, SkipAutomaticSecVet = skipAutomaticSecVet}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// Customer Profile Bundle Sid - /// A2P Messaging Profile Bundle Sid - /// Type of brand being created. One of: "STANDARD", "STARTER". - /// A boolean that specifies whether brand should be a mock or not. If true, brand will be - /// registered as a mock brand. Defaults to false if no value is provided. - /// Skip Automatic Secondary Vetting - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandRegistration - public static async System.Threading.Tasks.Task CreateAsync(string customerProfileBundleSid, - string a2PProfileBundleSid, - string brandType = null, - bool? mock = null, - bool? skipAutomaticSecVet = null, - ITwilioRestClient client = null) - { - var options = new CreateBrandRegistrationOptions(customerProfileBundleSid, a2PProfileBundleSid){BrandType = brandType, Mock = mock, SkipAutomaticSecVet = skipAutomaticSecVet}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BrandRegistrationResource object - /// - /// Raw JSON string - /// BrandRegistrationResource object represented by the provided JSON - public static BrandRegistrationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A2P BrandRegistration Sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A2P Messaging Profile Bundle BundleSid - /// - [JsonProperty("customer_profile_bundle_sid")] - public string CustomerProfileBundleSid { get; private set; } - /// - /// A2P Messaging Profile Bundle BundleSid - /// - [JsonProperty("a2p_profile_bundle_sid")] - public string A2PProfileBundleSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Type of brand. One of: "STANDARD", "STARTER". - /// - [JsonProperty("brand_type")] - public string BrandType { get; private set; } - /// - /// Brand Registration status. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public BrandRegistrationResource.StatusEnum Status { get; private set; } - /// - /// Campaign Registry (TCR) Brand ID - /// - [JsonProperty("tcr_id")] - public string TcrId { get; private set; } - /// - /// A reason why brand registration has failed - /// - [JsonProperty("failure_reason")] - public string FailureReason { get; private set; } - /// - /// The absolute URL of the Brand Registration - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Brand score - /// - [JsonProperty("brand_score")] - public int? BrandScore { get; private set; } - /// - /// Brand feedback - /// - [JsonProperty("brand_feedback")] - [JsonConverter(typeof(StringEnumConverter))] - public List BrandFeedback { get; private set; } - /// - /// Identity Status - /// - [JsonProperty("identity_status")] - [JsonConverter(typeof(StringEnumConverter))] - public BrandRegistrationResource.IdentityStatusEnum IdentityStatus { get; private set; } - /// - /// Russell 3000 - /// - [JsonProperty("russell_3000")] - public bool? Russell3000 { get; private set; } - /// - /// Tax Exempt Status - /// - [JsonProperty("tax_exempt_status")] - public string TaxExemptStatus { get; private set; } - /// - /// Skip Automatic Secondary Vetting - /// - [JsonProperty("skip_automatic_sec_vet")] - public bool? SkipAutomaticSecVet { get; private set; } - /// - /// A boolean that specifies whether brand should be a mock or not. If true, brand will be registered as a mock brand. Defaults to false if no value is provided. - /// - [JsonProperty("mock")] - public bool? Mock { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BrandRegistrationResource() - { - - } - } +{ + + public class BrandRegistrationResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Pending = new StatusEnum("PENDING"); + public static readonly StatusEnum Approved = new StatusEnum("APPROVED"); + public static readonly StatusEnum Failed = new StatusEnum("FAILED"); + public static readonly StatusEnum InReview = new StatusEnum("IN_REVIEW"); + public static readonly StatusEnum Deleted = new StatusEnum("DELETED"); + } + + public sealed class IdentityStatusEnum : StringEnum + { + private IdentityStatusEnum(string value) : base(value) { } + public IdentityStatusEnum() { } + public static implicit operator IdentityStatusEnum(string value) + { + return new IdentityStatusEnum(value); + } + + public static readonly IdentityStatusEnum SelfDeclared = new IdentityStatusEnum("SELF_DECLARED"); + public static readonly IdentityStatusEnum Unverified = new IdentityStatusEnum("UNVERIFIED"); + public static readonly IdentityStatusEnum Verified = new IdentityStatusEnum("VERIFIED"); + public static readonly IdentityStatusEnum VettedVerified = new IdentityStatusEnum("VETTED_VERIFIED"); + } + + public sealed class BrandFeedbackEnum : StringEnum + { + private BrandFeedbackEnum(string value) : base(value) { } + public BrandFeedbackEnum() { } + public static implicit operator BrandFeedbackEnum(string value) + { + return new BrandFeedbackEnum(value); + } + + public static readonly BrandFeedbackEnum TaxId = new BrandFeedbackEnum("TAX_ID"); + public static readonly BrandFeedbackEnum StockSymbol = new BrandFeedbackEnum("STOCK_SYMBOL"); + public static readonly BrandFeedbackEnum Nonprofit = new BrandFeedbackEnum("NONPROFIT"); + public static readonly BrandFeedbackEnum GovernmentEntity = new BrandFeedbackEnum("GOVERNMENT_ENTITY"); + public static readonly BrandFeedbackEnum Others = new BrandFeedbackEnum("OTHERS"); + } + + private static Request BuildFetchRequest(FetchBrandRegistrationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch BrandRegistration parameters + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static BrandRegistrationResource Fetch(FetchBrandRegistrationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch BrandRegistration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task FetchAsync(FetchBrandRegistrationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static BrandRegistrationResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBrandRegistrationOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBrandRegistrationOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBrandRegistrationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read BrandRegistration parameters + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static ResourceSet Read(ReadBrandRegistrationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("data", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read BrandRegistration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task> ReadAsync(ReadBrandRegistrationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("data", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBrandRegistrationOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBrandRegistrationOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("data", response.Content); + } + + private static Request BuildCreateRequest(CreateBrandRegistrationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/a2p/BrandRegistrations", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create BrandRegistration parameters + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static BrandRegistrationResource Create(CreateBrandRegistrationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create BrandRegistration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task CreateAsync(CreateBrandRegistrationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// Customer Profile Bundle Sid + /// A2P Messaging Profile Bundle Sid + /// Type of brand being created. One of: "STANDARD", "STARTER". + /// A boolean that specifies whether brand should be a mock or not. If true, brand will be + /// registered as a mock brand. Defaults to false if no value is provided. + /// Skip Automatic Secondary Vetting + /// Client to make requests to Twilio + /// A single instance of BrandRegistration + public static BrandRegistrationResource Create(string customerProfileBundleSid, + string a2PProfileBundleSid, + string brandType = null, + bool? mock = null, + bool? skipAutomaticSecVet = null, + ITwilioRestClient client = null) + { + var options = new CreateBrandRegistrationOptions(customerProfileBundleSid, a2PProfileBundleSid) { BrandType = brandType, Mock = mock, SkipAutomaticSecVet = skipAutomaticSecVet }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// Customer Profile Bundle Sid + /// A2P Messaging Profile Bundle Sid + /// Type of brand being created. One of: "STANDARD", "STARTER". + /// A boolean that specifies whether brand should be a mock or not. If true, brand will be + /// registered as a mock brand. Defaults to false if no value is provided. + /// Skip Automatic Secondary Vetting + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandRegistration + public static async System.Threading.Tasks.Task CreateAsync(string customerProfileBundleSid, + string a2PProfileBundleSid, + string brandType = null, + bool? mock = null, + bool? skipAutomaticSecVet = null, + ITwilioRestClient client = null) + { + var options = new CreateBrandRegistrationOptions(customerProfileBundleSid, a2PProfileBundleSid) { BrandType = brandType, Mock = mock, SkipAutomaticSecVet = skipAutomaticSecVet }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BrandRegistrationResource object + /// + /// Raw JSON string + /// BrandRegistrationResource object represented by the provided JSON + public static BrandRegistrationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A2P BrandRegistration Sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A2P Messaging Profile Bundle BundleSid + /// + [JsonProperty("customer_profile_bundle_sid")] + public string CustomerProfileBundleSid { get; private set; } + /// + /// A2P Messaging Profile Bundle BundleSid + /// + [JsonProperty("a2p_profile_bundle_sid")] + public string A2PProfileBundleSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Type of brand. One of: "STANDARD", "STARTER". + /// + [JsonProperty("brand_type")] + public string BrandType { get; private set; } + /// + /// Brand Registration status. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public BrandRegistrationResource.StatusEnum Status { get; private set; } + /// + /// Campaign Registry (TCR) Brand ID + /// + [JsonProperty("tcr_id")] + public string TcrId { get; private set; } + /// + /// A reason why brand registration has failed + /// + [JsonProperty("failure_reason")] + public string FailureReason { get; private set; } + /// + /// The absolute URL of the Brand Registration + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Brand score + /// + [JsonProperty("brand_score")] + public int? BrandScore { get; private set; } + /// + /// Brand feedback + /// + [JsonProperty("brand_feedback")] + [JsonConverter(typeof(StringEnumConverter))] + public List BrandFeedback { get; private set; } + /// + /// Identity Status + /// + [JsonProperty("identity_status")] + [JsonConverter(typeof(StringEnumConverter))] + public BrandRegistrationResource.IdentityStatusEnum IdentityStatus { get; private set; } + /// + /// Russell 3000 + /// + [JsonProperty("russell_3000")] + public bool? Russell3000 { get; private set; } + /// + /// Tax Exempt Status + /// + [JsonProperty("tax_exempt_status")] + public string TaxExemptStatus { get; private set; } + /// + /// Skip Automatic Secondary Vetting + /// + [JsonProperty("skip_automatic_sec_vet")] + public bool? SkipAutomaticSecVet { get; private set; } + /// + /// A boolean that specifies whether brand should be a mock or not. If true, brand will be registered as a mock brand. Defaults to false if no value is provided. + /// + [JsonProperty("mock")] + public bool? Mock { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BrandRegistrationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/DeactivationsOptions.cs b/src/Twilio/Rest/Messaging/V1/DeactivationsOptions.cs index 84d3c54ea..8f7eb1dd2 100644 --- a/src/Twilio/Rest/Messaging/V1/DeactivationsOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/DeactivationsOptions.cs @@ -9,31 +9,31 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1 -{ - +{ + + /// + /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// + public class FetchDeactivationsOptions : IOptions + { /// - /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// The date to retrieve deactivated numbers for. /// - public class FetchDeactivationsOptions : IOptions - { - /// - /// The date to retrieve deactivated numbers for. - /// - public DateTime? Date { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Date != null) - { - p.Add(new KeyValuePair("Date", Date.Value.ToString("yyyy-MM-dd"))); - } - - return p; - } - } + public DateTime? Date { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Date != null) + { + p.Add(new KeyValuePair("Date", Date.Value.ToString("yyyy-MM-dd"))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/DeactivationsResource.cs b/src/Twilio/Rest/Messaging/V1/DeactivationsResource.cs index 59707bc4b..3c67ee689 100644 --- a/src/Twilio/Rest/Messaging/V1/DeactivationsResource.cs +++ b/src/Twilio/Rest/Messaging/V1/DeactivationsResource.cs @@ -16,105 +16,105 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1 -{ - - public class DeactivationsResource : Resource - { - private static Request BuildFetchRequest(FetchDeactivationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Deactivations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a list of all United States numbers that have been deactivated on a specific date. - /// - /// Fetch Deactivations parameters - /// Client to make requests to Twilio - /// A single instance of Deactivations - public static DeactivationsResource Fetch(FetchDeactivationsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a list of all United States numbers that have been deactivated on a specific date. - /// - /// Fetch Deactivations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deactivations - public static async System.Threading.Tasks.Task FetchAsync(FetchDeactivationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a list of all United States numbers that have been deactivated on a specific date. - /// - /// The date to retrieve deactivated numbers for. - /// Client to make requests to Twilio - /// A single instance of Deactivations - public static DeactivationsResource Fetch(DateTime? date = null, ITwilioRestClient client = null) - { - var options = new FetchDeactivationsOptions(){Date = date}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a list of all United States numbers that have been deactivated on a specific date. - /// - /// The date to retrieve deactivated numbers for. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deactivations - public static async System.Threading.Tasks.Task FetchAsync(DateTime? date = null, - ITwilioRestClient client = null) - { - var options = new FetchDeactivationsOptions(){Date = date}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DeactivationsResource object - /// - /// Raw JSON string - /// DeactivationsResource object represented by the provided JSON - public static DeactivationsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Redirect url to the list of deactivated numbers. - /// - [JsonProperty("redirect_to")] - public Uri RedirectTo { get; private set; } - - private DeactivationsResource() - { - - } - } +{ + + public class DeactivationsResource : Resource + { + private static Request BuildFetchRequest(FetchDeactivationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Deactivations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// + /// Fetch Deactivations parameters + /// Client to make requests to Twilio + /// A single instance of Deactivations + public static DeactivationsResource Fetch(FetchDeactivationsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// + /// Fetch Deactivations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deactivations + public static async System.Threading.Tasks.Task FetchAsync(FetchDeactivationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// + /// The date to retrieve deactivated numbers for. + /// Client to make requests to Twilio + /// A single instance of Deactivations + public static DeactivationsResource Fetch(DateTime? date = null, ITwilioRestClient client = null) + { + var options = new FetchDeactivationsOptions() { Date = date }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a list of all United States numbers that have been deactivated on a specific date. + /// + /// The date to retrieve deactivated numbers for. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deactivations + public static async System.Threading.Tasks.Task FetchAsync(DateTime? date = null, + ITwilioRestClient client = null) + { + var options = new FetchDeactivationsOptions() { Date = date }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DeactivationsResource object + /// + /// Raw JSON string + /// DeactivationsResource object represented by the provided JSON + public static DeactivationsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Redirect url to the list of deactivated numbers. + /// + [JsonProperty("redirect_to")] + public Uri RedirectTo { get; private set; } + + private DeactivationsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/ExternalCampaignOptions.cs b/src/Twilio/Rest/Messaging/V1/ExternalCampaignOptions.cs index 881e90ca0..5bab964da 100644 --- a/src/Twilio/Rest/Messaging/V1/ExternalCampaignOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/ExternalCampaignOptions.cs @@ -9,53 +9,53 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateExternalCampaignOptions + /// + public class CreateExternalCampaignOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateExternalCampaignOptions + /// ID of the preregistered campaign. /// - public class CreateExternalCampaignOptions : IOptions - { - /// - /// ID of the preregistered campaign. - /// - public string CampaignId { get; } - /// - /// The SID of the Messaging Service the resource is associated with - /// - public string MessagingServiceSid { get; } - - /// - /// Construct a new CreateExternalCampaignOptions - /// - /// ID of the preregistered campaign. - /// The SID of the Messaging Service the resource is associated with - public CreateExternalCampaignOptions(string campaignId, string messagingServiceSid) - { - CampaignId = campaignId; - MessagingServiceSid = messagingServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CampaignId != null) - { - p.Add(new KeyValuePair("CampaignId", CampaignId)); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - return p; - } - } + public string CampaignId { get; } + /// + /// The SID of the Messaging Service the resource is associated with + /// + public string MessagingServiceSid { get; } + + /// + /// Construct a new CreateExternalCampaignOptions + /// + /// ID of the preregistered campaign. + /// The SID of the Messaging Service the resource is associated with + public CreateExternalCampaignOptions(string campaignId, string messagingServiceSid) + { + CampaignId = campaignId; + MessagingServiceSid = messagingServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CampaignId != null) + { + p.Add(new KeyValuePair("CampaignId", CampaignId)); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/ExternalCampaignResource.cs b/src/Twilio/Rest/Messaging/V1/ExternalCampaignResource.cs index c8d63dfef..424e35ed9 100644 --- a/src/Twilio/Rest/Messaging/V1/ExternalCampaignResource.cs +++ b/src/Twilio/Rest/Messaging/V1/ExternalCampaignResource.cs @@ -18,130 +18,130 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1 -{ - - public class ExternalCampaignResource : Resource - { - private static Request BuildCreateRequest(CreateExternalCampaignOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/PreregisteredUsa2p", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ExternalCampaign parameters - /// Client to make requests to Twilio - /// A single instance of ExternalCampaign - public static ExternalCampaignResource Create(CreateExternalCampaignOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ExternalCampaign parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExternalCampaign - public static async System.Threading.Tasks.Task CreateAsync(CreateExternalCampaignOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// ID of the preregistered campaign. - /// The SID of the Messaging Service the resource is associated with - /// Client to make requests to Twilio - /// A single instance of ExternalCampaign - public static ExternalCampaignResource Create(string campaignId, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new CreateExternalCampaignOptions(campaignId, messagingServiceSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// ID of the preregistered campaign. - /// The SID of the Messaging Service the resource is associated with - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExternalCampaign - public static async System.Threading.Tasks.Task CreateAsync(string campaignId, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new CreateExternalCampaignOptions(campaignId, messagingServiceSid); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExternalCampaignResource object - /// - /// Raw JSON string - /// ExternalCampaignResource object represented by the provided JSON - public static ExternalCampaignResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies a US A2P Compliance resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// ID of the preregistered campaign. - /// - [JsonProperty("campaign_id")] - public string CampaignId { get; private set; } - /// - /// The SID of the Messaging Service the resource is associated with - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - - private ExternalCampaignResource() - { - - } - } +{ + + public class ExternalCampaignResource : Resource + { + private static Request BuildCreateRequest(CreateExternalCampaignOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/PreregisteredUsa2p", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ExternalCampaign parameters + /// Client to make requests to Twilio + /// A single instance of ExternalCampaign + public static ExternalCampaignResource Create(CreateExternalCampaignOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ExternalCampaign parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExternalCampaign + public static async System.Threading.Tasks.Task CreateAsync(CreateExternalCampaignOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// ID of the preregistered campaign. + /// The SID of the Messaging Service the resource is associated with + /// Client to make requests to Twilio + /// A single instance of ExternalCampaign + public static ExternalCampaignResource Create(string campaignId, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new CreateExternalCampaignOptions(campaignId, messagingServiceSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// ID of the preregistered campaign. + /// The SID of the Messaging Service the resource is associated with + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExternalCampaign + public static async System.Threading.Tasks.Task CreateAsync(string campaignId, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new CreateExternalCampaignOptions(campaignId, messagingServiceSid); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExternalCampaignResource object + /// + /// Raw JSON string + /// ExternalCampaignResource object represented by the provided JSON + public static ExternalCampaignResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies a US A2P Compliance resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// ID of the preregistered campaign. + /// + [JsonProperty("campaign_id")] + public string CampaignId { get; private set; } + /// + /// The SID of the Messaging Service the resource is associated with + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + private ExternalCampaignResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderOptions.cs b/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderOptions.cs index 8241863d0..ff4159ef5 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderOptions.cs @@ -9,158 +9,158 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateAlphaSenderOptions + /// + public class CreateAlphaSenderOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateAlphaSenderOptions + /// The SID of the Service to create the resource under /// - public class CreateAlphaSenderOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The Alphanumeric Sender ID string - /// - public string AlphaSender { get; } - - /// - /// Construct a new CreateAlphaSenderOptions - /// - /// The SID of the Service to create the resource under - /// The Alphanumeric Sender ID string - public CreateAlphaSenderOptions(string pathServiceSid, string alphaSender) - { - PathServiceSid = pathServiceSid; - AlphaSender = alphaSender; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AlphaSender != null) - { - p.Add(new KeyValuePair("AlphaSender", AlphaSender)); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadAlphaSenderOptions + /// The Alphanumeric Sender ID string /// - public class ReadAlphaSenderOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadAlphaSenderOptions - /// - /// The SID of the Service to read the resources from - public ReadAlphaSenderOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string AlphaSender { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchAlphaSenderOptions + /// Construct a new CreateAlphaSenderOptions /// - public class FetchAlphaSenderOptions : IOptions - { - /// - /// The SID of the Messaging Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAlphaSenderOptions - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the resource to fetch - public FetchAlphaSenderOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service to create the resource under + /// The Alphanumeric Sender ID string + public CreateAlphaSenderOptions(string pathServiceSid, string alphaSender) + { + PathServiceSid = pathServiceSid; + AlphaSender = alphaSender; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteAlphaSenderOptions + /// Generate the necessary parameters /// - public class DeleteAlphaSenderOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAlphaSenderOptions - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - public DeleteAlphaSenderOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (AlphaSender != null) + { + p.Add(new KeyValuePair("AlphaSender", AlphaSender)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadAlphaSenderOptions + /// + public class ReadAlphaSenderOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadAlphaSenderOptions + /// + /// The SID of the Service to read the resources from + public ReadAlphaSenderOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchAlphaSenderOptions + /// + public class FetchAlphaSenderOptions : IOptions + { + /// + /// The SID of the Messaging Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAlphaSenderOptions + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the resource to fetch + public FetchAlphaSenderOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteAlphaSenderOptions + /// + public class DeleteAlphaSenderOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAlphaSenderOptions + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + public DeleteAlphaSenderOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderResource.cs b/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderResource.cs index a50d10604..c4178bfa8 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderResource.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/AlphaSenderResource.cs @@ -18,416 +18,416 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1.Service -{ - - public class AlphaSenderResource : Resource - { - private static Request BuildCreateRequest(CreateAlphaSenderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/AlphaSenders", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create AlphaSender parameters - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static AlphaSenderResource Create(CreateAlphaSenderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create AlphaSender parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task CreateAsync(CreateAlphaSenderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The Alphanumeric Sender ID string - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static AlphaSenderResource Create(string pathServiceSid, string alphaSender, ITwilioRestClient client = null) - { - var options = new CreateAlphaSenderOptions(pathServiceSid, alphaSender); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The Alphanumeric Sender ID string - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string alphaSender, - ITwilioRestClient client = null) - { - var options = new CreateAlphaSenderOptions(pathServiceSid, alphaSender); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAlphaSenderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/AlphaSenders", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read AlphaSender parameters - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static ResourceSet Read(ReadAlphaSenderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("alpha_senders", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read AlphaSender parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task> ReadAsync(ReadAlphaSenderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("alpha_senders", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAlphaSenderOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAlphaSenderOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("alpha_senders", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("alpha_senders", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("alpha_senders", response.Content); - } - - private static Request BuildFetchRequest(FetchAlphaSenderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/AlphaSenders/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch AlphaSender parameters - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static AlphaSenderResource Fetch(FetchAlphaSenderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch AlphaSender parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task FetchAsync(FetchAlphaSenderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static AlphaSenderResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAlphaSenderOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAlphaSenderOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAlphaSenderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/AlphaSenders/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete AlphaSender parameters - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static bool Delete(DeleteAlphaSenderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete AlphaSender parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAlphaSenderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of AlphaSender - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAlphaSenderOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AlphaSender - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteAlphaSenderOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AlphaSenderResource object - /// - /// Raw JSON string - /// AlphaSenderResource object represented by the provided JSON - public static AlphaSenderResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Alphanumeric Sender ID string - /// - [JsonProperty("alpha_sender")] - public string AlphaSender { get; private set; } - /// - /// An array of values that describe whether the number can receive calls or messages - /// - [JsonProperty("capabilities")] - public List Capabilities { get; private set; } - /// - /// The absolute URL of the AlphaSender resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private AlphaSenderResource() - { - - } - } +{ + + public class AlphaSenderResource : Resource + { + private static Request BuildCreateRequest(CreateAlphaSenderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/AlphaSenders", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create AlphaSender parameters + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static AlphaSenderResource Create(CreateAlphaSenderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create AlphaSender parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task CreateAsync(CreateAlphaSenderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The Alphanumeric Sender ID string + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static AlphaSenderResource Create(string pathServiceSid, string alphaSender, ITwilioRestClient client = null) + { + var options = new CreateAlphaSenderOptions(pathServiceSid, alphaSender); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The Alphanumeric Sender ID string + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string alphaSender, + ITwilioRestClient client = null) + { + var options = new CreateAlphaSenderOptions(pathServiceSid, alphaSender); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAlphaSenderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/AlphaSenders", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read AlphaSender parameters + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static ResourceSet Read(ReadAlphaSenderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("alpha_senders", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read AlphaSender parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task> ReadAsync(ReadAlphaSenderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("alpha_senders", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAlphaSenderOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAlphaSenderOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("alpha_senders", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("alpha_senders", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("alpha_senders", response.Content); + } + + private static Request BuildFetchRequest(FetchAlphaSenderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/AlphaSenders/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch AlphaSender parameters + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static AlphaSenderResource Fetch(FetchAlphaSenderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch AlphaSender parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task FetchAsync(FetchAlphaSenderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static AlphaSenderResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAlphaSenderOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAlphaSenderOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAlphaSenderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/AlphaSenders/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete AlphaSender parameters + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static bool Delete(DeleteAlphaSenderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete AlphaSender parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAlphaSenderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of AlphaSender + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAlphaSenderOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AlphaSender + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteAlphaSenderOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AlphaSenderResource object + /// + /// Raw JSON string + /// AlphaSenderResource object represented by the provided JSON + public static AlphaSenderResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Alphanumeric Sender ID string + /// + [JsonProperty("alpha_sender")] + public string AlphaSender { get; private set; } + /// + /// An array of values that describe whether the number can receive calls or messages + /// + [JsonProperty("capabilities")] + public List Capabilities { get; private set; } + /// + /// The absolute URL of the AlphaSender resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private AlphaSenderResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberOptions.cs b/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberOptions.cs index 6d8edc445..27935e4d8 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberOptions.cs @@ -9,158 +9,158 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreatePhoneNumberOptions + /// + public class CreatePhoneNumberOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreatePhoneNumberOptions + /// The SID of the Service to create the resource under /// - public class CreatePhoneNumberOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Phone Number being added to the Service - /// - public string PhoneNumberSid { get; } - - /// - /// Construct a new CreatePhoneNumberOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the Phone Number being added to the Service - public CreatePhoneNumberOptions(string pathServiceSid, string phoneNumberSid) - { - PathServiceSid = pathServiceSid; - PhoneNumberSid = phoneNumberSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumberSid != null) - { - p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeletePhoneNumberOptions + /// The SID of the Phone Number being added to the Service /// - public class DeletePhoneNumberOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeletePhoneNumberOptions - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - public DeletePhoneNumberOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PhoneNumberSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadPhoneNumberOptions + /// Construct a new CreatePhoneNumberOptions /// - public class ReadPhoneNumberOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadPhoneNumberOptions - /// - /// The SID of the Service to read the resources from - public ReadPhoneNumberOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service to create the resource under + /// The SID of the Phone Number being added to the Service + public CreatePhoneNumberOptions(string pathServiceSid, string phoneNumberSid) + { + PathServiceSid = pathServiceSid; + PhoneNumberSid = phoneNumberSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchPhoneNumberOptions + /// Generate the necessary parameters /// - public class FetchPhoneNumberOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPhoneNumberOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - public FetchPhoneNumberOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (PhoneNumberSid != null) + { + p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeletePhoneNumberOptions + /// + public class DeletePhoneNumberOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeletePhoneNumberOptions + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + public DeletePhoneNumberOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadPhoneNumberOptions + /// + public class ReadPhoneNumberOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadPhoneNumberOptions + /// + /// The SID of the Service to read the resources from + public ReadPhoneNumberOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchPhoneNumberOptions + /// + public class FetchPhoneNumberOptions : IOptions + { + /// + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPhoneNumberOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + public FetchPhoneNumberOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberResource.cs b/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberResource.cs index 98dbe53ed..9cf55d364 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberResource.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/PhoneNumberResource.cs @@ -18,424 +18,424 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1.Service -{ - - public class PhoneNumberResource : Resource - { - private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Phone Number being added to the Service - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(string pathServiceSid, - string phoneNumberSid, - ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathServiceSid, phoneNumberSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the Phone Number being added to the Service - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string phoneNumberSid, - ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathServiceSid, phoneNumberSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PhoneNumberResource object - /// - /// Raw JSON string - /// PhoneNumberResource object represented by the provided JSON - public static PhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The 2-character ISO Country Code of the number - /// - [JsonProperty("country_code")] - public string CountryCode { get; private set; } - /// - /// An array of values that describe whether the number can receive calls or messages - /// - [JsonProperty("capabilities")] - public List Capabilities { get; private set; } - /// - /// The absolute URL of the PhoneNumber resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private PhoneNumberResource() - { - - } - } +{ + + public class PhoneNumberResource : Resource + { + private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Phone Number being added to the Service + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(string pathServiceSid, + string phoneNumberSid, + ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathServiceSid, phoneNumberSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the Phone Number being added to the Service + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string phoneNumberSid, + ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathServiceSid, phoneNumberSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PhoneNumberResource object + /// + /// Raw JSON string + /// PhoneNumberResource object represented by the provided JSON + public static PhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The 2-character ISO Country Code of the number + /// + [JsonProperty("country_code")] + public string CountryCode { get; private set; } + /// + /// An array of values that describe whether the number can receive calls or messages + /// + [JsonProperty("capabilities")] + public List Capabilities { get; private set; } + /// + /// The absolute URL of the PhoneNumber resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private PhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/ShortCodeOptions.cs b/src/Twilio/Rest/Messaging/V1/Service/ShortCodeOptions.cs index 9279e10ac..9842018a8 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/ShortCodeOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/ShortCodeOptions.cs @@ -9,158 +9,158 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateShortCodeOptions + /// + public class CreateShortCodeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateShortCodeOptions + /// The SID of the Service to create the resource under /// - public class CreateShortCodeOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the ShortCode being added to the Service - /// - public string ShortCodeSid { get; } - - /// - /// Construct a new CreateShortCodeOptions - /// - /// The SID of the Service to create the resource under - /// The SID of the ShortCode being added to the Service - public CreateShortCodeOptions(string pathServiceSid, string shortCodeSid) - { - PathServiceSid = pathServiceSid; - ShortCodeSid = shortCodeSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ShortCodeSid != null) - { - p.Add(new KeyValuePair("ShortCodeSid", ShortCodeSid.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteShortCodeOptions + /// The SID of the ShortCode being added to the Service /// - public class DeleteShortCodeOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteShortCodeOptions - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - public DeleteShortCodeOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string ShortCodeSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadShortCodeOptions + /// Construct a new CreateShortCodeOptions /// - public class ReadShortCodeOptions : ReadOptions - { - /// - /// The SID of the Service to read the resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadShortCodeOptions - /// - /// The SID of the Service to read the resources from - public ReadShortCodeOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service to create the resource under + /// The SID of the ShortCode being added to the Service + public CreateShortCodeOptions(string pathServiceSid, string shortCodeSid) + { + PathServiceSid = pathServiceSid; + ShortCodeSid = shortCodeSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchShortCodeOptions + /// Generate the necessary parameters /// - public class FetchShortCodeOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchShortCodeOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - public FetchShortCodeOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (ShortCodeSid != null) + { + p.Add(new KeyValuePair("ShortCodeSid", ShortCodeSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteShortCodeOptions + /// + public class DeleteShortCodeOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteShortCodeOptions + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + public DeleteShortCodeOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadShortCodeOptions + /// + public class ReadShortCodeOptions : ReadOptions + { + /// + /// The SID of the Service to read the resources from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadShortCodeOptions + /// + /// The SID of the Service to read the resources from + public ReadShortCodeOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchShortCodeOptions + /// + public class FetchShortCodeOptions : IOptions + { + /// + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchShortCodeOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + public FetchShortCodeOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/ShortCodeResource.cs b/src/Twilio/Rest/Messaging/V1/Service/ShortCodeResource.cs index 806492fa3..111d9464b 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/ShortCodeResource.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/ShortCodeResource.cs @@ -18,421 +18,421 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1.Service -{ - - public class ShortCodeResource : Resource - { - private static Request BuildCreateRequest(CreateShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Create(CreateShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task CreateAsync(CreateShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the ShortCode being added to the Service - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Create(string pathServiceSid, string shortCodeSid, ITwilioRestClient client = null) - { - var options = new CreateShortCodeOptions(pathServiceSid, shortCodeSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The SID of the ShortCode being added to the Service - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string shortCodeSid, - ITwilioRestClient client = null) - { - var options = new CreateShortCodeOptions(pathServiceSid, shortCodeSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static bool Delete(DeleteShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task DeleteAsync(DeleteShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ShortCodeResource object - /// - /// Raw JSON string - /// ShortCodeResource object represented by the provided JSON - public static ShortCodeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The E.164 format of the short code - /// - [JsonProperty("short_code")] - public string ShortCode { get; private set; } - /// - /// The 2-character ISO Country Code of the number - /// - [JsonProperty("country_code")] - public string CountryCode { get; private set; } - /// - /// An array of values that describe whether the number can receive calls or messages - /// - [JsonProperty("capabilities")] - public List Capabilities { get; private set; } - /// - /// The absolute URL of the ShortCode resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ShortCodeResource() - { - - } - } +{ + + public class ShortCodeResource : Resource + { + private static Request BuildCreateRequest(CreateShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Create(CreateShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task CreateAsync(CreateShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the ShortCode being added to the Service + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Create(string pathServiceSid, string shortCodeSid, ITwilioRestClient client = null) + { + var options = new CreateShortCodeOptions(pathServiceSid, shortCodeSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The SID of the ShortCode being added to the Service + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string shortCodeSid, + ITwilioRestClient client = null) + { + var options = new CreateShortCodeOptions(pathServiceSid, shortCodeSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static bool Delete(DeleteShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task DeleteAsync(DeleteShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ShortCodeResource object + /// + /// Raw JSON string + /// ShortCodeResource object represented by the provided JSON + public static ShortCodeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The E.164 format of the short code + /// + [JsonProperty("short_code")] + public string ShortCode { get; private set; } + /// + /// The 2-character ISO Country Code of the number + /// + [JsonProperty("country_code")] + public string CountryCode { get; private set; } + /// + /// An array of values that describe whether the number can receive calls or messages + /// + [JsonProperty("capabilities")] + public List Capabilities { get; private set; } + /// + /// The absolute URL of the ShortCode resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ShortCodeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonOptions.cs b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonOptions.cs index b31aebd26..a3945e935 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonOptions.cs @@ -10,220 +10,220 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateUsAppToPersonOptions + /// + public class CreateUsAppToPersonOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateUsAppToPersonOptions - /// - public class CreateUsAppToPersonOptions : IOptions - { - /// - /// The SID of the Messaging Service to create the resource from - /// - public string PathMessagingServiceSid { get; } - /// - /// A2P Brand Registration SID - /// - public string BrandRegistrationSid { get; } - /// - /// A short description of what this SMS campaign does - /// - public string Description { get; } - /// - /// Message samples - /// - public List MessageSamples { get; } - /// - /// A2P Campaign Use Case. - /// - public string UsAppToPersonUsecase { get; } - /// - /// Indicates that this SMS campaign will send messages that contain links - /// - public bool? HasEmbeddedLinks { get; } - /// - /// Indicates that this SMS campaign will send messages that contain phone numbers - /// - public bool? HasEmbeddedPhone { get; } - - /// - /// Construct a new CreateUsAppToPersonOptions - /// - /// The SID of the Messaging Service to create the resource from - /// A2P Brand Registration SID - /// A short description of what this SMS campaign does - /// Message samples - /// A2P Campaign Use Case. - /// Indicates that this SMS campaign will send messages that contain links - /// Indicates that this SMS campaign will send messages that contain phone numbers - /// - public CreateUsAppToPersonOptions(string pathMessagingServiceSid, - string brandRegistrationSid, - string description, - List messageSamples, - string usAppToPersonUsecase, - bool? hasEmbeddedLinks, - bool? hasEmbeddedPhone) - { - PathMessagingServiceSid = pathMessagingServiceSid; - BrandRegistrationSid = brandRegistrationSid; - Description = description; - MessageSamples = messageSamples; - UsAppToPersonUsecase = usAppToPersonUsecase; - HasEmbeddedLinks = hasEmbeddedLinks; - HasEmbeddedPhone = hasEmbeddedPhone; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (BrandRegistrationSid != null) - { - p.Add(new KeyValuePair("BrandRegistrationSid", BrandRegistrationSid.ToString())); - } - - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - if (MessageSamples != null) - { - p.AddRange(MessageSamples.Select(prop => new KeyValuePair("MessageSamples", prop))); - } - - if (UsAppToPersonUsecase != null) - { - p.Add(new KeyValuePair("UsAppToPersonUsecase", UsAppToPersonUsecase)); - } - - if (HasEmbeddedLinks != null) - { - p.Add(new KeyValuePair("HasEmbeddedLinks", HasEmbeddedLinks.Value.ToString().ToLower())); - } - - if (HasEmbeddedPhone != null) - { - p.Add(new KeyValuePair("HasEmbeddedPhone", HasEmbeddedPhone.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The SID of the Messaging Service to create the resource from + /// + public string PathMessagingServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteUsAppToPersonOptions - /// - public class DeleteUsAppToPersonOptions : IOptions - { - /// - /// The SID of the Messaging Service to delete the resource from - /// - public string PathMessagingServiceSid { get; } - /// - /// The SID that identifies the US A2P Compliance resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteUsAppToPersonOptions - /// - /// The SID of the Messaging Service to delete the resource from - /// The SID that identifies the US A2P Compliance resource to delete - public DeleteUsAppToPersonOptions(string pathMessagingServiceSid, string pathSid) - { - PathMessagingServiceSid = pathMessagingServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A2P Brand Registration SID + /// + public string BrandRegistrationSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadUsAppToPersonOptions + /// A short description of what this SMS campaign does /// - public class ReadUsAppToPersonOptions : ReadOptions - { - /// - /// The SID of the Messaging Service to fetch the resource from - /// - public string PathMessagingServiceSid { get; } - - /// - /// Construct a new ReadUsAppToPersonOptions - /// - /// The SID of the Messaging Service to fetch the resource from - public ReadUsAppToPersonOptions(string pathMessagingServiceSid) - { - PathMessagingServiceSid = pathMessagingServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string Description { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchUsAppToPersonOptions - /// - public class FetchUsAppToPersonOptions : IOptions - { - /// - /// The SID of the Messaging Service to fetch the resource from - /// - public string PathMessagingServiceSid { get; } - /// - /// The SID that identifies the US A2P Compliance resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchUsAppToPersonOptions - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the US A2P Compliance resource to fetch - public FetchUsAppToPersonOptions(string pathMessagingServiceSid, string pathSid) - { - PathMessagingServiceSid = pathMessagingServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Message samples + /// + public List MessageSamples { get; } + /// + /// A2P Campaign Use Case. + /// + public string UsAppToPersonUsecase { get; } + /// + /// Indicates that this SMS campaign will send messages that contain links + /// + public bool? HasEmbeddedLinks { get; } + /// + /// Indicates that this SMS campaign will send messages that contain phone numbers + /// + public bool? HasEmbeddedPhone { get; } + + /// + /// Construct a new CreateUsAppToPersonOptions + /// + /// The SID of the Messaging Service to create the resource from + /// A2P Brand Registration SID + /// A short description of what this SMS campaign does + /// Message samples + /// A2P Campaign Use Case. + /// Indicates that this SMS campaign will send messages that contain links + /// Indicates that this SMS campaign will send messages that contain phone numbers + /// + public CreateUsAppToPersonOptions(string pathMessagingServiceSid, + string brandRegistrationSid, + string description, + List messageSamples, + string usAppToPersonUsecase, + bool? hasEmbeddedLinks, + bool? hasEmbeddedPhone) + { + PathMessagingServiceSid = pathMessagingServiceSid; + BrandRegistrationSid = brandRegistrationSid; + Description = description; + MessageSamples = messageSamples; + UsAppToPersonUsecase = usAppToPersonUsecase; + HasEmbeddedLinks = hasEmbeddedLinks; + HasEmbeddedPhone = hasEmbeddedPhone; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (BrandRegistrationSid != null) + { + p.Add(new KeyValuePair("BrandRegistrationSid", BrandRegistrationSid.ToString())); + } + + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + if (MessageSamples != null) + { + p.AddRange(MessageSamples.Select(prop => new KeyValuePair("MessageSamples", prop))); + } + + if (UsAppToPersonUsecase != null) + { + p.Add(new KeyValuePair("UsAppToPersonUsecase", UsAppToPersonUsecase)); + } + + if (HasEmbeddedLinks != null) + { + p.Add(new KeyValuePair("HasEmbeddedLinks", HasEmbeddedLinks.Value.ToString().ToLower())); + } + + if (HasEmbeddedPhone != null) + { + p.Add(new KeyValuePair("HasEmbeddedPhone", HasEmbeddedPhone.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteUsAppToPersonOptions + /// + public class DeleteUsAppToPersonOptions : IOptions + { + /// + /// The SID of the Messaging Service to delete the resource from + /// + public string PathMessagingServiceSid { get; } + /// + /// The SID that identifies the US A2P Compliance resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteUsAppToPersonOptions + /// + /// The SID of the Messaging Service to delete the resource from + /// The SID that identifies the US A2P Compliance resource to delete + public DeleteUsAppToPersonOptions(string pathMessagingServiceSid, string pathSid) + { + PathMessagingServiceSid = pathMessagingServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadUsAppToPersonOptions + /// + public class ReadUsAppToPersonOptions : ReadOptions + { + /// + /// The SID of the Messaging Service to fetch the resource from + /// + public string PathMessagingServiceSid { get; } + + /// + /// Construct a new ReadUsAppToPersonOptions + /// + /// The SID of the Messaging Service to fetch the resource from + public ReadUsAppToPersonOptions(string pathMessagingServiceSid) + { + PathMessagingServiceSid = pathMessagingServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchUsAppToPersonOptions + /// + public class FetchUsAppToPersonOptions : IOptions + { + /// + /// The SID of the Messaging Service to fetch the resource from + /// + public string PathMessagingServiceSid { get; } + /// + /// The SID that identifies the US A2P Compliance resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchUsAppToPersonOptions + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the US A2P Compliance resource to fetch + public FetchUsAppToPersonOptions(string pathMessagingServiceSid, string pathSid) + { + PathMessagingServiceSid = pathMessagingServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonResource.cs b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonResource.cs index 09c4b6750..cd48bf507 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonResource.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonResource.cs @@ -18,488 +18,488 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1.Service -{ - - public class UsAppToPersonResource : Resource - { - private static Request BuildCreateRequest(CreateUsAppToPersonOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create UsAppToPerson parameters - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static UsAppToPersonResource Create(CreateUsAppToPersonOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create UsAppToPerson parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task CreateAsync(CreateUsAppToPersonOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Messaging Service to create the resource from - /// A2P Brand Registration SID - /// A short description of what this SMS campaign does - /// Message samples - /// A2P Campaign Use Case. - /// Indicates that this SMS campaign will send messages that contain links - /// Indicates that this SMS campaign will send messages that contain phone numbers - /// - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static UsAppToPersonResource Create(string pathMessagingServiceSid, - string brandRegistrationSid, - string description, - List messageSamples, - string usAppToPersonUsecase, - bool? hasEmbeddedLinks, - bool? hasEmbeddedPhone, - ITwilioRestClient client = null) - { - var options = new CreateUsAppToPersonOptions(pathMessagingServiceSid, brandRegistrationSid, description, messageSamples, usAppToPersonUsecase, hasEmbeddedLinks, hasEmbeddedPhone); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Messaging Service to create the resource from - /// A2P Brand Registration SID - /// A short description of what this SMS campaign does - /// Message samples - /// A2P Campaign Use Case. - /// Indicates that this SMS campaign will send messages that contain links - /// Indicates that this SMS campaign will send messages that contain phone numbers - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task CreateAsync(string pathMessagingServiceSid, - string brandRegistrationSid, - string description, - List messageSamples, - string usAppToPersonUsecase, - bool? hasEmbeddedLinks, - bool? hasEmbeddedPhone, - ITwilioRestClient client = null) - { - var options = new CreateUsAppToPersonOptions(pathMessagingServiceSid, brandRegistrationSid, description, messageSamples, usAppToPersonUsecase, hasEmbeddedLinks, hasEmbeddedPhone); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteUsAppToPersonOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete UsAppToPerson parameters - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static bool Delete(DeleteUsAppToPersonOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete UsAppToPerson parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task DeleteAsync(DeleteUsAppToPersonOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Messaging Service to delete the resource from - /// The SID that identifies the US A2P Compliance resource to delete - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static bool Delete(string pathMessagingServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteUsAppToPersonOptions(pathMessagingServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Messaging Service to delete the resource from - /// The SID that identifies the US A2P Compliance resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task DeleteAsync(string pathMessagingServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteUsAppToPersonOptions(pathMessagingServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadUsAppToPersonOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UsAppToPerson parameters - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static ResourceSet Read(ReadUsAppToPersonOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("compliance", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UsAppToPerson parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task> ReadAsync(ReadUsAppToPersonOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("compliance", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Messaging Service to fetch the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static ResourceSet Read(string pathMessagingServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsAppToPersonOptions(pathMessagingServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Messaging Service to fetch the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task> ReadAsync(string pathMessagingServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsAppToPersonOptions(pathMessagingServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("compliance", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("compliance", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("compliance", response.Content); - } - - private static Request BuildFetchRequest(FetchUsAppToPersonOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UsAppToPerson parameters - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static UsAppToPersonResource Fetch(FetchUsAppToPersonOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UsAppToPerson parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task FetchAsync(FetchUsAppToPersonOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the US A2P Compliance resource to fetch - /// Client to make requests to Twilio - /// A single instance of UsAppToPerson - public static UsAppToPersonResource Fetch(string pathMessagingServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUsAppToPersonOptions(pathMessagingServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// The SID that identifies the US A2P Compliance resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPerson - public static async System.Threading.Tasks.Task FetchAsync(string pathMessagingServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchUsAppToPersonOptions(pathMessagingServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UsAppToPersonResource object - /// - /// Raw JSON string - /// UsAppToPersonResource object represented by the provided JSON - public static UsAppToPersonResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies a US A2P Compliance resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A2P Brand Registration SID - /// - [JsonProperty("brand_registration_sid")] - public string BrandRegistrationSid { get; private set; } - /// - /// The SID of the Messaging Service the resource is associated with - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// A short description of what this SMS campaign does - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// Message samples - /// - [JsonProperty("message_samples")] - public List MessageSamples { get; private set; } - /// - /// A2P Campaign Use Case. - /// - [JsonProperty("us_app_to_person_usecase")] - public string UsAppToPersonUsecase { get; private set; } - /// - /// Indicate that this SMS campaign will send messages that contain links - /// - [JsonProperty("has_embedded_links")] - public bool? HasEmbeddedLinks { get; private set; } - /// - /// Indicates that this SMS campaign will send messages that contain phone numbers - /// - [JsonProperty("has_embedded_phone")] - public bool? HasEmbeddedPhone { get; private set; } - /// - /// Campaign status - /// - [JsonProperty("campaign_status")] - public string CampaignStatus { get; private set; } - /// - /// The Campaign Registry (TCR) Campaign ID. - /// - [JsonProperty("campaign_id")] - public string CampaignId { get; private set; } - /// - /// Indicates whether the campaign was registered externally or not - /// - [JsonProperty("is_externally_registered")] - public bool? IsExternallyRegistered { get; private set; } - /// - /// Rate limit and/or classification set by each carrier - /// - [JsonProperty("rate_limits")] - public object RateLimits { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the US App to Person resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A boolean that specifies whether campaign is a mock or not. - /// - [JsonProperty("mock")] - public bool? Mock { get; private set; } - - private UsAppToPersonResource() - { - - } - } +{ + + public class UsAppToPersonResource : Resource + { + private static Request BuildCreateRequest(CreateUsAppToPersonOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create UsAppToPerson parameters + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static UsAppToPersonResource Create(CreateUsAppToPersonOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create UsAppToPerson parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task CreateAsync(CreateUsAppToPersonOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Messaging Service to create the resource from + /// A2P Brand Registration SID + /// A short description of what this SMS campaign does + /// Message samples + /// A2P Campaign Use Case. + /// Indicates that this SMS campaign will send messages that contain links + /// Indicates that this SMS campaign will send messages that contain phone numbers + /// + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static UsAppToPersonResource Create(string pathMessagingServiceSid, + string brandRegistrationSid, + string description, + List messageSamples, + string usAppToPersonUsecase, + bool? hasEmbeddedLinks, + bool? hasEmbeddedPhone, + ITwilioRestClient client = null) + { + var options = new CreateUsAppToPersonOptions(pathMessagingServiceSid, brandRegistrationSid, description, messageSamples, usAppToPersonUsecase, hasEmbeddedLinks, hasEmbeddedPhone); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Messaging Service to create the resource from + /// A2P Brand Registration SID + /// A short description of what this SMS campaign does + /// Message samples + /// A2P Campaign Use Case. + /// Indicates that this SMS campaign will send messages that contain links + /// Indicates that this SMS campaign will send messages that contain phone numbers + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task CreateAsync(string pathMessagingServiceSid, + string brandRegistrationSid, + string description, + List messageSamples, + string usAppToPersonUsecase, + bool? hasEmbeddedLinks, + bool? hasEmbeddedPhone, + ITwilioRestClient client = null) + { + var options = new CreateUsAppToPersonOptions(pathMessagingServiceSid, brandRegistrationSid, description, messageSamples, usAppToPersonUsecase, hasEmbeddedLinks, hasEmbeddedPhone); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteUsAppToPersonOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete UsAppToPerson parameters + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static bool Delete(DeleteUsAppToPersonOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete UsAppToPerson parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUsAppToPersonOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Messaging Service to delete the resource from + /// The SID that identifies the US A2P Compliance resource to delete + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static bool Delete(string pathMessagingServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteUsAppToPersonOptions(pathMessagingServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Messaging Service to delete the resource from + /// The SID that identifies the US A2P Compliance resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task DeleteAsync(string pathMessagingServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteUsAppToPersonOptions(pathMessagingServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadUsAppToPersonOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UsAppToPerson parameters + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static ResourceSet Read(ReadUsAppToPersonOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("compliance", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UsAppToPerson parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task> ReadAsync(ReadUsAppToPersonOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("compliance", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Messaging Service to fetch the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static ResourceSet Read(string pathMessagingServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsAppToPersonOptions(pathMessagingServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Messaging Service to fetch the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task> ReadAsync(string pathMessagingServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsAppToPersonOptions(pathMessagingServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("compliance", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("compliance", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("compliance", response.Content); + } + + private static Request BuildFetchRequest(FetchUsAppToPersonOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UsAppToPerson parameters + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static UsAppToPersonResource Fetch(FetchUsAppToPersonOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UsAppToPerson parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task FetchAsync(FetchUsAppToPersonOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the US A2P Compliance resource to fetch + /// Client to make requests to Twilio + /// A single instance of UsAppToPerson + public static UsAppToPersonResource Fetch(string pathMessagingServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUsAppToPersonOptions(pathMessagingServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// The SID that identifies the US A2P Compliance resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPerson + public static async System.Threading.Tasks.Task FetchAsync(string pathMessagingServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchUsAppToPersonOptions(pathMessagingServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UsAppToPersonResource object + /// + /// Raw JSON string + /// UsAppToPersonResource object represented by the provided JSON + public static UsAppToPersonResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies a US A2P Compliance resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A2P Brand Registration SID + /// + [JsonProperty("brand_registration_sid")] + public string BrandRegistrationSid { get; private set; } + /// + /// The SID of the Messaging Service the resource is associated with + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// A short description of what this SMS campaign does + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// Message samples + /// + [JsonProperty("message_samples")] + public List MessageSamples { get; private set; } + /// + /// A2P Campaign Use Case. + /// + [JsonProperty("us_app_to_person_usecase")] + public string UsAppToPersonUsecase { get; private set; } + /// + /// Indicate that this SMS campaign will send messages that contain links + /// + [JsonProperty("has_embedded_links")] + public bool? HasEmbeddedLinks { get; private set; } + /// + /// Indicates that this SMS campaign will send messages that contain phone numbers + /// + [JsonProperty("has_embedded_phone")] + public bool? HasEmbeddedPhone { get; private set; } + /// + /// Campaign status + /// + [JsonProperty("campaign_status")] + public string CampaignStatus { get; private set; } + /// + /// The Campaign Registry (TCR) Campaign ID. + /// + [JsonProperty("campaign_id")] + public string CampaignId { get; private set; } + /// + /// Indicates whether the campaign was registered externally or not + /// + [JsonProperty("is_externally_registered")] + public bool? IsExternallyRegistered { get; private set; } + /// + /// Rate limit and/or classification set by each carrier + /// + [JsonProperty("rate_limits")] + public object RateLimits { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the US App to Person resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A boolean that specifies whether campaign is a mock or not. + /// + [JsonProperty("mock")] + public bool? Mock { get; private set; } + + private UsAppToPersonResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseOptions.cs b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseOptions.cs index 9d56be807..33c15d068 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseOptions.cs @@ -9,46 +9,46 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchUsAppToPersonUsecaseOptions + /// + public class FetchUsAppToPersonUsecaseOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchUsAppToPersonUsecaseOptions + /// The SID of the Messaging Service to fetch the resource from /// - public class FetchUsAppToPersonUsecaseOptions : IOptions - { - /// - /// The SID of the Messaging Service to fetch the resource from - /// - public string PathMessagingServiceSid { get; } - /// - /// A2P Brand Registration SID - /// - public string BrandRegistrationSid { get; set; } - - /// - /// Construct a new FetchUsAppToPersonUsecaseOptions - /// - /// The SID of the Messaging Service to fetch the resource from - public FetchUsAppToPersonUsecaseOptions(string pathMessagingServiceSid) - { - PathMessagingServiceSid = pathMessagingServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (BrandRegistrationSid != null) - { - p.Add(new KeyValuePair("BrandRegistrationSid", BrandRegistrationSid.ToString())); - } - - return p; - } - } + public string PathMessagingServiceSid { get; } + /// + /// A2P Brand Registration SID + /// + public string BrandRegistrationSid { get; set; } + + /// + /// Construct a new FetchUsAppToPersonUsecaseOptions + /// + /// The SID of the Messaging Service to fetch the resource from + public FetchUsAppToPersonUsecaseOptions(string pathMessagingServiceSid) + { + PathMessagingServiceSid = pathMessagingServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (BrandRegistrationSid != null) + { + p.Add(new KeyValuePair("BrandRegistrationSid", BrandRegistrationSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseResource.cs b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseResource.cs index a6533ee9c..be9b1db56 100644 --- a/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseResource.cs +++ b/src/Twilio/Rest/Messaging/V1/Service/UsAppToPersonUsecaseResource.cs @@ -18,111 +18,111 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1.Service -{ - - public class UsAppToPersonUsecaseResource : Resource - { - private static Request BuildFetchRequest(FetchUsAppToPersonUsecaseOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/Usecases", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch UsAppToPersonUsecase parameters - /// Client to make requests to Twilio - /// A single instance of UsAppToPersonUsecase - public static UsAppToPersonUsecaseResource Fetch(FetchUsAppToPersonUsecaseOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch UsAppToPersonUsecase parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPersonUsecase - public static async System.Threading.Tasks.Task FetchAsync(FetchUsAppToPersonUsecaseOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// A2P Brand Registration SID - /// Client to make requests to Twilio - /// A single instance of UsAppToPersonUsecase - public static UsAppToPersonUsecaseResource Fetch(string pathMessagingServiceSid, - string brandRegistrationSid = null, - ITwilioRestClient client = null) - { - var options = new FetchUsAppToPersonUsecaseOptions(pathMessagingServiceSid){BrandRegistrationSid = brandRegistrationSid}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Messaging Service to fetch the resource from - /// A2P Brand Registration SID - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsAppToPersonUsecase - public static async System.Threading.Tasks.Task FetchAsync(string pathMessagingServiceSid, - string brandRegistrationSid = null, - ITwilioRestClient client = null) - { - var options = new FetchUsAppToPersonUsecaseOptions(pathMessagingServiceSid){BrandRegistrationSid = brandRegistrationSid}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UsAppToPersonUsecaseResource object - /// - /// Raw JSON string - /// UsAppToPersonUsecaseResource object represented by the provided JSON - public static UsAppToPersonUsecaseResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Human readable A2P Use Case details - /// - [JsonProperty("us_app_to_person_usecases")] - public List UsAppToPersonUsecases { get; private set; } - - private UsAppToPersonUsecaseResource() - { - - } - } +{ + + public class UsAppToPersonUsecaseResource : Resource + { + private static Request BuildFetchRequest(FetchUsAppToPersonUsecaseOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathMessagingServiceSid + "/Compliance/Usa2p/Usecases", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch UsAppToPersonUsecase parameters + /// Client to make requests to Twilio + /// A single instance of UsAppToPersonUsecase + public static UsAppToPersonUsecaseResource Fetch(FetchUsAppToPersonUsecaseOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch UsAppToPersonUsecase parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPersonUsecase + public static async System.Threading.Tasks.Task FetchAsync(FetchUsAppToPersonUsecaseOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// A2P Brand Registration SID + /// Client to make requests to Twilio + /// A single instance of UsAppToPersonUsecase + public static UsAppToPersonUsecaseResource Fetch(string pathMessagingServiceSid, + string brandRegistrationSid = null, + ITwilioRestClient client = null) + { + var options = new FetchUsAppToPersonUsecaseOptions(pathMessagingServiceSid) { BrandRegistrationSid = brandRegistrationSid }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Messaging Service to fetch the resource from + /// A2P Brand Registration SID + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsAppToPersonUsecase + public static async System.Threading.Tasks.Task FetchAsync(string pathMessagingServiceSid, + string brandRegistrationSid = null, + ITwilioRestClient client = null) + { + var options = new FetchUsAppToPersonUsecaseOptions(pathMessagingServiceSid) { BrandRegistrationSid = brandRegistrationSid }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UsAppToPersonUsecaseResource object + /// + /// Raw JSON string + /// UsAppToPersonUsecaseResource object represented by the provided JSON + public static UsAppToPersonUsecaseResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Human readable A2P Use Case details + /// + [JsonProperty("us_app_to_person_usecases")] + public List UsAppToPersonUsecases { get; private set; } + + private UsAppToPersonUsecaseResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/ServiceOptions.cs b/src/Twilio/Rest/Messaging/V1/ServiceOptions.cs index b65127693..de555ea13 100644 --- a/src/Twilio/Rest/Messaging/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/ServiceOptions.cs @@ -9,436 +9,436 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateServiceOptions - /// - public class CreateServiceOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - public Uri InboundRequestUrl { get; set; } - /// - /// The HTTP method we should use to call inbound_request_url - /// - public Twilio.Http.HttpMethod InboundMethod { get; set; } - /// - /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - public Uri FallbackUrl { get; set; } - /// - /// The HTTP method we should use to call fallback_url - /// - public Twilio.Http.HttpMethod FallbackMethod { get; set; } - /// - /// The URL we should call to pass status updates about message delivery - /// - public Uri StatusCallback { get; set; } - /// - /// Whether to enable Sticky Sender on the Service instance - /// - public bool? StickySender { get; set; } - /// - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - public bool? MmsConverter { get; set; } - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// - public bool? SmartEncoding { get; set; } - /// - /// Reserved - /// - public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; set; } - /// - /// Whether to enable Fallback to Long Code for messages sent through the Service instance - /// - public bool? FallbackToLongCode { get; set; } - /// - /// Whether to enable Area Code Geomatch on the Service Instance - /// - public bool? AreaCodeGeomatch { get; set; } - /// - /// How long, in seconds, messages sent from the Service are valid - /// - public int? ValidityPeriod { get; set; } - /// - /// Reserved - /// - public bool? SynchronousValidation { get; set; } - /// - /// A string describing the scenario in which the Messaging Service will be used - /// - public string Usecase { get; set; } - /// - /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. - /// - public bool? UseInboundWebhookOnNumber { get; set; } - - /// - /// Construct a new CreateServiceOptions - /// - /// A string to describe the resource - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (InboundRequestUrl != null) - { - p.Add(new KeyValuePair("InboundRequestUrl", Serializers.Url(InboundRequestUrl))); - } - - if (InboundMethod != null) - { - p.Add(new KeyValuePair("InboundMethod", InboundMethod.ToString())); - } - - if (FallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); - } - - if (FallbackMethod != null) - { - p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StickySender != null) - { - p.Add(new KeyValuePair("StickySender", StickySender.Value.ToString().ToLower())); - } - - if (MmsConverter != null) - { - p.Add(new KeyValuePair("MmsConverter", MmsConverter.Value.ToString().ToLower())); - } - - if (SmartEncoding != null) - { - p.Add(new KeyValuePair("SmartEncoding", SmartEncoding.Value.ToString().ToLower())); - } - - if (ScanMessageContent != null) - { - p.Add(new KeyValuePair("ScanMessageContent", ScanMessageContent.ToString())); - } - - if (FallbackToLongCode != null) - { - p.Add(new KeyValuePair("FallbackToLongCode", FallbackToLongCode.Value.ToString().ToLower())); - } - - if (AreaCodeGeomatch != null) - { - p.Add(new KeyValuePair("AreaCodeGeomatch", AreaCodeGeomatch.Value.ToString().ToLower())); - } - - if (ValidityPeriod != null) - { - p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); - } - - if (SynchronousValidation != null) - { - p.Add(new KeyValuePair("SynchronousValidation", SynchronousValidation.Value.ToString().ToLower())); - } - - if (Usecase != null) - { - p.Add(new KeyValuePair("Usecase", Usecase)); - } - - if (UseInboundWebhookOnNumber != null) - { - p.Add(new KeyValuePair("UseInboundWebhookOnNumber", UseInboundWebhookOnNumber.Value.ToString().ToLower())); - } - - return p; - } - } - + /// A string to describe the resource + /// + public string FriendlyName { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - public Uri InboundRequestUrl { get; set; } - /// - /// The HTTP method we should use to call inbound_request_url - /// - public Twilio.Http.HttpMethod InboundMethod { get; set; } - /// - /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - public Uri FallbackUrl { get; set; } - /// - /// The HTTP method we should use to call fallback_url - /// - public Twilio.Http.HttpMethod FallbackMethod { get; set; } - /// - /// The URL we should call to pass status updates about message delivery - /// - public Uri StatusCallback { get; set; } - /// - /// Whether to enable Sticky Sender on the Service instance - /// - public bool? StickySender { get; set; } - /// - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - public bool? MmsConverter { get; set; } - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// - public bool? SmartEncoding { get; set; } - /// - /// Reserved - /// - public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; set; } - /// - /// Whether to enable Fallback to Long Code for messages sent through the Service instance - /// - public bool? FallbackToLongCode { get; set; } - /// - /// Whether to enable Area Code Geomatch on the Service Instance - /// - public bool? AreaCodeGeomatch { get; set; } - /// - /// How long, in seconds, messages sent from the Service are valid - /// - public int? ValidityPeriod { get; set; } - /// - /// Reserved - /// - public bool? SynchronousValidation { get; set; } - /// - /// A string describing the scenario in which the Messaging Service will be used - /// - public string Usecase { get; set; } - /// - /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. - /// - public bool? UseInboundWebhookOnNumber { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The SID that identifies the resource to update - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (InboundRequestUrl != null) - { - p.Add(new KeyValuePair("InboundRequestUrl", Serializers.Url(InboundRequestUrl))); - } - - if (InboundMethod != null) - { - p.Add(new KeyValuePair("InboundMethod", InboundMethod.ToString())); - } - - if (FallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); - } - - if (FallbackMethod != null) - { - p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StickySender != null) - { - p.Add(new KeyValuePair("StickySender", StickySender.Value.ToString().ToLower())); - } - - if (MmsConverter != null) - { - p.Add(new KeyValuePair("MmsConverter", MmsConverter.Value.ToString().ToLower())); - } - - if (SmartEncoding != null) - { - p.Add(new KeyValuePair("SmartEncoding", SmartEncoding.Value.ToString().ToLower())); - } - - if (ScanMessageContent != null) - { - p.Add(new KeyValuePair("ScanMessageContent", ScanMessageContent.ToString())); - } - - if (FallbackToLongCode != null) - { - p.Add(new KeyValuePair("FallbackToLongCode", FallbackToLongCode.Value.ToString().ToLower())); - } - - if (AreaCodeGeomatch != null) - { - p.Add(new KeyValuePair("AreaCodeGeomatch", AreaCodeGeomatch.Value.ToString().ToLower())); - } - - if (ValidityPeriod != null) - { - p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); - } - - if (SynchronousValidation != null) - { - p.Add(new KeyValuePair("SynchronousValidation", SynchronousValidation.Value.ToString().ToLower())); - } - - if (Usecase != null) - { - p.Add(new KeyValuePair("Usecase", Usecase)); - } - - if (UseInboundWebhookOnNumber != null) - { - p.Add(new KeyValuePair("UseInboundWebhookOnNumber", UseInboundWebhookOnNumber.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. + /// + public Uri InboundRequestUrl { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The HTTP method we should use to call inbound_request_url + /// + public Twilio.Http.HttpMethod InboundMethod { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchServiceOptions + /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. /// - public class FetchServiceOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The SID that identifies the resource to fetch - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public Uri FallbackUrl { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteServiceOptions + /// The HTTP method we should use to call fallback_url /// - public class DeleteServiceOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The SID that identifies the resource to delete - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public Twilio.Http.HttpMethod FallbackMethod { get; set; } + /// + /// The URL we should call to pass status updates about message delivery + /// + public Uri StatusCallback { get; set; } + /// + /// Whether to enable Sticky Sender on the Service instance + /// + public bool? StickySender { get; set; } + /// + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + public bool? MmsConverter { get; set; } + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// + public bool? SmartEncoding { get; set; } + /// + /// Reserved + /// + public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; set; } + /// + /// Whether to enable Fallback to Long Code for messages sent through the Service instance + /// + public bool? FallbackToLongCode { get; set; } + /// + /// Whether to enable Area Code Geomatch on the Service Instance + /// + public bool? AreaCodeGeomatch { get; set; } + /// + /// How long, in seconds, messages sent from the Service are valid + /// + public int? ValidityPeriod { get; set; } + /// + /// Reserved + /// + public bool? SynchronousValidation { get; set; } + /// + /// A string describing the scenario in which the Messaging Service will be used + /// + public string Usecase { get; set; } + /// + /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. + /// + public bool? UseInboundWebhookOnNumber { get; set; } + + /// + /// Construct a new CreateServiceOptions + /// + /// A string to describe the resource + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (InboundRequestUrl != null) + { + p.Add(new KeyValuePair("InboundRequestUrl", Serializers.Url(InboundRequestUrl))); + } + + if (InboundMethod != null) + { + p.Add(new KeyValuePair("InboundMethod", InboundMethod.ToString())); + } + + if (FallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); + } + + if (FallbackMethod != null) + { + p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StickySender != null) + { + p.Add(new KeyValuePair("StickySender", StickySender.Value.ToString().ToLower())); + } + + if (MmsConverter != null) + { + p.Add(new KeyValuePair("MmsConverter", MmsConverter.Value.ToString().ToLower())); + } + + if (SmartEncoding != null) + { + p.Add(new KeyValuePair("SmartEncoding", SmartEncoding.Value.ToString().ToLower())); + } + + if (ScanMessageContent != null) + { + p.Add(new KeyValuePair("ScanMessageContent", ScanMessageContent.ToString())); + } + + if (FallbackToLongCode != null) + { + p.Add(new KeyValuePair("FallbackToLongCode", FallbackToLongCode.Value.ToString().ToLower())); + } + + if (AreaCodeGeomatch != null) + { + p.Add(new KeyValuePair("AreaCodeGeomatch", AreaCodeGeomatch.Value.ToString().ToLower())); + } + + if (ValidityPeriod != null) + { + p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); + } + + if (SynchronousValidation != null) + { + p.Add(new KeyValuePair("SynchronousValidation", SynchronousValidation.Value.ToString().ToLower())); + } + + if (Usecase != null) + { + p.Add(new KeyValuePair("Usecase", Usecase)); + } + + if (UseInboundWebhookOnNumber != null) + { + p.Add(new KeyValuePair("UseInboundWebhookOnNumber", UseInboundWebhookOnNumber.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. + /// + public Uri InboundRequestUrl { get; set; } + /// + /// The HTTP method we should use to call inbound_request_url + /// + public Twilio.Http.HttpMethod InboundMethod { get; set; } + /// + /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. + /// + public Uri FallbackUrl { get; set; } + /// + /// The HTTP method we should use to call fallback_url + /// + public Twilio.Http.HttpMethod FallbackMethod { get; set; } + /// + /// The URL we should call to pass status updates about message delivery + /// + public Uri StatusCallback { get; set; } + /// + /// Whether to enable Sticky Sender on the Service instance + /// + public bool? StickySender { get; set; } + /// + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + public bool? MmsConverter { get; set; } + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// + public bool? SmartEncoding { get; set; } + /// + /// Reserved + /// + public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; set; } + /// + /// Whether to enable Fallback to Long Code for messages sent through the Service instance + /// + public bool? FallbackToLongCode { get; set; } + /// + /// Whether to enable Area Code Geomatch on the Service Instance + /// + public bool? AreaCodeGeomatch { get; set; } + /// + /// How long, in seconds, messages sent from the Service are valid + /// + public int? ValidityPeriod { get; set; } + /// + /// Reserved + /// + public bool? SynchronousValidation { get; set; } + /// + /// A string describing the scenario in which the Messaging Service will be used + /// + public string Usecase { get; set; } + /// + /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. + /// + public bool? UseInboundWebhookOnNumber { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The SID that identifies the resource to update + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (InboundRequestUrl != null) + { + p.Add(new KeyValuePair("InboundRequestUrl", Serializers.Url(InboundRequestUrl))); + } + + if (InboundMethod != null) + { + p.Add(new KeyValuePair("InboundMethod", InboundMethod.ToString())); + } + + if (FallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackUrl", Serializers.Url(FallbackUrl))); + } + + if (FallbackMethod != null) + { + p.Add(new KeyValuePair("FallbackMethod", FallbackMethod.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StickySender != null) + { + p.Add(new KeyValuePair("StickySender", StickySender.Value.ToString().ToLower())); + } + + if (MmsConverter != null) + { + p.Add(new KeyValuePair("MmsConverter", MmsConverter.Value.ToString().ToLower())); + } + + if (SmartEncoding != null) + { + p.Add(new KeyValuePair("SmartEncoding", SmartEncoding.Value.ToString().ToLower())); + } + + if (ScanMessageContent != null) + { + p.Add(new KeyValuePair("ScanMessageContent", ScanMessageContent.ToString())); + } + + if (FallbackToLongCode != null) + { + p.Add(new KeyValuePair("FallbackToLongCode", FallbackToLongCode.Value.ToString().ToLower())); + } + + if (AreaCodeGeomatch != null) + { + p.Add(new KeyValuePair("AreaCodeGeomatch", AreaCodeGeomatch.Value.ToString().ToLower())); + } + + if (ValidityPeriod != null) + { + p.Add(new KeyValuePair("ValidityPeriod", ValidityPeriod.ToString())); + } + + if (SynchronousValidation != null) + { + p.Add(new KeyValuePair("SynchronousValidation", SynchronousValidation.Value.ToString().ToLower())); + } + + if (Usecase != null) + { + p.Add(new KeyValuePair("Usecase", Usecase)); + } + + if (UseInboundWebhookOnNumber != null) + { + p.Add(new KeyValuePair("UseInboundWebhookOnNumber", UseInboundWebhookOnNumber.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchServiceOptions + /// + /// The SID that identifies the resource to fetch + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// The SID that identifies the resource to delete + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/ServiceResource.cs b/src/Twilio/Rest/Messaging/V1/ServiceResource.cs index 6f469370b..f3e681768 100644 --- a/src/Twilio/Rest/Messaging/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Messaging/V1/ServiceResource.cs @@ -19,719 +19,719 @@ using Twilio.Types; namespace Twilio.Rest.Messaging.V1 -{ - - public class ServiceResource : Resource - { - public sealed class ScanMessageContentEnum : StringEnum - { - private ScanMessageContentEnum(string value) : base(value) {} - public ScanMessageContentEnum() {} - public static implicit operator ScanMessageContentEnum(string value) - { - return new ScanMessageContentEnum(value); - } - - public static readonly ScanMessageContentEnum Inherit = new ScanMessageContentEnum("inherit"); - public static readonly ScanMessageContentEnum Enable = new ScanMessageContentEnum("enable"); - public static readonly ScanMessageContentEnum Disable = new ScanMessageContentEnum("disable"); - } - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The URL we call using inbound_method when a message is received by any phone - /// number or short code in the Service. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call inbound_request_url - /// The URL that we call using fallback_method if an error occurs while retrieving or - /// executing the TwiML from the Inbound Request URL. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call fallback_url - /// The URL we should call to pass status updates about message delivery - /// Whether to enable Sticky Sender on the Service instance - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// Reserved - /// Whether to enable Fallback to Long Code for messages sent through the Service - /// instance - /// Whether to enable Area Code Geomatch on the Service Instance - /// How long, in seconds, messages sent from the Service are valid - /// Reserved - /// A string describing the scenario in which the Messaging Service will be used - /// If enabled, the webhook url configured on the phone number will be used - /// and will override the `inbound_request_url`/`fallback_url` url called when an - /// inbound message is received. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, - Uri inboundRequestUrl = null, - Twilio.Http.HttpMethod inboundMethod = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - bool? stickySender = null, - bool? mmsConverter = null, - bool? smartEncoding = null, - ServiceResource.ScanMessageContentEnum scanMessageContent = null, - bool? fallbackToLongCode = null, - bool? areaCodeGeomatch = null, - int? validityPeriod = null, - bool? synchronousValidation = null, - string usecase = null, - bool? useInboundWebhookOnNumber = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName){InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The URL we call using inbound_method when a message is received by any phone - /// number or short code in the Service. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call inbound_request_url - /// The URL that we call using fallback_method if an error occurs while retrieving or - /// executing the TwiML from the Inbound Request URL. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call fallback_url - /// The URL we should call to pass status updates about message delivery - /// Whether to enable Sticky Sender on the Service instance - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// Reserved - /// Whether to enable Fallback to Long Code for messages sent through the Service - /// instance - /// Whether to enable Area Code Geomatch on the Service Instance - /// How long, in seconds, messages sent from the Service are valid - /// Reserved - /// A string describing the scenario in which the Messaging Service will be used - /// If enabled, the webhook url configured on the phone number will be used - /// and will override the `inbound_request_url`/`fallback_url` url called when an - /// inbound message is received. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - Uri inboundRequestUrl = null, - Twilio.Http.HttpMethod inboundMethod = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - bool? stickySender = null, - bool? mmsConverter = null, - bool? smartEncoding = null, - ServiceResource.ScanMessageContentEnum scanMessageContent = null, - bool? fallbackToLongCode = null, - bool? areaCodeGeomatch = null, - int? validityPeriod = null, - bool? synchronousValidation = null, - string usecase = null, - bool? useInboundWebhookOnNumber = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName){InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// A string to describe the resource - /// The URL we call using inbound_method when a message is received by any phone - /// number or short code in the Service. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call inbound_request_url - /// The URL that we call using fallback_method if an error occurs while retrieving or - /// executing the TwiML from the Inbound Request URL. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call fallback_url - /// The URL we should call to pass status updates about message delivery - /// Whether to enable Sticky Sender on the Service instance - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// Reserved - /// Whether to enable Fallback to Long Code for messages sent through the Service - /// instance - /// Whether to enable Area Code Geomatch on the Service Instance - /// How long, in seconds, messages sent from the Service are valid - /// Reserved - /// A string describing the scenario in which the Messaging Service will be used - /// If enabled, the webhook url configured on the phone number will be used - /// and will override the `inbound_request_url`/`fallback_url` url called when an - /// inbound message is received. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - Uri inboundRequestUrl = null, - Twilio.Http.HttpMethod inboundMethod = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - bool? stickySender = null, - bool? mmsConverter = null, - bool? smartEncoding = null, - ServiceResource.ScanMessageContentEnum scanMessageContent = null, - bool? fallbackToLongCode = null, - bool? areaCodeGeomatch = null, - int? validityPeriod = null, - bool? synchronousValidation = null, - string usecase = null, - bool? useInboundWebhookOnNumber = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// A string to describe the resource - /// The URL we call using inbound_method when a message is received by any phone - /// number or short code in the Service. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call inbound_request_url - /// The URL that we call using fallback_method if an error occurs while retrieving or - /// executing the TwiML from the Inbound Request URL. This field will be overridden if the - /// `use_inbound_webhook_on_number` field is enabled. - /// The HTTP method we should use to call fallback_url - /// The URL we should call to pass status updates about message delivery - /// Whether to enable Sticky Sender on the Service instance - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// Reserved - /// Whether to enable Fallback to Long Code for messages sent through the Service - /// instance - /// Whether to enable Area Code Geomatch on the Service Instance - /// How long, in seconds, messages sent from the Service are valid - /// Reserved - /// A string describing the scenario in which the Messaging Service will be used - /// If enabled, the webhook url configured on the phone number will be used - /// and will override the `inbound_request_url`/`fallback_url` url called when an - /// inbound message is received. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - Uri inboundRequestUrl = null, - Twilio.Http.HttpMethod inboundMethod = null, - Uri fallbackUrl = null, - Twilio.Http.HttpMethod fallbackMethod = null, - Uri statusCallback = null, - bool? stickySender = null, - bool? mmsConverter = null, - bool? smartEncoding = null, - ServiceResource.ScanMessageContentEnum scanMessageContent = null, - bool? fallbackToLongCode = null, - bool? areaCodeGeomatch = null, - int? validityPeriod = null, - bool? synchronousValidation = null, - string usecase = null, - bool? useInboundWebhookOnNumber = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Messaging) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Messaging, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - [JsonProperty("inbound_request_url")] - public Uri InboundRequestUrl { get; private set; } - /// - /// The HTTP method we use to call inbound_request_url - /// - [JsonProperty("inbound_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod InboundMethod { get; private set; } - /// - /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. - /// - [JsonProperty("fallback_url")] - public Uri FallbackUrl { get; private set; } - /// - /// The HTTP method we use to call fallback_url - /// - [JsonProperty("fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod FallbackMethod { get; private set; } - /// - /// The URL we call to pass status updates about message delivery - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// Whether to enable Sticky Sender on the Service instance - /// - [JsonProperty("sticky_sender")] - public bool? StickySender { get; private set; } - /// - /// Whether to enable the MMS Converter for messages sent through the Service instance - /// - [JsonProperty("mms_converter")] - public bool? MmsConverter { get; private set; } - /// - /// Whether to enable Encoding for messages sent through the Service instance - /// - [JsonProperty("smart_encoding")] - public bool? SmartEncoding { get; private set; } - /// - /// Reserved - /// - [JsonProperty("scan_message_content")] - [JsonConverter(typeof(StringEnumConverter))] - public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; private set; } - /// - /// Whether to enable Fallback to Long Code for messages sent through the Service instance - /// - [JsonProperty("fallback_to_long_code")] - public bool? FallbackToLongCode { get; private set; } - /// - /// Whether to enable Area Code Geomatch on the Service Instance - /// - [JsonProperty("area_code_geomatch")] - public bool? AreaCodeGeomatch { get; private set; } - /// - /// Reserved - /// - [JsonProperty("synchronous_validation")] - public bool? SynchronousValidation { get; private set; } - /// - /// How long, in seconds, messages sent from the Service are valid - /// - [JsonProperty("validity_period")] - public int? ValidityPeriod { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The absolute URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// A string describing the scenario in which the Messaging Service will be used - /// - [JsonProperty("usecase")] - public string Usecase { get; private set; } - /// - /// Whether US A2P campaign is registered for this Service. - /// - [JsonProperty("us_app_to_person_registered")] - public bool? UsAppToPersonRegistered { get; private set; } - /// - /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. - /// - [JsonProperty("use_inbound_webhook_on_number")] - public bool? UseInboundWebhookOnNumber { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + public sealed class ScanMessageContentEnum : StringEnum + { + private ScanMessageContentEnum(string value) : base(value) { } + public ScanMessageContentEnum() { } + public static implicit operator ScanMessageContentEnum(string value) + { + return new ScanMessageContentEnum(value); + } + + public static readonly ScanMessageContentEnum Inherit = new ScanMessageContentEnum("inherit"); + public static readonly ScanMessageContentEnum Enable = new ScanMessageContentEnum("enable"); + public static readonly ScanMessageContentEnum Disable = new ScanMessageContentEnum("disable"); + } + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The URL we call using inbound_method when a message is received by any phone + /// number or short code in the Service. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call inbound_request_url + /// The URL that we call using fallback_method if an error occurs while retrieving or + /// executing the TwiML from the Inbound Request URL. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call fallback_url + /// The URL we should call to pass status updates about message delivery + /// Whether to enable Sticky Sender on the Service instance + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// Reserved + /// Whether to enable Fallback to Long Code for messages sent through the Service + /// instance + /// Whether to enable Area Code Geomatch on the Service Instance + /// How long, in seconds, messages sent from the Service are valid + /// Reserved + /// A string describing the scenario in which the Messaging Service will be used + /// If enabled, the webhook url configured on the phone number will be used + /// and will override the `inbound_request_url`/`fallback_url` url called when an + /// inbound message is received. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, + Uri inboundRequestUrl = null, + Twilio.Http.HttpMethod inboundMethod = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + bool? stickySender = null, + bool? mmsConverter = null, + bool? smartEncoding = null, + ServiceResource.ScanMessageContentEnum scanMessageContent = null, + bool? fallbackToLongCode = null, + bool? areaCodeGeomatch = null, + int? validityPeriod = null, + bool? synchronousValidation = null, + string usecase = null, + bool? useInboundWebhookOnNumber = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName) { InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The URL we call using inbound_method when a message is received by any phone + /// number or short code in the Service. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call inbound_request_url + /// The URL that we call using fallback_method if an error occurs while retrieving or + /// executing the TwiML from the Inbound Request URL. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call fallback_url + /// The URL we should call to pass status updates about message delivery + /// Whether to enable Sticky Sender on the Service instance + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// Reserved + /// Whether to enable Fallback to Long Code for messages sent through the Service + /// instance + /// Whether to enable Area Code Geomatch on the Service Instance + /// How long, in seconds, messages sent from the Service are valid + /// Reserved + /// A string describing the scenario in which the Messaging Service will be used + /// If enabled, the webhook url configured on the phone number will be used + /// and will override the `inbound_request_url`/`fallback_url` url called when an + /// inbound message is received. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + Uri inboundRequestUrl = null, + Twilio.Http.HttpMethod inboundMethod = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + bool? stickySender = null, + bool? mmsConverter = null, + bool? smartEncoding = null, + ServiceResource.ScanMessageContentEnum scanMessageContent = null, + bool? fallbackToLongCode = null, + bool? areaCodeGeomatch = null, + int? validityPeriod = null, + bool? synchronousValidation = null, + string usecase = null, + bool? useInboundWebhookOnNumber = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName) { InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// A string to describe the resource + /// The URL we call using inbound_method when a message is received by any phone + /// number or short code in the Service. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call inbound_request_url + /// The URL that we call using fallback_method if an error occurs while retrieving or + /// executing the TwiML from the Inbound Request URL. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call fallback_url + /// The URL we should call to pass status updates about message delivery + /// Whether to enable Sticky Sender on the Service instance + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// Reserved + /// Whether to enable Fallback to Long Code for messages sent through the Service + /// instance + /// Whether to enable Area Code Geomatch on the Service Instance + /// How long, in seconds, messages sent from the Service are valid + /// Reserved + /// A string describing the scenario in which the Messaging Service will be used + /// If enabled, the webhook url configured on the phone number will be used + /// and will override the `inbound_request_url`/`fallback_url` url called when an + /// inbound message is received. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + Uri inboundRequestUrl = null, + Twilio.Http.HttpMethod inboundMethod = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + bool? stickySender = null, + bool? mmsConverter = null, + bool? smartEncoding = null, + ServiceResource.ScanMessageContentEnum scanMessageContent = null, + bool? fallbackToLongCode = null, + bool? areaCodeGeomatch = null, + int? validityPeriod = null, + bool? synchronousValidation = null, + string usecase = null, + bool? useInboundWebhookOnNumber = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// A string to describe the resource + /// The URL we call using inbound_method when a message is received by any phone + /// number or short code in the Service. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call inbound_request_url + /// The URL that we call using fallback_method if an error occurs while retrieving or + /// executing the TwiML from the Inbound Request URL. This field will be overridden if the + /// `use_inbound_webhook_on_number` field is enabled. + /// The HTTP method we should use to call fallback_url + /// The URL we should call to pass status updates about message delivery + /// Whether to enable Sticky Sender on the Service instance + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// Reserved + /// Whether to enable Fallback to Long Code for messages sent through the Service + /// instance + /// Whether to enable Area Code Geomatch on the Service Instance + /// How long, in seconds, messages sent from the Service are valid + /// Reserved + /// A string describing the scenario in which the Messaging Service will be used + /// If enabled, the webhook url configured on the phone number will be used + /// and will override the `inbound_request_url`/`fallback_url` url called when an + /// inbound message is received. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + Uri inboundRequestUrl = null, + Twilio.Http.HttpMethod inboundMethod = null, + Uri fallbackUrl = null, + Twilio.Http.HttpMethod fallbackMethod = null, + Uri statusCallback = null, + bool? stickySender = null, + bool? mmsConverter = null, + bool? smartEncoding = null, + ServiceResource.ScanMessageContentEnum scanMessageContent = null, + bool? fallbackToLongCode = null, + bool? areaCodeGeomatch = null, + int? validityPeriod = null, + bool? synchronousValidation = null, + string usecase = null, + bool? useInboundWebhookOnNumber = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, InboundRequestUrl = inboundRequestUrl, InboundMethod = inboundMethod, FallbackUrl = fallbackUrl, FallbackMethod = fallbackMethod, StatusCallback = statusCallback, StickySender = stickySender, MmsConverter = mmsConverter, SmartEncoding = smartEncoding, ScanMessageContent = scanMessageContent, FallbackToLongCode = fallbackToLongCode, AreaCodeGeomatch = areaCodeGeomatch, ValidityPeriod = validityPeriod, SynchronousValidation = synchronousValidation, Usecase = usecase, UseInboundWebhookOnNumber = useInboundWebhookOnNumber }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Messaging) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Messaging, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. + /// + [JsonProperty("inbound_request_url")] + public Uri InboundRequestUrl { get; private set; } + /// + /// The HTTP method we use to call inbound_request_url + /// + [JsonProperty("inbound_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod InboundMethod { get; private set; } + /// + /// The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. + /// + [JsonProperty("fallback_url")] + public Uri FallbackUrl { get; private set; } + /// + /// The HTTP method we use to call fallback_url + /// + [JsonProperty("fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod FallbackMethod { get; private set; } + /// + /// The URL we call to pass status updates about message delivery + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// Whether to enable Sticky Sender on the Service instance + /// + [JsonProperty("sticky_sender")] + public bool? StickySender { get; private set; } + /// + /// Whether to enable the MMS Converter for messages sent through the Service instance + /// + [JsonProperty("mms_converter")] + public bool? MmsConverter { get; private set; } + /// + /// Whether to enable Encoding for messages sent through the Service instance + /// + [JsonProperty("smart_encoding")] + public bool? SmartEncoding { get; private set; } + /// + /// Reserved + /// + [JsonProperty("scan_message_content")] + [JsonConverter(typeof(StringEnumConverter))] + public ServiceResource.ScanMessageContentEnum ScanMessageContent { get; private set; } + /// + /// Whether to enable Fallback to Long Code for messages sent through the Service instance + /// + [JsonProperty("fallback_to_long_code")] + public bool? FallbackToLongCode { get; private set; } + /// + /// Whether to enable Area Code Geomatch on the Service Instance + /// + [JsonProperty("area_code_geomatch")] + public bool? AreaCodeGeomatch { get; private set; } + /// + /// Reserved + /// + [JsonProperty("synchronous_validation")] + public bool? SynchronousValidation { get; private set; } + /// + /// How long, in seconds, messages sent from the Service are valid + /// + [JsonProperty("validity_period")] + public int? ValidityPeriod { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The absolute URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// A string describing the scenario in which the Messaging Service will be used + /// + [JsonProperty("usecase")] + public string Usecase { get; private set; } + /// + /// Whether US A2P campaign is registered for this Service. + /// + [JsonProperty("us_app_to_person_registered")] + public bool? UsAppToPersonRegistered { get; private set; } + /// + /// If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. + /// + [JsonProperty("use_inbound_webhook_on_number")] + public bool? UseInboundWebhookOnNumber { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/UsecaseOptions.cs b/src/Twilio/Rest/Messaging/V1/UsecaseOptions.cs index ed4ec695e..d58799843 100644 --- a/src/Twilio/Rest/Messaging/V1/UsecaseOptions.cs +++ b/src/Twilio/Rest/Messaging/V1/UsecaseOptions.cs @@ -9,23 +9,23 @@ using Twilio.Converters; namespace Twilio.Rest.Messaging.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchUsecaseOptions + /// + public class FetchUsecaseOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchUsecaseOptions + /// Generate the necessary parameters /// - public class FetchUsecaseOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Messaging/V1/UsecaseResource.cs b/src/Twilio/Rest/Messaging/V1/UsecaseResource.cs index 843fc8521..7099cbbf7 100644 --- a/src/Twilio/Rest/Messaging/V1/UsecaseResource.cs +++ b/src/Twilio/Rest/Messaging/V1/UsecaseResource.cs @@ -18,102 +18,102 @@ using Twilio.Http; namespace Twilio.Rest.Messaging.V1 -{ - - public class UsecaseResource : Resource - { - private static Request BuildFetchRequest(FetchUsecaseOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Messaging, - "/v1/Services/Usecases", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Usecase parameters - /// Client to make requests to Twilio - /// A single instance of Usecase - public static UsecaseResource Fetch(FetchUsecaseOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Usecase parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Usecase - public static async System.Threading.Tasks.Task FetchAsync(FetchUsecaseOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// Client to make requests to Twilio - /// A single instance of Usecase - public static UsecaseResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchUsecaseOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Usecase - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchUsecaseOptions(); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UsecaseResource object - /// - /// Raw JSON string - /// UsecaseResource object represented by the provided JSON - public static UsecaseResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Human readable Messaging Service Use Case details - /// - [JsonProperty("usecases")] - public List Usecases { get; private set; } - - private UsecaseResource() - { - - } - } +{ + + public class UsecaseResource : Resource + { + private static Request BuildFetchRequest(FetchUsecaseOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Messaging, + "/v1/Services/Usecases", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Usecase parameters + /// Client to make requests to Twilio + /// A single instance of Usecase + public static UsecaseResource Fetch(FetchUsecaseOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Usecase parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Usecase + public static async System.Threading.Tasks.Task FetchAsync(FetchUsecaseOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// Client to make requests to Twilio + /// A single instance of Usecase + public static UsecaseResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchUsecaseOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Usecase + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchUsecaseOptions(); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UsecaseResource object + /// + /// Raw JSON string + /// UsecaseResource object represented by the provided JSON + public static UsecaseResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Human readable Messaging Service Use Case details + /// + [JsonProperty("usecases")] + public List Usecases { get; private set; } + + private UsecaseResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Monitor/V1/AlertOptions.cs b/src/Twilio/Rest/Monitor/V1/AlertOptions.cs index 294a1d154..21281d0e9 100644 --- a/src/Twilio/Rest/Monitor/V1/AlertOptions.cs +++ b/src/Twilio/Rest/Monitor/V1/AlertOptions.cs @@ -9,83 +9,83 @@ using Twilio.Converters; namespace Twilio.Rest.Monitor.V1 -{ - +{ + + /// + /// FetchAlertOptions + /// + public class FetchAlertOptions : IOptions + { /// - /// FetchAlertOptions + /// The SID that identifies the resource to fetch /// - public class FetchAlertOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAlertOptions - /// - /// The SID that identifies the resource to fetch - public FetchAlertOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// ReadAlertOptions + /// Construct a new FetchAlertOptions /// - public class ReadAlertOptions : ReadOptions - { - /// - /// Only show alerts for this log-level - /// - public string LogLevel { get; set; } - /// - /// Only include alerts that occurred on or after this date and time - /// - public DateTime? StartDate { get; set; } - /// - /// Only include alerts that occurred on or before this date and time - /// - public DateTime? EndDate { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (LogLevel != null) - { - p.Add(new KeyValuePair("LogLevel", LogLevel)); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID that identifies the resource to fetch + public FetchAlertOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadAlertOptions + /// + public class ReadAlertOptions : ReadOptions + { + /// + /// Only show alerts for this log-level + /// + public string LogLevel { get; set; } + /// + /// Only include alerts that occurred on or after this date and time + /// + public DateTime? StartDate { get; set; } + /// + /// Only include alerts that occurred on or before this date and time + /// + public DateTime? EndDate { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (LogLevel != null) + { + p.Add(new KeyValuePair("LogLevel", LogLevel)); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Monitor/V1/AlertResource.cs b/src/Twilio/Rest/Monitor/V1/AlertResource.cs index 6fa7ddc6d..711305c3c 100644 --- a/src/Twilio/Rest/Monitor/V1/AlertResource.cs +++ b/src/Twilio/Rest/Monitor/V1/AlertResource.cs @@ -16,337 +16,337 @@ using Twilio.Http; namespace Twilio.Rest.Monitor.V1 -{ - - public class AlertResource : Resource - { - private static Request BuildFetchRequest(FetchAlertOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Monitor, - "/v1/Alerts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Alert parameters - /// Client to make requests to Twilio - /// A single instance of Alert - public static AlertResource Fetch(FetchAlertOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Alert parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Alert - public static async System.Threading.Tasks.Task FetchAsync(FetchAlertOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Alert - public static AlertResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAlertOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Alert - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAlertOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAlertOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Monitor, - "/v1/Alerts", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Alert parameters - /// Client to make requests to Twilio - /// A single instance of Alert - public static ResourceSet Read(ReadAlertOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("alerts", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Alert parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Alert - public static async System.Threading.Tasks.Task> ReadAsync(ReadAlertOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("alerts", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Only show alerts for this log-level - /// Only include alerts that occurred on or after this date and time - /// Only include alerts that occurred on or before this date and time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Alert - public static ResourceSet Read(string logLevel = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAlertOptions(){LogLevel = logLevel, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Only show alerts for this log-level - /// Only include alerts that occurred on or after this date and time - /// Only include alerts that occurred on or before this date and time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Alert - public static async System.Threading.Tasks.Task> ReadAsync(string logLevel = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAlertOptions(){LogLevel = logLevel, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("alerts", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Monitor) - ); - - var response = client.Request(request); - return Page.FromJson("alerts", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Monitor) - ); - - var response = client.Request(request); - return Page.FromJson("alerts", response.Content); - } - - /// - /// Converts a JSON string into a AlertResource object - /// - /// Raw JSON string - /// AlertResource object represented by the provided JSON - public static AlertResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The text of the alert - /// - [JsonProperty("alert_text")] - public string AlertText { get; private set; } - /// - /// The API version used when the alert was generated - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date and time when the alert was generated specified in ISO 8601 format - /// - [JsonProperty("date_generated")] - public DateTime? DateGenerated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The error code for the condition that generated the alert - /// - [JsonProperty("error_code")] - public string ErrorCode { get; private set; } - /// - /// The log level - /// - [JsonProperty("log_level")] - public string LogLevel { get; private set; } - /// - /// The URL of the page in our Error Dictionary with more information about the error condition - /// - [JsonProperty("more_info")] - public string MoreInfo { get; private set; } - /// - /// The method used by the request that generated the alert - /// - [JsonProperty("request_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod RequestMethod { get; private set; } - /// - /// The URL of the request that generated the alert - /// - [JsonProperty("request_url")] - public string RequestUrl { get; private set; } - /// - /// The variables passed in the request that generated the alert - /// - [JsonProperty("request_variables")] - public string RequestVariables { get; private set; } - /// - /// The SID of the resource for which the alert was generated - /// - [JsonProperty("resource_sid")] - public string ResourceSid { get; private set; } - /// - /// The response body of the request that generated the alert - /// - [JsonProperty("response_body")] - public string ResponseBody { get; private set; } - /// - /// The response headers of the request that generated the alert - /// - [JsonProperty("response_headers")] - public string ResponseHeaders { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The absolute URL of the Alert resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The request headers of the request that generated the alert - /// - [JsonProperty("request_headers")] - public string RequestHeaders { get; private set; } - /// - /// The SID of the service or resource that generated the alert - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - - private AlertResource() - { - - } - } +{ + + public class AlertResource : Resource + { + private static Request BuildFetchRequest(FetchAlertOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Monitor, + "/v1/Alerts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Alert parameters + /// Client to make requests to Twilio + /// A single instance of Alert + public static AlertResource Fetch(FetchAlertOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Alert parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Alert + public static async System.Threading.Tasks.Task FetchAsync(FetchAlertOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Alert + public static AlertResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAlertOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Alert + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAlertOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAlertOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Monitor, + "/v1/Alerts", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Alert parameters + /// Client to make requests to Twilio + /// A single instance of Alert + public static ResourceSet Read(ReadAlertOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("alerts", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Alert parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Alert + public static async System.Threading.Tasks.Task> ReadAsync(ReadAlertOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("alerts", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Only show alerts for this log-level + /// Only include alerts that occurred on or after this date and time + /// Only include alerts that occurred on or before this date and time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Alert + public static ResourceSet Read(string logLevel = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAlertOptions() { LogLevel = logLevel, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Only show alerts for this log-level + /// Only include alerts that occurred on or after this date and time + /// Only include alerts that occurred on or before this date and time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Alert + public static async System.Threading.Tasks.Task> ReadAsync(string logLevel = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAlertOptions() { LogLevel = logLevel, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("alerts", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Monitor) + ); + + var response = client.Request(request); + return Page.FromJson("alerts", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Monitor) + ); + + var response = client.Request(request); + return Page.FromJson("alerts", response.Content); + } + + /// + /// Converts a JSON string into a AlertResource object + /// + /// Raw JSON string + /// AlertResource object represented by the provided JSON + public static AlertResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The text of the alert + /// + [JsonProperty("alert_text")] + public string AlertText { get; private set; } + /// + /// The API version used when the alert was generated + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date and time when the alert was generated specified in ISO 8601 format + /// + [JsonProperty("date_generated")] + public DateTime? DateGenerated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The error code for the condition that generated the alert + /// + [JsonProperty("error_code")] + public string ErrorCode { get; private set; } + /// + /// The log level + /// + [JsonProperty("log_level")] + public string LogLevel { get; private set; } + /// + /// The URL of the page in our Error Dictionary with more information about the error condition + /// + [JsonProperty("more_info")] + public string MoreInfo { get; private set; } + /// + /// The method used by the request that generated the alert + /// + [JsonProperty("request_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod RequestMethod { get; private set; } + /// + /// The URL of the request that generated the alert + /// + [JsonProperty("request_url")] + public string RequestUrl { get; private set; } + /// + /// The variables passed in the request that generated the alert + /// + [JsonProperty("request_variables")] + public string RequestVariables { get; private set; } + /// + /// The SID of the resource for which the alert was generated + /// + [JsonProperty("resource_sid")] + public string ResourceSid { get; private set; } + /// + /// The response body of the request that generated the alert + /// + [JsonProperty("response_body")] + public string ResponseBody { get; private set; } + /// + /// The response headers of the request that generated the alert + /// + [JsonProperty("response_headers")] + public string ResponseHeaders { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The absolute URL of the Alert resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The request headers of the request that generated the alert + /// + [JsonProperty("request_headers")] + public string RequestHeaders { get; private set; } + /// + /// The SID of the service or resource that generated the alert + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + + private AlertResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Monitor/V1/EventOptions.cs b/src/Twilio/Rest/Monitor/V1/EventOptions.cs index 3f21c19d3..4a58a4b0a 100644 --- a/src/Twilio/Rest/Monitor/V1/EventOptions.cs +++ b/src/Twilio/Rest/Monitor/V1/EventOptions.cs @@ -9,110 +9,110 @@ using Twilio.Converters; namespace Twilio.Rest.Monitor.V1 -{ - +{ + + /// + /// FetchEventOptions + /// + public class FetchEventOptions : IOptions + { /// - /// FetchEventOptions + /// The SID that identifies the resource to fetch /// - public class FetchEventOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEventOptions - /// - /// The SID that identifies the resource to fetch - public FetchEventOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Returns a list of events in the account, sorted by event-date. + /// Construct a new FetchEventOptions /// - public class ReadEventOptions : ReadOptions - { - /// - /// Only include events initiated by this Actor - /// - public string ActorSid { get; set; } - /// - /// Only include events of this Event Type - /// - public string EventType { get; set; } - /// - /// Only include events that refer to this resource - /// - public string ResourceSid { get; set; } - /// - /// Only include events that originated from this IP address - /// - public string SourceIpAddress { get; set; } - /// - /// Only include events that occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include events that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ActorSid != null) - { - p.Add(new KeyValuePair("ActorSid", ActorSid.ToString())); - } - - if (EventType != null) - { - p.Add(new KeyValuePair("EventType", EventType)); - } - - if (ResourceSid != null) - { - p.Add(new KeyValuePair("ResourceSid", ResourceSid.ToString())); - } - - if (SourceIpAddress != null) - { - p.Add(new KeyValuePair("SourceIpAddress", SourceIpAddress)); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID that identifies the resource to fetch + public FetchEventOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Returns a list of events in the account, sorted by event-date. + /// + public class ReadEventOptions : ReadOptions + { + /// + /// Only include events initiated by this Actor + /// + public string ActorSid { get; set; } + /// + /// Only include events of this Event Type + /// + public string EventType { get; set; } + /// + /// Only include events that refer to this resource + /// + public string ResourceSid { get; set; } + /// + /// Only include events that originated from this IP address + /// + public string SourceIpAddress { get; set; } + /// + /// Only include events that occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include events that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ActorSid != null) + { + p.Add(new KeyValuePair("ActorSid", ActorSid.ToString())); + } + + if (EventType != null) + { + p.Add(new KeyValuePair("EventType", EventType)); + } + + if (ResourceSid != null) + { + p.Add(new KeyValuePair("ResourceSid", ResourceSid.ToString())); + } + + if (SourceIpAddress != null) + { + p.Add(new KeyValuePair("SourceIpAddress", SourceIpAddress)); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Monitor/V1/EventResource.cs b/src/Twilio/Rest/Monitor/V1/EventResource.cs index 7fd95aad2..33b29dfc5 100644 --- a/src/Twilio/Rest/Monitor/V1/EventResource.cs +++ b/src/Twilio/Rest/Monitor/V1/EventResource.cs @@ -16,323 +16,323 @@ using Twilio.Http; namespace Twilio.Rest.Monitor.V1 -{ - - public class EventResource : Resource - { - private static Request BuildFetchRequest(FetchEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Monitor, - "/v1/Events/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static EventResource Fetch(FetchEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task FetchAsync(FetchEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Event - public static EventResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEventOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEventOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Monitor, - "/v1/Events", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of events in the account, sorted by event-date. - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Returns a list of events in the account, sorted by event-date. - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Returns a list of events in the account, sorted by event-date. - /// - /// Only include events initiated by this Actor - /// Only include events of this Event Type - /// Only include events that refer to this resource - /// Only include events that originated from this IP address - /// Only include events that occurred on or after this date - /// Only include events that occurred on or before this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(string actorSid = null, - string eventType = null, - string resourceSid = null, - string sourceIpAddress = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(){ActorSid = actorSid, EventType = eventType, ResourceSid = resourceSid, SourceIpAddress = sourceIpAddress, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Returns a list of events in the account, sorted by event-date. - /// - /// Only include events initiated by this Actor - /// Only include events of this Event Type - /// Only include events that refer to this resource - /// Only include events that originated from this IP address - /// Only include events that occurred on or after this date - /// Only include events that occurred on or before this date - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(string actorSid = null, - string eventType = null, - string resourceSid = null, - string sourceIpAddress = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(){ActorSid = actorSid, EventType = eventType, ResourceSid = resourceSid, SourceIpAddress = sourceIpAddress, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Monitor) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Monitor) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Converts a JSON string into a EventResource object - /// - /// Raw JSON string - /// EventResource object represented by the provided JSON - public static EventResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the actor that caused the event, if available - /// - [JsonProperty("actor_sid")] - public string ActorSid { get; private set; } - /// - /// The type of actor that caused the event - /// - [JsonProperty("actor_type")] - public string ActorType { get; private set; } - /// - /// A description of the event - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// A JSON string that represents an object with additional data about the event - /// - [JsonProperty("event_data")] - public object EventData { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the event was recorded - /// - [JsonProperty("event_date")] - public DateTime? EventDate { get; private set; } - /// - /// The event's type - /// - [JsonProperty("event_type")] - public string EventType { get; private set; } - /// - /// The SID of the resource that was affected - /// - [JsonProperty("resource_sid")] - public string ResourceSid { get; private set; } - /// - /// The type of resource that was affected - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The originating system or interface that caused the event - /// - [JsonProperty("source")] - public string Source { get; private set; } - /// - /// The IP address of the source - /// - [JsonProperty("source_ip_address")] - public string SourceIpAddress { get; private set; } - /// - /// The absolute URL of the resource that was affected - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The absolute URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private EventResource() - { - - } - } +{ + + public class EventResource : Resource + { + private static Request BuildFetchRequest(FetchEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Monitor, + "/v1/Events/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static EventResource Fetch(FetchEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task FetchAsync(FetchEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Event + public static EventResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEventOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEventOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Monitor, + "/v1/Events", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of events in the account, sorted by event-date. + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Returns a list of events in the account, sorted by event-date. + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Returns a list of events in the account, sorted by event-date. + /// + /// Only include events initiated by this Actor + /// Only include events of this Event Type + /// Only include events that refer to this resource + /// Only include events that originated from this IP address + /// Only include events that occurred on or after this date + /// Only include events that occurred on or before this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(string actorSid = null, + string eventType = null, + string resourceSid = null, + string sourceIpAddress = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions() { ActorSid = actorSid, EventType = eventType, ResourceSid = resourceSid, SourceIpAddress = sourceIpAddress, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Returns a list of events in the account, sorted by event-date. + /// + /// Only include events initiated by this Actor + /// Only include events of this Event Type + /// Only include events that refer to this resource + /// Only include events that originated from this IP address + /// Only include events that occurred on or after this date + /// Only include events that occurred on or before this date + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(string actorSid = null, + string eventType = null, + string resourceSid = null, + string sourceIpAddress = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions() { ActorSid = actorSid, EventType = eventType, ResourceSid = resourceSid, SourceIpAddress = sourceIpAddress, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Monitor) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Monitor) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Converts a JSON string into a EventResource object + /// + /// Raw JSON string + /// EventResource object represented by the provided JSON + public static EventResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the actor that caused the event, if available + /// + [JsonProperty("actor_sid")] + public string ActorSid { get; private set; } + /// + /// The type of actor that caused the event + /// + [JsonProperty("actor_type")] + public string ActorType { get; private set; } + /// + /// A description of the event + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// A JSON string that represents an object with additional data about the event + /// + [JsonProperty("event_data")] + public object EventData { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the event was recorded + /// + [JsonProperty("event_date")] + public DateTime? EventDate { get; private set; } + /// + /// The event's type + /// + [JsonProperty("event_type")] + public string EventType { get; private set; } + /// + /// The SID of the resource that was affected + /// + [JsonProperty("resource_sid")] + public string ResourceSid { get; private set; } + /// + /// The type of resource that was affected + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The originating system or interface that caused the event + /// + [JsonProperty("source")] + public string Source { get; private set; } + /// + /// The IP address of the source + /// + [JsonProperty("source_ip_address")] + public string SourceIpAddress { get; private set; } + /// + /// The absolute URL of the resource that was affected + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The absolute URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private EventResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/CredentialOptions.cs b/src/Twilio/Rest/Notify/V1/CredentialOptions.cs index b03c1ebb2..7207ea303 100644 --- a/src/Twilio/Rest/Notify/V1/CredentialOptions.cs +++ b/src/Twilio/Rest/Notify/V1/CredentialOptions.cs @@ -9,265 +9,265 @@ using Twilio.Converters; namespace Twilio.Rest.Notify.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadCredentialOptions + /// + public class ReadCredentialOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadCredentialOptions + /// Generate the necessary parameters /// - public class ReadCredentialOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateCredentialOptions + /// + public class CreateCredentialOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateCredentialOptions + /// The Credential type /// - public class CreateCredentialOptions : IOptions - { - /// - /// The Credential type - /// - public CredentialResource.PushServiceEnum Type { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL-encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] URL-encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging - /// - public string Secret { get; set; } - - /// - /// Construct a new CreateCredentialOptions - /// - /// The Credential type - public CreateCredentialOptions(CredentialResource.PushServiceEnum type) - { - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public CredentialResource.PushServiceEnum Type { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchCredentialOptions + /// A string to describe the resource /// - public class FetchCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialOptions - /// - /// The unique string that identifies the resource - public FetchCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// UpdateCredentialOptions + /// [APN only] The URL-encoded representation of the certificate /// - public class UpdateCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// [APN only] The URL-encoded representation of the certificate - /// - public string Certificate { get; set; } - /// - /// [APN only] URL-encoded representation of the private key - /// - public string PrivateKey { get; set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - public bool? Sandbox { get; set; } - /// - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging - /// - public string ApiKey { get; set; } - /// - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging - /// - public string Secret { get; set; } - - /// - /// Construct a new UpdateCredentialOptions - /// - /// The unique string that identifies the resource - public UpdateCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Certificate != null) - { - p.Add(new KeyValuePair("Certificate", Certificate)); - } - - if (PrivateKey != null) - { - p.Add(new KeyValuePair("PrivateKey", PrivateKey)); - } - - if (Sandbox != null) - { - p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); - } - - if (ApiKey != null) - { - p.Add(new KeyValuePair("ApiKey", ApiKey)); - } - - if (Secret != null) - { - p.Add(new KeyValuePair("Secret", Secret)); - } - - return p; - } - } - + public string Certificate { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteCredentialOptions + /// [APN only] URL-encoded representation of the private key /// - public class DeleteCredentialOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialOptions - /// - /// The unique string that identifies the resource - public DeleteCredentialOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging + /// + public string Secret { get; set; } + + /// + /// Construct a new CreateCredentialOptions + /// + /// The Credential type + public CreateCredentialOptions(CredentialResource.PushServiceEnum type) + { + Type = type; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchCredentialOptions + /// + public class FetchCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCredentialOptions + /// + /// The unique string that identifies the resource + public FetchCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// UpdateCredentialOptions + /// + public class UpdateCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// [APN only] The URL-encoded representation of the certificate + /// + public string Certificate { get; set; } + /// + /// [APN only] URL-encoded representation of the private key + /// + public string PrivateKey { get; set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + public bool? Sandbox { get; set; } + /// + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging + /// + public string ApiKey { get; set; } + /// + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging + /// + public string Secret { get; set; } + + /// + /// Construct a new UpdateCredentialOptions + /// + /// The unique string that identifies the resource + public UpdateCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Certificate != null) + { + p.Add(new KeyValuePair("Certificate", Certificate)); + } + + if (PrivateKey != null) + { + p.Add(new KeyValuePair("PrivateKey", PrivateKey)); + } + + if (Sandbox != null) + { + p.Add(new KeyValuePair("Sandbox", Sandbox.Value.ToString().ToLower())); + } + + if (ApiKey != null) + { + p.Add(new KeyValuePair("ApiKey", ApiKey)); + } + + if (Secret != null) + { + p.Add(new KeyValuePair("Secret", Secret)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteCredentialOptions + /// + public class DeleteCredentialOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialOptions + /// + /// The unique string that identifies the resource + public DeleteCredentialOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/CredentialResource.cs b/src/Twilio/Rest/Notify/V1/CredentialResource.cs index 4c3a8625e..bbd166a54 100644 --- a/src/Twilio/Rest/Notify/V1/CredentialResource.cs +++ b/src/Twilio/Rest/Notify/V1/CredentialResource.cs @@ -19,542 +19,542 @@ using Twilio.Types; namespace Twilio.Rest.Notify.V1 -{ - - public class CredentialResource : Resource - { - public sealed class PushServiceEnum : StringEnum - { - private PushServiceEnum(string value) : base(value) {} - public PushServiceEnum() {} - public static implicit operator PushServiceEnum(string value) - { - return new PushServiceEnum(value); - } - - public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); - public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); - public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); - } - - private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Credentials", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Credential - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("credentials", response.Content); - } - - private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Credentials", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The Credential type - /// A string to describe the resource - /// [APN only] The URL-encoded representation of the certificate - /// [APN only] URL-encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Create(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The Credential type - /// A string to describe the resource - /// [APN only] The URL-encoded representation of the certificate - /// [APN only] URL-encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new CreateCredentialOptions(type){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Credentials/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// [APN only] The URL-encoded representation of the certificate - /// [APN only] URL-encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// Client to make requests to Twilio - /// A single instance of Credential - public static CredentialResource Update(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// [APN only] The URL-encoded representation of the certificate - /// [APN only] URL-encoded representation of the private key - /// [APN only] Whether to send the credential to sandbox APNs - /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud - /// messaging - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string certificate = null, - string privateKey = null, - bool? sandbox = null, - string apiKey = null, - string secret = null, - ITwilioRestClient client = null) - { - var options = new UpdateCredentialOptions(pathSid){FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Notify, - "/v1/Credentials/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Credential parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Credential - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Credential - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CredentialResource object - /// - /// Raw JSON string - /// CredentialResource object represented by the provided JSON - public static CredentialResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The Credential type, one of `gcm`, `fcm`, or `apn` - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public CredentialResource.PushServiceEnum Type { get; private set; } - /// - /// [APN only] Whether to send the credential to sandbox APNs - /// - [JsonProperty("sandbox")] - public string Sandbox { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Credential resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialResource() - { - - } - } +{ + + public class CredentialResource : Resource + { + public sealed class PushServiceEnum : StringEnum + { + private PushServiceEnum(string value) : base(value) { } + public PushServiceEnum() { } + public static implicit operator PushServiceEnum(string value) + { + return new PushServiceEnum(value); + } + + public static readonly PushServiceEnum Gcm = new PushServiceEnum("gcm"); + public static readonly PushServiceEnum Apn = new PushServiceEnum("apn"); + public static readonly PushServiceEnum Fcm = new PushServiceEnum("fcm"); + } + + private static Request BuildReadRequest(ReadCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Credentials", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(ReadCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Credential + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("credentials", response.Content); + } + + private static Request BuildCreateRequest(CreateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Credentials", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CreateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The Credential type + /// A string to describe the resource + /// [APN only] The URL-encoded representation of the certificate + /// [APN only] URL-encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Create(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The Credential type + /// A string to describe the resource + /// [APN only] The URL-encoded representation of the certificate + /// [APN only] URL-encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task CreateAsync(CredentialResource.PushServiceEnum type, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new CreateCredentialOptions(type) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Credentials/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(UpdateCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// [APN only] The URL-encoded representation of the certificate + /// [APN only] URL-encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// Client to make requests to Twilio + /// A single instance of Credential + public static CredentialResource Update(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// [APN only] The URL-encoded representation of the certificate + /// [APN only] URL-encoded representation of the private key + /// [APN only] Whether to send the credential to sandbox APNs + /// [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud + /// messaging + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string certificate = null, + string privateKey = null, + bool? sandbox = null, + string apiKey = null, + string secret = null, + ITwilioRestClient client = null) + { + var options = new UpdateCredentialOptions(pathSid) { FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Notify, + "/v1/Credentials/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Credential parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Credential + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Credential + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CredentialResource object + /// + /// Raw JSON string + /// CredentialResource object represented by the provided JSON + public static CredentialResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The Credential type, one of `gcm`, `fcm`, or `apn` + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public CredentialResource.PushServiceEnum Type { get; private set; } + /// + /// [APN only] Whether to send the credential to sandbox APNs + /// + [JsonProperty("sandbox")] + public string Sandbox { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Credential resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/Service/BindingOptions.cs b/src/Twilio/Rest/Notify/V1/Service/BindingOptions.cs index b597e9b41..76201cd11 100644 --- a/src/Twilio/Rest/Notify/V1/Service/BindingOptions.cs +++ b/src/Twilio/Rest/Notify/V1/Service/BindingOptions.cs @@ -10,258 +10,258 @@ using Twilio.Converters; namespace Twilio.Rest.Notify.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchBindingOptions + /// + public class FetchBindingOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchBindingOptions + /// The SID of the Service to fetch the resource from /// - public class FetchBindingOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBindingOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - public FetchBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteBindingOptions + /// The unique string that identifies the resource /// - public class DeleteBindingOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBindingOptions - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - public DeleteBindingOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateBindingOptions + /// Construct a new FetchBindingOptions /// - public class CreateBindingOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public string Identity { get; } - /// - /// The type of the Binding - /// - public BindingResource.BindingTypeEnum BindingType { get; } - /// - /// The channel-specific address - /// - public string Address { get; } - /// - /// A tag that can be used to select the Bindings to notify - /// - public List Tag { get; set; } - /// - /// The protocol version to use to send the notification - /// - public string NotificationProtocolVersion { get; set; } - /// - /// The SID of the Credential resource to be used to send notifications to this Binding - /// - public string CredentialSid { get; set; } - /// - /// Deprecated - /// - public string Endpoint { get; set; } - - /// - /// Construct a new CreateBindingOptions - /// - /// The SID of the Service to create the resource under - /// The `identity` value that identifies the new resource's User - /// The type of the Binding - /// The channel-specific address - public CreateBindingOptions(string pathServiceSid, - string identity, - BindingResource.BindingTypeEnum bindingType, - string address) - { - PathServiceSid = pathServiceSid; - Identity = identity; - BindingType = bindingType; - Address = address; - Tag = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (BindingType != null) - { - p.Add(new KeyValuePair("BindingType", BindingType.ToString())); - } - - if (Address != null) - { - p.Add(new KeyValuePair("Address", Address)); - } - - if (Tag != null) - { - p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); - } - - if (NotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("NotificationProtocolVersion", NotificationProtocolVersion)); - } - - if (CredentialSid != null) - { - p.Add(new KeyValuePair("CredentialSid", CredentialSid.ToString())); - } - - if (Endpoint != null) - { - p.Add(new KeyValuePair("Endpoint", Endpoint)); - } - - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + public FetchBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadBindingOptions + /// Generate the necessary parameters /// - public class ReadBindingOptions : ReadOptions - { - /// - /// The SID of the Service to read the resource from - /// - public string PathServiceSid { get; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// The `identity` value of the resources to read - /// - public List Identity { get; set; } - /// - /// Only list Bindings that have all of the specified Tags - /// - public List Tag { get; set; } - - /// - /// Construct a new ReadBindingOptions - /// - /// The SID of the Service to read the resource from - public ReadBindingOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Identity = new List(); - Tag = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); - } - - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (Tag != null) - { - p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteBindingOptions + /// + public class DeleteBindingOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBindingOptions + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + public DeleteBindingOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateBindingOptions + /// + public class CreateBindingOptions : IOptions + { + /// + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public string Identity { get; } + /// + /// The type of the Binding + /// + public BindingResource.BindingTypeEnum BindingType { get; } + /// + /// The channel-specific address + /// + public string Address { get; } + /// + /// A tag that can be used to select the Bindings to notify + /// + public List Tag { get; set; } + /// + /// The protocol version to use to send the notification + /// + public string NotificationProtocolVersion { get; set; } + /// + /// The SID of the Credential resource to be used to send notifications to this Binding + /// + public string CredentialSid { get; set; } + /// + /// Deprecated + /// + public string Endpoint { get; set; } + + /// + /// Construct a new CreateBindingOptions + /// + /// The SID of the Service to create the resource under + /// The `identity` value that identifies the new resource's User + /// The type of the Binding + /// The channel-specific address + public CreateBindingOptions(string pathServiceSid, + string identity, + BindingResource.BindingTypeEnum bindingType, + string address) + { + PathServiceSid = pathServiceSid; + Identity = identity; + BindingType = bindingType; + Address = address; + Tag = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (BindingType != null) + { + p.Add(new KeyValuePair("BindingType", BindingType.ToString())); + } + + if (Address != null) + { + p.Add(new KeyValuePair("Address", Address)); + } + + if (Tag != null) + { + p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); + } + + if (NotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("NotificationProtocolVersion", NotificationProtocolVersion)); + } + + if (CredentialSid != null) + { + p.Add(new KeyValuePair("CredentialSid", CredentialSid.ToString())); + } + + if (Endpoint != null) + { + p.Add(new KeyValuePair("Endpoint", Endpoint)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadBindingOptions + /// + public class ReadBindingOptions : ReadOptions + { + /// + /// The SID of the Service to read the resource from + /// + public string PathServiceSid { get; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// The `identity` value of the resources to read + /// + public List Identity { get; set; } + /// + /// Only list Bindings that have all of the specified Tags + /// + public List Tag { get; set; } + + /// + /// Construct a new ReadBindingOptions + /// + /// The SID of the Service to read the resource from + public ReadBindingOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Identity = new List(); + Tag = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", StartDate.Value.ToString("yyyy-MM-dd"))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", EndDate.Value.ToString("yyyy-MM-dd"))); + } + + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (Tag != null) + { + p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/Service/BindingResource.cs b/src/Twilio/Rest/Notify/V1/Service/BindingResource.cs index 8ab1eb8ee..0358305ee 100644 --- a/src/Twilio/Rest/Notify/V1/Service/BindingResource.cs +++ b/src/Twilio/Rest/Notify/V1/Service/BindingResource.cs @@ -19,507 +19,507 @@ using Twilio.Types; namespace Twilio.Rest.Notify.V1.Service -{ - - public class BindingResource : Resource - { - public sealed class BindingTypeEnum : StringEnum - { - private BindingTypeEnum(string value) : base(value) {} - public BindingTypeEnum() {} - public static implicit operator BindingTypeEnum(string value) - { - return new BindingTypeEnum(value); - } - - public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); - public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); - public static readonly BindingTypeEnum Sms = new BindingTypeEnum("sms"); - public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); - public static readonly BindingTypeEnum FacebookMessenger = new BindingTypeEnum("facebook-messenger"); - public static readonly BindingTypeEnum Alexa = new BindingTypeEnum("alexa"); - } - - private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBindingOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Notify, - "/v1/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Binding - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBindingOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Services/" + options.PathServiceSid + "/Bindings", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Create(CreateBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task CreateAsync(CreateBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The `identity` value that identifies the new resource's User - /// The type of the Binding - /// The channel-specific address - /// A tag that can be used to select the Bindings to notify - /// The protocol version to use to send the notification - /// The SID of the Credential resource to be used to send notifications to this Binding - /// - /// Deprecated - /// Client to make requests to Twilio - /// A single instance of Binding - public static BindingResource Create(string pathServiceSid, - string identity, - BindingResource.BindingTypeEnum bindingType, - string address, - List tag = null, - string notificationProtocolVersion = null, - string credentialSid = null, - string endpoint = null, - ITwilioRestClient client = null) - { - var options = new CreateBindingOptions(pathServiceSid, identity, bindingType, address){Tag = tag, NotificationProtocolVersion = notificationProtocolVersion, CredentialSid = credentialSid, Endpoint = endpoint}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The `identity` value that identifies the new resource's User - /// The type of the Binding - /// The channel-specific address - /// A tag that can be used to select the Bindings to notify - /// The protocol version to use to send the notification - /// The SID of the Credential resource to be used to send notifications to this Binding - /// - /// Deprecated - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - BindingResource.BindingTypeEnum bindingType, - string address, - List tag = null, - string notificationProtocolVersion = null, - string credentialSid = null, - string endpoint = null, - ITwilioRestClient client = null) - { - var options = new CreateBindingOptions(pathServiceSid, identity, bindingType, address){Tag = tag, NotificationProtocolVersion = notificationProtocolVersion, CredentialSid = credentialSid, Endpoint = endpoint}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Services/" + options.PathServiceSid + "/Bindings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Binding parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("bindings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resource from - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// The `identity` value of the resources to read - /// Only list Bindings that have all of the specified Tags - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Binding - public static ResourceSet Read(string pathServiceSid, - DateTime? startDate = null, - DateTime? endDate = null, - List identity = null, - List tag = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){StartDate = startDate, EndDate = endDate, Identity = identity, Tag = tag, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resource from - /// Only include usage that has occurred on or after this date - /// Only include usage that occurred on or before this date - /// The `identity` value of the resources to read - /// Only list Bindings that have all of the specified Tags - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Binding - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - DateTime? startDate = null, - DateTime? endDate = null, - List identity = null, - List tag = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBindingOptions(pathServiceSid){StartDate = startDate, EndDate = endDate, Identity = identity, Tag = tag, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("bindings", response.Content); - } - - /// - /// Converts a JSON string into a BindingResource object - /// - /// Raw JSON string - /// BindingResource object represented by the provided JSON - public static BindingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Credential resource to be used to send notifications to this Binding - /// - [JsonProperty("credential_sid")] - public string CredentialSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The protocol version to use to send the notification - /// - [JsonProperty("notification_protocol_version")] - public string NotificationProtocolVersion { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("endpoint")] - public string Endpoint { get; private set; } - /// - /// The `identity` value that identifies the new resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The type of the Binding - /// - [JsonProperty("binding_type")] - public string BindingType { get; private set; } - /// - /// The channel-specific address - /// - [JsonProperty("address")] - public string Address { get; private set; } - /// - /// The list of tags associated with this Binding - /// - [JsonProperty("tags")] - public List Tags { get; private set; } - /// - /// The absolute URL of the Binding resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BindingResource() - { - - } - } +{ + + public class BindingResource : Resource + { + public sealed class BindingTypeEnum : StringEnum + { + private BindingTypeEnum(string value) : base(value) { } + public BindingTypeEnum() { } + public static implicit operator BindingTypeEnum(string value) + { + return new BindingTypeEnum(value); + } + + public static readonly BindingTypeEnum Apn = new BindingTypeEnum("apn"); + public static readonly BindingTypeEnum Gcm = new BindingTypeEnum("gcm"); + public static readonly BindingTypeEnum Sms = new BindingTypeEnum("sms"); + public static readonly BindingTypeEnum Fcm = new BindingTypeEnum("fcm"); + public static readonly BindingTypeEnum FacebookMessenger = new BindingTypeEnum("facebook-messenger"); + public static readonly BindingTypeEnum Alexa = new BindingTypeEnum("alexa"); + } + + private static Request BuildFetchRequest(FetchBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(FetchBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBindingOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Notify, + "/v1/Services/" + options.PathServiceSid + "/Bindings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Binding + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBindingOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Services/" + options.PathServiceSid + "/Bindings", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Create(CreateBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task CreateAsync(CreateBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The `identity` value that identifies the new resource's User + /// The type of the Binding + /// The channel-specific address + /// A tag that can be used to select the Bindings to notify + /// The protocol version to use to send the notification + /// The SID of the Credential resource to be used to send notifications to this Binding + /// + /// Deprecated + /// Client to make requests to Twilio + /// A single instance of Binding + public static BindingResource Create(string pathServiceSid, + string identity, + BindingResource.BindingTypeEnum bindingType, + string address, + List tag = null, + string notificationProtocolVersion = null, + string credentialSid = null, + string endpoint = null, + ITwilioRestClient client = null) + { + var options = new CreateBindingOptions(pathServiceSid, identity, bindingType, address) { Tag = tag, NotificationProtocolVersion = notificationProtocolVersion, CredentialSid = credentialSid, Endpoint = endpoint }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The `identity` value that identifies the new resource's User + /// The type of the Binding + /// The channel-specific address + /// A tag that can be used to select the Bindings to notify + /// The protocol version to use to send the notification + /// The SID of the Credential resource to be used to send notifications to this Binding + /// + /// Deprecated + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + BindingResource.BindingTypeEnum bindingType, + string address, + List tag = null, + string notificationProtocolVersion = null, + string credentialSid = null, + string endpoint = null, + ITwilioRestClient client = null) + { + var options = new CreateBindingOptions(pathServiceSid, identity, bindingType, address) { Tag = tag, NotificationProtocolVersion = notificationProtocolVersion, CredentialSid = credentialSid, Endpoint = endpoint }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBindingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Services/" + options.PathServiceSid + "/Bindings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(ReadBindingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Binding parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(ReadBindingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("bindings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resource from + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// The `identity` value of the resources to read + /// Only list Bindings that have all of the specified Tags + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Binding + public static ResourceSet Read(string pathServiceSid, + DateTime? startDate = null, + DateTime? endDate = null, + List identity = null, + List tag = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { StartDate = startDate, EndDate = endDate, Identity = identity, Tag = tag, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resource from + /// Only include usage that has occurred on or after this date + /// Only include usage that occurred on or before this date + /// The `identity` value of the resources to read + /// Only list Bindings that have all of the specified Tags + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Binding + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + DateTime? startDate = null, + DateTime? endDate = null, + List identity = null, + List tag = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBindingOptions(pathServiceSid) { StartDate = startDate, EndDate = endDate, Identity = identity, Tag = tag, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("bindings", response.Content); + } + + /// + /// Converts a JSON string into a BindingResource object + /// + /// Raw JSON string + /// BindingResource object represented by the provided JSON + public static BindingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Credential resource to be used to send notifications to this Binding + /// + [JsonProperty("credential_sid")] + public string CredentialSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The protocol version to use to send the notification + /// + [JsonProperty("notification_protocol_version")] + public string NotificationProtocolVersion { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("endpoint")] + public string Endpoint { get; private set; } + /// + /// The `identity` value that identifies the new resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The type of the Binding + /// + [JsonProperty("binding_type")] + public string BindingType { get; private set; } + /// + /// The channel-specific address + /// + [JsonProperty("address")] + public string Address { get; private set; } + /// + /// The list of tags associated with this Binding + /// + [JsonProperty("tags")] + public List Tags { get; private set; } + /// + /// The absolute URL of the Binding resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BindingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/Service/NotificationOptions.cs b/src/Twilio/Rest/Notify/V1/Service/NotificationOptions.cs index a9b22f596..03d86ebe9 100644 --- a/src/Twilio/Rest/Notify/V1/Service/NotificationOptions.cs +++ b/src/Twilio/Rest/Notify/V1/Service/NotificationOptions.cs @@ -10,203 +10,203 @@ using Twilio.Converters; namespace Twilio.Rest.Notify.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateNotificationOptions + /// + public class CreateNotificationOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateNotificationOptions - /// - public class CreateNotificationOptions : IOptions - { - /// - /// The SID of the Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The `identity` value that identifies the new resource's User - /// - public List Identity { get; set; } - /// - /// A tag that selects the Bindings to notify - /// - public List Tag { get; set; } - /// - /// The notification body text - /// - public string Body { get; set; } - /// - /// The priority of the notification - /// - public NotificationResource.PriorityEnum Priority { get; set; } - /// - /// How long, in seconds, the notification is valid - /// - public int? Ttl { get; set; } - /// - /// The notification title - /// - public string Title { get; set; } - /// - /// The name of the sound to be played for the notification - /// - public string Sound { get; set; } - /// - /// The actions to display for the notification - /// - public string Action { get; set; } - /// - /// The custom key-value pairs of the notification's payload - /// - public object Data { get; set; } - /// - /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS Bindings - /// - public object Apn { get; set; } - /// - /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM Bindings - /// - public object Gcm { get; set; } - /// - /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS Bindings - /// - public object Sms { get; set; } - /// - /// Deprecated - /// - public object FacebookMessenger { get; set; } - /// - /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM Bindings - /// - public object Fcm { get; set; } - /// - /// A Segment to notify - /// - public List Segment { get; set; } - /// - /// Deprecated - /// - public object Alexa { get; set; } - /// - /// The destination address specified as a JSON string - /// - public List ToBinding { get; set; } - /// - /// URL to send webhooks - /// - public string DeliveryCallbackUrl { get; set; } - - /// - /// Construct a new CreateNotificationOptions - /// - /// The SID of the Service to create the resource under - public CreateNotificationOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Identity = new List(); - Tag = new List(); - Segment = new List(); - ToBinding = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); - } - - if (Tag != null) - { - p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); - } - - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (Title != null) - { - p.Add(new KeyValuePair("Title", Title)); - } - - if (Sound != null) - { - p.Add(new KeyValuePair("Sound", Sound)); - } - - if (Action != null) - { - p.Add(new KeyValuePair("Action", Action)); - } - - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Apn != null) - { - p.Add(new KeyValuePair("Apn", Serializers.JsonObject(Apn))); - } - - if (Gcm != null) - { - p.Add(new KeyValuePair("Gcm", Serializers.JsonObject(Gcm))); - } - - if (Sms != null) - { - p.Add(new KeyValuePair("Sms", Serializers.JsonObject(Sms))); - } - - if (FacebookMessenger != null) - { - p.Add(new KeyValuePair("FacebookMessenger", Serializers.JsonObject(FacebookMessenger))); - } - - if (Fcm != null) - { - p.Add(new KeyValuePair("Fcm", Serializers.JsonObject(Fcm))); - } - - if (Segment != null) - { - p.AddRange(Segment.Select(prop => new KeyValuePair("Segment", prop))); - } - - if (Alexa != null) - { - p.Add(new KeyValuePair("Alexa", Serializers.JsonObject(Alexa))); - } - - if (ToBinding != null) - { - p.AddRange(ToBinding.Select(prop => new KeyValuePair("ToBinding", prop))); - } - - if (DeliveryCallbackUrl != null) - { - p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); - } - - return p; - } - } + /// The SID of the Service to create the resource under + /// + public string PathServiceSid { get; } + /// + /// The `identity` value that identifies the new resource's User + /// + public List Identity { get; set; } + /// + /// A tag that selects the Bindings to notify + /// + public List Tag { get; set; } + /// + /// The notification body text + /// + public string Body { get; set; } + /// + /// The priority of the notification + /// + public NotificationResource.PriorityEnum Priority { get; set; } + /// + /// How long, in seconds, the notification is valid + /// + public int? Ttl { get; set; } + /// + /// The notification title + /// + public string Title { get; set; } + /// + /// The name of the sound to be played for the notification + /// + public string Sound { get; set; } + /// + /// The actions to display for the notification + /// + public string Action { get; set; } + /// + /// The custom key-value pairs of the notification's payload + /// + public object Data { get; set; } + /// + /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS Bindings + /// + public object Apn { get; set; } + /// + /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM Bindings + /// + public object Gcm { get; set; } + /// + /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS Bindings + /// + public object Sms { get; set; } + /// + /// Deprecated + /// + public object FacebookMessenger { get; set; } + /// + /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM Bindings + /// + public object Fcm { get; set; } + /// + /// A Segment to notify + /// + public List Segment { get; set; } + /// + /// Deprecated + /// + public object Alexa { get; set; } + /// + /// The destination address specified as a JSON string + /// + public List ToBinding { get; set; } + /// + /// URL to send webhooks + /// + public string DeliveryCallbackUrl { get; set; } + + /// + /// Construct a new CreateNotificationOptions + /// + /// The SID of the Service to create the resource under + public CreateNotificationOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Identity = new List(); + Tag = new List(); + Segment = new List(); + ToBinding = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.AddRange(Identity.Select(prop => new KeyValuePair("Identity", prop))); + } + + if (Tag != null) + { + p.AddRange(Tag.Select(prop => new KeyValuePair("Tag", prop))); + } + + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (Title != null) + { + p.Add(new KeyValuePair("Title", Title)); + } + + if (Sound != null) + { + p.Add(new KeyValuePair("Sound", Sound)); + } + + if (Action != null) + { + p.Add(new KeyValuePair("Action", Action)); + } + + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Apn != null) + { + p.Add(new KeyValuePair("Apn", Serializers.JsonObject(Apn))); + } + + if (Gcm != null) + { + p.Add(new KeyValuePair("Gcm", Serializers.JsonObject(Gcm))); + } + + if (Sms != null) + { + p.Add(new KeyValuePair("Sms", Serializers.JsonObject(Sms))); + } + + if (FacebookMessenger != null) + { + p.Add(new KeyValuePair("FacebookMessenger", Serializers.JsonObject(FacebookMessenger))); + } + + if (Fcm != null) + { + p.Add(new KeyValuePair("Fcm", Serializers.JsonObject(Fcm))); + } + + if (Segment != null) + { + p.AddRange(Segment.Select(prop => new KeyValuePair("Segment", prop))); + } + + if (Alexa != null) + { + p.Add(new KeyValuePair("Alexa", Serializers.JsonObject(Alexa))); + } + + if (ToBinding != null) + { + p.AddRange(ToBinding.Select(prop => new KeyValuePair("ToBinding", prop))); + } + + if (DeliveryCallbackUrl != null) + { + p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/Service/NotificationResource.cs b/src/Twilio/Rest/Notify/V1/Service/NotificationResource.cs index 9e0941965..32188faa3 100644 --- a/src/Twilio/Rest/Notify/V1/Service/NotificationResource.cs +++ b/src/Twilio/Rest/Notify/V1/Service/NotificationResource.cs @@ -19,295 +19,295 @@ using Twilio.Types; namespace Twilio.Rest.Notify.V1.Service -{ - - public class NotificationResource : Resource - { - public sealed class PriorityEnum : StringEnum - { - private PriorityEnum(string value) : base(value) {} - public PriorityEnum() {} - public static implicit operator PriorityEnum(string value) - { - return new PriorityEnum(value); - } - - public static readonly PriorityEnum High = new PriorityEnum("high"); - public static readonly PriorityEnum Low = new PriorityEnum("low"); - } - - private static Request BuildCreateRequest(CreateNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Services/" + options.PathServiceSid + "/Notifications", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Create(CreateNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task CreateAsync(CreateNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The `identity` value that identifies the new resource's User - /// A tag that selects the Bindings to notify - /// The notification body text - /// The priority of the notification - /// How long, in seconds, the notification is valid - /// The notification title - /// The name of the sound to be played for the notification - /// The actions to display for the notification - /// The custom key-value pairs of the notification's payload - /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS - /// Bindings - /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM - /// Bindings - /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS - /// Bindings - /// Deprecated - /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM - /// Bindings - /// A Segment to notify - /// Deprecated - /// The destination address specified as a JSON string - /// URL to send webhooks - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Create(string pathServiceSid, - List identity = null, - List tag = null, - string body = null, - NotificationResource.PriorityEnum priority = null, - int? ttl = null, - string title = null, - string sound = null, - string action = null, - object data = null, - object apn = null, - object gcm = null, - object sms = null, - object facebookMessenger = null, - object fcm = null, - List segment = null, - object alexa = null, - List toBinding = null, - string deliveryCallbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateNotificationOptions(pathServiceSid){Identity = identity, Tag = tag, Body = body, Priority = priority, Ttl = ttl, Title = title, Sound = sound, Action = action, Data = data, Apn = apn, Gcm = gcm, Sms = sms, FacebookMessenger = facebookMessenger, Fcm = fcm, Segment = segment, Alexa = alexa, ToBinding = toBinding, DeliveryCallbackUrl = deliveryCallbackUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Service to create the resource under - /// The `identity` value that identifies the new resource's User - /// A tag that selects the Bindings to notify - /// The notification body text - /// The priority of the notification - /// How long, in seconds, the notification is valid - /// The notification title - /// The name of the sound to be played for the notification - /// The actions to display for the notification - /// The custom key-value pairs of the notification's payload - /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS - /// Bindings - /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM - /// Bindings - /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS - /// Bindings - /// Deprecated - /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM - /// Bindings - /// A Segment to notify - /// Deprecated - /// The destination address specified as a JSON string - /// URL to send webhooks - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - List identity = null, - List tag = null, - string body = null, - NotificationResource.PriorityEnum priority = null, - int? ttl = null, - string title = null, - string sound = null, - string action = null, - object data = null, - object apn = null, - object gcm = null, - object sms = null, - object facebookMessenger = null, - object fcm = null, - List segment = null, - object alexa = null, - List toBinding = null, - string deliveryCallbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateNotificationOptions(pathServiceSid){Identity = identity, Tag = tag, Body = body, Priority = priority, Ttl = ttl, Title = title, Sound = sound, Action = action, Data = data, Apn = apn, Gcm = gcm, Sms = sms, FacebookMessenger = facebookMessenger, Fcm = fcm, Segment = segment, Alexa = alexa, ToBinding = toBinding, DeliveryCallbackUrl = deliveryCallbackUrl}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NotificationResource object - /// - /// Raw JSON string - /// NotificationResource object represented by the provided JSON - public static NotificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The list of identity values of the Users to notify - /// - [JsonProperty("identities")] - public List Identities { get; private set; } - /// - /// The tags that select the Bindings to notify - /// - [JsonProperty("tags")] - public List Tags { get; private set; } - /// - /// The list of Segments to notify - /// - [JsonProperty("segments")] - public List Segments { get; private set; } - /// - /// The priority of the notification - /// - [JsonProperty("priority")] - [JsonConverter(typeof(StringEnumConverter))] - public NotificationResource.PriorityEnum Priority { get; private set; } - /// - /// How long, in seconds, the notification is valid - /// - [JsonProperty("ttl")] - public int? Ttl { get; private set; } - /// - /// The notification title - /// - [JsonProperty("title")] - public string Title { get; private set; } - /// - /// The notification body text - /// - [JsonProperty("body")] - public string Body { get; private set; } - /// - /// The name of the sound to be played for the notification - /// - [JsonProperty("sound")] - public string Sound { get; private set; } - /// - /// The actions to display for the notification - /// - [JsonProperty("action")] - public string Action { get; private set; } - /// - /// The custom key-value pairs of the notification's payload - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS Bindings - /// - [JsonProperty("apn")] - public object Apn { get; private set; } - /// - /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM Bindings - /// - [JsonProperty("gcm")] - public object Gcm { get; private set; } - /// - /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM Bindings - /// - [JsonProperty("fcm")] - public object Fcm { get; private set; } - /// - /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS Bindings - /// - [JsonProperty("sms")] - public object Sms { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("facebook_messenger")] - public object FacebookMessenger { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("alexa")] - public object Alexa { get; private set; } - - private NotificationResource() - { - - } - } +{ + + public class NotificationResource : Resource + { + public sealed class PriorityEnum : StringEnum + { + private PriorityEnum(string value) : base(value) { } + public PriorityEnum() { } + public static implicit operator PriorityEnum(string value) + { + return new PriorityEnum(value); + } + + public static readonly PriorityEnum High = new PriorityEnum("high"); + public static readonly PriorityEnum Low = new PriorityEnum("low"); + } + + private static Request BuildCreateRequest(CreateNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Services/" + options.PathServiceSid + "/Notifications", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Create(CreateNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task CreateAsync(CreateNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The `identity` value that identifies the new resource's User + /// A tag that selects the Bindings to notify + /// The notification body text + /// The priority of the notification + /// How long, in seconds, the notification is valid + /// The notification title + /// The name of the sound to be played for the notification + /// The actions to display for the notification + /// The custom key-value pairs of the notification's payload + /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS + /// Bindings + /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM + /// Bindings + /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS + /// Bindings + /// Deprecated + /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM + /// Bindings + /// A Segment to notify + /// Deprecated + /// The destination address specified as a JSON string + /// URL to send webhooks + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Create(string pathServiceSid, + List identity = null, + List tag = null, + string body = null, + NotificationResource.PriorityEnum priority = null, + int? ttl = null, + string title = null, + string sound = null, + string action = null, + object data = null, + object apn = null, + object gcm = null, + object sms = null, + object facebookMessenger = null, + object fcm = null, + List segment = null, + object alexa = null, + List toBinding = null, + string deliveryCallbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateNotificationOptions(pathServiceSid) { Identity = identity, Tag = tag, Body = body, Priority = priority, Ttl = ttl, Title = title, Sound = sound, Action = action, Data = data, Apn = apn, Gcm = gcm, Sms = sms, FacebookMessenger = facebookMessenger, Fcm = fcm, Segment = segment, Alexa = alexa, ToBinding = toBinding, DeliveryCallbackUrl = deliveryCallbackUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Service to create the resource under + /// The `identity` value that identifies the new resource's User + /// A tag that selects the Bindings to notify + /// The notification body text + /// The priority of the notification + /// How long, in seconds, the notification is valid + /// The notification title + /// The name of the sound to be played for the notification + /// The actions to display for the notification + /// The custom key-value pairs of the notification's payload + /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS + /// Bindings + /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM + /// Bindings + /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS + /// Bindings + /// Deprecated + /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM + /// Bindings + /// A Segment to notify + /// Deprecated + /// The destination address specified as a JSON string + /// URL to send webhooks + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + List identity = null, + List tag = null, + string body = null, + NotificationResource.PriorityEnum priority = null, + int? ttl = null, + string title = null, + string sound = null, + string action = null, + object data = null, + object apn = null, + object gcm = null, + object sms = null, + object facebookMessenger = null, + object fcm = null, + List segment = null, + object alexa = null, + List toBinding = null, + string deliveryCallbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateNotificationOptions(pathServiceSid) { Identity = identity, Tag = tag, Body = body, Priority = priority, Ttl = ttl, Title = title, Sound = sound, Action = action, Data = data, Apn = apn, Gcm = gcm, Sms = sms, FacebookMessenger = facebookMessenger, Fcm = fcm, Segment = segment, Alexa = alexa, ToBinding = toBinding, DeliveryCallbackUrl = deliveryCallbackUrl }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NotificationResource object + /// + /// Raw JSON string + /// NotificationResource object represented by the provided JSON + public static NotificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The list of identity values of the Users to notify + /// + [JsonProperty("identities")] + public List Identities { get; private set; } + /// + /// The tags that select the Bindings to notify + /// + [JsonProperty("tags")] + public List Tags { get; private set; } + /// + /// The list of Segments to notify + /// + [JsonProperty("segments")] + public List Segments { get; private set; } + /// + /// The priority of the notification + /// + [JsonProperty("priority")] + [JsonConverter(typeof(StringEnumConverter))] + public NotificationResource.PriorityEnum Priority { get; private set; } + /// + /// How long, in seconds, the notification is valid + /// + [JsonProperty("ttl")] + public int? Ttl { get; private set; } + /// + /// The notification title + /// + [JsonProperty("title")] + public string Title { get; private set; } + /// + /// The notification body text + /// + [JsonProperty("body")] + public string Body { get; private set; } + /// + /// The name of the sound to be played for the notification + /// + [JsonProperty("sound")] + public string Sound { get; private set; } + /// + /// The actions to display for the notification + /// + [JsonProperty("action")] + public string Action { get; private set; } + /// + /// The custom key-value pairs of the notification's payload + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The APNS-specific payload that overrides corresponding attributes in a generic payload for APNS Bindings + /// + [JsonProperty("apn")] + public object Apn { get; private set; } + /// + /// The GCM-specific payload that overrides corresponding attributes in generic payload for GCM Bindings + /// + [JsonProperty("gcm")] + public object Gcm { get; private set; } + /// + /// The FCM-specific payload that overrides corresponding attributes in generic payload for FCM Bindings + /// + [JsonProperty("fcm")] + public object Fcm { get; private set; } + /// + /// The SMS-specific payload that overrides corresponding attributes in generic payload for SMS Bindings + /// + [JsonProperty("sms")] + public object Sms { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("facebook_messenger")] + public object FacebookMessenger { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("alexa")] + public object Alexa { get; private set; } + + private NotificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/ServiceOptions.cs b/src/Twilio/Rest/Notify/V1/ServiceOptions.cs index 765faec1a..504ca6e4e 100644 --- a/src/Twilio/Rest/Notify/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Notify/V1/ServiceOptions.cs @@ -9,401 +9,401 @@ using Twilio.Converters; namespace Twilio.Rest.Notify.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// CreateServiceOptions - /// - public class CreateServiceOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The SID of the Credential to use for APN Bindings - /// - public string ApnCredentialSid { get; set; } - /// - /// The SID of the Credential to use for GCM Bindings - /// - public string GcmCredentialSid { get; set; } - /// - /// The SID of the Messaging Service to use for SMS Bindings - /// - public string MessagingServiceSid { get; set; } - /// - /// Deprecated - /// - public string FacebookMessengerPageId { get; set; } - /// - /// The protocol version to use for sending APNS notifications - /// - public string DefaultApnNotificationProtocolVersion { get; set; } - /// - /// The protocol version to use for sending GCM notifications - /// - public string DefaultGcmNotificationProtocolVersion { get; set; } - /// - /// The SID of the Credential to use for FCM Bindings - /// - public string FcmCredentialSid { get; set; } - /// - /// The protocol version to use for sending FCM notifications - /// - public string DefaultFcmNotificationProtocolVersion { get; set; } - /// - /// Whether to log notifications - /// - public bool? LogEnabled { get; set; } - /// - /// Deprecated - /// - public string AlexaSkillId { get; set; } - /// - /// Deprecated - /// - public string DefaultAlexaNotificationProtocolVersion { get; set; } - /// - /// Webhook URL - /// - public string DeliveryCallbackUrl { get; set; } - /// - /// Enable delivery callbacks - /// - public bool? DeliveryCallbackEnabled { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ApnCredentialSid != null) - { - p.Add(new KeyValuePair("ApnCredentialSid", ApnCredentialSid.ToString())); - } - - if (GcmCredentialSid != null) - { - p.Add(new KeyValuePair("GcmCredentialSid", GcmCredentialSid.ToString())); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (FacebookMessengerPageId != null) - { - p.Add(new KeyValuePair("FacebookMessengerPageId", FacebookMessengerPageId)); - } - - if (DefaultApnNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultApnNotificationProtocolVersion", DefaultApnNotificationProtocolVersion)); - } - - if (DefaultGcmNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultGcmNotificationProtocolVersion", DefaultGcmNotificationProtocolVersion)); - } - - if (FcmCredentialSid != null) - { - p.Add(new KeyValuePair("FcmCredentialSid", FcmCredentialSid.ToString())); - } - - if (DefaultFcmNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultFcmNotificationProtocolVersion", DefaultFcmNotificationProtocolVersion)); - } - - if (LogEnabled != null) - { - p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); - } - - if (AlexaSkillId != null) - { - p.Add(new KeyValuePair("AlexaSkillId", AlexaSkillId)); - } - - if (DefaultAlexaNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultAlexaNotificationProtocolVersion", DefaultAlexaNotificationProtocolVersion)); - } - - if (DeliveryCallbackUrl != null) - { - p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); - } - - if (DeliveryCallbackEnabled != null) - { - p.Add(new KeyValuePair("DeliveryCallbackEnabled", DeliveryCallbackEnabled.Value.ToString().ToLower())); - } - - return p; - } - } - + /// A string to describe the resource + /// + public string FriendlyName { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// DeleteServiceOptions + /// The SID of the Credential to use for APN Bindings /// - public class DeleteServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The unique string that identifies the resource - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string ApnCredentialSid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchServiceOptions + /// The SID of the Credential to use for GCM Bindings /// - public class FetchServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The unique string that identifies the resource - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string GcmCredentialSid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadServiceOptions + /// The SID of the Messaging Service to use for SMS Bindings /// - public class ReadServiceOptions : ReadOptions - { - /// - /// The string that identifies the Service resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string MessagingServiceSid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The SID of the Credential to use for APN Bindings - /// - public string ApnCredentialSid { get; set; } - /// - /// The SID of the Credential to use for GCM Bindings - /// - public string GcmCredentialSid { get; set; } - /// - /// The SID of the Messaging Service to use for SMS Bindings - /// - public string MessagingServiceSid { get; set; } - /// - /// Deprecated - /// - public string FacebookMessengerPageId { get; set; } - /// - /// The protocol version to use for sending APNS notifications - /// - public string DefaultApnNotificationProtocolVersion { get; set; } - /// - /// The protocol version to use for sending GCM notifications - /// - public string DefaultGcmNotificationProtocolVersion { get; set; } - /// - /// The SID of the Credential to use for FCM Bindings - /// - public string FcmCredentialSid { get; set; } - /// - /// The protocol version to use for sending FCM notifications - /// - public string DefaultFcmNotificationProtocolVersion { get; set; } - /// - /// Whether to log notifications - /// - public bool? LogEnabled { get; set; } - /// - /// Deprecated - /// - public string AlexaSkillId { get; set; } - /// - /// Deprecated - /// - public string DefaultAlexaNotificationProtocolVersion { get; set; } - /// - /// Webhook URL - /// - public string DeliveryCallbackUrl { get; set; } - /// - /// Enable delivery callbacks - /// - public bool? DeliveryCallbackEnabled { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The unique string that identifies the resource - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ApnCredentialSid != null) - { - p.Add(new KeyValuePair("ApnCredentialSid", ApnCredentialSid.ToString())); - } - - if (GcmCredentialSid != null) - { - p.Add(new KeyValuePair("GcmCredentialSid", GcmCredentialSid.ToString())); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - if (FacebookMessengerPageId != null) - { - p.Add(new KeyValuePair("FacebookMessengerPageId", FacebookMessengerPageId)); - } - - if (DefaultApnNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultApnNotificationProtocolVersion", DefaultApnNotificationProtocolVersion)); - } - - if (DefaultGcmNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultGcmNotificationProtocolVersion", DefaultGcmNotificationProtocolVersion)); - } - - if (FcmCredentialSid != null) - { - p.Add(new KeyValuePair("FcmCredentialSid", FcmCredentialSid.ToString())); - } - - if (DefaultFcmNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultFcmNotificationProtocolVersion", DefaultFcmNotificationProtocolVersion)); - } - - if (LogEnabled != null) - { - p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); - } - - if (AlexaSkillId != null) - { - p.Add(new KeyValuePair("AlexaSkillId", AlexaSkillId)); - } - - if (DefaultAlexaNotificationProtocolVersion != null) - { - p.Add(new KeyValuePair("DefaultAlexaNotificationProtocolVersion", DefaultAlexaNotificationProtocolVersion)); - } - - if (DeliveryCallbackUrl != null) - { - p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); - } - - if (DeliveryCallbackEnabled != null) - { - p.Add(new KeyValuePair("DeliveryCallbackEnabled", DeliveryCallbackEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// Deprecated + /// + public string FacebookMessengerPageId { get; set; } + /// + /// The protocol version to use for sending APNS notifications + /// + public string DefaultApnNotificationProtocolVersion { get; set; } + /// + /// The protocol version to use for sending GCM notifications + /// + public string DefaultGcmNotificationProtocolVersion { get; set; } + /// + /// The SID of the Credential to use for FCM Bindings + /// + public string FcmCredentialSid { get; set; } + /// + /// The protocol version to use for sending FCM notifications + /// + public string DefaultFcmNotificationProtocolVersion { get; set; } + /// + /// Whether to log notifications + /// + public bool? LogEnabled { get; set; } + /// + /// Deprecated + /// + public string AlexaSkillId { get; set; } + /// + /// Deprecated + /// + public string DefaultAlexaNotificationProtocolVersion { get; set; } + /// + /// Webhook URL + /// + public string DeliveryCallbackUrl { get; set; } + /// + /// Enable delivery callbacks + /// + public bool? DeliveryCallbackEnabled { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ApnCredentialSid != null) + { + p.Add(new KeyValuePair("ApnCredentialSid", ApnCredentialSid.ToString())); + } + + if (GcmCredentialSid != null) + { + p.Add(new KeyValuePair("GcmCredentialSid", GcmCredentialSid.ToString())); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (FacebookMessengerPageId != null) + { + p.Add(new KeyValuePair("FacebookMessengerPageId", FacebookMessengerPageId)); + } + + if (DefaultApnNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultApnNotificationProtocolVersion", DefaultApnNotificationProtocolVersion)); + } + + if (DefaultGcmNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultGcmNotificationProtocolVersion", DefaultGcmNotificationProtocolVersion)); + } + + if (FcmCredentialSid != null) + { + p.Add(new KeyValuePair("FcmCredentialSid", FcmCredentialSid.ToString())); + } + + if (DefaultFcmNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultFcmNotificationProtocolVersion", DefaultFcmNotificationProtocolVersion)); + } + + if (LogEnabled != null) + { + p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); + } + + if (AlexaSkillId != null) + { + p.Add(new KeyValuePair("AlexaSkillId", AlexaSkillId)); + } + + if (DefaultAlexaNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultAlexaNotificationProtocolVersion", DefaultAlexaNotificationProtocolVersion)); + } + + if (DeliveryCallbackUrl != null) + { + p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); + } + + if (DeliveryCallbackEnabled != null) + { + p.Add(new KeyValuePair("DeliveryCallbackEnabled", DeliveryCallbackEnabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// The unique string that identifies the resource + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchServiceOptions + /// + /// The unique string that identifies the resource + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// The string that identifies the Service resources to read + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The SID of the Credential to use for APN Bindings + /// + public string ApnCredentialSid { get; set; } + /// + /// The SID of the Credential to use for GCM Bindings + /// + public string GcmCredentialSid { get; set; } + /// + /// The SID of the Messaging Service to use for SMS Bindings + /// + public string MessagingServiceSid { get; set; } + /// + /// Deprecated + /// + public string FacebookMessengerPageId { get; set; } + /// + /// The protocol version to use for sending APNS notifications + /// + public string DefaultApnNotificationProtocolVersion { get; set; } + /// + /// The protocol version to use for sending GCM notifications + /// + public string DefaultGcmNotificationProtocolVersion { get; set; } + /// + /// The SID of the Credential to use for FCM Bindings + /// + public string FcmCredentialSid { get; set; } + /// + /// The protocol version to use for sending FCM notifications + /// + public string DefaultFcmNotificationProtocolVersion { get; set; } + /// + /// Whether to log notifications + /// + public bool? LogEnabled { get; set; } + /// + /// Deprecated + /// + public string AlexaSkillId { get; set; } + /// + /// Deprecated + /// + public string DefaultAlexaNotificationProtocolVersion { get; set; } + /// + /// Webhook URL + /// + public string DeliveryCallbackUrl { get; set; } + /// + /// Enable delivery callbacks + /// + public bool? DeliveryCallbackEnabled { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The unique string that identifies the resource + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ApnCredentialSid != null) + { + p.Add(new KeyValuePair("ApnCredentialSid", ApnCredentialSid.ToString())); + } + + if (GcmCredentialSid != null) + { + p.Add(new KeyValuePair("GcmCredentialSid", GcmCredentialSid.ToString())); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + if (FacebookMessengerPageId != null) + { + p.Add(new KeyValuePair("FacebookMessengerPageId", FacebookMessengerPageId)); + } + + if (DefaultApnNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultApnNotificationProtocolVersion", DefaultApnNotificationProtocolVersion)); + } + + if (DefaultGcmNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultGcmNotificationProtocolVersion", DefaultGcmNotificationProtocolVersion)); + } + + if (FcmCredentialSid != null) + { + p.Add(new KeyValuePair("FcmCredentialSid", FcmCredentialSid.ToString())); + } + + if (DefaultFcmNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultFcmNotificationProtocolVersion", DefaultFcmNotificationProtocolVersion)); + } + + if (LogEnabled != null) + { + p.Add(new KeyValuePair("LogEnabled", LogEnabled.Value.ToString().ToLower())); + } + + if (AlexaSkillId != null) + { + p.Add(new KeyValuePair("AlexaSkillId", AlexaSkillId)); + } + + if (DefaultAlexaNotificationProtocolVersion != null) + { + p.Add(new KeyValuePair("DefaultAlexaNotificationProtocolVersion", DefaultAlexaNotificationProtocolVersion)); + } + + if (DeliveryCallbackUrl != null) + { + p.Add(new KeyValuePair("DeliveryCallbackUrl", DeliveryCallbackUrl)); + } + + if (DeliveryCallbackEnabled != null) + { + p.Add(new KeyValuePair("DeliveryCallbackEnabled", DeliveryCallbackEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Notify/V1/ServiceResource.cs b/src/Twilio/Rest/Notify/V1/ServiceResource.cs index c15fc03d0..d4af7549a 100644 --- a/src/Twilio/Rest/Notify/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Notify/V1/ServiceResource.cs @@ -18,655 +18,655 @@ using Twilio.Http; namespace Twilio.Rest.Notify.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The SID of the Credential to use for APN Bindings - /// The SID of the Credential to use for GCM Bindings - /// The SID of the Messaging Service to use for SMS Bindings - /// Deprecated - /// The protocol version to use for sending APNS notifications - /// - /// The protocol version to use for sending GCM notifications - /// - /// The SID of the Credential to use for FCM Bindings - /// The protocol version to use for sending FCM notifications - /// - /// Whether to log notifications - /// Deprecated - /// Deprecated - /// Webhook URL - /// Enable delivery callbacks - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName = null, - string apnCredentialSid = null, - string gcmCredentialSid = null, - string messagingServiceSid = null, - string facebookMessengerPageId = null, - string defaultApnNotificationProtocolVersion = null, - string defaultGcmNotificationProtocolVersion = null, - string fcmCredentialSid = null, - string defaultFcmNotificationProtocolVersion = null, - bool? logEnabled = null, - string alexaSkillId = null, - string defaultAlexaNotificationProtocolVersion = null, - string deliveryCallbackUrl = null, - bool? deliveryCallbackEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The SID of the Credential to use for APN Bindings - /// The SID of the Credential to use for GCM Bindings - /// The SID of the Messaging Service to use for SMS Bindings - /// Deprecated - /// The protocol version to use for sending APNS notifications - /// - /// The protocol version to use for sending GCM notifications - /// - /// The SID of the Credential to use for FCM Bindings - /// The protocol version to use for sending FCM notifications - /// - /// Whether to log notifications - /// Deprecated - /// Deprecated - /// Webhook URL - /// Enable delivery callbacks - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - string apnCredentialSid = null, - string gcmCredentialSid = null, - string messagingServiceSid = null, - string facebookMessengerPageId = null, - string defaultApnNotificationProtocolVersion = null, - string defaultGcmNotificationProtocolVersion = null, - string fcmCredentialSid = null, - string defaultFcmNotificationProtocolVersion = null, - bool? logEnabled = null, - string alexaSkillId = null, - string defaultAlexaNotificationProtocolVersion = null, - string deliveryCallbackUrl = null, - bool? deliveryCallbackEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Notify, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Notify, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The string that identifies the Service resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The string that identifies the Service resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Notify) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Notify, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The SID of the Credential to use for APN Bindings - /// The SID of the Credential to use for GCM Bindings - /// The SID of the Messaging Service to use for SMS Bindings - /// Deprecated - /// The protocol version to use for sending APNS notifications - /// - /// The protocol version to use for sending GCM notifications - /// - /// The SID of the Credential to use for FCM Bindings - /// The protocol version to use for sending FCM notifications - /// - /// Whether to log notifications - /// Deprecated - /// Deprecated - /// Webhook URL - /// Enable delivery callbacks - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - string apnCredentialSid = null, - string gcmCredentialSid = null, - string messagingServiceSid = null, - string facebookMessengerPageId = null, - string defaultApnNotificationProtocolVersion = null, - string defaultGcmNotificationProtocolVersion = null, - string fcmCredentialSid = null, - string defaultFcmNotificationProtocolVersion = null, - bool? logEnabled = null, - string alexaSkillId = null, - string defaultAlexaNotificationProtocolVersion = null, - string deliveryCallbackUrl = null, - bool? deliveryCallbackEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The SID of the Credential to use for APN Bindings - /// The SID of the Credential to use for GCM Bindings - /// The SID of the Messaging Service to use for SMS Bindings - /// Deprecated - /// The protocol version to use for sending APNS notifications - /// - /// The protocol version to use for sending GCM notifications - /// - /// The SID of the Credential to use for FCM Bindings - /// The protocol version to use for sending FCM notifications - /// - /// Whether to log notifications - /// Deprecated - /// Deprecated - /// Webhook URL - /// Enable delivery callbacks - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string apnCredentialSid = null, - string gcmCredentialSid = null, - string messagingServiceSid = null, - string facebookMessengerPageId = null, - string defaultApnNotificationProtocolVersion = null, - string defaultGcmNotificationProtocolVersion = null, - string fcmCredentialSid = null, - string defaultFcmNotificationProtocolVersion = null, - bool? logEnabled = null, - string alexaSkillId = null, - string defaultAlexaNotificationProtocolVersion = null, - string deliveryCallbackUrl = null, - bool? deliveryCallbackEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Credential to use for APN Bindings - /// - [JsonProperty("apn_credential_sid")] - public string ApnCredentialSid { get; private set; } - /// - /// The SID of the Credential to use for GCM Bindings - /// - [JsonProperty("gcm_credential_sid")] - public string GcmCredentialSid { get; private set; } - /// - /// The SID of the Credential to use for FCM Bindings - /// - [JsonProperty("fcm_credential_sid")] - public string FcmCredentialSid { get; private set; } - /// - /// The SID of the Messaging Service to use for SMS Bindings - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("facebook_messenger_page_id")] - public string FacebookMessengerPageId { get; private set; } - /// - /// The protocol version to use for sending APNS notifications - /// - [JsonProperty("default_apn_notification_protocol_version")] - public string DefaultApnNotificationProtocolVersion { get; private set; } - /// - /// The protocol version to use for sending GCM notifications - /// - [JsonProperty("default_gcm_notification_protocol_version")] - public string DefaultGcmNotificationProtocolVersion { get; private set; } - /// - /// The protocol version to use for sending FCM notifications - /// - [JsonProperty("default_fcm_notification_protocol_version")] - public string DefaultFcmNotificationProtocolVersion { get; private set; } - /// - /// Whether to log notifications - /// - [JsonProperty("log_enabled")] - public bool? LogEnabled { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the resources related to the service - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("alexa_skill_id")] - public string AlexaSkillId { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("default_alexa_notification_protocol_version")] - public string DefaultAlexaNotificationProtocolVersion { get; private set; } - /// - /// Webhook URL - /// - [JsonProperty("delivery_callback_url")] - public string DeliveryCallbackUrl { get; private set; } - /// - /// Enable delivery callbacks - /// - [JsonProperty("delivery_callback_enabled")] - public bool? DeliveryCallbackEnabled { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The SID of the Credential to use for APN Bindings + /// The SID of the Credential to use for GCM Bindings + /// The SID of the Messaging Service to use for SMS Bindings + /// Deprecated + /// The protocol version to use for sending APNS notifications + /// + /// The protocol version to use for sending GCM notifications + /// + /// The SID of the Credential to use for FCM Bindings + /// The protocol version to use for sending FCM notifications + /// + /// Whether to log notifications + /// Deprecated + /// Deprecated + /// Webhook URL + /// Enable delivery callbacks + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName = null, + string apnCredentialSid = null, + string gcmCredentialSid = null, + string messagingServiceSid = null, + string facebookMessengerPageId = null, + string defaultApnNotificationProtocolVersion = null, + string defaultGcmNotificationProtocolVersion = null, + string fcmCredentialSid = null, + string defaultFcmNotificationProtocolVersion = null, + bool? logEnabled = null, + string alexaSkillId = null, + string defaultAlexaNotificationProtocolVersion = null, + string deliveryCallbackUrl = null, + bool? deliveryCallbackEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The SID of the Credential to use for APN Bindings + /// The SID of the Credential to use for GCM Bindings + /// The SID of the Messaging Service to use for SMS Bindings + /// Deprecated + /// The protocol version to use for sending APNS notifications + /// + /// The protocol version to use for sending GCM notifications + /// + /// The SID of the Credential to use for FCM Bindings + /// The protocol version to use for sending FCM notifications + /// + /// Whether to log notifications + /// Deprecated + /// Deprecated + /// Webhook URL + /// Enable delivery callbacks + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + string apnCredentialSid = null, + string gcmCredentialSid = null, + string messagingServiceSid = null, + string facebookMessengerPageId = null, + string defaultApnNotificationProtocolVersion = null, + string defaultGcmNotificationProtocolVersion = null, + string fcmCredentialSid = null, + string defaultFcmNotificationProtocolVersion = null, + bool? logEnabled = null, + string alexaSkillId = null, + string defaultAlexaNotificationProtocolVersion = null, + string deliveryCallbackUrl = null, + bool? deliveryCallbackEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Notify, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Notify, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The string that identifies the Service resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The string that identifies the Service resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Notify) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Notify, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The SID of the Credential to use for APN Bindings + /// The SID of the Credential to use for GCM Bindings + /// The SID of the Messaging Service to use for SMS Bindings + /// Deprecated + /// The protocol version to use for sending APNS notifications + /// + /// The protocol version to use for sending GCM notifications + /// + /// The SID of the Credential to use for FCM Bindings + /// The protocol version to use for sending FCM notifications + /// + /// Whether to log notifications + /// Deprecated + /// Deprecated + /// Webhook URL + /// Enable delivery callbacks + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + string apnCredentialSid = null, + string gcmCredentialSid = null, + string messagingServiceSid = null, + string facebookMessengerPageId = null, + string defaultApnNotificationProtocolVersion = null, + string defaultGcmNotificationProtocolVersion = null, + string fcmCredentialSid = null, + string defaultFcmNotificationProtocolVersion = null, + bool? logEnabled = null, + string alexaSkillId = null, + string defaultAlexaNotificationProtocolVersion = null, + string deliveryCallbackUrl = null, + bool? deliveryCallbackEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The SID of the Credential to use for APN Bindings + /// The SID of the Credential to use for GCM Bindings + /// The SID of the Messaging Service to use for SMS Bindings + /// Deprecated + /// The protocol version to use for sending APNS notifications + /// + /// The protocol version to use for sending GCM notifications + /// + /// The SID of the Credential to use for FCM Bindings + /// The protocol version to use for sending FCM notifications + /// + /// Whether to log notifications + /// Deprecated + /// Deprecated + /// Webhook URL + /// Enable delivery callbacks + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string apnCredentialSid = null, + string gcmCredentialSid = null, + string messagingServiceSid = null, + string facebookMessengerPageId = null, + string defaultApnNotificationProtocolVersion = null, + string defaultGcmNotificationProtocolVersion = null, + string fcmCredentialSid = null, + string defaultFcmNotificationProtocolVersion = null, + bool? logEnabled = null, + string alexaSkillId = null, + string defaultAlexaNotificationProtocolVersion = null, + string deliveryCallbackUrl = null, + bool? deliveryCallbackEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, ApnCredentialSid = apnCredentialSid, GcmCredentialSid = gcmCredentialSid, MessagingServiceSid = messagingServiceSid, FacebookMessengerPageId = facebookMessengerPageId, DefaultApnNotificationProtocolVersion = defaultApnNotificationProtocolVersion, DefaultGcmNotificationProtocolVersion = defaultGcmNotificationProtocolVersion, FcmCredentialSid = fcmCredentialSid, DefaultFcmNotificationProtocolVersion = defaultFcmNotificationProtocolVersion, LogEnabled = logEnabled, AlexaSkillId = alexaSkillId, DefaultAlexaNotificationProtocolVersion = defaultAlexaNotificationProtocolVersion, DeliveryCallbackUrl = deliveryCallbackUrl, DeliveryCallbackEnabled = deliveryCallbackEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Credential to use for APN Bindings + /// + [JsonProperty("apn_credential_sid")] + public string ApnCredentialSid { get; private set; } + /// + /// The SID of the Credential to use for GCM Bindings + /// + [JsonProperty("gcm_credential_sid")] + public string GcmCredentialSid { get; private set; } + /// + /// The SID of the Credential to use for FCM Bindings + /// + [JsonProperty("fcm_credential_sid")] + public string FcmCredentialSid { get; private set; } + /// + /// The SID of the Messaging Service to use for SMS Bindings + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("facebook_messenger_page_id")] + public string FacebookMessengerPageId { get; private set; } + /// + /// The protocol version to use for sending APNS notifications + /// + [JsonProperty("default_apn_notification_protocol_version")] + public string DefaultApnNotificationProtocolVersion { get; private set; } + /// + /// The protocol version to use for sending GCM notifications + /// + [JsonProperty("default_gcm_notification_protocol_version")] + public string DefaultGcmNotificationProtocolVersion { get; private set; } + /// + /// The protocol version to use for sending FCM notifications + /// + [JsonProperty("default_fcm_notification_protocol_version")] + public string DefaultFcmNotificationProtocolVersion { get; private set; } + /// + /// Whether to log notifications + /// + [JsonProperty("log_enabled")] + public bool? LogEnabled { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the resources related to the service + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("alexa_skill_id")] + public string AlexaSkillId { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("default_alexa_notification_protocol_version")] + public string DefaultAlexaNotificationProtocolVersion { get; private set; } + /// + /// Webhook URL + /// + [JsonProperty("delivery_callback_url")] + public string DeliveryCallbackUrl { get; private set; } + /// + /// Enable delivery callbacks + /// + [JsonProperty("delivery_callback_enabled")] + public bool? DeliveryCallbackEnabled { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyOptions.cs index 2c12a5be5..54cf66c44 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyOptions.cs @@ -9,47 +9,47 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) + /// of the original bundle + /// + public class CreateBundleCopyOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) - /// of the original bundle + /// The unique string that identifies the Bundle to be copied /// - public class CreateBundleCopyOptions : IOptions - { - /// - /// The unique string that identifies the Bundle to be copied - /// - public string PathBundleSid { get; } - /// - /// The string that you assigned to describe the copied bundle - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new CreateBundleCopyOptions - /// - /// The unique string that identifies the Bundle to be copied - public CreateBundleCopyOptions(string pathBundleSid) - { - PathBundleSid = pathBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + public string PathBundleSid { get; } + /// + /// The string that you assigned to describe the copied bundle + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new CreateBundleCopyOptions + /// + /// The unique string that identifies the Bundle to be copied + public CreateBundleCopyOptions(string pathBundleSid) + { + PathBundleSid = pathBundleSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyResource.cs index 5d742a61d..912e879ac 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/BundleCopyResource.cs @@ -19,190 +19,190 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - - public class BundleCopyResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum InReview = new StatusEnum("in-review"); - public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); - public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); - public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); - } - - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateBundleCopyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Copies", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) - /// of the original bundle - /// - /// Create BundleCopy parameters - /// Client to make requests to Twilio - /// A single instance of BundleCopy - public static BundleCopyResource Create(CreateBundleCopyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) - /// of the original bundle - /// - /// Create BundleCopy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BundleCopy - public static async System.Threading.Tasks.Task CreateAsync(CreateBundleCopyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) - /// of the original bundle - /// - /// The unique string that identifies the Bundle to be copied - /// The string that you assigned to describe the copied bundle - /// Client to make requests to Twilio - /// A single instance of BundleCopy - public static BundleCopyResource Create(string pathBundleSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateBundleCopyOptions(pathBundleSid){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) - /// of the original bundle - /// - /// The unique string that identifies the Bundle to be copied - /// The string that you assigned to describe the copied bundle - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BundleCopy - public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateBundleCopyOptions(pathBundleSid){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BundleCopyResource object - /// - /// Raw JSON string - /// BundleCopyResource object represented by the provided JSON - public static BundleCopyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a regulation - /// - [JsonProperty("regulation_sid")] - public string RegulationSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The verification status of the Bundle resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public BundleCopyResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource will be valid until - /// - [JsonProperty("valid_until")] - public DateTime? ValidUntil { get; private set; } - /// - /// The email address - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The URL we call to inform your application of status changes - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private BundleCopyResource() - { - - } - } +{ + + public class BundleCopyResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum InReview = new StatusEnum("in-review"); + public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); + public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); + public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); + } + + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateBundleCopyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Copies", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) + /// of the original bundle + /// + /// Create BundleCopy parameters + /// Client to make requests to Twilio + /// A single instance of BundleCopy + public static BundleCopyResource Create(CreateBundleCopyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) + /// of the original bundle + /// + /// Create BundleCopy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BundleCopy + public static async System.Threading.Tasks.Task CreateAsync(CreateBundleCopyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) + /// of the original bundle + /// + /// The unique string that identifies the Bundle to be copied + /// The string that you assigned to describe the copied bundle + /// Client to make requests to Twilio + /// A single instance of BundleCopy + public static BundleCopyResource Create(string pathBundleSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateBundleCopyOptions(pathBundleSid) { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Creates a new copy of a Bundle. It will internally create copies of all the bundle items (identities and documents) + /// of the original bundle + /// + /// The unique string that identifies the Bundle to be copied + /// The string that you assigned to describe the copied bundle + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BundleCopy + public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateBundleCopyOptions(pathBundleSid) { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BundleCopyResource object + /// + /// Raw JSON string + /// BundleCopyResource object represented by the provided JSON + public static BundleCopyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a regulation + /// + [JsonProperty("regulation_sid")] + public string RegulationSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The verification status of the Bundle resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public BundleCopyResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource will be valid until + /// + [JsonProperty("valid_until")] + public DateTime? ValidUntil { get; private set; } + /// + /// The email address + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The URL we call to inform your application of status changes + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private BundleCopyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationOptions.cs index bd9519cd8..e781d7149 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationOptions.cs @@ -9,104 +9,104 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - +{ + + /// + /// Creates an evaluation for a bundle + /// + public class CreateEvaluationOptions : IOptions + { /// - /// Creates an evaluation for a bundle + /// The unique string that identifies the resource /// - public class CreateEvaluationOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathBundleSid { get; } - - /// - /// Construct a new CreateEvaluationOptions - /// - /// The unique string that identifies the resource - public CreateEvaluationOptions(string pathBundleSid) - { - PathBundleSid = pathBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathBundleSid { get; } + /// - /// Retrieve a list of Evaluations associated to the Bundle resource. + /// Construct a new CreateEvaluationOptions /// - public class ReadEvaluationOptions : ReadOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathBundleSid { get; } - - /// - /// Construct a new ReadEvaluationOptions - /// - /// The unique string that identifies the resource - public ReadEvaluationOptions(string pathBundleSid) - { - PathBundleSid = pathBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + public CreateEvaluationOptions(string pathBundleSid) + { + PathBundleSid = pathBundleSid; + } + /// - /// Fetch specific Evaluation Instance. + /// Generate the necessary parameters /// - public class FetchEvaluationOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathBundleSid { get; } - /// - /// The unique string that identifies the Evaluation resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEvaluationOptions - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - public FetchEvaluationOptions(string pathBundleSid, string pathSid) - { - PathBundleSid = pathBundleSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of Evaluations associated to the Bundle resource. + /// + public class ReadEvaluationOptions : ReadOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathBundleSid { get; } + + /// + /// Construct a new ReadEvaluationOptions + /// + /// The unique string that identifies the resource + public ReadEvaluationOptions(string pathBundleSid) + { + PathBundleSid = pathBundleSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Evaluation Instance. + /// + public class FetchEvaluationOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathBundleSid { get; } + /// + /// The unique string that identifies the Evaluation resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEvaluationOptions + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + public FetchEvaluationOptions(string pathBundleSid, string pathSid) + { + PathBundleSid = pathBundleSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationResource.cs index 2424cdcba..705279388 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/EvaluationResource.cs @@ -17,357 +17,357 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - - public class EvaluationResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Compliant = new StatusEnum("compliant"); - public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); - } - - private static Request BuildCreateRequest(CreateEvaluationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Creates an evaluation for a bundle - /// - /// Create Evaluation parameters - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static EvaluationResource Create(CreateEvaluationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Creates an evaluation for a bundle - /// - /// Create Evaluation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task CreateAsync(CreateEvaluationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Creates an evaluation for a bundle - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static EvaluationResource Create(string pathBundleSid, ITwilioRestClient client = null) - { - var options = new CreateEvaluationOptions(pathBundleSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Creates an evaluation for a bundle - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, - ITwilioRestClient client = null) - { - var options = new CreateEvaluationOptions(pathBundleSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEvaluationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Evaluations associated to the Bundle resource. - /// - /// Read Evaluation parameters - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static ResourceSet Read(ReadEvaluationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the Bundle resource. - /// - /// Read Evaluation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task> ReadAsync(ReadEvaluationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Evaluations associated to the Bundle resource. - /// - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static ResourceSet Read(string pathBundleSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEvaluationOptions(pathBundleSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the Bundle resource. - /// - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task> ReadAsync(string pathBundleSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEvaluationOptions(pathBundleSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchEvaluationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch Evaluation parameters - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static EvaluationResource Fetch(FetchEvaluationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch Evaluation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task FetchAsync(FetchEvaluationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// A single instance of Evaluation - public static EvaluationResource Fetch(string pathBundleSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEvaluationOptions(pathBundleSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Evaluation - public static async System.Threading.Tasks.Task FetchAsync(string pathBundleSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEvaluationOptions(pathBundleSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EvaluationResource object - /// - /// Raw JSON string - /// EvaluationResource object represented by the provided JSON - public static EvaluationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Evaluation resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a regulation - /// - [JsonProperty("regulation_sid")] - public string RegulationSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The compliance status of the Evaluation resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public EvaluationResource.StatusEnum Status { get; private set; } - /// - /// The results of the Evaluation resource - /// - [JsonProperty("results")] - public List Results { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EvaluationResource() - { - - } - } +{ + + public class EvaluationResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Compliant = new StatusEnum("compliant"); + public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); + } + + private static Request BuildCreateRequest(CreateEvaluationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Creates an evaluation for a bundle + /// + /// Create Evaluation parameters + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static EvaluationResource Create(CreateEvaluationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Creates an evaluation for a bundle + /// + /// Create Evaluation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task CreateAsync(CreateEvaluationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Creates an evaluation for a bundle + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static EvaluationResource Create(string pathBundleSid, ITwilioRestClient client = null) + { + var options = new CreateEvaluationOptions(pathBundleSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Creates an evaluation for a bundle + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, + ITwilioRestClient client = null) + { + var options = new CreateEvaluationOptions(pathBundleSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEvaluationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Evaluations associated to the Bundle resource. + /// + /// Read Evaluation parameters + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static ResourceSet Read(ReadEvaluationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the Bundle resource. + /// + /// Read Evaluation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task> ReadAsync(ReadEvaluationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Evaluations associated to the Bundle resource. + /// + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static ResourceSet Read(string pathBundleSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEvaluationOptions(pathBundleSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the Bundle resource. + /// + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task> ReadAsync(string pathBundleSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEvaluationOptions(pathBundleSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchEvaluationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/Evaluations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch Evaluation parameters + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static EvaluationResource Fetch(FetchEvaluationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch Evaluation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task FetchAsync(FetchEvaluationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// A single instance of Evaluation + public static EvaluationResource Fetch(string pathBundleSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEvaluationOptions(pathBundleSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Evaluation + public static async System.Threading.Tasks.Task FetchAsync(string pathBundleSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEvaluationOptions(pathBundleSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EvaluationResource object + /// + /// Raw JSON string + /// EvaluationResource object represented by the provided JSON + public static EvaluationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Evaluation resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a regulation + /// + [JsonProperty("regulation_sid")] + public string RegulationSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The compliance status of the Evaluation resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public EvaluationResource.StatusEnum Status { get; private set; } + /// + /// The results of the Evaluation resource + /// + [JsonProperty("results")] + public List Results { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EvaluationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentOptions.cs index ead2e913d..56c65ffda 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentOptions.cs @@ -9,150 +9,150 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - +{ + + /// + /// Create a new Assigned Item. + /// + public class CreateItemAssignmentOptions : IOptions + { /// - /// Create a new Assigned Item. + /// The unique string that identifies the resource. /// - public class CreateItemAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathBundleSid { get; } - /// - /// The sid of an object bag - /// - public string ObjectSid { get; } - - /// - /// Construct a new CreateItemAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - public CreateItemAssignmentOptions(string pathBundleSid, string objectSid) - { - PathBundleSid = pathBundleSid; - ObjectSid = objectSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ObjectSid != null) - { - p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); - } - - return p; - } - } - + public string PathBundleSid { get; } /// - /// Retrieve a list of all Assigned Items for an account. + /// The sid of an object bag /// - public class ReadItemAssignmentOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathBundleSid { get; } - - /// - /// Construct a new ReadItemAssignmentOptions - /// - /// The unique string that identifies the resource. - public ReadItemAssignmentOptions(string pathBundleSid) - { - PathBundleSid = pathBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string ObjectSid { get; } + /// - /// Fetch specific Assigned Item Instance. + /// Construct a new CreateItemAssignmentOptions /// - public class FetchItemAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathBundleSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchItemAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public FetchItemAssignmentOptions(string pathBundleSid, string pathSid) - { - PathBundleSid = pathBundleSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource. + /// The sid of an object bag + public CreateItemAssignmentOptions(string pathBundleSid, string objectSid) + { + PathBundleSid = pathBundleSid; + ObjectSid = objectSid; + } + /// - /// Remove an Assignment Item Instance. + /// Generate the necessary parameters /// - public class DeleteItemAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathBundleSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteItemAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public DeleteItemAssignmentOptions(string pathBundleSid, string pathSid) - { - PathBundleSid = pathBundleSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (ObjectSid != null) + { + p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + public class ReadItemAssignmentOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathBundleSid { get; } + + /// + /// Construct a new ReadItemAssignmentOptions + /// + /// The unique string that identifies the resource. + public ReadItemAssignmentOptions(string pathBundleSid) + { + PathBundleSid = pathBundleSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Assigned Item Instance. + /// + public class FetchItemAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathBundleSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchItemAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public FetchItemAssignmentOptions(string pathBundleSid, string pathSid) + { + PathBundleSid = pathBundleSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an Assignment Item Instance. + /// + public class DeleteItemAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathBundleSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteItemAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public DeleteItemAssignmentOptions(string pathBundleSid, string pathSid) + { + PathBundleSid = pathBundleSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentResource.cs index 8507770b1..b2c513b29 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ItemAssignmentResource.cs @@ -16,407 +16,407 @@ using Twilio.Http; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - - public class ItemAssignmentResource : Resource - { - private static Request BuildCreateRequest(CreateItemAssignmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Assigned Item. - /// - /// Create ItemAssignment parameters - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ItemAssignmentResource Create(CreateItemAssignmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// Create ItemAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task CreateAsync(CreateItemAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ItemAssignmentResource Create(string pathBundleSid, string objectSid, ITwilioRestClient client = null) - { - var options = new CreateItemAssignmentOptions(pathBundleSid, objectSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, - string objectSid, - ITwilioRestClient client = null) - { - var options = new CreateItemAssignmentOptions(pathBundleSid, objectSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadItemAssignmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read ItemAssignment parameters - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ResourceSet Read(ReadItemAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read ItemAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task> ReadAsync(ReadItemAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ResourceSet Read(string pathBundleSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadItemAssignmentOptions(pathBundleSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task> ReadAsync(string pathBundleSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadItemAssignmentOptions(pathBundleSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchItemAssignmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch ItemAssignment parameters - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ItemAssignmentResource Fetch(FetchItemAssignmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch ItemAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task FetchAsync(FetchItemAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static ItemAssignmentResource Fetch(string pathBundleSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchItemAssignmentOptions(pathBundleSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task FetchAsync(string pathBundleSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchItemAssignmentOptions(pathBundleSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteItemAssignmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Assignment Item Instance. - /// - /// Delete ItemAssignment parameters - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static bool Delete(DeleteItemAssignmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// Delete ItemAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task DeleteAsync(DeleteItemAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ItemAssignment - public static bool Delete(string pathBundleSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteItemAssignmentOptions(pathBundleSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ItemAssignment - public static async System.Threading.Tasks.Task DeleteAsync(string pathBundleSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteItemAssignmentOptions(pathBundleSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ItemAssignmentResource object - /// - /// Raw JSON string - /// ItemAssignmentResource object represented by the provided JSON - public static ItemAssignmentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the Bundle resource. - /// - [JsonProperty("bundle_sid")] - public string BundleSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The sid of an object bag - /// - [JsonProperty("object_sid")] - public string ObjectSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Identity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ItemAssignmentResource() - { - - } - } +{ + + public class ItemAssignmentResource : Resource + { + private static Request BuildCreateRequest(CreateItemAssignmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Assigned Item. + /// + /// Create ItemAssignment parameters + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ItemAssignmentResource Create(CreateItemAssignmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// Create ItemAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task CreateAsync(CreateItemAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ItemAssignmentResource Create(string pathBundleSid, string objectSid, ITwilioRestClient client = null) + { + var options = new CreateItemAssignmentOptions(pathBundleSid, objectSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, + string objectSid, + ITwilioRestClient client = null) + { + var options = new CreateItemAssignmentOptions(pathBundleSid, objectSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadItemAssignmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read ItemAssignment parameters + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ResourceSet Read(ReadItemAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read ItemAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task> ReadAsync(ReadItemAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ResourceSet Read(string pathBundleSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadItemAssignmentOptions(pathBundleSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task> ReadAsync(string pathBundleSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadItemAssignmentOptions(pathBundleSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchItemAssignmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch ItemAssignment parameters + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ItemAssignmentResource Fetch(FetchItemAssignmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch ItemAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task FetchAsync(FetchItemAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static ItemAssignmentResource Fetch(string pathBundleSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchItemAssignmentOptions(pathBundleSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task FetchAsync(string pathBundleSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchItemAssignmentOptions(pathBundleSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteItemAssignmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ItemAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Assignment Item Instance. + /// + /// Delete ItemAssignment parameters + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static bool Delete(DeleteItemAssignmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// Delete ItemAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task DeleteAsync(DeleteItemAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ItemAssignment + public static bool Delete(string pathBundleSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteItemAssignmentOptions(pathBundleSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ItemAssignment + public static async System.Threading.Tasks.Task DeleteAsync(string pathBundleSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteItemAssignmentOptions(pathBundleSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ItemAssignmentResource object + /// + /// Raw JSON string + /// ItemAssignmentResource object represented by the provided JSON + public static ItemAssignmentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the Bundle resource. + /// + [JsonProperty("bundle_sid")] + public string BundleSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The sid of an object bag + /// + [JsonProperty("object_sid")] + public string ObjectSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Identity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ItemAssignmentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsOptions.cs index a67c5cd7c..8fc002ada 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsOptions.cs @@ -9,50 +9,50 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source + /// bundle (specified by the from_bundle_sid body param) + /// + public class CreateReplaceItemsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source - /// bundle (specified by the from_bundle_sid body param) + /// The unique string that identifies the Bundle where the item assignments are going to be replaced /// - public class CreateReplaceItemsOptions : IOptions - { - /// - /// The unique string that identifies the Bundle where the item assignments are going to be replaced - /// - public string PathBundleSid { get; } - /// - /// The source bundle sid to copy the item assignments from - /// - public string FromBundleSid { get; } - - /// - /// Construct a new CreateReplaceItemsOptions - /// - /// The unique string that identifies the Bundle where the item assignments are going to - /// be replaced - /// The source bundle sid to copy the item assignments from - public CreateReplaceItemsOptions(string pathBundleSid, string fromBundleSid) - { - PathBundleSid = pathBundleSid; - FromBundleSid = fromBundleSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FromBundleSid != null) - { - p.Add(new KeyValuePair("FromBundleSid", FromBundleSid.ToString())); - } - - return p; - } - } + public string PathBundleSid { get; } + /// + /// The source bundle sid to copy the item assignments from + /// + public string FromBundleSid { get; } + + /// + /// Construct a new CreateReplaceItemsOptions + /// + /// The unique string that identifies the Bundle where the item assignments are going to + /// be replaced + /// The source bundle sid to copy the item assignments from + public CreateReplaceItemsOptions(string pathBundleSid, string fromBundleSid) + { + PathBundleSid = pathBundleSid; + FromBundleSid = fromBundleSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FromBundleSid != null) + { + p.Add(new KeyValuePair("FromBundleSid", FromBundleSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsResource.cs index 484543deb..43c59a8e2 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/Bundle/ReplaceItemsResource.cs @@ -19,192 +19,192 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance.Bundle -{ - - public class ReplaceItemsResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum InReview = new StatusEnum("in-review"); - public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); - public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); - public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); - } - - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateReplaceItemsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ReplaceItems", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source - /// bundle (specified by the from_bundle_sid body param) - /// - /// Create ReplaceItems parameters - /// Client to make requests to Twilio - /// A single instance of ReplaceItems - public static ReplaceItemsResource Create(CreateReplaceItemsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source - /// bundle (specified by the from_bundle_sid body param) - /// - /// Create ReplaceItems parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ReplaceItems - public static async System.Threading.Tasks.Task CreateAsync(CreateReplaceItemsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source - /// bundle (specified by the from_bundle_sid body param) - /// - /// The unique string that identifies the Bundle where the item assignments are going to - /// be replaced - /// The source bundle sid to copy the item assignments from - /// Client to make requests to Twilio - /// A single instance of ReplaceItems - public static ReplaceItemsResource Create(string pathBundleSid, - string fromBundleSid, - ITwilioRestClient client = null) - { - var options = new CreateReplaceItemsOptions(pathBundleSid, fromBundleSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source - /// bundle (specified by the from_bundle_sid body param) - /// - /// The unique string that identifies the Bundle where the item assignments are going to - /// be replaced - /// The source bundle sid to copy the item assignments from - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ReplaceItems - public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, - string fromBundleSid, - ITwilioRestClient client = null) - { - var options = new CreateReplaceItemsOptions(pathBundleSid, fromBundleSid); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ReplaceItemsResource object - /// - /// Raw JSON string - /// ReplaceItemsResource object represented by the provided JSON - public static ReplaceItemsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a regulation - /// - [JsonProperty("regulation_sid")] - public string RegulationSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The verification status of the Bundle resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ReplaceItemsResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource will be valid until - /// - [JsonProperty("valid_until")] - public DateTime? ValidUntil { get; private set; } - /// - /// The email address - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The URL we call to inform your application of status changes - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private ReplaceItemsResource() - { - - } - } +{ + + public class ReplaceItemsResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum InReview = new StatusEnum("in-review"); + public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); + public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); + public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); + } + + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateReplaceItemsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathBundleSid + "/ReplaceItems", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source + /// bundle (specified by the from_bundle_sid body param) + /// + /// Create ReplaceItems parameters + /// Client to make requests to Twilio + /// A single instance of ReplaceItems + public static ReplaceItemsResource Create(CreateReplaceItemsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source + /// bundle (specified by the from_bundle_sid body param) + /// + /// Create ReplaceItems parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ReplaceItems + public static async System.Threading.Tasks.Task CreateAsync(CreateReplaceItemsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source + /// bundle (specified by the from_bundle_sid body param) + /// + /// The unique string that identifies the Bundle where the item assignments are going to + /// be replaced + /// The source bundle sid to copy the item assignments from + /// Client to make requests to Twilio + /// A single instance of ReplaceItems + public static ReplaceItemsResource Create(string pathBundleSid, + string fromBundleSid, + ITwilioRestClient client = null) + { + var options = new CreateReplaceItemsOptions(pathBundleSid, fromBundleSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source + /// bundle (specified by the from_bundle_sid body param) + /// + /// The unique string that identifies the Bundle where the item assignments are going to + /// be replaced + /// The source bundle sid to copy the item assignments from + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ReplaceItems + public static async System.Threading.Tasks.Task CreateAsync(string pathBundleSid, + string fromBundleSid, + ITwilioRestClient client = null) + { + var options = new CreateReplaceItemsOptions(pathBundleSid, fromBundleSid); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ReplaceItemsResource object + /// + /// Raw JSON string + /// ReplaceItemsResource object represented by the provided JSON + public static ReplaceItemsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a regulation + /// + [JsonProperty("regulation_sid")] + public string RegulationSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The verification status of the Bundle resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ReplaceItemsResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource will be valid until + /// + [JsonProperty("valid_until")] + public DateTime? ValidUntil { get; private set; } + /// + /// The email address + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The URL we call to inform your application of status changes + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private ReplaceItemsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.cs index 6098f2edf..06a1bb1fa 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.cs @@ -9,285 +9,285 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Create a new Bundle. + /// + public class CreateBundleOptions : IOptions + { /// - /// Create a new Bundle. + /// The string that you assigned to describe the resource /// - public class CreateBundleOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The email address - /// - public string Email { get; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - /// - /// The unique string of a regulation. - /// - public string RegulationSid { get; set; } - /// - /// The ISO country code of the country - /// - public string IsoCountry { get; set; } - /// - /// The type of End User of the Bundle resource - /// - public BundleResource.EndUserTypeEnum EndUserType { get; set; } - /// - /// The type of phone number - /// - public string NumberType { get; set; } - - /// - /// Construct a new CreateBundleOptions - /// - /// The string that you assigned to describe the resource - /// The email address - public CreateBundleOptions(string friendlyName, string email) - { - FriendlyName = friendlyName; - Email = email; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (RegulationSid != null) - { - p.Add(new KeyValuePair("RegulationSid", RegulationSid.ToString())); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry)); - } - - if (EndUserType != null) - { - p.Add(new KeyValuePair("EndUserType", EndUserType.ToString())); - } - - if (NumberType != null) - { - p.Add(new KeyValuePair("NumberType", NumberType)); - } - - return p; - } - } - + public string FriendlyName { get; } /// - /// Retrieve a list of all Bundles for an account. + /// The email address /// - public class ReadBundleOptions : ReadOptions - { - /// - /// The verification status of the Bundle resource - /// - public BundleResource.StatusEnum Status { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The unique string of a regulation. - /// - public string RegulationSid { get; set; } - /// - /// The ISO country code of the country - /// - public string IsoCountry { get; set; } - /// - /// The type of phone number - /// - public string NumberType { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (RegulationSid != null) - { - p.Add(new KeyValuePair("RegulationSid", RegulationSid.ToString())); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry)); - } - - if (NumberType != null) - { - p.Add(new KeyValuePair("NumberType", NumberType)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string Email { get; } /// - /// Fetch a specific Bundle instance. + /// The URL we call to inform your application of status changes. /// - public class FetchBundleOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBundleOptions - /// - /// The unique string that identifies the resource. - public FetchBundleOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public Uri StatusCallback { get; set; } /// - /// Updates a Bundle in an account. + /// The unique string of a regulation. /// - public class UpdateBundleOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - /// - /// The verification status of the Bundle resource - /// - public BundleResource.StatusEnum Status { get; set; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The email address - /// - public string Email { get; set; } - - /// - /// Construct a new UpdateBundleOptions - /// - /// The unique string that identifies the resource. - public UpdateBundleOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - return p; - } - } - + public string RegulationSid { get; set; } /// - /// Delete a specific Bundle. + /// The ISO country code of the country /// - public class DeleteBundleOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBundleOptions - /// - /// The unique string that identifies the resource. - public DeleteBundleOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string IsoCountry { get; set; } + /// + /// The type of End User of the Bundle resource + /// + public BundleResource.EndUserTypeEnum EndUserType { get; set; } + /// + /// The type of phone number + /// + public string NumberType { get; set; } + + /// + /// Construct a new CreateBundleOptions + /// + /// The string that you assigned to describe the resource + /// The email address + public CreateBundleOptions(string friendlyName, string email) + { + FriendlyName = friendlyName; + Email = email; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (RegulationSid != null) + { + p.Add(new KeyValuePair("RegulationSid", RegulationSid.ToString())); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry)); + } + + if (EndUserType != null) + { + p.Add(new KeyValuePair("EndUserType", EndUserType.ToString())); + } + + if (NumberType != null) + { + p.Add(new KeyValuePair("NumberType", NumberType)); + } + + return p; + } + } + + /// + /// Retrieve a list of all Bundles for an account. + /// + public class ReadBundleOptions : ReadOptions + { + /// + /// The verification status of the Bundle resource + /// + public BundleResource.StatusEnum Status { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The unique string of a regulation. + /// + public string RegulationSid { get; set; } + /// + /// The ISO country code of the country + /// + public string IsoCountry { get; set; } + /// + /// The type of phone number + /// + public string NumberType { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (RegulationSid != null) + { + p.Add(new KeyValuePair("RegulationSid", RegulationSid.ToString())); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry)); + } + + if (NumberType != null) + { + p.Add(new KeyValuePair("NumberType", NumberType)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Bundle instance. + /// + public class FetchBundleOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBundleOptions + /// + /// The unique string that identifies the resource. + public FetchBundleOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Updates a Bundle in an account. + /// + public class UpdateBundleOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + /// + /// The verification status of the Bundle resource + /// + public BundleResource.StatusEnum Status { get; set; } + /// + /// The URL we call to inform your application of status changes. + /// + public Uri StatusCallback { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The email address + /// + public string Email { get; set; } + + /// + /// Construct a new UpdateBundleOptions + /// + /// The unique string that identifies the resource. + public UpdateBundleOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + return p; + } + } + + /// + /// Delete a specific Bundle. + /// + public class DeleteBundleOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBundleOptions + /// + /// The unique string that identifies the resource. + public DeleteBundleOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleResource.cs index 4df1594e6..ed100694c 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleResource.cs @@ -17,582 +17,582 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class BundleResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum InReview = new StatusEnum("in-review"); - public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); - public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); - public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); - } - - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateBundleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Bundle. - /// - /// Create Bundle parameters - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Create(CreateBundleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Bundle. - /// - /// Create Bundle parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task CreateAsync(CreateBundleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Bundle. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The URL we call to inform your application of status changes. - /// The unique string of a regulation. - /// The ISO country code of the country - /// The type of End User of the Bundle resource - /// The type of phone number - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Create(string friendlyName, - string email, - Uri statusCallback = null, - string regulationSid = null, - string isoCountry = null, - BundleResource.EndUserTypeEnum endUserType = null, - string numberType = null, - ITwilioRestClient client = null) - { - var options = new CreateBundleOptions(friendlyName, email){StatusCallback = statusCallback, RegulationSid = regulationSid, IsoCountry = isoCountry, EndUserType = endUserType, NumberType = numberType}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Bundle. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The URL we call to inform your application of status changes. - /// The unique string of a regulation. - /// The ISO country code of the country - /// The type of End User of the Bundle resource - /// The type of phone number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string email, - Uri statusCallback = null, - string regulationSid = null, - string isoCountry = null, - BundleResource.EndUserTypeEnum endUserType = null, - string numberType = null, - ITwilioRestClient client = null) - { - var options = new CreateBundleOptions(friendlyName, email){StatusCallback = statusCallback, RegulationSid = regulationSid, IsoCountry = isoCountry, EndUserType = endUserType, NumberType = numberType}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBundleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Bundles for an account. - /// - /// Read Bundle parameters - /// Client to make requests to Twilio - /// A single instance of Bundle - public static ResourceSet Read(ReadBundleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Bundles for an account. - /// - /// Read Bundle parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task> ReadAsync(ReadBundleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Bundles for an account. - /// - /// The verification status of the Bundle resource - /// The string that you assigned to describe the resource - /// The unique string of a regulation. - /// The ISO country code of the country - /// The type of phone number - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Bundle - public static ResourceSet Read(BundleResource.StatusEnum status = null, - string friendlyName = null, - string regulationSid = null, - string isoCountry = null, - string numberType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBundleOptions(){Status = status, FriendlyName = friendlyName, RegulationSid = regulationSid, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Bundles for an account. - /// - /// The verification status of the Bundle resource - /// The string that you assigned to describe the resource - /// The unique string of a regulation. - /// The ISO country code of the country - /// The type of phone number - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task> ReadAsync(BundleResource.StatusEnum status = null, - string friendlyName = null, - string regulationSid = null, - string isoCountry = null, - string numberType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBundleOptions(){Status = status, FriendlyName = friendlyName, RegulationSid = regulationSid, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchBundleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Bundle instance. - /// - /// Fetch Bundle parameters - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Fetch(FetchBundleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Bundle instance. - /// - /// Fetch Bundle parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task FetchAsync(FetchBundleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Bundle instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBundleOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Bundle instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBundleOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateBundleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a Bundle in an account. - /// - /// Update Bundle parameters - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Update(UpdateBundleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a Bundle in an account. - /// - /// Update Bundle parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task UpdateAsync(UpdateBundleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a Bundle in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Bundle resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// A single instance of Bundle - public static BundleResource Update(string pathSid, - BundleResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateBundleOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a Bundle in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Bundle resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - BundleResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateBundleOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteBundleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Bundle. - /// - /// Delete Bundle parameters - /// Client to make requests to Twilio - /// A single instance of Bundle - public static bool Delete(DeleteBundleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Bundle. - /// - /// Delete Bundle parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBundleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Bundle. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of Bundle - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBundleOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Bundle. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bundle - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBundleOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BundleResource object - /// - /// Raw JSON string - /// BundleResource object represented by the provided JSON - public static BundleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a regulation. - /// - [JsonProperty("regulation_sid")] - public string RegulationSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The verification status of the Bundle resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public BundleResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource will be valid until. - /// - [JsonProperty("valid_until")] - public DateTime? ValidUntil { get; private set; } - /// - /// The email address - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The URL we call to inform your application of status changes. - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Bundle resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Assigned Items of the Bundle resource - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BundleResource() - { - - } - } +{ + + public class BundleResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum InReview = new StatusEnum("in-review"); + public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); + public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); + public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); + } + + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateBundleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Bundle. + /// + /// Create Bundle parameters + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Create(CreateBundleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Bundle. + /// + /// Create Bundle parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task CreateAsync(CreateBundleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Bundle. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The URL we call to inform your application of status changes. + /// The unique string of a regulation. + /// The ISO country code of the country + /// The type of End User of the Bundle resource + /// The type of phone number + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Create(string friendlyName, + string email, + Uri statusCallback = null, + string regulationSid = null, + string isoCountry = null, + BundleResource.EndUserTypeEnum endUserType = null, + string numberType = null, + ITwilioRestClient client = null) + { + var options = new CreateBundleOptions(friendlyName, email) { StatusCallback = statusCallback, RegulationSid = regulationSid, IsoCountry = isoCountry, EndUserType = endUserType, NumberType = numberType }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Bundle. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The URL we call to inform your application of status changes. + /// The unique string of a regulation. + /// The ISO country code of the country + /// The type of End User of the Bundle resource + /// The type of phone number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string email, + Uri statusCallback = null, + string regulationSid = null, + string isoCountry = null, + BundleResource.EndUserTypeEnum endUserType = null, + string numberType = null, + ITwilioRestClient client = null) + { + var options = new CreateBundleOptions(friendlyName, email) { StatusCallback = statusCallback, RegulationSid = regulationSid, IsoCountry = isoCountry, EndUserType = endUserType, NumberType = numberType }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBundleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Bundles for an account. + /// + /// Read Bundle parameters + /// Client to make requests to Twilio + /// A single instance of Bundle + public static ResourceSet Read(ReadBundleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Bundles for an account. + /// + /// Read Bundle parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task> ReadAsync(ReadBundleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Bundles for an account. + /// + /// The verification status of the Bundle resource + /// The string that you assigned to describe the resource + /// The unique string of a regulation. + /// The ISO country code of the country + /// The type of phone number + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Bundle + public static ResourceSet Read(BundleResource.StatusEnum status = null, + string friendlyName = null, + string regulationSid = null, + string isoCountry = null, + string numberType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBundleOptions() { Status = status, FriendlyName = friendlyName, RegulationSid = regulationSid, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Bundles for an account. + /// + /// The verification status of the Bundle resource + /// The string that you assigned to describe the resource + /// The unique string of a regulation. + /// The ISO country code of the country + /// The type of phone number + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task> ReadAsync(BundleResource.StatusEnum status = null, + string friendlyName = null, + string regulationSid = null, + string isoCountry = null, + string numberType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBundleOptions() { Status = status, FriendlyName = friendlyName, RegulationSid = regulationSid, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchBundleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Bundle instance. + /// + /// Fetch Bundle parameters + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Fetch(FetchBundleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Bundle instance. + /// + /// Fetch Bundle parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task FetchAsync(FetchBundleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Bundle instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBundleOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Bundle instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBundleOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateBundleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a Bundle in an account. + /// + /// Update Bundle parameters + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Update(UpdateBundleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a Bundle in an account. + /// + /// Update Bundle parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task UpdateAsync(UpdateBundleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a Bundle in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Bundle resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// A single instance of Bundle + public static BundleResource Update(string pathSid, + BundleResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateBundleOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a Bundle in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Bundle resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + BundleResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateBundleOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteBundleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Bundles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Bundle. + /// + /// Delete Bundle parameters + /// Client to make requests to Twilio + /// A single instance of Bundle + public static bool Delete(DeleteBundleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Bundle. + /// + /// Delete Bundle parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBundleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Bundle. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of Bundle + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBundleOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Bundle. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bundle + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBundleOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BundleResource object + /// + /// Raw JSON string + /// BundleResource object represented by the provided JSON + public static BundleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a regulation. + /// + [JsonProperty("regulation_sid")] + public string RegulationSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The verification status of the Bundle resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public BundleResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource will be valid until. + /// + [JsonProperty("valid_until")] + public DateTime? ValidUntil { get; private set; } + /// + /// The email address + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The URL we call to inform your application of status changes. + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Bundle resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Assigned Items of the Bundle resource + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BundleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserOptions.cs index d43bc90e4..00c35dc11 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserOptions.cs @@ -9,185 +9,185 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Create a new End User. + /// + public class CreateEndUserOptions : IOptions + { /// - /// Create a new End User. - /// - public class CreateEndUserOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The type of end user of the Bundle resource - /// - public EndUserResource.TypeEnum Type { get; } - /// - /// The set of parameters that compose the End User resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new CreateEndUserOptions - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - public CreateEndUserOptions(string friendlyName, EndUserResource.TypeEnum type) - { - FriendlyName = friendlyName; - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all End User for an account. - /// - public class ReadEndUserOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of end user of the Bundle resource + /// + public EndUserResource.TypeEnum Type { get; } /// - /// Fetch specific End User Instance. + /// The set of parameters that compose the End User resource /// - public class FetchEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEndUserOptions - /// - /// The unique string that identifies the resource - public FetchEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public object Attributes { get; set; } + /// - /// Update an existing End User. - /// - public class UpdateEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The set of parameters that compose the End User resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new UpdateEndUserOptions - /// - /// The unique string that identifies the resource - public UpdateEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// Construct a new CreateEndUserOptions + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + public CreateEndUserOptions(string friendlyName, EndUserResource.TypeEnum type) + { + FriendlyName = friendlyName; + Type = type; + } + /// - /// Delete a specific End User. + /// Generate the necessary parameters /// - public class DeleteEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteEndUserOptions - /// - /// The unique string that identifies the resource - public DeleteEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Retrieve a list of all End User for an account. + /// + public class ReadEndUserOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific End User Instance. + /// + public class FetchEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEndUserOptions + /// + /// The unique string that identifies the resource + public FetchEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an existing End User. + /// + public class UpdateEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The set of parameters that compose the End User resource + /// + public object Attributes { get; set; } + + /// + /// Construct a new UpdateEndUserOptions + /// + /// The unique string that identifies the resource + public UpdateEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Delete a specific End User. + /// + public class DeleteEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteEndUserOptions + /// + /// The unique string that identifies the resource + public DeleteEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserResource.cs index 59522fb61..e8d5c18be 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserResource.cs @@ -17,501 +17,501 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class EndUserResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Individual = new TypeEnum("individual"); - public static readonly TypeEnum Business = new TypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUsers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new End User. - /// - /// Create EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Create(CreateEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new End User. - /// - /// Create EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task CreateAsync(CreateEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new End User. - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Create(string friendlyName, - EndUserResource.TypeEnum type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateEndUserOptions(friendlyName, type){Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new End User. - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - EndUserResource.TypeEnum type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateEndUserOptions(friendlyName, type){Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUsers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all End User for an account. - /// - /// Read EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static ResourceSet Read(ReadEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End User for an account. - /// - /// Read EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all End User for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of EndUser - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End User for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific End User Instance. - /// - /// Fetch EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Fetch(FetchEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific End User Instance. - /// - /// Fetch EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific End User Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEndUserOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific End User Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEndUserOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing End User. - /// - /// Update EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Update(UpdateEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing End User. - /// - /// Update EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task UpdateAsync(UpdateEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing End User. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Update(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateEndUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing End User. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateEndUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific End User. - /// - /// Delete EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static bool Delete(DeleteEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific End User. - /// - /// Delete EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task DeleteAsync(DeleteEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific End User. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEndUserOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific End User. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEndUserOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EndUserResource object - /// - /// Raw JSON string - /// EndUserResource object represented by the provided JSON - public static EndUserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of end user of the Bundle resource - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public EndUserResource.TypeEnum Type { get; private set; } - /// - /// The set of parameters that compose the End Users resource - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the End User resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EndUserResource() - { - - } - } +{ + + public class EndUserResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Individual = new TypeEnum("individual"); + public static readonly TypeEnum Business = new TypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUsers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new End User. + /// + /// Create EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Create(CreateEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new End User. + /// + /// Create EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task CreateAsync(CreateEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new End User. + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Create(string friendlyName, + EndUserResource.TypeEnum type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateEndUserOptions(friendlyName, type) { Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new End User. + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + EndUserResource.TypeEnum type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateEndUserOptions(friendlyName, type) { Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUsers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all End User for an account. + /// + /// Read EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static ResourceSet Read(ReadEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End User for an account. + /// + /// Read EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all End User for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of EndUser + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End User for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific End User Instance. + /// + /// Fetch EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Fetch(FetchEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific End User Instance. + /// + /// Fetch EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific End User Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEndUserOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific End User Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEndUserOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing End User. + /// + /// Update EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Update(UpdateEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing End User. + /// + /// Update EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task UpdateAsync(UpdateEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing End User. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Update(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateEndUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing End User. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateEndUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUsers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific End User. + /// + /// Delete EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static bool Delete(DeleteEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific End User. + /// + /// Delete EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task DeleteAsync(DeleteEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific End User. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEndUserOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific End User. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEndUserOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EndUserResource object + /// + /// Raw JSON string + /// EndUserResource object represented by the provided JSON + public static EndUserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of end user of the Bundle resource + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public EndUserResource.TypeEnum Type { get; private set; } + /// + /// The set of parameters that compose the End Users resource + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the End User resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EndUserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeOptions.cs index 79017f464..7331f34e4 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Retrieve a list of all End-User Types. + /// + public class ReadEndUserTypeOptions : ReadOptions + { /// - /// Retrieve a list of all End-User Types. + /// Generate the necessary parameters /// - public class ReadEndUserTypeOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific End-User Type Instance. + /// + public class FetchEndUserTypeOptions : IOptions + { /// - /// Fetch a specific End-User Type Instance. + /// The unique string that identifies the End-User Type resource /// - public class FetchEndUserTypeOptions : IOptions - { - /// - /// The unique string that identifies the End-User Type resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEndUserTypeOptions - /// - /// The unique string that identifies the End-User Type resource - public FetchEndUserTypeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchEndUserTypeOptions + /// + /// The unique string that identifies the End-User Type resource + public FetchEndUserTypeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeResource.cs index 77c02ebc0..b2acfd3cc 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/EndUserTypeResource.cs @@ -16,254 +16,254 @@ using Twilio.Http; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class EndUserTypeResource : Resource - { - private static Request BuildReadRequest(ReadEndUserTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUserTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all End-User Types. - /// - /// Read EndUserType parameters - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static ResourceSet Read(ReadEndUserTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("end_user_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End-User Types. - /// - /// Read EndUserType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("end_user_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all End-User Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserTypeOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End-User Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserTypeOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - private static Request BuildFetchRequest(FetchEndUserTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/EndUserTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific End-User Type Instance. - /// - /// Fetch EndUserType parameters - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static EndUserTypeResource Fetch(FetchEndUserTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific End-User Type Instance. - /// - /// Fetch EndUserType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific End-User Type Instance. - /// - /// The unique string that identifies the End-User Type resource - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static EndUserTypeResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEndUserTypeOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific End-User Type Instance. - /// - /// The unique string that identifies the End-User Type resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEndUserTypeOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EndUserTypeResource object - /// - /// Raw JSON string - /// EndUserTypeResource object represented by the provided JSON - public static EndUserTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the End-User Type resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the End-User Type resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A machine-readable description of the End-User Type resource - /// - [JsonProperty("machine_name")] - public string MachineName { get; private set; } - /// - /// The required information for creating an End-User. - /// - [JsonProperty("fields")] - public List Fields { get; private set; } - /// - /// The absolute URL of the End-User Type resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EndUserTypeResource() - { - - } - } +{ + + public class EndUserTypeResource : Resource + { + private static Request BuildReadRequest(ReadEndUserTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUserTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all End-User Types. + /// + /// Read EndUserType parameters + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static ResourceSet Read(ReadEndUserTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("end_user_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End-User Types. + /// + /// Read EndUserType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("end_user_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all End-User Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserTypeOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End-User Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserTypeOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + private static Request BuildFetchRequest(FetchEndUserTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/EndUserTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific End-User Type Instance. + /// + /// Fetch EndUserType parameters + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static EndUserTypeResource Fetch(FetchEndUserTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific End-User Type Instance. + /// + /// Fetch EndUserType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific End-User Type Instance. + /// + /// The unique string that identifies the End-User Type resource + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static EndUserTypeResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEndUserTypeOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific End-User Type Instance. + /// + /// The unique string that identifies the End-User Type resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEndUserTypeOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EndUserTypeResource object + /// + /// Raw JSON string + /// EndUserTypeResource object represented by the provided JSON + public static EndUserTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the End-User Type resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the End-User Type resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A machine-readable description of the End-User Type resource + /// + [JsonProperty("machine_name")] + public string MachineName { get; private set; } + /// + /// The required information for creating an End-User. + /// + [JsonProperty("fields")] + public List Fields { get; private set; } + /// + /// The absolute URL of the End-User Type resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EndUserTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationOptions.cs index e06019965..6ea926a3c 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationOptions.cs @@ -9,83 +9,83 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Retrieve a list of all Regulations. + /// + public class ReadRegulationOptions : ReadOptions + { /// - /// Retrieve a list of all Regulations. + /// The type of End User of the Regulation resource /// - public class ReadRegulationOptions : ReadOptions - { - /// - /// The type of End User of the Regulation resource - /// - public RegulationResource.EndUserTypeEnum EndUserType { get; set; } - /// - /// The ISO country code of the phone number's country - /// - public string IsoCountry { get; set; } - /// - /// The type of phone number being regulated - /// - public string NumberType { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (EndUserType != null) - { - p.Add(new KeyValuePair("EndUserType", EndUserType.ToString())); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry)); - } - - if (NumberType != null) - { - p.Add(new KeyValuePair("NumberType", NumberType)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public RegulationResource.EndUserTypeEnum EndUserType { get; set; } /// - /// Fetch specific Regulation Instance. + /// The ISO country code of the phone number's country /// - public class FetchRegulationOptions : IOptions - { - /// - /// The unique string that identifies the Regulation resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRegulationOptions - /// - /// The unique string that identifies the Regulation resource - public FetchRegulationOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string IsoCountry { get; set; } + /// + /// The type of phone number being regulated + /// + public string NumberType { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (EndUserType != null) + { + p.Add(new KeyValuePair("EndUserType", EndUserType.ToString())); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry)); + } + + if (NumberType != null) + { + p.Add(new KeyValuePair("NumberType", NumberType)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Regulation Instance. + /// + public class FetchRegulationOptions : IOptions + { + /// + /// The unique string that identifies the Regulation resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRegulationOptions + /// + /// The unique string that identifies the Regulation resource + public FetchRegulationOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationResource.cs index d0ad0f968..940ad0b98 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/RegulationResource.cs @@ -17,290 +17,290 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class RegulationResource : Resource - { - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildReadRequest(ReadRegulationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Regulations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Regulations. - /// - /// Read Regulation parameters - /// Client to make requests to Twilio - /// A single instance of Regulation - public static ResourceSet Read(ReadRegulationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Regulations. - /// - /// Read Regulation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Regulation - public static async System.Threading.Tasks.Task> ReadAsync(ReadRegulationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Regulations. - /// - /// The type of End User of the Regulation resource - /// The ISO country code of the phone number's country - /// The type of phone number being regulated - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Regulation - public static ResourceSet Read(RegulationResource.EndUserTypeEnum endUserType = null, - string isoCountry = null, - string numberType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRegulationOptions(){EndUserType = endUserType, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Regulations. - /// - /// The type of End User of the Regulation resource - /// The ISO country code of the phone number's country - /// The type of phone number being regulated - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Regulation - public static async System.Threading.Tasks.Task> ReadAsync(RegulationResource.EndUserTypeEnum endUserType = null, - string isoCountry = null, - string numberType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRegulationOptions(){EndUserType = endUserType, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchRegulationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/Regulations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Regulation Instance. - /// - /// Fetch Regulation parameters - /// Client to make requests to Twilio - /// A single instance of Regulation - public static RegulationResource Fetch(FetchRegulationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Regulation Instance. - /// - /// Fetch Regulation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Regulation - public static async System.Threading.Tasks.Task FetchAsync(FetchRegulationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Regulation Instance. - /// - /// The unique string that identifies the Regulation resource - /// Client to make requests to Twilio - /// A single instance of Regulation - public static RegulationResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRegulationOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Regulation Instance. - /// - /// The unique string that identifies the Regulation resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Regulation - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRegulationOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RegulationResource object - /// - /// Raw JSON string - /// RegulationResource object represented by the provided JSON - public static RegulationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Regulation resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the Regulation resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO country code of the phone number's country - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The type of phone number restricted by the regulatory requirement - /// - [JsonProperty("number_type")] - public string NumberType { get; private set; } - /// - /// The type of End User of the Regulation resource - /// - [JsonProperty("end_user_type")] - [JsonConverter(typeof(StringEnumConverter))] - public RegulationResource.EndUserTypeEnum EndUserType { get; private set; } - /// - /// The sid of a regulation object that dictates requirements - /// - [JsonProperty("requirements")] - public object Requirements { get; private set; } - /// - /// The absolute URL of the Regulation resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RegulationResource() - { - - } - } +{ + + public class RegulationResource : Resource + { + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildReadRequest(ReadRegulationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Regulations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Regulations. + /// + /// Read Regulation parameters + /// Client to make requests to Twilio + /// A single instance of Regulation + public static ResourceSet Read(ReadRegulationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Regulations. + /// + /// Read Regulation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Regulation + public static async System.Threading.Tasks.Task> ReadAsync(ReadRegulationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Regulations. + /// + /// The type of End User of the Regulation resource + /// The ISO country code of the phone number's country + /// The type of phone number being regulated + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Regulation + public static ResourceSet Read(RegulationResource.EndUserTypeEnum endUserType = null, + string isoCountry = null, + string numberType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRegulationOptions() { EndUserType = endUserType, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Regulations. + /// + /// The type of End User of the Regulation resource + /// The ISO country code of the phone number's country + /// The type of phone number being regulated + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Regulation + public static async System.Threading.Tasks.Task> ReadAsync(RegulationResource.EndUserTypeEnum endUserType = null, + string isoCountry = null, + string numberType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRegulationOptions() { EndUserType = endUserType, IsoCountry = isoCountry, NumberType = numberType, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchRegulationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/Regulations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Regulation Instance. + /// + /// Fetch Regulation parameters + /// Client to make requests to Twilio + /// A single instance of Regulation + public static RegulationResource Fetch(FetchRegulationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Regulation Instance. + /// + /// Fetch Regulation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Regulation + public static async System.Threading.Tasks.Task FetchAsync(FetchRegulationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Regulation Instance. + /// + /// The unique string that identifies the Regulation resource + /// Client to make requests to Twilio + /// A single instance of Regulation + public static RegulationResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRegulationOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Regulation Instance. + /// + /// The unique string that identifies the Regulation resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Regulation + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRegulationOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RegulationResource object + /// + /// Raw JSON string + /// RegulationResource object represented by the provided JSON + public static RegulationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Regulation resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the Regulation resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO country code of the phone number's country + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The type of phone number restricted by the regulatory requirement + /// + [JsonProperty("number_type")] + public string NumberType { get; private set; } + /// + /// The type of End User of the Regulation resource + /// + [JsonProperty("end_user_type")] + [JsonConverter(typeof(StringEnumConverter))] + public RegulationResource.EndUserTypeEnum EndUserType { get; private set; } + /// + /// The sid of a regulation object that dictates requirements + /// + [JsonProperty("requirements")] + public object Requirements { get; private set; } + /// + /// The absolute URL of the Regulation resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RegulationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentOptions.cs index 826278492..f4fb2acee 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentOptions.cs @@ -9,185 +9,185 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Create a new Supporting Document. + /// + public class CreateSupportingDocumentOptions : IOptions + { /// - /// Create a new Supporting Document. - /// - public class CreateSupportingDocumentOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The type of the Supporting Document - /// - public string Type { get; } - /// - /// The set of parameters that compose the Supporting Documents resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new CreateSupportingDocumentOptions - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - public CreateSupportingDocumentOptions(string friendlyName, string type) - { - FriendlyName = friendlyName; - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all Supporting Document for an account. - /// - public class ReadSupportingDocumentOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of the Supporting Document + /// + public string Type { get; } /// - /// Fetch specific Supporting Document Instance. + /// The set of parameters that compose the Supporting Documents resource /// - public class FetchSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public FetchSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public object Attributes { get; set; } + /// - /// Update an existing Supporting Document. - /// - public class UpdateSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The set of parameters that compose the Supporting Document resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new UpdateSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public UpdateSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// Construct a new CreateSupportingDocumentOptions + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + public CreateSupportingDocumentOptions(string friendlyName, string type) + { + FriendlyName = friendlyName; + Type = type; + } + /// - /// Delete a specific Supporting Document. + /// Generate the necessary parameters /// - public class DeleteSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public DeleteSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + public class ReadSupportingDocumentOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Supporting Document Instance. + /// + public class FetchSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public FetchSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an existing Supporting Document. + /// + public class UpdateSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The set of parameters that compose the Supporting Document resource + /// + public object Attributes { get; set; } + + /// + /// Construct a new UpdateSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public UpdateSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Delete a specific Supporting Document. + /// + public class DeleteSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public DeleteSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentResource.cs index 13dbddb1e..1ea53df9f 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class SupportingDocumentResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum Rejected = new StatusEnum("rejected"); - public static readonly StatusEnum Approved = new StatusEnum("approved"); - public static readonly StatusEnum Expired = new StatusEnum("expired"); - public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); - } - - private static Request BuildCreateRequest(CreateSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocuments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Supporting Document. - /// - /// Create SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Create(CreateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Supporting Document. - /// - /// Create SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task CreateAsync(CreateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Supporting Document. - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - /// The set of parameters that compose the Supporting Documents resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Create(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateSupportingDocumentOptions(friendlyName, type){Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Supporting Document. - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - /// The set of parameters that compose the Supporting Documents resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateSupportingDocumentOptions(friendlyName, type){Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocuments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Read SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static ResourceSet Read(ReadSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Read SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Supporting Document Instance. - /// - /// Fetch SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Fetch(FetchSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Supporting Document Instance. - /// - /// Fetch SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Supporting Document Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Supporting Document Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing Supporting Document. - /// - /// Update SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Update(UpdateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing Supporting Document. - /// - /// Update SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing Supporting Document. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the Supporting Document resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Update(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateSupportingDocumentOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing Supporting Document. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the Supporting Document resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateSupportingDocumentOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Supporting Document. - /// - /// Delete SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static bool Delete(DeleteSupportingDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Supporting Document. - /// - /// Delete SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Supporting Document. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSupportingDocumentOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Supporting Document. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSupportingDocumentOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SupportingDocumentResource object - /// - /// Raw JSON string - /// SupportingDocumentResource object represented by the provided JSON - public static SupportingDocumentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The image type of the file - /// - [JsonProperty("mime_type")] - public string MimeType { get; private set; } - /// - /// The verification status of the Supporting Document resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SupportingDocumentResource.StatusEnum Status { get; private set; } - /// - /// The type of the Supporting Document - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The set of parameters that compose the Supporting Documents resource - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Supporting Document resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SupportingDocumentResource() - { - - } - } +{ + + public class SupportingDocumentResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum Rejected = new StatusEnum("rejected"); + public static readonly StatusEnum Approved = new StatusEnum("approved"); + public static readonly StatusEnum Expired = new StatusEnum("expired"); + public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); + } + + private static Request BuildCreateRequest(CreateSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocuments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Supporting Document. + /// + /// Create SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Create(CreateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Supporting Document. + /// + /// Create SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task CreateAsync(CreateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Supporting Document. + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + /// The set of parameters that compose the Supporting Documents resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Create(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateSupportingDocumentOptions(friendlyName, type) { Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Supporting Document. + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + /// The set of parameters that compose the Supporting Documents resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateSupportingDocumentOptions(friendlyName, type) { Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocuments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Read SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static ResourceSet Read(ReadSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Read SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Supporting Document Instance. + /// + /// Fetch SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Fetch(FetchSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Supporting Document Instance. + /// + /// Fetch SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Supporting Document Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Supporting Document Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing Supporting Document. + /// + /// Update SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Update(UpdateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing Supporting Document. + /// + /// Update SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing Supporting Document. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the Supporting Document resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Update(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateSupportingDocumentOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing Supporting Document. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the Supporting Document resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateSupportingDocumentOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocuments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Supporting Document. + /// + /// Delete SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static bool Delete(DeleteSupportingDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Supporting Document. + /// + /// Delete SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Supporting Document. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSupportingDocumentOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Supporting Document. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSupportingDocumentOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SupportingDocumentResource object + /// + /// Raw JSON string + /// SupportingDocumentResource object represented by the provided JSON + public static SupportingDocumentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The image type of the file + /// + [JsonProperty("mime_type")] + public string MimeType { get; private set; } + /// + /// The verification status of the Supporting Document resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SupportingDocumentResource.StatusEnum Status { get; private set; } + /// + /// The type of the Supporting Document + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The set of parameters that compose the Supporting Documents resource + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Supporting Document resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SupportingDocumentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeOptions.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeOptions.cs index f6df8a848..606d0190a 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeOptions.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - +{ + + /// + /// Retrieve a list of all Supporting Document Types. + /// + public class ReadSupportingDocumentTypeOptions : ReadOptions + { /// - /// Retrieve a list of all Supporting Document Types. + /// Generate the necessary parameters /// - public class ReadSupportingDocumentTypeOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + public class FetchSupportingDocumentTypeOptions : IOptions + { /// - /// Fetch a specific Supporting Document Type Instance. + /// The unique string that identifies the Supporting Document Type resource /// - public class FetchSupportingDocumentTypeOptions : IOptions - { - /// - /// The unique string that identifies the Supporting Document Type resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSupportingDocumentTypeOptions - /// - /// The unique string that identifies the Supporting Document Type resource - public FetchSupportingDocumentTypeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchSupportingDocumentTypeOptions + /// + /// The unique string that identifies the Supporting Document Type resource + public FetchSupportingDocumentTypeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeResource.cs b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeResource.cs index 2e6c47dd1..a2361d45a 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeResource.cs +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/SupportingDocumentTypeResource.cs @@ -16,258 +16,258 @@ using Twilio.Http; namespace Twilio.Rest.Numbers.V2.RegulatoryCompliance -{ - - public class SupportingDocumentTypeResource : Resource - { - private static Request BuildReadRequest(ReadSupportingDocumentTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocumentTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Read SupportingDocumentType parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static ResourceSet Read(ReadSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("supporting_document_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Read SupportingDocumentType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("supporting_document_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentTypeOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentTypeOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Numbers) - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - private static Request BuildFetchRequest(FetchSupportingDocumentTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Numbers, - "/v2/RegulatoryCompliance/SupportingDocumentTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// Fetch SupportingDocumentType parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static SupportingDocumentTypeResource Fetch(FetchSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// Fetch SupportingDocumentType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// The unique string that identifies the Supporting Document Type resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static SupportingDocumentTypeResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentTypeOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// The unique string that identifies the Supporting Document Type resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentTypeOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SupportingDocumentTypeResource object - /// - /// Raw JSON string - /// SupportingDocumentTypeResource object represented by the provided JSON - public static SupportingDocumentTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Supporting Document Type resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the Supporting Document Type resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The machine-readable description of the Supporting Document Type resource - /// - [JsonProperty("machine_name")] - public string MachineName { get; private set; } - /// - /// The required information for creating a Supporting Document - /// - [JsonProperty("fields")] - public List Fields { get; private set; } - /// - /// The absolute URL of the Supporting Document Type resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SupportingDocumentTypeResource() - { - - } - } +{ + + public class SupportingDocumentTypeResource : Resource + { + private static Request BuildReadRequest(ReadSupportingDocumentTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocumentTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Read SupportingDocumentType parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static ResourceSet Read(ReadSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("supporting_document_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Read SupportingDocumentType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("supporting_document_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentTypeOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentTypeOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Numbers) + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + private static Request BuildFetchRequest(FetchSupportingDocumentTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Numbers, + "/v2/RegulatoryCompliance/SupportingDocumentTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// Fetch SupportingDocumentType parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static SupportingDocumentTypeResource Fetch(FetchSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// Fetch SupportingDocumentType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// The unique string that identifies the Supporting Document Type resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static SupportingDocumentTypeResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentTypeOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// The unique string that identifies the Supporting Document Type resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentTypeOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SupportingDocumentTypeResource object + /// + /// Raw JSON string + /// SupportingDocumentTypeResource object represented by the provided JSON + public static SupportingDocumentTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Supporting Document Type resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the Supporting Document Type resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The machine-readable description of the Supporting Document Type resource + /// + [JsonProperty("machine_name")] + public string MachineName { get; private set; } + /// + /// The required information for creating a Supporting Document + /// + [JsonProperty("fields")] + public List Fields { get; private set; } + /// + /// The absolute URL of the Supporting Document Type resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SupportingDocumentTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/DayOptions.cs b/src/Twilio/Rest/Preview/BulkExports/Export/DayOptions.cs index 70e728e5d..5a29e0242 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/DayOptions.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/DayOptions.cs @@ -9,81 +9,81 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.BulkExports.Export -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Day. + /// + public class FetchDayOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Day. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchDayOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// The date of the data in the file - /// - public string PathDay { get; } - - /// - /// Construct a new FetchDayOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - public FetchDayOptions(string pathResourceType, string pathDay) - { - PathResourceType = pathResourceType; - PathDay = pathDay; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathResourceType { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Days for a resource. + /// The date of the data in the file /// - public class ReadDayOptions : ReadOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new ReadDayOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public ReadDayOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathDay { get; } + + /// + /// Construct a new FetchDayOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + public FetchDayOptions(string pathResourceType, string pathDay) + { + PathResourceType = pathResourceType; + PathDay = pathDay; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Days for a resource. + /// + public class ReadDayOptions : ReadOptions + { + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + + /// + /// Construct a new ReadDayOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public ReadDayOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/DayResource.cs b/src/Twilio/Rest/Preview/BulkExports/Export/DayResource.cs index 0989efd3a..ae0d0284e 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/DayResource.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/DayResource.cs @@ -19,266 +19,266 @@ using Twilio.Http; namespace Twilio.Rest.Preview.BulkExports.Export -{ - - public class DayResource : Resource - { - private static Request BuildFetchRequest(FetchDayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Days/" + options.PathDay + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Day. - /// - /// Fetch Day parameters - /// Client to make requests to Twilio - /// A single instance of Day - public static DayResource Fetch(FetchDayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Day. - /// - /// Fetch Day parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task FetchAsync(FetchDayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Day. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - /// Client to make requests to Twilio - /// A single instance of Day - public static DayResource Fetch(string pathResourceType, string pathDay, ITwilioRestClient client = null) - { - var options = new FetchDayOptions(pathResourceType, pathDay); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Day. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// The date of the data in the file - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - string pathDay, - ITwilioRestClient client = null) - { - var options = new FetchDayOptions(pathResourceType, pathDay); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDayOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Days", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Days for a resource. - /// - /// Read Day parameters - /// Client to make requests to Twilio - /// A single instance of Day - public static ResourceSet Read(ReadDayOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("days", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Days for a resource. - /// - /// Read Day parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task> ReadAsync(ReadDayOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("days", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Days for a resource. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Day - public static ResourceSet Read(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDayOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Days for a resource. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Day - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDayOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("days", response.Content); - } - - /// - /// Converts a JSON string into a DayResource object - /// - /// Raw JSON string - /// DayResource object represented by the provided JSON - public static DayResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The redirect_to - /// - [JsonProperty("redirect_to")] - public Uri RedirectTo { get; private set; } - /// - /// The date of the data in the file - /// - [JsonProperty("day")] - public string Day { get; private set; } - /// - /// Size of the file in bytes - /// - [JsonProperty("size")] - public int? Size { get; private set; } - /// - /// The date when resource is created - /// - [JsonProperty("create_date")] - public string CreateDate { get; private set; } - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - - private DayResource() - { - - } - } +{ + + public class DayResource : Resource + { + private static Request BuildFetchRequest(FetchDayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Days/" + options.PathDay + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Day. + /// + /// Fetch Day parameters + /// Client to make requests to Twilio + /// A single instance of Day + public static DayResource Fetch(FetchDayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Day. + /// + /// Fetch Day parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task FetchAsync(FetchDayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Day. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + /// Client to make requests to Twilio + /// A single instance of Day + public static DayResource Fetch(string pathResourceType, string pathDay, ITwilioRestClient client = null) + { + var options = new FetchDayOptions(pathResourceType, pathDay); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Day. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// The date of the data in the file + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + string pathDay, + ITwilioRestClient client = null) + { + var options = new FetchDayOptions(pathResourceType, pathDay); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDayOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Days", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Days for a resource. + /// + /// Read Day parameters + /// Client to make requests to Twilio + /// A single instance of Day + public static ResourceSet Read(ReadDayOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("days", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Days for a resource. + /// + /// Read Day parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task> ReadAsync(ReadDayOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("days", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Days for a resource. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Day + public static ResourceSet Read(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDayOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Days for a resource. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Day + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDayOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("days", response.Content); + } + + /// + /// Converts a JSON string into a DayResource object + /// + /// Raw JSON string + /// DayResource object represented by the provided JSON + public static DayResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The redirect_to + /// + [JsonProperty("redirect_to")] + public Uri RedirectTo { get; private set; } + /// + /// The date of the data in the file + /// + [JsonProperty("day")] + public string Day { get; private set; } + /// + /// Size of the file in bytes + /// + [JsonProperty("size")] + public int? Size { get; private set; } + /// + /// The date when resource is created + /// + [JsonProperty("create_date")] + public string CreateDate { get; private set; } + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + + private DayResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobOptions.cs b/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobOptions.cs index 6e12a142b..1fd897efb 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobOptions.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobOptions.cs @@ -9,138 +9,138 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.BulkExports.Export -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadExportCustomJobOptions + /// + public class ReadExportCustomJobOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadExportCustomJobOptions + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class ReadExportCustomJobOptions : ReadOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new ReadExportCustomJobOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public ReadExportCustomJobOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathResourceType { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateExportCustomJobOptions + /// Construct a new ReadExportCustomJobOptions /// - public class CreateExportCustomJobOptions : IOptions - { - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - public string StartDay { get; } - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. - /// - public string EndDay { get; } - /// - /// The friendly name specified when creating the job - /// - public string FriendlyName { get; } - /// - /// The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. - /// - public string WebhookUrl { get; set; } - /// - /// This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. - /// - public string WebhookMethod { get; set; } - /// - /// The optional email to send the completion notification to - /// - public string Email { get; set; } - - /// - /// Construct a new CreateExportCustomJobOptions - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - public CreateExportCustomJobOptions(string pathResourceType, string startDay, string endDay, string friendlyName) - { - PathResourceType = pathResourceType; - StartDay = startDay; - EndDay = endDay; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StartDay != null) - { - p.Add(new KeyValuePair("StartDay", StartDay)); - } - - if (EndDay != null) - { - p.Add(new KeyValuePair("EndDay", EndDay)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - return p; - } - } + /// The type of communication – Messages, Calls, Conferences, and Participants + public ReadExportCustomJobOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateExportCustomJobOptions + /// + public class CreateExportCustomJobOptions : IOptions + { + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + public string StartDay { get; } + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. + /// + public string EndDay { get; } + /// + /// The friendly name specified when creating the job + /// + public string FriendlyName { get; } + /// + /// The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. + /// + public string WebhookUrl { get; set; } + /// + /// This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. + /// + public string WebhookMethod { get; set; } + /// + /// The optional email to send the completion notification to + /// + public string Email { get; set; } + + /// + /// Construct a new CreateExportCustomJobOptions + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + public CreateExportCustomJobOptions(string pathResourceType, string startDay, string endDay, string friendlyName) + { + PathResourceType = pathResourceType; + StartDay = startDay; + EndDay = endDay; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StartDay != null) + { + p.Add(new KeyValuePair("StartDay", StartDay)); + } + + if (EndDay != null) + { + p.Add(new KeyValuePair("EndDay", EndDay)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobResource.cs b/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobResource.cs index c3322d363..2ffd497ad 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobResource.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/ExportCustomJobResource.cs @@ -19,315 +19,315 @@ using Twilio.Http; namespace Twilio.Rest.Preview.BulkExports.Export -{ - - public class ExportCustomJobResource : Resource - { - private static Request BuildReadRequest(ReadExportCustomJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Jobs", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ExportCustomJob parameters - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ResourceSet Read(ReadExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("jobs", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ExportCustomJob parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task> ReadAsync(ReadExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("jobs", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ResourceSet Read(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExportCustomJobOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExportCustomJobOptions(pathResourceType){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("jobs", response.Content); - } - - private static Request BuildCreateRequest(CreateExportCustomJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Jobs", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ExportCustomJob parameters - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ExportCustomJobResource Create(CreateExportCustomJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ExportCustomJob parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task CreateAsync(CreateExportCustomJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - /// The optional webhook url called on completion of the job. If this is supplied, - /// `WebhookMethod` must also be supplied. - /// This is the method used to call the webhook on completion of the job. If this is - /// supplied, `WebhookUrl` must also be supplied. - /// The optional email to send the completion notification to - /// Client to make requests to Twilio - /// A single instance of ExportCustomJob - public static ExportCustomJobResource Create(string pathResourceType, - string startDay, - string endDay, - string friendlyName, - string webhookUrl = null, - string webhookMethod = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName){WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The type of communication – Messages or Calls, Conferences, and Participants - /// - /// The start day for the custom export specified as a string in the format of yyyy-mm-dd - /// - /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day - /// is inclusive and must be 2 days earlier than the current UTC day. - /// The friendly name specified when creating the job - /// The optional webhook url called on completion of the job. If this is supplied, - /// `WebhookMethod` must also be supplied. - /// This is the method used to call the webhook on completion of the job. If this is - /// supplied, `WebhookUrl` must also be supplied. - /// The optional email to send the completion notification to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportCustomJob - public static async System.Threading.Tasks.Task CreateAsync(string pathResourceType, - string startDay, - string endDay, - string friendlyName, - string webhookUrl = null, - string webhookMethod = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName){WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportCustomJobResource object - /// - /// Raw JSON string - /// ExportCustomJobResource object represented by the provided JSON - public static ExportCustomJobResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The start day for the custom export specified as a string in the format of yyyy-MM-dd - /// - [JsonProperty("start_day")] - public string StartDay { get; private set; } - /// - /// The end day for the custom export specified as a string in the format of yyyy-MM-dd - /// - [JsonProperty("end_day")] - public string EndDay { get; private set; } - /// - /// The optional webhook url called on completion - /// - [JsonProperty("webhook_url")] - public string WebhookUrl { get; private set; } - /// - /// This is the method used to call the webhook - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The optional email to send the completion notification to - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The unique job_sid returned when the custom export was created. This can be used to look up the status of the job. - /// - [JsonProperty("job_sid")] - public string JobSid { get; private set; } - /// - /// The details - /// - [JsonProperty("details")] - public object Details { get; private set; } - - private ExportCustomJobResource() - { - - } - } +{ + + public class ExportCustomJobResource : Resource + { + private static Request BuildReadRequest(ReadExportCustomJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Jobs", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ExportCustomJob parameters + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ResourceSet Read(ReadExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("jobs", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ExportCustomJob parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task> ReadAsync(ReadExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("jobs", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ResourceSet Read(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExportCustomJobOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task> ReadAsync(string pathResourceType, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExportCustomJobOptions(pathResourceType) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("jobs", response.Content); + } + + private static Request BuildCreateRequest(CreateExportCustomJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Jobs", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ExportCustomJob parameters + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ExportCustomJobResource Create(CreateExportCustomJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ExportCustomJob parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task CreateAsync(CreateExportCustomJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + /// The optional webhook url called on completion of the job. If this is supplied, + /// `WebhookMethod` must also be supplied. + /// This is the method used to call the webhook on completion of the job. If this is + /// supplied, `WebhookUrl` must also be supplied. + /// The optional email to send the completion notification to + /// Client to make requests to Twilio + /// A single instance of ExportCustomJob + public static ExportCustomJobResource Create(string pathResourceType, + string startDay, + string endDay, + string friendlyName, + string webhookUrl = null, + string webhookMethod = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName) { WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The type of communication – Messages or Calls, Conferences, and Participants + /// + /// The start day for the custom export specified as a string in the format of yyyy-mm-dd + /// + /// The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day + /// is inclusive and must be 2 days earlier than the current UTC day. + /// The friendly name specified when creating the job + /// The optional webhook url called on completion of the job. If this is supplied, + /// `WebhookMethod` must also be supplied. + /// This is the method used to call the webhook on completion of the job. If this is + /// supplied, `WebhookUrl` must also be supplied. + /// The optional email to send the completion notification to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportCustomJob + public static async System.Threading.Tasks.Task CreateAsync(string pathResourceType, + string startDay, + string endDay, + string friendlyName, + string webhookUrl = null, + string webhookMethod = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new CreateExportCustomJobOptions(pathResourceType, startDay, endDay, friendlyName) { WebhookUrl = webhookUrl, WebhookMethod = webhookMethod, Email = email }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportCustomJobResource object + /// + /// Raw JSON string + /// ExportCustomJobResource object represented by the provided JSON + public static ExportCustomJobResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The start day for the custom export specified as a string in the format of yyyy-MM-dd + /// + [JsonProperty("start_day")] + public string StartDay { get; private set; } + /// + /// The end day for the custom export specified as a string in the format of yyyy-MM-dd + /// + [JsonProperty("end_day")] + public string EndDay { get; private set; } + /// + /// The optional webhook url called on completion + /// + [JsonProperty("webhook_url")] + public string WebhookUrl { get; private set; } + /// + /// This is the method used to call the webhook + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The optional email to send the completion notification to + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The unique job_sid returned when the custom export was created. This can be used to look up the status of the job. + /// + [JsonProperty("job_sid")] + public string JobSid { get; private set; } + /// + /// The details + /// + [JsonProperty("details")] + public object Details { get; private set; } + + private ExportCustomJobResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/JobOptions.cs b/src/Twilio/Rest/Preview/BulkExports/Export/JobOptions.cs index 6e028a505..7b3362d1c 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/JobOptions.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/JobOptions.cs @@ -9,70 +9,70 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.BulkExports.Export -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchJobOptions + /// + public class FetchJobOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchJobOptions + /// The unique string that that we created to identify the Bulk Export job /// - public class FetchJobOptions : IOptions - { - /// - /// The unique string that that we created to identify the Bulk Export job - /// - public string PathJobSid { get; } - - /// - /// Construct a new FetchJobOptions - /// - /// The unique string that that we created to identify the Bulk Export job - public FetchJobOptions(string pathJobSid) - { - PathJobSid = pathJobSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathJobSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteJobOptions + /// Construct a new FetchJobOptions /// - public class DeleteJobOptions : IOptions - { - /// - /// The unique string that that we created to identify the Bulk Export job - /// - public string PathJobSid { get; } - - /// - /// Construct a new DeleteJobOptions - /// - /// The unique string that that we created to identify the Bulk Export job - public DeleteJobOptions(string pathJobSid) - { - PathJobSid = pathJobSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique string that that we created to identify the Bulk Export job + public FetchJobOptions(string pathJobSid) + { + PathJobSid = pathJobSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteJobOptions + /// + public class DeleteJobOptions : IOptions + { + /// + /// The unique string that that we created to identify the Bulk Export job + /// + public string PathJobSid { get; } + + /// + /// Construct a new DeleteJobOptions + /// + /// The unique string that that we created to identify the Bulk Export job + public DeleteJobOptions(string pathJobSid) + { + PathJobSid = pathJobSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/Export/JobResource.cs b/src/Twilio/Rest/Preview/BulkExports/Export/JobResource.cs index 62192acb8..03f1b154f 100644 --- a/src/Twilio/Rest/Preview/BulkExports/Export/JobResource.cs +++ b/src/Twilio/Rest/Preview/BulkExports/Export/JobResource.cs @@ -19,216 +19,216 @@ using Twilio.Http; namespace Twilio.Rest.Preview.BulkExports.Export -{ - - public class JobResource : Resource - { - private static Request BuildFetchRequest(FetchJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/Jobs/" + options.PathJobSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Job parameters - /// Client to make requests to Twilio - /// A single instance of Job - public static JobResource Fetch(FetchJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Job parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task FetchAsync(FetchJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// A single instance of Job - public static JobResource Fetch(string pathJobSid, ITwilioRestClient client = null) - { - var options = new FetchJobOptions(pathJobSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task FetchAsync(string pathJobSid, - ITwilioRestClient client = null) - { - var options = new FetchJobOptions(pathJobSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteJobOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/BulkExports/Exports/Jobs/" + options.PathJobSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Job parameters - /// Client to make requests to Twilio - /// A single instance of Job - public static bool Delete(DeleteJobOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Job parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task DeleteAsync(DeleteJobOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// A single instance of Job - public static bool Delete(string pathJobSid, ITwilioRestClient client = null) - { - var options = new DeleteJobOptions(pathJobSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that that we created to identify the Bulk Export job - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Job - public static async System.Threading.Tasks.Task DeleteAsync(string pathJobSid, ITwilioRestClient client = null) - { - var options = new DeleteJobOptions(pathJobSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a JobResource object - /// - /// Raw JSON string - /// JobResource object represented by the provided JSON - public static JobResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The friendly name specified when creating the job - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// This is a list of the completed, pending, or errored dates within the export time range, with one entry for each status with more than one day in that status - /// - [JsonProperty("details")] - public object Details { get; private set; } - /// - /// The start time for the export specified when creating the job - /// - [JsonProperty("start_day")] - public string StartDay { get; private set; } - /// - /// The end time for the export specified when creating the job - /// - [JsonProperty("end_day")] - public string EndDay { get; private set; } - /// - /// The job_sid returned when the export was created - /// - [JsonProperty("job_sid")] - public string JobSid { get; private set; } - /// - /// The optional webhook url called on completion - /// - [JsonProperty("webhook_url")] - public string WebhookUrl { get; private set; } - /// - /// This is the method used to call the webhook - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The optional email to send the completion notification to - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private JobResource() - { - - } - } +{ + + public class JobResource : Resource + { + private static Request BuildFetchRequest(FetchJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/Jobs/" + options.PathJobSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Job parameters + /// Client to make requests to Twilio + /// A single instance of Job + public static JobResource Fetch(FetchJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Job parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task FetchAsync(FetchJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// A single instance of Job + public static JobResource Fetch(string pathJobSid, ITwilioRestClient client = null) + { + var options = new FetchJobOptions(pathJobSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task FetchAsync(string pathJobSid, + ITwilioRestClient client = null) + { + var options = new FetchJobOptions(pathJobSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteJobOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/BulkExports/Exports/Jobs/" + options.PathJobSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Job parameters + /// Client to make requests to Twilio + /// A single instance of Job + public static bool Delete(DeleteJobOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Job parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task DeleteAsync(DeleteJobOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// A single instance of Job + public static bool Delete(string pathJobSid, ITwilioRestClient client = null) + { + var options = new DeleteJobOptions(pathJobSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that that we created to identify the Bulk Export job + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Job + public static async System.Threading.Tasks.Task DeleteAsync(string pathJobSid, ITwilioRestClient client = null) + { + var options = new DeleteJobOptions(pathJobSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a JobResource object + /// + /// Raw JSON string + /// JobResource object represented by the provided JSON + public static JobResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The friendly name specified when creating the job + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// This is a list of the completed, pending, or errored dates within the export time range, with one entry for each status with more than one day in that status + /// + [JsonProperty("details")] + public object Details { get; private set; } + /// + /// The start time for the export specified when creating the job + /// + [JsonProperty("start_day")] + public string StartDay { get; private set; } + /// + /// The end time for the export specified when creating the job + /// + [JsonProperty("end_day")] + public string EndDay { get; private set; } + /// + /// The job_sid returned when the export was created + /// + [JsonProperty("job_sid")] + public string JobSid { get; private set; } + /// + /// The optional webhook url called on completion + /// + [JsonProperty("webhook_url")] + public string WebhookUrl { get; private set; } + /// + /// This is the method used to call the webhook + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The optional email to send the completion notification to + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private JobResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationOptions.cs b/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationOptions.cs index 90143494f..2729495f4 100644 --- a/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationOptions.cs +++ b/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationOptions.cs @@ -9,97 +9,97 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.BulkExports -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Export Configuration. + /// + public class FetchExportConfigurationOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Export Configuration. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchExportConfigurationOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new FetchExportConfigurationOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public FetchExportConfigurationOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathResourceType { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update a specific Export Configuration. + /// Construct a new FetchExportConfigurationOptions /// - public class UpdateExportConfigurationOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - /// - /// Whether files are automatically generated - /// - public bool? Enabled { get; set; } - /// - /// URL targeted at export - /// - public Uri WebhookUrl { get; set; } - /// - /// Whether to GET or POST to the webhook url - /// - public string WebhookMethod { get; set; } - - /// - /// Construct a new UpdateExportConfigurationOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public UpdateExportConfigurationOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (WebhookMethod != null) - { - p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); - } - - return p; - } - } + /// The type of communication – Messages, Calls, Conferences, and Participants + public FetchExportConfigurationOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update a specific Export Configuration. + /// + public class UpdateExportConfigurationOptions : IOptions + { + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + public string PathResourceType { get; } + /// + /// Whether files are automatically generated + /// + public bool? Enabled { get; set; } + /// + /// URL targeted at export + /// + public Uri WebhookUrl { get; set; } + /// + /// Whether to GET or POST to the webhook url + /// + public string WebhookMethod { get; set; } + + /// + /// Construct a new UpdateExportConfigurationOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public UpdateExportConfigurationOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (WebhookMethod != null) + { + p.Add(new KeyValuePair("WebhookMethod", WebhookMethod)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationResource.cs b/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationResource.cs index 972b3eb3f..c1b696c20 100644 --- a/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationResource.cs +++ b/src/Twilio/Rest/Preview/BulkExports/ExportConfigurationResource.cs @@ -19,207 +19,207 @@ using Twilio.Http; namespace Twilio.Rest.Preview.BulkExports -{ - - public class ExportConfigurationResource : Resource - { - private static Request BuildFetchRequest(FetchExportConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Configuration", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Export Configuration. - /// - /// Fetch ExportConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Fetch(FetchExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Export Configuration. - /// - /// Fetch ExportConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task FetchAsync(FetchExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Fetch(string pathResourceType, ITwilioRestClient client = null) - { - var options = new FetchExportConfigurationOptions(pathResourceType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - ITwilioRestClient client = null) - { - var options = new FetchExportConfigurationOptions(pathResourceType); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateExportConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "/Configuration", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Export Configuration. - /// - /// Update ExportConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Update(UpdateExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Export Configuration. - /// - /// Update ExportConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateExportConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Whether files are automatically generated - /// URL targeted at export - /// Whether to GET or POST to the webhook url - /// Client to make requests to Twilio - /// A single instance of ExportConfiguration - public static ExportConfigurationResource Update(string pathResourceType, - bool? enabled = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateExportConfigurationOptions(pathResourceType){Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Export Configuration. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Whether files are automatically generated - /// URL targeted at export - /// Whether to GET or POST to the webhook url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExportConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(string pathResourceType, - bool? enabled = null, - Uri webhookUrl = null, - string webhookMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateExportConfigurationOptions(pathResourceType){Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportConfigurationResource object - /// - /// Raw JSON string - /// ExportConfigurationResource object represented by the provided JSON - public static ExportConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Whether files are automatically generated - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// URL targeted at export - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// Whether to GET or POST to the webhook url - /// - [JsonProperty("webhook_method")] - public string WebhookMethod { get; private set; } - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExportConfigurationResource() - { - - } - } +{ + + public class ExportConfigurationResource : Resource + { + private static Request BuildFetchRequest(FetchExportConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Configuration", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Export Configuration. + /// + /// Fetch ExportConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Fetch(FetchExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Export Configuration. + /// + /// Fetch ExportConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task FetchAsync(FetchExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Fetch(string pathResourceType, ITwilioRestClient client = null) + { + var options = new FetchExportConfigurationOptions(pathResourceType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + ITwilioRestClient client = null) + { + var options = new FetchExportConfigurationOptions(pathResourceType); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateExportConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "/Configuration", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Export Configuration. + /// + /// Update ExportConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Update(UpdateExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Export Configuration. + /// + /// Update ExportConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateExportConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Whether files are automatically generated + /// URL targeted at export + /// Whether to GET or POST to the webhook url + /// Client to make requests to Twilio + /// A single instance of ExportConfiguration + public static ExportConfigurationResource Update(string pathResourceType, + bool? enabled = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateExportConfigurationOptions(pathResourceType) { Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Export Configuration. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Whether files are automatically generated + /// URL targeted at export + /// Whether to GET or POST to the webhook url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExportConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(string pathResourceType, + bool? enabled = null, + Uri webhookUrl = null, + string webhookMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateExportConfigurationOptions(pathResourceType) { Enabled = enabled, WebhookUrl = webhookUrl, WebhookMethod = webhookMethod }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportConfigurationResource object + /// + /// Raw JSON string + /// ExportConfigurationResource object represented by the provided JSON + public static ExportConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Whether files are automatically generated + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// URL targeted at export + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// Whether to GET or POST to the webhook url + /// + [JsonProperty("webhook_method")] + public string WebhookMethod { get; private set; } + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExportConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/ExportOptions.cs b/src/Twilio/Rest/Preview/BulkExports/ExportOptions.cs index 1ad6dd552..a3aafb89d 100644 --- a/src/Twilio/Rest/Preview/BulkExports/ExportOptions.cs +++ b/src/Twilio/Rest/Preview/BulkExports/ExportOptions.cs @@ -9,38 +9,38 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.BulkExports -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Export. + /// + public class FetchExportOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Export. + /// The type of communication – Messages, Calls, Conferences, and Participants /// - public class FetchExportOptions : IOptions - { - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - public string PathResourceType { get; } - - /// - /// Construct a new FetchExportOptions - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - public FetchExportOptions(string pathResourceType) - { - PathResourceType = pathResourceType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathResourceType { get; } + + /// + /// Construct a new FetchExportOptions + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + public FetchExportOptions(string pathResourceType) + { + PathResourceType = pathResourceType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/BulkExports/ExportResource.cs b/src/Twilio/Rest/Preview/BulkExports/ExportResource.cs index d3d749e34..318c7bb62 100644 --- a/src/Twilio/Rest/Preview/BulkExports/ExportResource.cs +++ b/src/Twilio/Rest/Preview/BulkExports/ExportResource.cs @@ -19,115 +19,115 @@ using Twilio.Http; namespace Twilio.Rest.Preview.BulkExports -{ - - public class ExportResource : Resource - { - private static Request BuildFetchRequest(FetchExportOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/BulkExports/Exports/" + options.PathResourceType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Export. - /// - /// Fetch Export parameters - /// Client to make requests to Twilio - /// A single instance of Export - public static ExportResource Fetch(FetchExportOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Export. - /// - /// Fetch Export parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Export - public static async System.Threading.Tasks.Task FetchAsync(FetchExportOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Export. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// A single instance of Export - public static ExportResource Fetch(string pathResourceType, ITwilioRestClient client = null) - { - var options = new FetchExportOptions(pathResourceType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Export. - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Export - public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, - ITwilioRestClient client = null) - { - var options = new FetchExportOptions(pathResourceType); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExportResource object - /// - /// Raw JSON string - /// ExportResource object represented by the provided JSON - public static ExportResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The type of communication – Messages, Calls, Conferences, and Participants - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExportResource() - { - - } - } +{ + + public class ExportResource : Resource + { + private static Request BuildFetchRequest(FetchExportOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/BulkExports/Exports/" + options.PathResourceType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Export. + /// + /// Fetch Export parameters + /// Client to make requests to Twilio + /// A single instance of Export + public static ExportResource Fetch(FetchExportOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Export. + /// + /// Fetch Export parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Export + public static async System.Threading.Tasks.Task FetchAsync(FetchExportOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Export. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// A single instance of Export + public static ExportResource Fetch(string pathResourceType, ITwilioRestClient client = null) + { + var options = new FetchExportOptions(pathResourceType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Export. + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Export + public static async System.Threading.Tasks.Task FetchAsync(string pathResourceType, + ITwilioRestClient client = null) + { + var options = new FetchExportOptions(pathResourceType); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExportResource object + /// + /// Raw JSON string + /// ExportResource object represented by the provided JSON + public static ExportResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The type of communication – Messages, Calls, Conferences, and Participants + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExportResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateOptions.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateOptions.cs index cb8425e86..8b51c94df 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateOptions.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateOptions.cs @@ -9,247 +9,247 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch information about a specific Certificate credential in the Fleet. + /// + public class FetchCertificateOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch information about a specific Certificate credential in the Fleet. - /// - public class FetchCertificateOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Certificate. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCertificateOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - public FetchCertificateOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The fleet_sid + /// + public string PathFleetSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections - /// that are presenting it. - /// - public class DeleteCertificateOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Certificate. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCertificateOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - public DeleteCertificateOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string that uniquely identifies the Certificate. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - public class CreateCertificateOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// The public certificate data. - /// - public string CertificateData { get; } - /// - /// The human readable description for this Certificate. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of a Device to be authenticated. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new CreateCertificateOptions - /// - /// The fleet_sid - /// The public certificate data. - public CreateCertificateOptions(string pathFleetSid, string certificateData) - { - PathFleetSid = pathFleetSid; - CertificateData = certificateData; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CertificateData != null) - { - p.Add(new KeyValuePair("CertificateData", CertificateData)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - return p; - } - } - + /// Construct a new FetchCertificateOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + public FetchCertificateOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Certificate credentials belonging to the Fleet. - /// - public class ReadCertificateOptions : ReadOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// Find all Certificates authenticating specified Device. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new ReadCertificateOptions - /// - /// The fleet_sid - public ReadCertificateOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections + /// that are presenting it. + /// + public class DeleteCertificateOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or - /// assigning to a Device. - /// - public class UpdateCertificateOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Certificate. - /// - public string PathSid { get; } - /// - /// The human readable description for this Certificate. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of a Device to be authenticated. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new UpdateCertificateOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - public UpdateCertificateOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - return p; - } - } + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Certificate. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCertificateOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + public DeleteCertificateOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + public class CreateCertificateOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// The public certificate data. + /// + public string CertificateData { get; } + /// + /// The human readable description for this Certificate. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of a Device to be authenticated. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new CreateCertificateOptions + /// + /// The fleet_sid + /// The public certificate data. + public CreateCertificateOptions(string pathFleetSid, string certificateData) + { + PathFleetSid = pathFleetSid; + CertificateData = certificateData; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CertificateData != null) + { + p.Add(new KeyValuePair("CertificateData", CertificateData)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Certificate credentials belonging to the Fleet. + /// + public class ReadCertificateOptions : ReadOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// Find all Certificates authenticating specified Device. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new ReadCertificateOptions + /// + /// The fleet_sid + public ReadCertificateOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or + /// assigning to a Device. + /// + public class UpdateCertificateOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Certificate. + /// + public string PathSid { get; } + /// + /// The human readable description for this Certificate. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of a Device to be authenticated. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new UpdateCertificateOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + public UpdateCertificateOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateResource.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateResource.cs index 8622f8698..3862a5d00 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateResource.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/CertificateResource.cs @@ -19,523 +19,523 @@ using Twilio.Http; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - - public class CertificateResource : Resource - { - private static Request BuildFetchRequest(FetchCertificateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch information about a specific Certificate credential in the Fleet. - /// - /// Fetch Certificate parameters - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Fetch(FetchCertificateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch information about a specific Certificate credential in the Fleet. - /// - /// Fetch Certificate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task FetchAsync(FetchCertificateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch information about a specific Certificate credential in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCertificateOptions(pathFleetSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch information about a specific Certificate credential in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCertificateOptions(pathFleetSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCertificateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections - /// that are presenting it. - /// - /// Delete Certificate parameters - /// Client to make requests to Twilio - /// A single instance of Certificate - public static bool Delete(DeleteCertificateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections - /// that are presenting it. - /// - /// Delete Certificate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCertificateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections - /// that are presenting it. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// Client to make requests to Twilio - /// A single instance of Certificate - public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCertificateOptions(pathFleetSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections - /// that are presenting it. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteCertificateOptions(pathFleetSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateCertificateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// Create Certificate parameters - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Create(CreateCertificateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// Create Certificate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task CreateAsync(CreateCertificateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// The fleet_sid - /// The public certificate data. - /// The human readable description for this Certificate. - /// The unique identifier of a Device to be authenticated. - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Create(string pathFleetSid, - string certificateData, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCertificateOptions(pathFleetSid, certificateData){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// The fleet_sid - /// The public certificate data. - /// The human readable description for this Certificate. - /// The unique identifier of a Device to be authenticated. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, - string certificateData, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCertificateOptions(pathFleetSid, certificateData){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCertificateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Certificate credentials belonging to the Fleet. - /// - /// Read Certificate parameters - /// Client to make requests to Twilio - /// A single instance of Certificate - public static ResourceSet Read(ReadCertificateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("certificates", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Certificate credentials belonging to the Fleet. - /// - /// Read Certificate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task> ReadAsync(ReadCertificateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("certificates", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Certificate credentials belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Certificates authenticating specified Device. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Certificate - public static ResourceSet Read(string pathFleetSid, - string deviceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCertificateOptions(pathFleetSid){DeviceSid = deviceSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Certificate credentials belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Certificates authenticating specified Device. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, - string deviceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCertificateOptions(pathFleetSid){DeviceSid = deviceSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("certificates", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("certificates", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("certificates", response.Content); - } - - private static Request BuildUpdateRequest(UpdateCertificateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or - /// assigning to a Device. - /// - /// Update Certificate parameters - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Update(UpdateCertificateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or - /// assigning to a Device. - /// - /// Update Certificate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCertificateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or - /// assigning to a Device. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// The human readable description for this Certificate. - /// The unique identifier of a Device to be authenticated. - /// Client to make requests to Twilio - /// A single instance of Certificate - public static CertificateResource Update(string pathFleetSid, - string pathSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateCertificateOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or - /// assigning to a Device. - /// - /// The fleet_sid - /// A string that uniquely identifies the Certificate. - /// The human readable description for this Certificate. - /// The unique identifier of a Device to be authenticated. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Certificate - public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, - string pathSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateCertificateOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CertificateResource object - /// - /// Raw JSON string - /// CertificateResource object represented by the provided JSON - public static CertificateResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Certificate. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// URL of this Certificate. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A human readable description for this Certificate. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique identifier of the Fleet. - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// The unique SID that identifies this Account. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique identifier of a mapped Device. - /// - [JsonProperty("device_sid")] - public string DeviceSid { get; private set; } - /// - /// A Certificate unique payload hash. - /// - [JsonProperty("thumbprint")] - public string Thumbprint { get; private set; } - /// - /// The date this Certificate was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Certificate was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private CertificateResource() - { - - } - } +{ + + public class CertificateResource : Resource + { + private static Request BuildFetchRequest(FetchCertificateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch information about a specific Certificate credential in the Fleet. + /// + /// Fetch Certificate parameters + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Fetch(FetchCertificateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch information about a specific Certificate credential in the Fleet. + /// + /// Fetch Certificate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task FetchAsync(FetchCertificateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch information about a specific Certificate credential in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCertificateOptions(pathFleetSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch information about a specific Certificate credential in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCertificateOptions(pathFleetSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCertificateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections + /// that are presenting it. + /// + /// Delete Certificate parameters + /// Client to make requests to Twilio + /// A single instance of Certificate + public static bool Delete(DeleteCertificateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections + /// that are presenting it. + /// + /// Delete Certificate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCertificateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections + /// that are presenting it. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// Client to make requests to Twilio + /// A single instance of Certificate + public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCertificateOptions(pathFleetSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Unregister a specific Certificate credential from the Fleet, effectively disallowing any inbound client connections + /// that are presenting it. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteCertificateOptions(pathFleetSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateCertificateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// Create Certificate parameters + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Create(CreateCertificateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// Create Certificate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task CreateAsync(CreateCertificateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// The fleet_sid + /// The public certificate data. + /// The human readable description for this Certificate. + /// The unique identifier of a Device to be authenticated. + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Create(string pathFleetSid, + string certificateData, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCertificateOptions(pathFleetSid, certificateData) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Enroll a new Certificate credential to the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// The fleet_sid + /// The public certificate data. + /// The human readable description for this Certificate. + /// The unique identifier of a Device to be authenticated. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, + string certificateData, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCertificateOptions(pathFleetSid, certificateData) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCertificateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Certificate credentials belonging to the Fleet. + /// + /// Read Certificate parameters + /// Client to make requests to Twilio + /// A single instance of Certificate + public static ResourceSet Read(ReadCertificateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("certificates", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Certificate credentials belonging to the Fleet. + /// + /// Read Certificate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task> ReadAsync(ReadCertificateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("certificates", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Certificate credentials belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Certificates authenticating specified Device. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Certificate + public static ResourceSet Read(string pathFleetSid, + string deviceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCertificateOptions(pathFleetSid) { DeviceSid = deviceSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Certificate credentials belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Certificates authenticating specified Device. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, + string deviceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCertificateOptions(pathFleetSid) { DeviceSid = deviceSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("certificates", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("certificates", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("certificates", response.Content); + } + + private static Request BuildUpdateRequest(UpdateCertificateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Certificates/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or + /// assigning to a Device. + /// + /// Update Certificate parameters + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Update(UpdateCertificateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or + /// assigning to a Device. + /// + /// Update Certificate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCertificateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or + /// assigning to a Device. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// The human readable description for this Certificate. + /// The unique identifier of a Device to be authenticated. + /// Client to make requests to Twilio + /// A single instance of Certificate + public static CertificateResource Update(string pathFleetSid, + string pathSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateCertificateOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the given properties of a specific Certificate credential in the Fleet, giving it a friendly name or + /// assigning to a Device. + /// + /// The fleet_sid + /// A string that uniquely identifies the Certificate. + /// The human readable description for this Certificate. + /// The unique identifier of a Device to be authenticated. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Certificate + public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, + string pathSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateCertificateOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CertificateResource object + /// + /// Raw JSON string + /// CertificateResource object represented by the provided JSON + public static CertificateResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Certificate. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// URL of this Certificate. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A human readable description for this Certificate. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique identifier of the Fleet. + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// The unique SID that identifies this Account. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique identifier of a mapped Device. + /// + [JsonProperty("device_sid")] + public string DeviceSid { get; private set; } + /// + /// A Certificate unique payload hash. + /// + [JsonProperty("thumbprint")] + public string Thumbprint { get; private set; } + /// + /// The date this Certificate was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Certificate was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private CertificateResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentOptions.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentOptions.cs index 0d921d51e..003b1da30 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentOptions.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentOptions.cs @@ -9,227 +9,227 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch information about a specific Deployment in the Fleet. + /// + public class FetchDeploymentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch information about a specific Deployment in the Fleet. - /// - public class FetchDeploymentOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Deployment. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDeploymentOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - public FetchDeploymentOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The fleet_sid + /// + public string PathFleetSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. - /// - public class DeleteDeploymentOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Deployment. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteDeploymentOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - public DeleteDeploymentOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string that uniquely identifies the Deployment. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync - /// service instance. - /// - public class CreateDeploymentOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A human readable description for this Deployment. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of the Sync service instance. - /// - public string SyncServiceSid { get; set; } - - /// - /// Construct a new CreateDeploymentOptions - /// - /// The fleet_sid - public CreateDeploymentOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SyncServiceSid != null) - { - p.Add(new KeyValuePair("SyncServiceSid", SyncServiceSid.ToString())); - } - - return p; - } - } - + /// Construct a new FetchDeploymentOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + public FetchDeploymentOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Deployments belonging to the Fleet. - /// - public class ReadDeploymentOptions : ReadOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - - /// - /// Construct a new ReadDeploymentOptions - /// - /// The fleet_sid - public ReadDeploymentOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. + /// + public class DeleteDeploymentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking - /// to a specific Twilio Sync service instance. - /// - public class UpdateDeploymentOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Deployment. - /// - public string PathSid { get; } - /// - /// A human readable description for this Deployment. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of the Sync service instance. - /// - public string SyncServiceSid { get; set; } - - /// - /// Construct a new UpdateDeploymentOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - public UpdateDeploymentOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SyncServiceSid != null) - { - p.Add(new KeyValuePair("SyncServiceSid", SyncServiceSid.ToString())); - } - - return p; - } - } + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Deployment. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteDeploymentOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + public DeleteDeploymentOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync + /// service instance. + /// + public class CreateDeploymentOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A human readable description for this Deployment. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of the Sync service instance. + /// + public string SyncServiceSid { get; set; } + + /// + /// Construct a new CreateDeploymentOptions + /// + /// The fleet_sid + public CreateDeploymentOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SyncServiceSid != null) + { + p.Add(new KeyValuePair("SyncServiceSid", SyncServiceSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Deployments belonging to the Fleet. + /// + public class ReadDeploymentOptions : ReadOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + + /// + /// Construct a new ReadDeploymentOptions + /// + /// The fleet_sid + public ReadDeploymentOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking + /// to a specific Twilio Sync service instance. + /// + public class UpdateDeploymentOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Deployment. + /// + public string PathSid { get; } + /// + /// A human readable description for this Deployment. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of the Sync service instance. + /// + public string SyncServiceSid { get; set; } + + /// + /// Construct a new UpdateDeploymentOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + public UpdateDeploymentOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SyncServiceSid != null) + { + p.Add(new KeyValuePair("SyncServiceSid", SyncServiceSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentResource.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentResource.cs index 257204b9b..848f0b654 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentResource.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeploymentResource.cs @@ -19,510 +19,510 @@ using Twilio.Http; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - - public class DeploymentResource : Resource - { - private static Request BuildFetchRequest(FetchDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch information about a specific Deployment in the Fleet. - /// - /// Fetch Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Fetch(FetchDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch information about a specific Deployment in the Fleet. - /// - /// Fetch Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task FetchAsync(FetchDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch information about a specific Deployment in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDeploymentOptions(pathFleetSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch information about a specific Deployment in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeploymentOptions(pathFleetSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. - /// - /// Delete Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static bool Delete(DeleteDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. - /// - /// Delete Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// Client to make requests to Twilio - /// A single instance of Deployment - public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteDeploymentOptions(pathFleetSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteDeploymentOptions(pathFleetSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync - /// service instance. - /// - /// Create Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Create(CreateDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync - /// service instance. - /// - /// Create Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task CreateAsync(CreateDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync - /// service instance. - /// - /// The fleet_sid - /// A human readable description for this Deployment. - /// The unique identifier of the Sync service instance. - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Create(string pathFleetSid, - string friendlyName = null, - string syncServiceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDeploymentOptions(pathFleetSid){FriendlyName = friendlyName, SyncServiceSid = syncServiceSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync - /// service instance. - /// - /// The fleet_sid - /// A human readable description for this Deployment. - /// The unique identifier of the Sync service instance. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, - string friendlyName = null, - string syncServiceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDeploymentOptions(pathFleetSid){FriendlyName = friendlyName, SyncServiceSid = syncServiceSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Deployments belonging to the Fleet. - /// - /// Read Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static ResourceSet Read(ReadDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("deployments", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Deployments belonging to the Fleet. - /// - /// Read Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task> ReadAsync(ReadDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("deployments", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Deployments belonging to the Fleet. - /// - /// The fleet_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Deployment - public static ResourceSet Read(string pathFleetSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeploymentOptions(pathFleetSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Deployments belonging to the Fleet. - /// - /// The fleet_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeploymentOptions(pathFleetSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking - /// to a specific Twilio Sync service instance. - /// - /// Update Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Update(UpdateDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking - /// to a specific Twilio Sync service instance. - /// - /// Update Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking - /// to a specific Twilio Sync service instance. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// A human readable description for this Deployment. - /// The unique identifier of the Sync service instance. - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Update(string pathFleetSid, - string pathSid, - string friendlyName = null, - string syncServiceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateDeploymentOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, SyncServiceSid = syncServiceSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking - /// to a specific Twilio Sync service instance. - /// - /// The fleet_sid - /// A string that uniquely identifies the Deployment. - /// A human readable description for this Deployment. - /// The unique identifier of the Sync service instance. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, - string pathSid, - string friendlyName = null, - string syncServiceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateDeploymentOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, SyncServiceSid = syncServiceSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DeploymentResource object - /// - /// Raw JSON string - /// DeploymentResource object represented by the provided JSON - public static DeploymentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Deployment. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// URL of this Deployment. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A human readable description for this Deployment - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique identifier of the Fleet. - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// The unique SID that identifies this Account. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique identifier of the Sync service instance. - /// - [JsonProperty("sync_service_sid")] - public string SyncServiceSid { get; private set; } - /// - /// The date this Deployment was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Deployment was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private DeploymentResource() - { - - } - } +{ + + public class DeploymentResource : Resource + { + private static Request BuildFetchRequest(FetchDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch information about a specific Deployment in the Fleet. + /// + /// Fetch Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Fetch(FetchDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch information about a specific Deployment in the Fleet. + /// + /// Fetch Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task FetchAsync(FetchDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch information about a specific Deployment in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDeploymentOptions(pathFleetSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch information about a specific Deployment in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeploymentOptions(pathFleetSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. + /// + /// Delete Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static bool Delete(DeleteDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. + /// + /// Delete Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// Client to make requests to Twilio + /// A single instance of Deployment + public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteDeploymentOptions(pathFleetSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Deployment from the Fleet, leaving associated devices effectively undeployed. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteDeploymentOptions(pathFleetSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync + /// service instance. + /// + /// Create Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Create(CreateDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync + /// service instance. + /// + /// Create Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task CreateAsync(CreateDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync + /// service instance. + /// + /// The fleet_sid + /// A human readable description for this Deployment. + /// The unique identifier of the Sync service instance. + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Create(string pathFleetSid, + string friendlyName = null, + string syncServiceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDeploymentOptions(pathFleetSid) { FriendlyName = friendlyName, SyncServiceSid = syncServiceSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Deployment in the Fleet, optionally giving it a friendly name and linking to a specific Twilio Sync + /// service instance. + /// + /// The fleet_sid + /// A human readable description for this Deployment. + /// The unique identifier of the Sync service instance. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, + string friendlyName = null, + string syncServiceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDeploymentOptions(pathFleetSid) { FriendlyName = friendlyName, SyncServiceSid = syncServiceSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Deployments belonging to the Fleet. + /// + /// Read Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static ResourceSet Read(ReadDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("deployments", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Deployments belonging to the Fleet. + /// + /// Read Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task> ReadAsync(ReadDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("deployments", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Deployments belonging to the Fleet. + /// + /// The fleet_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Deployment + public static ResourceSet Read(string pathFleetSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeploymentOptions(pathFleetSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Deployments belonging to the Fleet. + /// + /// The fleet_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeploymentOptions(pathFleetSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Deployments/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking + /// to a specific Twilio Sync service instance. + /// + /// Update Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Update(UpdateDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking + /// to a specific Twilio Sync service instance. + /// + /// Update Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking + /// to a specific Twilio Sync service instance. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// A human readable description for this Deployment. + /// The unique identifier of the Sync service instance. + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Update(string pathFleetSid, + string pathSid, + string friendlyName = null, + string syncServiceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateDeploymentOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, SyncServiceSid = syncServiceSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the given properties of a specific Deployment credential in the Fleet, giving it a friendly name or linking + /// to a specific Twilio Sync service instance. + /// + /// The fleet_sid + /// A string that uniquely identifies the Deployment. + /// A human readable description for this Deployment. + /// The unique identifier of the Sync service instance. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, + string pathSid, + string friendlyName = null, + string syncServiceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateDeploymentOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, SyncServiceSid = syncServiceSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DeploymentResource object + /// + /// Raw JSON string + /// DeploymentResource object represented by the provided JSON + public static DeploymentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Deployment. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// URL of this Deployment. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A human readable description for this Deployment + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique identifier of the Fleet. + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// The unique SID that identifies this Account. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique identifier of the Sync service instance. + /// + [JsonProperty("sync_service_sid")] + public string SyncServiceSid { get; private set; } + /// + /// The date this Deployment was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Deployment was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private DeploymentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceOptions.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceOptions.cs index 87792e5a2..5bb7906e1 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceOptions.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceOptions.cs @@ -9,281 +9,281 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch information about a specific Device in the Fleet. + /// + public class FetchDeviceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch information about a specific Device in the Fleet. + /// The fleet_sid /// - public class FetchDeviceOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Device. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDeviceOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - public FetchDeviceOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathFleetSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// A string that uniquely identifies the Device. /// - public class DeleteDeviceOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Device. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteDeviceOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - public DeleteDeviceOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment - /// and/or human identity. + /// Construct a new FetchDeviceOptions /// - public class CreateDeviceOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A unique, addressable name of this Device. - /// - public string UniqueName { get; set; } - /// - /// A human readable description for this Device. - /// - public string FriendlyName { get; set; } - /// - /// An identifier of the Device user. - /// - public string Identity { get; set; } - /// - /// The unique SID of the Deployment group. - /// - public string DeploymentSid { get; set; } - /// - /// The enabled - /// - public bool? Enabled { get; set; } - - /// - /// Construct a new CreateDeviceOptions - /// - /// The fleet_sid - public CreateDeviceOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (DeploymentSid != null) - { - p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The fleet_sid + /// A string that uniquely identifies the Device. + public FetchDeviceOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Devices belonging to the Fleet. + /// Generate the necessary parameters /// - public class ReadDeviceOptions : ReadOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// Find all Devices grouped under the specified Deployment. - /// - public string DeploymentSid { get; set; } - - /// - /// Construct a new ReadDeviceOptions - /// - /// The fleet_sid - public ReadDeviceOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DeploymentSid != null) - { - p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// + public class DeleteDeviceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, - /// or a human identity. + /// The fleet_sid /// - public class UpdateDeviceOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Device. - /// - public string PathSid { get; } - /// - /// A human readable description for this Device. - /// - public string FriendlyName { get; set; } - /// - /// An identifier of the Device user. - /// - public string Identity { get; set; } - /// - /// The unique SID of the Deployment group. - /// - public string DeploymentSid { get; set; } - /// - /// The enabled - /// - public bool? Enabled { get; set; } - - /// - /// Construct a new UpdateDeviceOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - public UpdateDeviceOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (DeploymentSid != null) - { - p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - return p; - } - } + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Device. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteDeviceOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + public DeleteDeviceOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment + /// and/or human identity. + /// + public class CreateDeviceOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A unique, addressable name of this Device. + /// + public string UniqueName { get; set; } + /// + /// A human readable description for this Device. + /// + public string FriendlyName { get; set; } + /// + /// An identifier of the Device user. + /// + public string Identity { get; set; } + /// + /// The unique SID of the Deployment group. + /// + public string DeploymentSid { get; set; } + /// + /// The enabled + /// + public bool? Enabled { get; set; } + + /// + /// Construct a new CreateDeviceOptions + /// + /// The fleet_sid + public CreateDeviceOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (DeploymentSid != null) + { + p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Devices belonging to the Fleet. + /// + public class ReadDeviceOptions : ReadOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// Find all Devices grouped under the specified Deployment. + /// + public string DeploymentSid { get; set; } + + /// + /// Construct a new ReadDeviceOptions + /// + /// The fleet_sid + public ReadDeviceOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DeploymentSid != null) + { + p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, + /// or a human identity. + /// + public class UpdateDeviceOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Device. + /// + public string PathSid { get; } + /// + /// A human readable description for this Device. + /// + public string FriendlyName { get; set; } + /// + /// An identifier of the Device user. + /// + public string Identity { get; set; } + /// + /// The unique SID of the Deployment group. + /// + public string DeploymentSid { get; set; } + /// + /// The enabled + /// + public bool? Enabled { get; set; } + + /// + /// Construct a new UpdateDeviceOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + public UpdateDeviceOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (DeploymentSid != null) + { + p.Add(new KeyValuePair("DeploymentSid", DeploymentSid.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceResource.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceResource.cs index 4aa9ac8ae..f03d9ffaa 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceResource.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/DeviceResource.cs @@ -19,554 +19,554 @@ using Twilio.Http; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - - public class DeviceResource : Resource - { - private static Request BuildFetchRequest(FetchDeviceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch information about a specific Device in the Fleet. - /// - /// Fetch Device parameters - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Fetch(FetchDeviceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch information about a specific Device in the Fleet. - /// - /// Fetch Device parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task FetchAsync(FetchDeviceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch information about a specific Device in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDeviceOptions(pathFleetSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch information about a specific Device in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeviceOptions(pathFleetSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDeviceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Device from the Fleet, also removing it from associated Deployments. - /// - /// Delete Device parameters - /// Client to make requests to Twilio - /// A single instance of Device - public static bool Delete(DeleteDeviceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Device from the Fleet, also removing it from associated Deployments. - /// - /// Delete Device parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDeviceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Device from the Fleet, also removing it from associated Deployments. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// Client to make requests to Twilio - /// A single instance of Device - public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteDeviceOptions(pathFleetSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Device from the Fleet, also removing it from associated Deployments. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteDeviceOptions(pathFleetSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateDeviceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment - /// and/or human identity. - /// - /// Create Device parameters - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Create(CreateDeviceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment - /// and/or human identity. - /// - /// Create Device parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task CreateAsync(CreateDeviceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment - /// and/or human identity. - /// - /// The fleet_sid - /// A unique, addressable name of this Device. - /// A human readable description for this Device. - /// An identifier of the Device user. - /// The unique SID of the Deployment group. - /// The enabled - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Create(string pathFleetSid, - string uniqueName = null, - string friendlyName = null, - string identity = null, - string deploymentSid = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new CreateDeviceOptions(pathFleetSid){UniqueName = uniqueName, FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment - /// and/or human identity. - /// - /// The fleet_sid - /// A unique, addressable name of this Device. - /// A human readable description for this Device. - /// An identifier of the Device user. - /// The unique SID of the Deployment group. - /// The enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, - string uniqueName = null, - string friendlyName = null, - string identity = null, - string deploymentSid = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new CreateDeviceOptions(pathFleetSid){UniqueName = uniqueName, FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDeviceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Devices belonging to the Fleet. - /// - /// Read Device parameters - /// Client to make requests to Twilio - /// A single instance of Device - public static ResourceSet Read(ReadDeviceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("devices", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Devices belonging to the Fleet. - /// - /// Read Device parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task> ReadAsync(ReadDeviceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("devices", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Devices belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Devices grouped under the specified Deployment. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Device - public static ResourceSet Read(string pathFleetSid, - string deploymentSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeviceOptions(pathFleetSid){DeploymentSid = deploymentSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Devices belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Devices grouped under the specified Deployment. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, - string deploymentSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeviceOptions(pathFleetSid){DeploymentSid = deploymentSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("devices", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("devices", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("devices", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDeviceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, - /// or a human identity. - /// - /// Update Device parameters - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Update(UpdateDeviceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, - /// or a human identity. - /// - /// Update Device parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDeviceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, - /// or a human identity. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// A human readable description for this Device. - /// An identifier of the Device user. - /// The unique SID of the Deployment group. - /// The enabled - /// Client to make requests to Twilio - /// A single instance of Device - public static DeviceResource Update(string pathFleetSid, - string pathSid, - string friendlyName = null, - string identity = null, - string deploymentSid = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateDeviceOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, - /// or a human identity. - /// - /// The fleet_sid - /// A string that uniquely identifies the Device. - /// A human readable description for this Device. - /// An identifier of the Device user. - /// The unique SID of the Deployment group. - /// The enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Device - public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, - string pathSid, - string friendlyName = null, - string identity = null, - string deploymentSid = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateDeviceOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DeviceResource object - /// - /// Raw JSON string - /// DeviceResource object represented by the provided JSON - public static DeviceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Device. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// URL of this Device. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A unique, addressable name of this Device. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// A human readable description for this Device - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique identifier of the Fleet. - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// Device enabled flag. - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The unique SID that identifies this Account. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// An identifier of the Device user. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The unique SID of the Deployment group. - /// - [JsonProperty("deployment_sid")] - public string DeploymentSid { get; private set; } - /// - /// The date this Device was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Device was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The date this Device was authenticated. - /// - [JsonProperty("date_authenticated")] - public DateTime? DateAuthenticated { get; private set; } - - private DeviceResource() - { - - } - } +{ + + public class DeviceResource : Resource + { + private static Request BuildFetchRequest(FetchDeviceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch information about a specific Device in the Fleet. + /// + /// Fetch Device parameters + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Fetch(FetchDeviceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch information about a specific Device in the Fleet. + /// + /// Fetch Device parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task FetchAsync(FetchDeviceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch information about a specific Device in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDeviceOptions(pathFleetSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch information about a specific Device in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeviceOptions(pathFleetSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDeviceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// + /// Delete Device parameters + /// Client to make requests to Twilio + /// A single instance of Device + public static bool Delete(DeleteDeviceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// + /// Delete Device parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDeviceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// Client to make requests to Twilio + /// A single instance of Device + public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteDeviceOptions(pathFleetSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Device from the Fleet, also removing it from associated Deployments. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteDeviceOptions(pathFleetSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateDeviceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment + /// and/or human identity. + /// + /// Create Device parameters + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Create(CreateDeviceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment + /// and/or human identity. + /// + /// Create Device parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task CreateAsync(CreateDeviceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment + /// and/or human identity. + /// + /// The fleet_sid + /// A unique, addressable name of this Device. + /// A human readable description for this Device. + /// An identifier of the Device user. + /// The unique SID of the Deployment group. + /// The enabled + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Create(string pathFleetSid, + string uniqueName = null, + string friendlyName = null, + string identity = null, + string deploymentSid = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new CreateDeviceOptions(pathFleetSid) { UniqueName = uniqueName, FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Device in the Fleet, optionally giving it a unique name, friendly name, and assigning to a Deployment + /// and/or human identity. + /// + /// The fleet_sid + /// A unique, addressable name of this Device. + /// A human readable description for this Device. + /// An identifier of the Device user. + /// The unique SID of the Deployment group. + /// The enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, + string uniqueName = null, + string friendlyName = null, + string identity = null, + string deploymentSid = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new CreateDeviceOptions(pathFleetSid) { UniqueName = uniqueName, FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDeviceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Devices belonging to the Fleet. + /// + /// Read Device parameters + /// Client to make requests to Twilio + /// A single instance of Device + public static ResourceSet Read(ReadDeviceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("devices", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Devices belonging to the Fleet. + /// + /// Read Device parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task> ReadAsync(ReadDeviceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("devices", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Devices belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Devices grouped under the specified Deployment. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Device + public static ResourceSet Read(string pathFleetSid, + string deploymentSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeviceOptions(pathFleetSid) { DeploymentSid = deploymentSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Devices belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Devices grouped under the specified Deployment. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, + string deploymentSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeviceOptions(pathFleetSid) { DeploymentSid = deploymentSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("devices", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("devices", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("devices", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDeviceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Devices/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, + /// or a human identity. + /// + /// Update Device parameters + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Update(UpdateDeviceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, + /// or a human identity. + /// + /// Update Device parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDeviceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, + /// or a human identity. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// A human readable description for this Device. + /// An identifier of the Device user. + /// The unique SID of the Deployment group. + /// The enabled + /// Client to make requests to Twilio + /// A single instance of Device + public static DeviceResource Update(string pathFleetSid, + string pathSid, + string friendlyName = null, + string identity = null, + string deploymentSid = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateDeviceOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the given properties of a specific Device in the Fleet, giving it a friendly name, assigning to a Deployment, + /// or a human identity. + /// + /// The fleet_sid + /// A string that uniquely identifies the Device. + /// A human readable description for this Device. + /// An identifier of the Device user. + /// The unique SID of the Deployment group. + /// The enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Device + public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, + string pathSid, + string friendlyName = null, + string identity = null, + string deploymentSid = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateDeviceOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, Identity = identity, DeploymentSid = deploymentSid, Enabled = enabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DeviceResource object + /// + /// Raw JSON string + /// DeviceResource object represented by the provided JSON + public static DeviceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Device. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// URL of this Device. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A unique, addressable name of this Device. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// A human readable description for this Device + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique identifier of the Fleet. + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// Device enabled flag. + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The unique SID that identifies this Account. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// An identifier of the Device user. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The unique SID of the Deployment group. + /// + [JsonProperty("deployment_sid")] + public string DeploymentSid { get; private set; } + /// + /// The date this Device was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Device was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The date this Device was authenticated. + /// + [JsonProperty("date_authenticated")] + public DateTime? DateAuthenticated { get; private set; } + + private DeviceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyOptions.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyOptions.cs index 2843a740f..b4c8553d2 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyOptions.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyOptions.cs @@ -9,236 +9,236 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch information about a specific Key credential in the Fleet. + /// + public class FetchKeyOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch information about a specific Key credential in the Fleet. - /// - public class FetchKeyOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Key. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchKeyOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - public FetchKeyOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The fleet_sid + /// + public string PathFleetSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are - /// presenting it. - /// - public class DeleteKeyOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Key. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteKeyOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - public DeleteKeyOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string that uniquely identifies the Key. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - public class CreateKeyOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// The human readable description for this Key. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of a Key to be authenticated. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new CreateKeyOptions - /// - /// The fleet_sid - public CreateKeyOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - return p; - } - } - + /// Construct a new FetchKeyOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + public FetchKeyOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Keys credentials belonging to the Fleet. - /// - public class ReadKeyOptions : ReadOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// Find all Keys authenticating specified Device. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new ReadKeyOptions - /// - /// The fleet_sid - public ReadKeyOptions(string pathFleetSid) - { - PathFleetSid = pathFleetSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are + /// presenting it. + /// + public class DeleteKeyOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a - /// Device. - /// - public class UpdateKeyOptions : IOptions - { - /// - /// The fleet_sid - /// - public string PathFleetSid { get; } - /// - /// A string that uniquely identifies the Key. - /// - public string PathSid { get; } - /// - /// The human readable description for this Key. - /// - public string FriendlyName { get; set; } - /// - /// The unique identifier of a Key to be authenticated. - /// - public string DeviceSid { get; set; } - - /// - /// Construct a new UpdateKeyOptions - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - public UpdateKeyOptions(string pathFleetSid, string pathSid) - { - PathFleetSid = pathFleetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DeviceSid != null) - { - p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); - } - - return p; - } - } + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Key. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteKeyOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + public DeleteKeyOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + public class CreateKeyOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// The human readable description for this Key. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of a Key to be authenticated. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new CreateKeyOptions + /// + /// The fleet_sid + public CreateKeyOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Keys credentials belonging to the Fleet. + /// + public class ReadKeyOptions : ReadOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// Find all Keys authenticating specified Device. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new ReadKeyOptions + /// + /// The fleet_sid + public ReadKeyOptions(string pathFleetSid) + { + PathFleetSid = pathFleetSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a + /// Device. + /// + public class UpdateKeyOptions : IOptions + { + /// + /// The fleet_sid + /// + public string PathFleetSid { get; } + /// + /// A string that uniquely identifies the Key. + /// + public string PathSid { get; } + /// + /// The human readable description for this Key. + /// + public string FriendlyName { get; set; } + /// + /// The unique identifier of a Key to be authenticated. + /// + public string DeviceSid { get; set; } + + /// + /// Construct a new UpdateKeyOptions + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + public UpdateKeyOptions(string pathFleetSid, string pathSid) + { + PathFleetSid = pathFleetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DeviceSid != null) + { + p.Add(new KeyValuePair("DeviceSid", DeviceSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyResource.cs b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyResource.cs index 7f91d963a..3bb524942 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyResource.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/Fleet/KeyResource.cs @@ -19,519 +19,519 @@ using Twilio.Http; namespace Twilio.Rest.Preview.DeployedDevices.Fleet -{ - - public class KeyResource : Resource - { - private static Request BuildFetchRequest(FetchKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch information about a specific Key credential in the Fleet. - /// - /// Fetch Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Fetch(FetchKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch information about a specific Key credential in the Fleet. - /// - /// Fetch Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task FetchAsync(FetchKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch information about a specific Key credential in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchKeyOptions(pathFleetSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch information about a specific Key credential in the Fleet. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchKeyOptions(pathFleetSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are - /// presenting it. - /// - /// Delete Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static bool Delete(DeleteKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are - /// presenting it. - /// - /// Delete Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task DeleteAsync(DeleteKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are - /// presenting it. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// Client to make requests to Twilio - /// A single instance of Key - public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteKeyOptions(pathFleetSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are - /// presenting it. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteKeyOptions(pathFleetSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// Create Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Create(CreateKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// Create Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task CreateAsync(CreateKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// The fleet_sid - /// The human readable description for this Key. - /// The unique identifier of a Key to be authenticated. - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Create(string pathFleetSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateKeyOptions(pathFleetSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. - /// - /// The fleet_sid - /// The human readable description for this Key. - /// The unique identifier of a Key to be authenticated. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateKeyOptions(pathFleetSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Keys credentials belonging to the Fleet. - /// - /// Read Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static ResourceSet Read(ReadKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("keys", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Keys credentials belonging to the Fleet. - /// - /// Read Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task> ReadAsync(ReadKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("keys", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Keys credentials belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Keys authenticating specified Device. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Key - public static ResourceSet Read(string pathFleetSid, - string deviceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadKeyOptions(pathFleetSid){DeviceSid = deviceSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Keys credentials belonging to the Fleet. - /// - /// The fleet_sid - /// Find all Keys authenticating specified Device. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, - string deviceSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadKeyOptions(pathFleetSid){DeviceSid = deviceSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("keys", response.Content); - } - - private static Request BuildUpdateRequest(UpdateKeyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a - /// Device. - /// - /// Update Key parameters - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Update(UpdateKeyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a - /// Device. - /// - /// Update Key parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task UpdateAsync(UpdateKeyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a - /// Device. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// The human readable description for this Key. - /// The unique identifier of a Key to be authenticated. - /// Client to make requests to Twilio - /// A single instance of Key - public static KeyResource Update(string pathFleetSid, - string pathSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateKeyOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a - /// Device. - /// - /// The fleet_sid - /// A string that uniquely identifies the Key. - /// The human readable description for this Key. - /// The unique identifier of a Key to be authenticated. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Key - public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, - string pathSid, - string friendlyName = null, - string deviceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateKeyOptions(pathFleetSid, pathSid){FriendlyName = friendlyName, DeviceSid = deviceSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a KeyResource object - /// - /// Raw JSON string - /// KeyResource object represented by the provided JSON - public static KeyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Key. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// URL of this Key. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A human readable description for this Key. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique identifier of the Fleet. - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// The unique SID that identifies this Account. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique identifier of a mapped Device. - /// - [JsonProperty("device_sid")] - public string DeviceSid { get; private set; } - /// - /// The key secret. - /// - [JsonProperty("secret")] - public string Secret { get; private set; } - /// - /// The date this Key credential was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Key credential was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private KeyResource() - { - - } - } +{ + + public class KeyResource : Resource + { + private static Request BuildFetchRequest(FetchKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch information about a specific Key credential in the Fleet. + /// + /// Fetch Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Fetch(FetchKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch information about a specific Key credential in the Fleet. + /// + /// Fetch Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task FetchAsync(FetchKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch information about a specific Key credential in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Fetch(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchKeyOptions(pathFleetSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch information about a specific Key credential in the Fleet. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task FetchAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchKeyOptions(pathFleetSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are + /// presenting it. + /// + /// Delete Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static bool Delete(DeleteKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are + /// presenting it. + /// + /// Delete Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task DeleteAsync(DeleteKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are + /// presenting it. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// Client to make requests to Twilio + /// A single instance of Key + public static bool Delete(string pathFleetSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteKeyOptions(pathFleetSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Key credential from the Fleet, effectively disallowing any inbound client connections that are + /// presenting it. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task DeleteAsync(string pathFleetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteKeyOptions(pathFleetSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// Create Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Create(CreateKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// Create Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task CreateAsync(CreateKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// The fleet_sid + /// The human readable description for this Key. + /// The unique identifier of a Key to be authenticated. + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Create(string pathFleetSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateKeyOptions(pathFleetSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Key credential in the Fleet, optionally giving it a friendly name and assigning to a Device. + /// + /// The fleet_sid + /// The human readable description for this Key. + /// The unique identifier of a Key to be authenticated. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task CreateAsync(string pathFleetSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateKeyOptions(pathFleetSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Keys credentials belonging to the Fleet. + /// + /// Read Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static ResourceSet Read(ReadKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("keys", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Keys credentials belonging to the Fleet. + /// + /// Read Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task> ReadAsync(ReadKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("keys", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Keys credentials belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Keys authenticating specified Device. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Key + public static ResourceSet Read(string pathFleetSid, + string deviceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadKeyOptions(pathFleetSid) { DeviceSid = deviceSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Keys credentials belonging to the Fleet. + /// + /// The fleet_sid + /// Find all Keys authenticating specified Device. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task> ReadAsync(string pathFleetSid, + string deviceSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadKeyOptions(pathFleetSid) { DeviceSid = deviceSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("keys", response.Content); + } + + private static Request BuildUpdateRequest(UpdateKeyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathFleetSid + "/Keys/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a + /// Device. + /// + /// Update Key parameters + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Update(UpdateKeyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a + /// Device. + /// + /// Update Key parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task UpdateAsync(UpdateKeyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a + /// Device. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// The human readable description for this Key. + /// The unique identifier of a Key to be authenticated. + /// Client to make requests to Twilio + /// A single instance of Key + public static KeyResource Update(string pathFleetSid, + string pathSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateKeyOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the given properties of a specific Key credential in the Fleet, giving it a friendly name or assigning to a + /// Device. + /// + /// The fleet_sid + /// A string that uniquely identifies the Key. + /// The human readable description for this Key. + /// The unique identifier of a Key to be authenticated. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Key + public static async System.Threading.Tasks.Task UpdateAsync(string pathFleetSid, + string pathSid, + string friendlyName = null, + string deviceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateKeyOptions(pathFleetSid, pathSid) { FriendlyName = friendlyName, DeviceSid = deviceSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a KeyResource object + /// + /// Raw JSON string + /// KeyResource object represented by the provided JSON + public static KeyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Key. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// URL of this Key. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A human readable description for this Key. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique identifier of the Fleet. + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// The unique SID that identifies this Account. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique identifier of a mapped Device. + /// + [JsonProperty("device_sid")] + public string DeviceSid { get; private set; } + /// + /// The key secret. + /// + [JsonProperty("secret")] + public string Secret { get; private set; } + /// + /// The date this Key credential was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Key credential was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private KeyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/FleetOptions.cs b/src/Twilio/Rest/Preview/DeployedDevices/FleetOptions.cs index f60bb9375..6a360c6cb 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/FleetOptions.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/FleetOptions.cs @@ -9,172 +9,172 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.DeployedDevices -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch information about a specific Fleet in your account. + /// + public class FetchFleetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch information about a specific Fleet in your account. + /// A string that uniquely identifies the Fleet. /// - public class FetchFleetOptions : IOptions - { - /// - /// A string that uniquely identifies the Fleet. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFleetOptions - /// - /// A string that uniquely identifies the Fleet. - public FetchFleetOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, - /// Keys. + /// Construct a new FetchFleetOptions /// - public class DeleteFleetOptions : IOptions - { - /// - /// A string that uniquely identifies the Fleet. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFleetOptions - /// - /// A string that uniquely identifies the Fleet. - public DeleteFleetOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// A string that uniquely identifies the Fleet. + public FetchFleetOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create a new Fleet for scoping of deployed devices within your account. + /// Generate the necessary parameters /// - public class CreateFleetOptions : IOptions - { - /// - /// A human readable description for this Fleet. - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, + /// Keys. + /// + public class DeleteFleetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Fleets belonging to your account. + /// A string that uniquely identifies the Fleet. /// - public class ReadFleetOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update the friendly name property of a specific Fleet in your account. + /// Construct a new DeleteFleetOptions /// - public class UpdateFleetOptions : IOptions - { - /// - /// A string that uniquely identifies the Fleet. - /// - public string PathSid { get; } - /// - /// A human readable description for this Fleet. - /// - public string FriendlyName { get; set; } - /// - /// A default Deployment SID. - /// - public string DefaultDeploymentSid { get; set; } - - /// - /// Construct a new UpdateFleetOptions - /// - /// A string that uniquely identifies the Fleet. - public UpdateFleetOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DefaultDeploymentSid != null) - { - p.Add(new KeyValuePair("DefaultDeploymentSid", DefaultDeploymentSid.ToString())); - } - - return p; - } - } + /// A string that uniquely identifies the Fleet. + public DeleteFleetOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create a new Fleet for scoping of deployed devices within your account. + /// + public class CreateFleetOptions : IOptions + { + /// + /// A human readable description for this Fleet. + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Fleets belonging to your account. + /// + public class ReadFleetOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update the friendly name property of a specific Fleet in your account. + /// + public class UpdateFleetOptions : IOptions + { + /// + /// A string that uniquely identifies the Fleet. + /// + public string PathSid { get; } + /// + /// A human readable description for this Fleet. + /// + public string FriendlyName { get; set; } + /// + /// A default Deployment SID. + /// + public string DefaultDeploymentSid { get; set; } + + /// + /// Construct a new UpdateFleetOptions + /// + /// A string that uniquely identifies the Fleet. + public UpdateFleetOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DefaultDeploymentSid != null) + { + p.Add(new KeyValuePair("DefaultDeploymentSid", DefaultDeploymentSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/DeployedDevices/FleetResource.cs b/src/Twilio/Rest/Preview/DeployedDevices/FleetResource.cs index 71ae8290f..96370a95f 100644 --- a/src/Twilio/Rest/Preview/DeployedDevices/FleetResource.cs +++ b/src/Twilio/Rest/Preview/DeployedDevices/FleetResource.cs @@ -19,487 +19,487 @@ using Twilio.Http; namespace Twilio.Rest.Preview.DeployedDevices -{ - - public class FleetResource : Resource - { - private static Request BuildFetchRequest(FetchFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch information about a specific Fleet in your account. - /// - /// Fetch Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch information about a specific Fleet in your account. - /// - /// Fetch Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch information about a specific Fleet in your account. - /// - /// A string that uniquely identifies the Fleet. - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFleetOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch information about a specific Fleet in your account. - /// - /// A string that uniquely identifies the Fleet. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFleetOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, - /// Keys. - /// - /// Delete Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static bool Delete(DeleteFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, - /// Keys. - /// - /// Delete Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, - /// Keys. - /// - /// A string that uniquely identifies the Fleet. - /// Client to make requests to Twilio - /// A single instance of Fleet - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFleetOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, - /// Keys. - /// - /// A string that uniquely identifies the Fleet. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFleetOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Fleet for scoping of deployed devices within your account. - /// - /// Create Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Fleet for scoping of deployed devices within your account. - /// - /// Create Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Fleet for scoping of deployed devices within your account. - /// - /// A human readable description for this Fleet. - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Create(string friendlyName = null, ITwilioRestClient client = null) - { - var options = new CreateFleetOptions(){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Fleet for scoping of deployed devices within your account. - /// - /// A human readable description for this Fleet. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateFleetOptions(){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/DeployedDevices/Fleets", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Fleets belonging to your account. - /// - /// Read Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static ResourceSet Read(ReadFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("fleets", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Fleets belonging to your account. - /// - /// Read Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task> ReadAsync(ReadFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("fleets", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Fleets belonging to your account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Fleet - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFleetOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Fleets belonging to your account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFleetOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - private static Request BuildUpdateRequest(UpdateFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/DeployedDevices/Fleets/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the friendly name property of a specific Fleet in your account. - /// - /// Update Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Update(UpdateFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the friendly name property of a specific Fleet in your account. - /// - /// Update Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the friendly name property of a specific Fleet in your account. - /// - /// A string that uniquely identifies the Fleet. - /// A human readable description for this Fleet. - /// A default Deployment SID. - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Update(string pathSid, - string friendlyName = null, - string defaultDeploymentSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateFleetOptions(pathSid){FriendlyName = friendlyName, DefaultDeploymentSid = defaultDeploymentSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the friendly name property of a specific Fleet in your account. - /// - /// A string that uniquely identifies the Fleet. - /// A human readable description for this Fleet. - /// A default Deployment SID. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string defaultDeploymentSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateFleetOptions(pathSid){FriendlyName = friendlyName, DefaultDeploymentSid = defaultDeploymentSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FleetResource object - /// - /// Raw JSON string - /// FleetResource object represented by the provided JSON - public static FleetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Fleet. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// URL of this Fleet. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A unique, addressable name of this Fleet. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// A human readable description for this Fleet. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique SID that identifies this Account. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique SID that identifies this Fleet's default Deployment. - /// - [JsonProperty("default_deployment_sid")] - public string DefaultDeploymentSid { get; private set; } - /// - /// The date this Fleet was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Fleet was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private FleetResource() - { - - } - } +{ + + public class FleetResource : Resource + { + private static Request BuildFetchRequest(FetchFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch information about a specific Fleet in your account. + /// + /// Fetch Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch information about a specific Fleet in your account. + /// + /// Fetch Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch information about a specific Fleet in your account. + /// + /// A string that uniquely identifies the Fleet. + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFleetOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch information about a specific Fleet in your account. + /// + /// A string that uniquely identifies the Fleet. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFleetOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, + /// Keys. + /// + /// Delete Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static bool Delete(DeleteFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, + /// Keys. + /// + /// Delete Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, + /// Keys. + /// + /// A string that uniquely identifies the Fleet. + /// Client to make requests to Twilio + /// A single instance of Fleet + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFleetOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Fleet from your account, also destroys all nested resources: Devices, Deployments, Certificates, + /// Keys. + /// + /// A string that uniquely identifies the Fleet. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFleetOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Fleet for scoping of deployed devices within your account. + /// + /// Create Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Fleet for scoping of deployed devices within your account. + /// + /// Create Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Fleet for scoping of deployed devices within your account. + /// + /// A human readable description for this Fleet. + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Create(string friendlyName = null, ITwilioRestClient client = null) + { + var options = new CreateFleetOptions() { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Fleet for scoping of deployed devices within your account. + /// + /// A human readable description for this Fleet. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateFleetOptions() { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/DeployedDevices/Fleets", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Fleets belonging to your account. + /// + /// Read Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static ResourceSet Read(ReadFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("fleets", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Fleets belonging to your account. + /// + /// Read Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task> ReadAsync(ReadFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("fleets", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Fleets belonging to your account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Fleet + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFleetOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Fleets belonging to your account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFleetOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + private static Request BuildUpdateRequest(UpdateFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/DeployedDevices/Fleets/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the friendly name property of a specific Fleet in your account. + /// + /// Update Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Update(UpdateFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the friendly name property of a specific Fleet in your account. + /// + /// Update Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the friendly name property of a specific Fleet in your account. + /// + /// A string that uniquely identifies the Fleet. + /// A human readable description for this Fleet. + /// A default Deployment SID. + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Update(string pathSid, + string friendlyName = null, + string defaultDeploymentSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateFleetOptions(pathSid) { FriendlyName = friendlyName, DefaultDeploymentSid = defaultDeploymentSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the friendly name property of a specific Fleet in your account. + /// + /// A string that uniquely identifies the Fleet. + /// A human readable description for this Fleet. + /// A default Deployment SID. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string defaultDeploymentSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateFleetOptions(pathSid) { FriendlyName = friendlyName, DefaultDeploymentSid = defaultDeploymentSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FleetResource object + /// + /// Raw JSON string + /// FleetResource object represented by the provided JSON + public static FleetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Fleet. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// URL of this Fleet. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A unique, addressable name of this Fleet. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// A human readable description for this Fleet. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique SID that identifies this Account. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique SID that identifies this Fleet's default Deployment. + /// + [JsonProperty("default_deployment_sid")] + public string DefaultDeploymentSid { get; private set; } + /// + /// The date this Fleet was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Fleet was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private FleetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderOptions.cs b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderOptions.cs index 713c5dd32..db2d147ec 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderOptions.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderOptions.cs @@ -9,88 +9,88 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.HostedNumbers.AuthorizationDocument -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// + public class ReadDependentHostedNumberOrderOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// The signing_document_sid /// - public class ReadDependentHostedNumberOrderOptions : ReadOptions - { - /// - /// The signing_document_sid - /// - public string PathSigningDocumentSid { get; } - /// - /// The Status of this HostedNumberOrder. - /// - public DependentHostedNumberOrderResource.StatusEnum Status { get; set; } - /// - /// An E164 formatted phone number. - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// IncomingPhoneNumber sid. - /// - public string IncomingPhoneNumberSid { get; set; } - /// - /// A human readable description of this resource. - /// - public string FriendlyName { get; set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - public string UniqueName { get; set; } - - /// - /// Construct a new ReadDependentHostedNumberOrderOptions - /// - /// The signing_document_sid - public ReadDependentHostedNumberOrderOptions(string pathSigningDocumentSid) - { - PathSigningDocumentSid = pathSigningDocumentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (IncomingPhoneNumberSid != null) - { - p.Add(new KeyValuePair("IncomingPhoneNumberSid", IncomingPhoneNumberSid.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSigningDocumentSid { get; } + /// + /// The Status of this HostedNumberOrder. + /// + public DependentHostedNumberOrderResource.StatusEnum Status { get; set; } + /// + /// An E164 formatted phone number. + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// IncomingPhoneNumber sid. + /// + public string IncomingPhoneNumberSid { get; set; } + /// + /// A human readable description of this resource. + /// + public string FriendlyName { get; set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + public string UniqueName { get; set; } + + /// + /// Construct a new ReadDependentHostedNumberOrderOptions + /// + /// The signing_document_sid + public ReadDependentHostedNumberOrderOptions(string pathSigningDocumentSid) + { + PathSigningDocumentSid = pathSigningDocumentSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (IncomingPhoneNumberSid != null) + { + p.Add(new KeyValuePair("IncomingPhoneNumberSid", IncomingPhoneNumberSid.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderResource.cs b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderResource.cs index 0ff6d6393..15c66ec4a 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderResource.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocument/DependentHostedNumberOrderResource.cs @@ -20,335 +20,335 @@ using Twilio.Types; namespace Twilio.Rest.Preview.HostedNumbers.AuthorizationDocument -{ - - public class DependentHostedNumberOrderResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum PendingVerification = new StatusEnum("pending-verification"); - public static readonly StatusEnum Verified = new StatusEnum("verified"); - public static readonly StatusEnum PendingLoa = new StatusEnum("pending-loa"); - public static readonly StatusEnum CarrierProcessing = new StatusEnum("carrier-processing"); - public static readonly StatusEnum Testing = new StatusEnum("testing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum ActionRequired = new StatusEnum("action-required"); - } - - public sealed class VerificationTypeEnum : StringEnum - { - private VerificationTypeEnum(string value) : base(value) {} - public VerificationTypeEnum() {} - public static implicit operator VerificationTypeEnum(string value) - { - return new VerificationTypeEnum(value); - } - - public static readonly VerificationTypeEnum PhoneCall = new VerificationTypeEnum("phone-call"); - public static readonly VerificationTypeEnum PhoneBill = new VerificationTypeEnum("phone-bill"); - } - - private static Request BuildReadRequest(ReadDependentHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/HostedNumbers/AuthorizationDocuments/" + options.PathSigningDocumentSid + "/DependentHostedNumberOrders", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. - /// - /// Read DependentHostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of DependentHostedNumberOrder - public static ResourceSet Read(ReadDependentHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. - /// - /// Read DependentHostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DependentHostedNumberOrder - public static async System.Threading.Tasks.Task> ReadAsync(ReadDependentHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. - /// - /// The signing_document_sid - /// The Status of this HostedNumberOrder. - /// An E164 formatted phone number. - /// IncomingPhoneNumber sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DependentHostedNumberOrder - public static ResourceSet Read(string pathSigningDocumentSid, - DependentHostedNumberOrderResource.StatusEnum status = null, - Types.PhoneNumber phoneNumber = null, - string incomingPhoneNumberSid = null, - string friendlyName = null, - string uniqueName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDependentHostedNumberOrderOptions(pathSigningDocumentSid){Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. - /// - /// The signing_document_sid - /// The Status of this HostedNumberOrder. - /// An E164 formatted phone number. - /// IncomingPhoneNumber sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DependentHostedNumberOrder - public static async System.Threading.Tasks.Task> ReadAsync(string pathSigningDocumentSid, - DependentHostedNumberOrderResource.StatusEnum status = null, - Types.PhoneNumber phoneNumber = null, - string incomingPhoneNumberSid = null, - string friendlyName = null, - string uniqueName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDependentHostedNumberOrderOptions(pathSigningDocumentSid){Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Converts a JSON string into a DependentHostedNumberOrderResource object - /// - /// Raw JSON string - /// DependentHostedNumberOrderResource object represented by the provided JSON - public static DependentHostedNumberOrderResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// HostedNumberOrder sid. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// IncomingPhoneNumber sid. - /// - [JsonProperty("incoming_phone_number_sid")] - public string IncomingPhoneNumberSid { get; private set; } - /// - /// Address sid. - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// LOA document sid. - /// - [JsonProperty("signing_document_sid")] - public string SigningDocumentSid { get; private set; } - /// - /// An E164 formatted phone number. - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// A mapping of phone number capabilities. - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// A human readable description of this resource. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The Status of this HostedNumberOrder. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public DependentHostedNumberOrderResource.StatusEnum Status { get; private set; } - /// - /// Why a hosted_number_order reached status "action-required" - /// - [JsonProperty("failure_reason")] - public string FailureReason { get; private set; } - /// - /// The date this HostedNumberOrder was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this HostedNumberOrder was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The number of attempts made to verify ownership of the phone number. - /// - [JsonProperty("verification_attempts")] - public int? VerificationAttempts { get; private set; } - /// - /// Email. - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// A list of emails. - /// - [JsonProperty("cc_emails")] - public List CcEmails { get; private set; } - /// - /// The method used for verifying ownership of the number to be hosted. - /// - [JsonProperty("verification_type")] - [JsonConverter(typeof(StringEnumConverter))] - public DependentHostedNumberOrderResource.VerificationTypeEnum VerificationType { get; private set; } - /// - /// Verification Document Sid. - /// - [JsonProperty("verification_document_sid")] - public string VerificationDocumentSid { get; private set; } - /// - /// Phone extension to use for ownership verification call. - /// - [JsonProperty("extension")] - public string Extension { get; private set; } - /// - /// Seconds (0-30) to delay ownership verification call by. - /// - [JsonProperty("call_delay")] - public int? CallDelay { get; private set; } - /// - /// The digits passed during the ownership verification call. - /// - [JsonProperty("verification_code")] - public string VerificationCode { get; private set; } - /// - /// List of IDs for ownership verification calls. - /// - [JsonProperty("verification_call_sids")] - public List VerificationCallSids { get; private set; } - - private DependentHostedNumberOrderResource() - { - - } - } +{ + + public class DependentHostedNumberOrderResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum PendingVerification = new StatusEnum("pending-verification"); + public static readonly StatusEnum Verified = new StatusEnum("verified"); + public static readonly StatusEnum PendingLoa = new StatusEnum("pending-loa"); + public static readonly StatusEnum CarrierProcessing = new StatusEnum("carrier-processing"); + public static readonly StatusEnum Testing = new StatusEnum("testing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum ActionRequired = new StatusEnum("action-required"); + } + + public sealed class VerificationTypeEnum : StringEnum + { + private VerificationTypeEnum(string value) : base(value) { } + public VerificationTypeEnum() { } + public static implicit operator VerificationTypeEnum(string value) + { + return new VerificationTypeEnum(value); + } + + public static readonly VerificationTypeEnum PhoneCall = new VerificationTypeEnum("phone-call"); + public static readonly VerificationTypeEnum PhoneBill = new VerificationTypeEnum("phone-bill"); + } + + private static Request BuildReadRequest(ReadDependentHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/HostedNumbers/AuthorizationDocuments/" + options.PathSigningDocumentSid + "/DependentHostedNumberOrders", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// + /// Read DependentHostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of DependentHostedNumberOrder + public static ResourceSet Read(ReadDependentHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// + /// Read DependentHostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DependentHostedNumberOrder + public static async System.Threading.Tasks.Task> ReadAsync(ReadDependentHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// + /// The signing_document_sid + /// The Status of this HostedNumberOrder. + /// An E164 formatted phone number. + /// IncomingPhoneNumber sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DependentHostedNumberOrder + public static ResourceSet Read(string pathSigningDocumentSid, + DependentHostedNumberOrderResource.StatusEnum status = null, + Types.PhoneNumber phoneNumber = null, + string incomingPhoneNumberSid = null, + string friendlyName = null, + string uniqueName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDependentHostedNumberOrderOptions(pathSigningDocumentSid) { Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of dependent HostedNumberOrders belonging to the AuthorizationDocument. + /// + /// The signing_document_sid + /// The Status of this HostedNumberOrder. + /// An E164 formatted phone number. + /// IncomingPhoneNumber sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DependentHostedNumberOrder + public static async System.Threading.Tasks.Task> ReadAsync(string pathSigningDocumentSid, + DependentHostedNumberOrderResource.StatusEnum status = null, + Types.PhoneNumber phoneNumber = null, + string incomingPhoneNumberSid = null, + string friendlyName = null, + string uniqueName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDependentHostedNumberOrderOptions(pathSigningDocumentSid) { Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Converts a JSON string into a DependentHostedNumberOrderResource object + /// + /// Raw JSON string + /// DependentHostedNumberOrderResource object represented by the provided JSON + public static DependentHostedNumberOrderResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// HostedNumberOrder sid. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// IncomingPhoneNumber sid. + /// + [JsonProperty("incoming_phone_number_sid")] + public string IncomingPhoneNumberSid { get; private set; } + /// + /// Address sid. + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// LOA document sid. + /// + [JsonProperty("signing_document_sid")] + public string SigningDocumentSid { get; private set; } + /// + /// An E164 formatted phone number. + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// A mapping of phone number capabilities. + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// A human readable description of this resource. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The Status of this HostedNumberOrder. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public DependentHostedNumberOrderResource.StatusEnum Status { get; private set; } + /// + /// Why a hosted_number_order reached status "action-required" + /// + [JsonProperty("failure_reason")] + public string FailureReason { get; private set; } + /// + /// The date this HostedNumberOrder was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this HostedNumberOrder was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The number of attempts made to verify ownership of the phone number. + /// + [JsonProperty("verification_attempts")] + public int? VerificationAttempts { get; private set; } + /// + /// Email. + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// A list of emails. + /// + [JsonProperty("cc_emails")] + public List CcEmails { get; private set; } + /// + /// The method used for verifying ownership of the number to be hosted. + /// + [JsonProperty("verification_type")] + [JsonConverter(typeof(StringEnumConverter))] + public DependentHostedNumberOrderResource.VerificationTypeEnum VerificationType { get; private set; } + /// + /// Verification Document Sid. + /// + [JsonProperty("verification_document_sid")] + public string VerificationDocumentSid { get; private set; } + /// + /// Phone extension to use for ownership verification call. + /// + [JsonProperty("extension")] + public string Extension { get; private set; } + /// + /// Seconds (0-30) to delay ownership verification call by. + /// + [JsonProperty("call_delay")] + public int? CallDelay { get; private set; } + /// + /// The digits passed during the ownership verification call. + /// + [JsonProperty("verification_code")] + public string VerificationCode { get; private set; } + /// + /// List of IDs for ownership verification calls. + /// + [JsonProperty("verification_call_sids")] + public List VerificationCallSids { get; private set; } + + private DependentHostedNumberOrderResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentOptions.cs b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentOptions.cs index f4056c9b9..e034ad5e6 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentOptions.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentOptions.cs @@ -10,272 +10,272 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.HostedNumbers -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific AuthorizationDocument. + /// + public class FetchAuthorizationDocumentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific AuthorizationDocument. + /// AuthorizationDocument sid. /// - public class FetchAuthorizationDocumentOptions : IOptions - { - /// - /// AuthorizationDocument sid. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAuthorizationDocumentOptions - /// - /// AuthorizationDocument sid. - public FetchAuthorizationDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates a specific AuthorizationDocument. + /// Construct a new FetchAuthorizationDocumentOptions /// - public class UpdateAuthorizationDocumentOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// A list of HostedNumberOrder sids. - /// - public List HostedNumberOrderSids { get; set; } - /// - /// Address sid. - /// - public string AddressSid { get; set; } - /// - /// Email. - /// - public string Email { get; set; } - /// - /// A list of emails. - /// - public List CcEmails { get; set; } - /// - /// The Status of this AuthorizationDocument. - /// - public AuthorizationDocumentResource.StatusEnum Status { get; set; } - /// - /// Title of signee of this Authorization Document. - /// - public string ContactTitle { get; set; } - /// - /// Authorization Document's signee's phone number. - /// - public string ContactPhoneNumber { get; set; } - - /// - /// Construct a new UpdateAuthorizationDocumentOptions - /// - /// The sid - public UpdateAuthorizationDocumentOptions(string pathSid) - { - PathSid = pathSid; - HostedNumberOrderSids = new List(); - CcEmails = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (HostedNumberOrderSids != null) - { - p.AddRange(HostedNumberOrderSids.Select(prop => new KeyValuePair("HostedNumberOrderSids", prop))); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (CcEmails != null) - { - p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (ContactTitle != null) - { - p.Add(new KeyValuePair("ContactTitle", ContactTitle)); - } - - if (ContactPhoneNumber != null) - { - p.Add(new KeyValuePair("ContactPhoneNumber", ContactPhoneNumber)); - } - - return p; - } - } - + /// AuthorizationDocument sid. + public FetchAuthorizationDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// Generate the necessary parameters /// - public class ReadAuthorizationDocumentOptions : ReadOptions - { - /// - /// Email. - /// - public string Email { get; set; } - /// - /// The Status of this AuthorizationDocument. - /// - public AuthorizationDocumentResource.StatusEnum Status { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates a specific AuthorizationDocument. + /// + public class UpdateAuthorizationDocumentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// The sid /// - public class CreateAuthorizationDocumentOptions : IOptions - { - /// - /// A list of HostedNumberOrder sids. - /// - public List HostedNumberOrderSids { get; } - /// - /// Address sid. - /// - public string AddressSid { get; } - /// - /// Email. - /// - public string Email { get; } - /// - /// Title of signee of this Authorization Document. - /// - public string ContactTitle { get; } - /// - /// Authorization Document's signee's phone number. - /// - public string ContactPhoneNumber { get; } - /// - /// A list of emails. - /// - public List CcEmails { get; set; } - - /// - /// Construct a new CreateAuthorizationDocumentOptions - /// - /// A list of HostedNumberOrder sids. - /// Address sid. - /// Email. - /// Title of signee of this Authorization Document. - /// Authorization Document's signee's phone number. - public CreateAuthorizationDocumentOptions(List hostedNumberOrderSids, - string addressSid, - string email, - string contactTitle, - string contactPhoneNumber) - { - HostedNumberOrderSids = hostedNumberOrderSids; - AddressSid = addressSid; - Email = email; - ContactTitle = contactTitle; - ContactPhoneNumber = contactPhoneNumber; - CcEmails = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (HostedNumberOrderSids != null) - { - p.AddRange(HostedNumberOrderSids.Select(prop => new KeyValuePair("HostedNumberOrderSids", prop))); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (ContactTitle != null) - { - p.Add(new KeyValuePair("ContactTitle", ContactTitle)); - } - - if (ContactPhoneNumber != null) - { - p.Add(new KeyValuePair("ContactPhoneNumber", ContactPhoneNumber)); - } - - if (CcEmails != null) - { - p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); - } - - return p; - } - } + public string PathSid { get; } + /// + /// A list of HostedNumberOrder sids. + /// + public List HostedNumberOrderSids { get; set; } + /// + /// Address sid. + /// + public string AddressSid { get; set; } + /// + /// Email. + /// + public string Email { get; set; } + /// + /// A list of emails. + /// + public List CcEmails { get; set; } + /// + /// The Status of this AuthorizationDocument. + /// + public AuthorizationDocumentResource.StatusEnum Status { get; set; } + /// + /// Title of signee of this Authorization Document. + /// + public string ContactTitle { get; set; } + /// + /// Authorization Document's signee's phone number. + /// + public string ContactPhoneNumber { get; set; } + + /// + /// Construct a new UpdateAuthorizationDocumentOptions + /// + /// The sid + public UpdateAuthorizationDocumentOptions(string pathSid) + { + PathSid = pathSid; + HostedNumberOrderSids = new List(); + CcEmails = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (HostedNumberOrderSids != null) + { + p.AddRange(HostedNumberOrderSids.Select(prop => new KeyValuePair("HostedNumberOrderSids", prop))); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (CcEmails != null) + { + p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (ContactTitle != null) + { + p.Add(new KeyValuePair("ContactTitle", ContactTitle)); + } + + if (ContactPhoneNumber != null) + { + p.Add(new KeyValuePair("ContactPhoneNumber", ContactPhoneNumber)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// + public class ReadAuthorizationDocumentOptions : ReadOptions + { + /// + /// Email. + /// + public string Email { get; set; } + /// + /// The Status of this AuthorizationDocument. + /// + public AuthorizationDocumentResource.StatusEnum Status { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// + public class CreateAuthorizationDocumentOptions : IOptions + { + /// + /// A list of HostedNumberOrder sids. + /// + public List HostedNumberOrderSids { get; } + /// + /// Address sid. + /// + public string AddressSid { get; } + /// + /// Email. + /// + public string Email { get; } + /// + /// Title of signee of this Authorization Document. + /// + public string ContactTitle { get; } + /// + /// Authorization Document's signee's phone number. + /// + public string ContactPhoneNumber { get; } + /// + /// A list of emails. + /// + public List CcEmails { get; set; } + + /// + /// Construct a new CreateAuthorizationDocumentOptions + /// + /// A list of HostedNumberOrder sids. + /// Address sid. + /// Email. + /// Title of signee of this Authorization Document. + /// Authorization Document's signee's phone number. + public CreateAuthorizationDocumentOptions(List hostedNumberOrderSids, + string addressSid, + string email, + string contactTitle, + string contactPhoneNumber) + { + HostedNumberOrderSids = hostedNumberOrderSids; + AddressSid = addressSid; + Email = email; + ContactTitle = contactTitle; + ContactPhoneNumber = contactPhoneNumber; + CcEmails = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (HostedNumberOrderSids != null) + { + p.AddRange(HostedNumberOrderSids.Select(prop => new KeyValuePair("HostedNumberOrderSids", prop))); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (ContactTitle != null) + { + p.Add(new KeyValuePair("ContactTitle", ContactTitle)); + } + + if (ContactPhoneNumber != null) + { + p.Add(new KeyValuePair("ContactPhoneNumber", ContactPhoneNumber)); + } + + if (CcEmails != null) + { + p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentResource.cs b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentResource.cs index 78a05a011..318cc06a2 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentResource.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentResource.cs @@ -20,489 +20,489 @@ using Twilio.Types; namespace Twilio.Rest.Preview.HostedNumbers -{ - - public class AuthorizationDocumentResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Opened = new StatusEnum("opened"); - public static readonly StatusEnum Signing = new StatusEnum("signing"); - public static readonly StatusEnum Signed = new StatusEnum("signed"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - private static Request BuildFetchRequest(FetchAuthorizationDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/HostedNumbers/AuthorizationDocuments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific AuthorizationDocument. - /// - /// Fetch AuthorizationDocument parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Fetch(FetchAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific AuthorizationDocument. - /// - /// Fetch AuthorizationDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task FetchAsync(FetchAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific AuthorizationDocument. - /// - /// AuthorizationDocument sid. - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAuthorizationDocumentOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific AuthorizationDocument. - /// - /// AuthorizationDocument sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAuthorizationDocumentOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAuthorizationDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/HostedNumbers/AuthorizationDocuments/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a specific AuthorizationDocument. - /// - /// Update AuthorizationDocument parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Update(UpdateAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a specific AuthorizationDocument. - /// - /// Update AuthorizationDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a specific AuthorizationDocument. - /// - /// The sid - /// A list of HostedNumberOrder sids. - /// Address sid. - /// Email. - /// A list of emails. - /// The Status of this AuthorizationDocument. - /// Title of signee of this Authorization Document. - /// Authorization Document's signee's phone number. - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Update(string pathSid, - List hostedNumberOrderSids = null, - string addressSid = null, - string email = null, - List ccEmails = null, - AuthorizationDocumentResource.StatusEnum status = null, - string contactTitle = null, - string contactPhoneNumber = null, - ITwilioRestClient client = null) - { - var options = new UpdateAuthorizationDocumentOptions(pathSid){HostedNumberOrderSids = hostedNumberOrderSids, AddressSid = addressSid, Email = email, CcEmails = ccEmails, Status = status, ContactTitle = contactTitle, ContactPhoneNumber = contactPhoneNumber}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a specific AuthorizationDocument. - /// - /// The sid - /// A list of HostedNumberOrder sids. - /// Address sid. - /// Email. - /// A list of emails. - /// The Status of this AuthorizationDocument. - /// Title of signee of this Authorization Document. - /// Authorization Document's signee's phone number. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - List hostedNumberOrderSids = null, - string addressSid = null, - string email = null, - List ccEmails = null, - AuthorizationDocumentResource.StatusEnum status = null, - string contactTitle = null, - string contactPhoneNumber = null, - ITwilioRestClient client = null) - { - var options = new UpdateAuthorizationDocumentOptions(pathSid){HostedNumberOrderSids = hostedNumberOrderSids, AddressSid = addressSid, Email = email, CcEmails = ccEmails, Status = status, ContactTitle = contactTitle, ContactPhoneNumber = contactPhoneNumber}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAuthorizationDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/HostedNumbers/AuthorizationDocuments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. - /// - /// Read AuthorizationDocument parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static ResourceSet Read(ReadAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. - /// - /// Read AuthorizationDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. - /// - /// Email. - /// The Status of this AuthorizationDocument. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static ResourceSet Read(string email = null, - AuthorizationDocumentResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthorizationDocumentOptions(){Email = email, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. - /// - /// Email. - /// The Status of this AuthorizationDocument. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task> ReadAsync(string email = null, - AuthorizationDocumentResource.StatusEnum status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAuthorizationDocumentOptions(){Email = email, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildCreateRequest(CreateAuthorizationDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/HostedNumbers/AuthorizationDocuments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. - /// - /// Create AuthorizationDocument parameters - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Create(CreateAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. - /// - /// Create AuthorizationDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task CreateAsync(CreateAuthorizationDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. - /// - /// A list of HostedNumberOrder sids. - /// Address sid. - /// Email. - /// Title of signee of this Authorization Document. - /// Authorization Document's signee's phone number. - /// A list of emails. - /// Client to make requests to Twilio - /// A single instance of AuthorizationDocument - public static AuthorizationDocumentResource Create(List hostedNumberOrderSids, - string addressSid, - string email, - string contactTitle, - string contactPhoneNumber, - List ccEmails = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthorizationDocumentOptions(hostedNumberOrderSids, addressSid, email, contactTitle, contactPhoneNumber){CcEmails = ccEmails}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. - /// - /// A list of HostedNumberOrder sids. - /// Address sid. - /// Email. - /// Title of signee of this Authorization Document. - /// Authorization Document's signee's phone number. - /// A list of emails. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AuthorizationDocument - public static async System.Threading.Tasks.Task CreateAsync(List hostedNumberOrderSids, - string addressSid, - string email, - string contactTitle, - string contactPhoneNumber, - List ccEmails = null, - ITwilioRestClient client = null) - { - var options = new CreateAuthorizationDocumentOptions(hostedNumberOrderSids, addressSid, email, contactTitle, contactPhoneNumber){CcEmails = ccEmails}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AuthorizationDocumentResource object - /// - /// Raw JSON string - /// AuthorizationDocumentResource object represented by the provided JSON - public static AuthorizationDocumentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// AuthorizationDocument sid. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Address sid. - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// The Status of this AuthorizationDocument. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public AuthorizationDocumentResource.StatusEnum Status { get; private set; } - /// - /// Email. - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// A list of emails. - /// - [JsonProperty("cc_emails")] - public List CcEmails { get; private set; } - /// - /// The date this AuthorizationDocument was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this AuthorizationDocument was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private AuthorizationDocumentResource() - { - - } - } +{ + + public class AuthorizationDocumentResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Opened = new StatusEnum("opened"); + public static readonly StatusEnum Signing = new StatusEnum("signing"); + public static readonly StatusEnum Signed = new StatusEnum("signed"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + private static Request BuildFetchRequest(FetchAuthorizationDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/HostedNumbers/AuthorizationDocuments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific AuthorizationDocument. + /// + /// Fetch AuthorizationDocument parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Fetch(FetchAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific AuthorizationDocument. + /// + /// Fetch AuthorizationDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task FetchAsync(FetchAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific AuthorizationDocument. + /// + /// AuthorizationDocument sid. + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAuthorizationDocumentOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific AuthorizationDocument. + /// + /// AuthorizationDocument sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAuthorizationDocumentOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAuthorizationDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/HostedNumbers/AuthorizationDocuments/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a specific AuthorizationDocument. + /// + /// Update AuthorizationDocument parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Update(UpdateAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a specific AuthorizationDocument. + /// + /// Update AuthorizationDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a specific AuthorizationDocument. + /// + /// The sid + /// A list of HostedNumberOrder sids. + /// Address sid. + /// Email. + /// A list of emails. + /// The Status of this AuthorizationDocument. + /// Title of signee of this Authorization Document. + /// Authorization Document's signee's phone number. + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Update(string pathSid, + List hostedNumberOrderSids = null, + string addressSid = null, + string email = null, + List ccEmails = null, + AuthorizationDocumentResource.StatusEnum status = null, + string contactTitle = null, + string contactPhoneNumber = null, + ITwilioRestClient client = null) + { + var options = new UpdateAuthorizationDocumentOptions(pathSid) { HostedNumberOrderSids = hostedNumberOrderSids, AddressSid = addressSid, Email = email, CcEmails = ccEmails, Status = status, ContactTitle = contactTitle, ContactPhoneNumber = contactPhoneNumber }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a specific AuthorizationDocument. + /// + /// The sid + /// A list of HostedNumberOrder sids. + /// Address sid. + /// Email. + /// A list of emails. + /// The Status of this AuthorizationDocument. + /// Title of signee of this Authorization Document. + /// Authorization Document's signee's phone number. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + List hostedNumberOrderSids = null, + string addressSid = null, + string email = null, + List ccEmails = null, + AuthorizationDocumentResource.StatusEnum status = null, + string contactTitle = null, + string contactPhoneNumber = null, + ITwilioRestClient client = null) + { + var options = new UpdateAuthorizationDocumentOptions(pathSid) { HostedNumberOrderSids = hostedNumberOrderSids, AddressSid = addressSid, Email = email, CcEmails = ccEmails, Status = status, ContactTitle = contactTitle, ContactPhoneNumber = contactPhoneNumber }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAuthorizationDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/HostedNumbers/AuthorizationDocuments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// + /// Read AuthorizationDocument parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static ResourceSet Read(ReadAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// + /// Read AuthorizationDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task> ReadAsync(ReadAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// + /// Email. + /// The Status of this AuthorizationDocument. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static ResourceSet Read(string email = null, + AuthorizationDocumentResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthorizationDocumentOptions() { Email = email, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of AuthorizationDocuments belonging to the account initiating the request. + /// + /// Email. + /// The Status of this AuthorizationDocument. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task> ReadAsync(string email = null, + AuthorizationDocumentResource.StatusEnum status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAuthorizationDocumentOptions() { Email = email, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildCreateRequest(CreateAuthorizationDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/HostedNumbers/AuthorizationDocuments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// + /// Create AuthorizationDocument parameters + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Create(CreateAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// + /// Create AuthorizationDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task CreateAsync(CreateAuthorizationDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// + /// A list of HostedNumberOrder sids. + /// Address sid. + /// Email. + /// Title of signee of this Authorization Document. + /// Authorization Document's signee's phone number. + /// A list of emails. + /// Client to make requests to Twilio + /// A single instance of AuthorizationDocument + public static AuthorizationDocumentResource Create(List hostedNumberOrderSids, + string addressSid, + string email, + string contactTitle, + string contactPhoneNumber, + List ccEmails = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthorizationDocumentOptions(hostedNumberOrderSids, addressSid, email, contactTitle, contactPhoneNumber) { CcEmails = ccEmails }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create an AuthorizationDocument for authorizing the hosting of phone number capabilities on Twilio's platform. + /// + /// A list of HostedNumberOrder sids. + /// Address sid. + /// Email. + /// Title of signee of this Authorization Document. + /// Authorization Document's signee's phone number. + /// A list of emails. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AuthorizationDocument + public static async System.Threading.Tasks.Task CreateAsync(List hostedNumberOrderSids, + string addressSid, + string email, + string contactTitle, + string contactPhoneNumber, + List ccEmails = null, + ITwilioRestClient client = null) + { + var options = new CreateAuthorizationDocumentOptions(hostedNumberOrderSids, addressSid, email, contactTitle, contactPhoneNumber) { CcEmails = ccEmails }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AuthorizationDocumentResource object + /// + /// Raw JSON string + /// AuthorizationDocumentResource object represented by the provided JSON + public static AuthorizationDocumentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// AuthorizationDocument sid. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Address sid. + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// The Status of this AuthorizationDocument. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public AuthorizationDocumentResource.StatusEnum Status { get; private set; } + /// + /// Email. + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// A list of emails. + /// + [JsonProperty("cc_emails")] + public List CcEmails { get; private set; } + /// + /// The date this AuthorizationDocument was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this AuthorizationDocument was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private AuthorizationDocumentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderOptions.cs b/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderOptions.cs index 2589739e5..a7697a6fc 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderOptions.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderOptions.cs @@ -10,446 +10,446 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.HostedNumbers -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific HostedNumberOrder. + /// + public class FetchHostedNumberOrderOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific HostedNumberOrder. - /// - public class FetchHostedNumberOrderOptions : IOptions - { - /// - /// HostedNumberOrder sid. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchHostedNumberOrderOptions - /// - /// HostedNumberOrder sid. - public FetchHostedNumberOrderOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// HostedNumberOrder sid. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Cancel the HostedNumberOrder (only available when the status is in `received`). - /// - public class DeleteHostedNumberOrderOptions : IOptions - { - /// - /// HostedNumberOrder sid. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteHostedNumberOrderOptions - /// - /// HostedNumberOrder sid. - public DeleteHostedNumberOrderOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchHostedNumberOrderOptions + /// + /// HostedNumberOrder sid. + public FetchHostedNumberOrderOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates a specific HostedNumberOrder. - /// - public class UpdateHostedNumberOrderOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// A human readable description of this resource. - /// - public string FriendlyName { get; set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - public string UniqueName { get; set; } - /// - /// Email. - /// - public string Email { get; set; } - /// - /// A list of emails. - /// - public List CcEmails { get; set; } - /// - /// The Status of this HostedNumberOrder. - /// - public HostedNumberOrderResource.StatusEnum Status { get; set; } - /// - /// A verification code. - /// - public string VerificationCode { get; set; } - /// - /// Verification Type. - /// - public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; set; } - /// - /// Verification Document Sid - /// - public string VerificationDocumentSid { get; set; } - /// - /// Digits to dial after connecting the verification call. - /// - public string Extension { get; set; } - /// - /// The number of seconds, between 0 and 60, to delay before initiating the verification call. - /// - public int? CallDelay { get; set; } - - /// - /// Construct a new UpdateHostedNumberOrderOptions - /// - /// The sid - public UpdateHostedNumberOrderOptions(string pathSid) - { - PathSid = pathSid; - CcEmails = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (CcEmails != null) - { - p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (VerificationCode != null) - { - p.Add(new KeyValuePair("VerificationCode", VerificationCode)); - } - - if (VerificationType != null) - { - p.Add(new KeyValuePair("VerificationType", VerificationType.ToString())); - } - - if (VerificationDocumentSid != null) - { - p.Add(new KeyValuePair("VerificationDocumentSid", VerificationDocumentSid.ToString())); - } - - if (Extension != null) - { - p.Add(new KeyValuePair("Extension", Extension)); - } - - if (CallDelay != null) - { - p.Add(new KeyValuePair("CallDelay", CallDelay.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Cancel the HostedNumberOrder (only available when the status is in `received`). + /// + public class DeleteHostedNumberOrderOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. - /// - public class ReadHostedNumberOrderOptions : ReadOptions - { - /// - /// The Status of this HostedNumberOrder. - /// - public HostedNumberOrderResource.StatusEnum Status { get; set; } - /// - /// An E164 formatted phone number. - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// IncomingPhoneNumber sid. - /// - public string IncomingPhoneNumberSid { get; set; } - /// - /// A human readable description of this resource. - /// - public string FriendlyName { get; set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - public string UniqueName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (IncomingPhoneNumberSid != null) - { - p.Add(new KeyValuePair("IncomingPhoneNumberSid", IncomingPhoneNumberSid.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// HostedNumberOrder sid. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Host a phone number's capability on Twilio's platform. - /// - public class CreateHostedNumberOrderOptions : IOptions - { - /// - /// An E164 formatted phone number. - /// - public Types.PhoneNumber PhoneNumber { get; } - /// - /// Specify SMS capability to host. - /// - public bool? SmsCapability { get; } - /// - /// Account Sid. - /// - public string AccountSid { get; set; } - /// - /// A human readable description of this resource. - /// - public string FriendlyName { get; set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - public string UniqueName { get; set; } - /// - /// A list of emails. - /// - public List CcEmails { get; set; } - /// - /// SMS URL. - /// - public Uri SmsUrl { get; set; } - /// - /// SMS Method. - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// SMS Fallback URL. - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// SMS Fallback Method. - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// Status Callback URL. - /// - public Uri StatusCallbackUrl { get; set; } - /// - /// Status Callback Method. - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// SMS Application Sid. - /// - public string SmsApplicationSid { get; set; } - /// - /// Address sid. - /// - public string AddressSid { get; set; } - /// - /// Email. - /// - public string Email { get; set; } - /// - /// Verification Type. - /// - public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; set; } - /// - /// Verification Document Sid - /// - public string VerificationDocumentSid { get; set; } - - /// - /// Construct a new CreateHostedNumberOrderOptions - /// - /// An E164 formatted phone number. - /// Specify SMS capability to host. - public CreateHostedNumberOrderOptions(Types.PhoneNumber phoneNumber, bool? smsCapability) - { - PhoneNumber = phoneNumber; - SmsCapability = smsCapability; - CcEmails = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (SmsCapability != null) - { - p.Add(new KeyValuePair("SmsCapability", SmsCapability.Value.ToString().ToLower())); - } - - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CcEmails != null) - { - p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (StatusCallbackUrl != null) - { - p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (SmsApplicationSid != null) - { - p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); - } - - if (AddressSid != null) - { - p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (VerificationType != null) - { - p.Add(new KeyValuePair("VerificationType", VerificationType.ToString())); - } - - if (VerificationDocumentSid != null) - { - p.Add(new KeyValuePair("VerificationDocumentSid", VerificationDocumentSid.ToString())); - } - - return p; - } - } + /// Construct a new DeleteHostedNumberOrderOptions + /// + /// HostedNumberOrder sid. + public DeleteHostedNumberOrderOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates a specific HostedNumberOrder. + /// + public class UpdateHostedNumberOrderOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// A human readable description of this resource. + /// + public string FriendlyName { get; set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + public string UniqueName { get; set; } + /// + /// Email. + /// + public string Email { get; set; } + /// + /// A list of emails. + /// + public List CcEmails { get; set; } + /// + /// The Status of this HostedNumberOrder. + /// + public HostedNumberOrderResource.StatusEnum Status { get; set; } + /// + /// A verification code. + /// + public string VerificationCode { get; set; } + /// + /// Verification Type. + /// + public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; set; } + /// + /// Verification Document Sid + /// + public string VerificationDocumentSid { get; set; } + /// + /// Digits to dial after connecting the verification call. + /// + public string Extension { get; set; } + /// + /// The number of seconds, between 0 and 60, to delay before initiating the verification call. + /// + public int? CallDelay { get; set; } + + /// + /// Construct a new UpdateHostedNumberOrderOptions + /// + /// The sid + public UpdateHostedNumberOrderOptions(string pathSid) + { + PathSid = pathSid; + CcEmails = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (CcEmails != null) + { + p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (VerificationCode != null) + { + p.Add(new KeyValuePair("VerificationCode", VerificationCode)); + } + + if (VerificationType != null) + { + p.Add(new KeyValuePair("VerificationType", VerificationType.ToString())); + } + + if (VerificationDocumentSid != null) + { + p.Add(new KeyValuePair("VerificationDocumentSid", VerificationDocumentSid.ToString())); + } + + if (Extension != null) + { + p.Add(new KeyValuePair("Extension", Extension)); + } + + if (CallDelay != null) + { + p.Add(new KeyValuePair("CallDelay", CallDelay.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. + /// + public class ReadHostedNumberOrderOptions : ReadOptions + { + /// + /// The Status of this HostedNumberOrder. + /// + public HostedNumberOrderResource.StatusEnum Status { get; set; } + /// + /// An E164 formatted phone number. + /// + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// IncomingPhoneNumber sid. + /// + public string IncomingPhoneNumberSid { get; set; } + /// + /// A human readable description of this resource. + /// + public string FriendlyName { get; set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + public string UniqueName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (IncomingPhoneNumberSid != null) + { + p.Add(new KeyValuePair("IncomingPhoneNumberSid", IncomingPhoneNumberSid.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Host a phone number's capability on Twilio's platform. + /// + public class CreateHostedNumberOrderOptions : IOptions + { + /// + /// An E164 formatted phone number. + /// + public Types.PhoneNumber PhoneNumber { get; } + /// + /// Specify SMS capability to host. + /// + public bool? SmsCapability { get; } + /// + /// Account Sid. + /// + public string AccountSid { get; set; } + /// + /// A human readable description of this resource. + /// + public string FriendlyName { get; set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + public string UniqueName { get; set; } + /// + /// A list of emails. + /// + public List CcEmails { get; set; } + /// + /// SMS URL. + /// + public Uri SmsUrl { get; set; } + /// + /// SMS Method. + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// SMS Fallback URL. + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// SMS Fallback Method. + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// Status Callback URL. + /// + public Uri StatusCallbackUrl { get; set; } + /// + /// Status Callback Method. + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// SMS Application Sid. + /// + public string SmsApplicationSid { get; set; } + /// + /// Address sid. + /// + public string AddressSid { get; set; } + /// + /// Email. + /// + public string Email { get; set; } + /// + /// Verification Type. + /// + public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; set; } + /// + /// Verification Document Sid + /// + public string VerificationDocumentSid { get; set; } + + /// + /// Construct a new CreateHostedNumberOrderOptions + /// + /// An E164 formatted phone number. + /// Specify SMS capability to host. + public CreateHostedNumberOrderOptions(Types.PhoneNumber phoneNumber, bool? smsCapability) + { + PhoneNumber = phoneNumber; + SmsCapability = smsCapability; + CcEmails = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (SmsCapability != null) + { + p.Add(new KeyValuePair("SmsCapability", SmsCapability.Value.ToString().ToLower())); + } + + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CcEmails != null) + { + p.AddRange(CcEmails.Select(prop => new KeyValuePair("CcEmails", prop))); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (StatusCallbackUrl != null) + { + p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (SmsApplicationSid != null) + { + p.Add(new KeyValuePair("SmsApplicationSid", SmsApplicationSid.ToString())); + } + + if (AddressSid != null) + { + p.Add(new KeyValuePair("AddressSid", AddressSid.ToString())); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (VerificationType != null) + { + p.Add(new KeyValuePair("VerificationType", VerificationType.ToString())); + } + + if (VerificationDocumentSid != null) + { + p.Add(new KeyValuePair("VerificationDocumentSid", VerificationDocumentSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderResource.cs b/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderResource.cs index b07e5b285..60bd142cd 100644 --- a/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderResource.cs +++ b/src/Twilio/Rest/Preview/HostedNumbers/HostedNumberOrderResource.cs @@ -20,713 +20,713 @@ using Twilio.Types; namespace Twilio.Rest.Preview.HostedNumbers -{ - - public class HostedNumberOrderResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum PendingVerification = new StatusEnum("pending-verification"); - public static readonly StatusEnum Verified = new StatusEnum("verified"); - public static readonly StatusEnum PendingLoa = new StatusEnum("pending-loa"); - public static readonly StatusEnum CarrierProcessing = new StatusEnum("carrier-processing"); - public static readonly StatusEnum Testing = new StatusEnum("testing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum ActionRequired = new StatusEnum("action-required"); - } - - public sealed class VerificationTypeEnum : StringEnum - { - private VerificationTypeEnum(string value) : base(value) {} - public VerificationTypeEnum() {} - public static implicit operator VerificationTypeEnum(string value) - { - return new VerificationTypeEnum(value); - } - - public static readonly VerificationTypeEnum PhoneCall = new VerificationTypeEnum("phone-call"); - public static readonly VerificationTypeEnum PhoneBill = new VerificationTypeEnum("phone-bill"); - } - - private static Request BuildFetchRequest(FetchHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific HostedNumberOrder. - /// - /// Fetch HostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Fetch(FetchHostedNumberOrderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific HostedNumberOrder. - /// - /// Fetch HostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task FetchAsync(FetchHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific HostedNumberOrder. - /// - /// HostedNumberOrder sid. - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchHostedNumberOrderOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific HostedNumberOrder. - /// - /// HostedNumberOrder sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchHostedNumberOrderOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Cancel the HostedNumberOrder (only available when the status is in `received`). - /// - /// Delete HostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static bool Delete(DeleteHostedNumberOrderOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Cancel the HostedNumberOrder (only available when the status is in `received`). - /// - /// Delete HostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task DeleteAsync(DeleteHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Cancel the HostedNumberOrder (only available when the status is in `received`). - /// - /// HostedNumberOrder sid. - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteHostedNumberOrderOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Cancel the HostedNumberOrder (only available when the status is in `received`). - /// - /// HostedNumberOrder sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteHostedNumberOrderOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a specific HostedNumberOrder. - /// - /// Update HostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Update(UpdateHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a specific HostedNumberOrder. - /// - /// Update HostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task UpdateAsync(UpdateHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a specific HostedNumberOrder. - /// - /// The sid - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Email. - /// A list of emails. - /// The Status of this HostedNumberOrder. - /// A verification code. - /// Verification Type. - /// Verification Document Sid - /// Digits to dial after connecting the verification call. - /// The number of seconds, between 0 and 60, to delay before initiating the verification call. - /// - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Update(string pathSid, - string friendlyName = null, - string uniqueName = null, - string email = null, - List ccEmails = null, - HostedNumberOrderResource.StatusEnum status = null, - string verificationCode = null, - HostedNumberOrderResource.VerificationTypeEnum verificationType = null, - string verificationDocumentSid = null, - string extension = null, - int? callDelay = null, - ITwilioRestClient client = null) - { - var options = new UpdateHostedNumberOrderOptions(pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Email = email, CcEmails = ccEmails, Status = status, VerificationCode = verificationCode, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid, Extension = extension, CallDelay = callDelay}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a specific HostedNumberOrder. - /// - /// The sid - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Email. - /// A list of emails. - /// The Status of this HostedNumberOrder. - /// A verification code. - /// Verification Type. - /// Verification Document Sid - /// Digits to dial after connecting the verification call. - /// The number of seconds, between 0 and 60, to delay before initiating the verification call. - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string uniqueName = null, - string email = null, - List ccEmails = null, - HostedNumberOrderResource.StatusEnum status = null, - string verificationCode = null, - HostedNumberOrderResource.VerificationTypeEnum verificationType = null, - string verificationDocumentSid = null, - string extension = null, - int? callDelay = null, - ITwilioRestClient client = null) - { - var options = new UpdateHostedNumberOrderOptions(pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Email = email, CcEmails = ccEmails, Status = status, VerificationCode = verificationCode, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid, Extension = extension, CallDelay = callDelay}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/HostedNumbers/HostedNumberOrders", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. - /// - /// Read HostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static ResourceSet Read(ReadHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. - /// - /// Read HostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task> ReadAsync(ReadHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. - /// - /// The Status of this HostedNumberOrder. - /// An E164 formatted phone number. - /// IncomingPhoneNumber sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static ResourceSet Read(HostedNumberOrderResource.StatusEnum status = null, - Types.PhoneNumber phoneNumber = null, - string incomingPhoneNumberSid = null, - string friendlyName = null, - string uniqueName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadHostedNumberOrderOptions(){Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. - /// - /// The Status of this HostedNumberOrder. - /// An E164 formatted phone number. - /// IncomingPhoneNumber sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task> ReadAsync(HostedNumberOrderResource.StatusEnum status = null, - Types.PhoneNumber phoneNumber = null, - string incomingPhoneNumberSid = null, - string friendlyName = null, - string uniqueName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadHostedNumberOrderOptions(){Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildCreateRequest(CreateHostedNumberOrderOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/HostedNumbers/HostedNumberOrders", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Host a phone number's capability on Twilio's platform. - /// - /// Create HostedNumberOrder parameters - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Create(CreateHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Host a phone number's capability on Twilio's platform. - /// - /// Create HostedNumberOrder parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task CreateAsync(CreateHostedNumberOrderOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Host a phone number's capability on Twilio's platform. - /// - /// An E164 formatted phone number. - /// Specify SMS capability to host. - /// Account Sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// A list of emails. - /// SMS URL. - /// SMS Method. - /// SMS Fallback URL. - /// SMS Fallback Method. - /// Status Callback URL. - /// Status Callback Method. - /// SMS Application Sid. - /// Address sid. - /// Email. - /// Verification Type. - /// Verification Document Sid - /// Client to make requests to Twilio - /// A single instance of HostedNumberOrder - public static HostedNumberOrderResource Create(Types.PhoneNumber phoneNumber, - bool? smsCapability, - string accountSid = null, - string friendlyName = null, - string uniqueName = null, - List ccEmails = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string smsApplicationSid = null, - string addressSid = null, - string email = null, - HostedNumberOrderResource.VerificationTypeEnum verificationType = null, - string verificationDocumentSid = null, - ITwilioRestClient client = null) - { - var options = new CreateHostedNumberOrderOptions(phoneNumber, smsCapability){AccountSid = accountSid, FriendlyName = friendlyName, UniqueName = uniqueName, CcEmails = ccEmails, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, SmsApplicationSid = smsApplicationSid, AddressSid = addressSid, Email = email, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Host a phone number's capability on Twilio's platform. - /// - /// An E164 formatted phone number. - /// Specify SMS capability to host. - /// Account Sid. - /// A human readable description of this resource. - /// A unique, developer assigned name of this HostedNumberOrder. - /// A list of emails. - /// SMS URL. - /// SMS Method. - /// SMS Fallback URL. - /// SMS Fallback Method. - /// Status Callback URL. - /// Status Callback Method. - /// SMS Application Sid. - /// Address sid. - /// Email. - /// Verification Type. - /// Verification Document Sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HostedNumberOrder - public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, - bool? smsCapability, - string accountSid = null, - string friendlyName = null, - string uniqueName = null, - List ccEmails = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string smsApplicationSid = null, - string addressSid = null, - string email = null, - HostedNumberOrderResource.VerificationTypeEnum verificationType = null, - string verificationDocumentSid = null, - ITwilioRestClient client = null) - { - var options = new CreateHostedNumberOrderOptions(phoneNumber, smsCapability){AccountSid = accountSid, FriendlyName = friendlyName, UniqueName = uniqueName, CcEmails = ccEmails, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, SmsApplicationSid = smsApplicationSid, AddressSid = addressSid, Email = email, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a HostedNumberOrderResource object - /// - /// Raw JSON string - /// HostedNumberOrderResource object represented by the provided JSON - public static HostedNumberOrderResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// HostedNumberOrder sid. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// IncomingPhoneNumber sid. - /// - [JsonProperty("incoming_phone_number_sid")] - public string IncomingPhoneNumberSid { get; private set; } - /// - /// Address sid. - /// - [JsonProperty("address_sid")] - public string AddressSid { get; private set; } - /// - /// LOA document sid. - /// - [JsonProperty("signing_document_sid")] - public string SigningDocumentSid { get; private set; } - /// - /// An E164 formatted phone number. - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// A mapping of phone number capabilities. - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// A human readable description of this resource. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A unique, developer assigned name of this HostedNumberOrder. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The Status of this HostedNumberOrder. - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public HostedNumberOrderResource.StatusEnum Status { get; private set; } - /// - /// Why a hosted_number_order reached status "action-required" - /// - [JsonProperty("failure_reason")] - public string FailureReason { get; private set; } - /// - /// The date this HostedNumberOrder was created. - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this HostedNumberOrder was updated. - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The number of attempts made to verify ownership of the phone number. - /// - [JsonProperty("verification_attempts")] - public int? VerificationAttempts { get; private set; } - /// - /// Email. - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// A list of emails. - /// - [JsonProperty("cc_emails")] - public List CcEmails { get; private set; } - /// - /// The URL of this HostedNumberOrder. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The method used for verifying ownership of the number to be hosted. - /// - [JsonProperty("verification_type")] - [JsonConverter(typeof(StringEnumConverter))] - public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; private set; } - /// - /// Verification Document Sid. - /// - [JsonProperty("verification_document_sid")] - public string VerificationDocumentSid { get; private set; } - /// - /// Phone extension to use for ownership verification call. - /// - [JsonProperty("extension")] - public string Extension { get; private set; } - /// - /// Seconds (0-30) to delay ownership verification call by. - /// - [JsonProperty("call_delay")] - public int? CallDelay { get; private set; } - /// - /// The digits passed during the ownership verification call. - /// - [JsonProperty("verification_code")] - public string VerificationCode { get; private set; } - /// - /// List of IDs for ownership verification calls. - /// - [JsonProperty("verification_call_sids")] - public List VerificationCallSids { get; private set; } - - private HostedNumberOrderResource() - { - - } - } +{ + + public class HostedNumberOrderResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum PendingVerification = new StatusEnum("pending-verification"); + public static readonly StatusEnum Verified = new StatusEnum("verified"); + public static readonly StatusEnum PendingLoa = new StatusEnum("pending-loa"); + public static readonly StatusEnum CarrierProcessing = new StatusEnum("carrier-processing"); + public static readonly StatusEnum Testing = new StatusEnum("testing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum ActionRequired = new StatusEnum("action-required"); + } + + public sealed class VerificationTypeEnum : StringEnum + { + private VerificationTypeEnum(string value) : base(value) { } + public VerificationTypeEnum() { } + public static implicit operator VerificationTypeEnum(string value) + { + return new VerificationTypeEnum(value); + } + + public static readonly VerificationTypeEnum PhoneCall = new VerificationTypeEnum("phone-call"); + public static readonly VerificationTypeEnum PhoneBill = new VerificationTypeEnum("phone-bill"); + } + + private static Request BuildFetchRequest(FetchHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific HostedNumberOrder. + /// + /// Fetch HostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Fetch(FetchHostedNumberOrderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific HostedNumberOrder. + /// + /// Fetch HostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task FetchAsync(FetchHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific HostedNumberOrder. + /// + /// HostedNumberOrder sid. + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchHostedNumberOrderOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific HostedNumberOrder. + /// + /// HostedNumberOrder sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchHostedNumberOrderOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Cancel the HostedNumberOrder (only available when the status is in `received`). + /// + /// Delete HostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static bool Delete(DeleteHostedNumberOrderOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Cancel the HostedNumberOrder (only available when the status is in `received`). + /// + /// Delete HostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task DeleteAsync(DeleteHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Cancel the HostedNumberOrder (only available when the status is in `received`). + /// + /// HostedNumberOrder sid. + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteHostedNumberOrderOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Cancel the HostedNumberOrder (only available when the status is in `received`). + /// + /// HostedNumberOrder sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteHostedNumberOrderOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/HostedNumbers/HostedNumberOrders/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a specific HostedNumberOrder. + /// + /// Update HostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Update(UpdateHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a specific HostedNumberOrder. + /// + /// Update HostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task UpdateAsync(UpdateHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a specific HostedNumberOrder. + /// + /// The sid + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Email. + /// A list of emails. + /// The Status of this HostedNumberOrder. + /// A verification code. + /// Verification Type. + /// Verification Document Sid + /// Digits to dial after connecting the verification call. + /// The number of seconds, between 0 and 60, to delay before initiating the verification call. + /// + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Update(string pathSid, + string friendlyName = null, + string uniqueName = null, + string email = null, + List ccEmails = null, + HostedNumberOrderResource.StatusEnum status = null, + string verificationCode = null, + HostedNumberOrderResource.VerificationTypeEnum verificationType = null, + string verificationDocumentSid = null, + string extension = null, + int? callDelay = null, + ITwilioRestClient client = null) + { + var options = new UpdateHostedNumberOrderOptions(pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Email = email, CcEmails = ccEmails, Status = status, VerificationCode = verificationCode, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid, Extension = extension, CallDelay = callDelay }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a specific HostedNumberOrder. + /// + /// The sid + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Email. + /// A list of emails. + /// The Status of this HostedNumberOrder. + /// A verification code. + /// Verification Type. + /// Verification Document Sid + /// Digits to dial after connecting the verification call. + /// The number of seconds, between 0 and 60, to delay before initiating the verification call. + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string uniqueName = null, + string email = null, + List ccEmails = null, + HostedNumberOrderResource.StatusEnum status = null, + string verificationCode = null, + HostedNumberOrderResource.VerificationTypeEnum verificationType = null, + string verificationDocumentSid = null, + string extension = null, + int? callDelay = null, + ITwilioRestClient client = null) + { + var options = new UpdateHostedNumberOrderOptions(pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Email = email, CcEmails = ccEmails, Status = status, VerificationCode = verificationCode, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid, Extension = extension, CallDelay = callDelay }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/HostedNumbers/HostedNumberOrders", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. + /// + /// Read HostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static ResourceSet Read(ReadHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. + /// + /// Read HostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task> ReadAsync(ReadHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. + /// + /// The Status of this HostedNumberOrder. + /// An E164 formatted phone number. + /// IncomingPhoneNumber sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static ResourceSet Read(HostedNumberOrderResource.StatusEnum status = null, + Types.PhoneNumber phoneNumber = null, + string incomingPhoneNumberSid = null, + string friendlyName = null, + string uniqueName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadHostedNumberOrderOptions() { Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of HostedNumberOrders belonging to the account initiating the request. + /// + /// The Status of this HostedNumberOrder. + /// An E164 formatted phone number. + /// IncomingPhoneNumber sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task> ReadAsync(HostedNumberOrderResource.StatusEnum status = null, + Types.PhoneNumber phoneNumber = null, + string incomingPhoneNumberSid = null, + string friendlyName = null, + string uniqueName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadHostedNumberOrderOptions() { Status = status, PhoneNumber = phoneNumber, IncomingPhoneNumberSid = incomingPhoneNumberSid, FriendlyName = friendlyName, UniqueName = uniqueName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildCreateRequest(CreateHostedNumberOrderOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/HostedNumbers/HostedNumberOrders", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Host a phone number's capability on Twilio's platform. + /// + /// Create HostedNumberOrder parameters + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Create(CreateHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Host a phone number's capability on Twilio's platform. + /// + /// Create HostedNumberOrder parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task CreateAsync(CreateHostedNumberOrderOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Host a phone number's capability on Twilio's platform. + /// + /// An E164 formatted phone number. + /// Specify SMS capability to host. + /// Account Sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// A list of emails. + /// SMS URL. + /// SMS Method. + /// SMS Fallback URL. + /// SMS Fallback Method. + /// Status Callback URL. + /// Status Callback Method. + /// SMS Application Sid. + /// Address sid. + /// Email. + /// Verification Type. + /// Verification Document Sid + /// Client to make requests to Twilio + /// A single instance of HostedNumberOrder + public static HostedNumberOrderResource Create(Types.PhoneNumber phoneNumber, + bool? smsCapability, + string accountSid = null, + string friendlyName = null, + string uniqueName = null, + List ccEmails = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string smsApplicationSid = null, + string addressSid = null, + string email = null, + HostedNumberOrderResource.VerificationTypeEnum verificationType = null, + string verificationDocumentSid = null, + ITwilioRestClient client = null) + { + var options = new CreateHostedNumberOrderOptions(phoneNumber, smsCapability) { AccountSid = accountSid, FriendlyName = friendlyName, UniqueName = uniqueName, CcEmails = ccEmails, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, SmsApplicationSid = smsApplicationSid, AddressSid = addressSid, Email = email, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Host a phone number's capability on Twilio's platform. + /// + /// An E164 formatted phone number. + /// Specify SMS capability to host. + /// Account Sid. + /// A human readable description of this resource. + /// A unique, developer assigned name of this HostedNumberOrder. + /// A list of emails. + /// SMS URL. + /// SMS Method. + /// SMS Fallback URL. + /// SMS Fallback Method. + /// Status Callback URL. + /// Status Callback Method. + /// SMS Application Sid. + /// Address sid. + /// Email. + /// Verification Type. + /// Verification Document Sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HostedNumberOrder + public static async System.Threading.Tasks.Task CreateAsync(Types.PhoneNumber phoneNumber, + bool? smsCapability, + string accountSid = null, + string friendlyName = null, + string uniqueName = null, + List ccEmails = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string smsApplicationSid = null, + string addressSid = null, + string email = null, + HostedNumberOrderResource.VerificationTypeEnum verificationType = null, + string verificationDocumentSid = null, + ITwilioRestClient client = null) + { + var options = new CreateHostedNumberOrderOptions(phoneNumber, smsCapability) { AccountSid = accountSid, FriendlyName = friendlyName, UniqueName = uniqueName, CcEmails = ccEmails, SmsUrl = smsUrl, SmsMethod = smsMethod, SmsFallbackUrl = smsFallbackUrl, SmsFallbackMethod = smsFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, SmsApplicationSid = smsApplicationSid, AddressSid = addressSid, Email = email, VerificationType = verificationType, VerificationDocumentSid = verificationDocumentSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a HostedNumberOrderResource object + /// + /// Raw JSON string + /// HostedNumberOrderResource object represented by the provided JSON + public static HostedNumberOrderResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// HostedNumberOrder sid. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// IncomingPhoneNumber sid. + /// + [JsonProperty("incoming_phone_number_sid")] + public string IncomingPhoneNumberSid { get; private set; } + /// + /// Address sid. + /// + [JsonProperty("address_sid")] + public string AddressSid { get; private set; } + /// + /// LOA document sid. + /// + [JsonProperty("signing_document_sid")] + public string SigningDocumentSid { get; private set; } + /// + /// An E164 formatted phone number. + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// A mapping of phone number capabilities. + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// A human readable description of this resource. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A unique, developer assigned name of this HostedNumberOrder. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The Status of this HostedNumberOrder. + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public HostedNumberOrderResource.StatusEnum Status { get; private set; } + /// + /// Why a hosted_number_order reached status "action-required" + /// + [JsonProperty("failure_reason")] + public string FailureReason { get; private set; } + /// + /// The date this HostedNumberOrder was created. + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this HostedNumberOrder was updated. + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The number of attempts made to verify ownership of the phone number. + /// + [JsonProperty("verification_attempts")] + public int? VerificationAttempts { get; private set; } + /// + /// Email. + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// A list of emails. + /// + [JsonProperty("cc_emails")] + public List CcEmails { get; private set; } + /// + /// The URL of this HostedNumberOrder. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The method used for verifying ownership of the number to be hosted. + /// + [JsonProperty("verification_type")] + [JsonConverter(typeof(StringEnumConverter))] + public HostedNumberOrderResource.VerificationTypeEnum VerificationType { get; private set; } + /// + /// Verification Document Sid. + /// + [JsonProperty("verification_document_sid")] + public string VerificationDocumentSid { get; private set; } + /// + /// Phone extension to use for ownership verification call. + /// + [JsonProperty("extension")] + public string Extension { get; private set; } + /// + /// Seconds (0-30) to delay ownership verification call by. + /// + [JsonProperty("call_delay")] + public int? CallDelay { get; private set; } + /// + /// The digits passed during the ownership verification call. + /// + [JsonProperty("verification_code")] + public string VerificationCode { get; private set; } + /// + /// List of IDs for ownership verification calls. + /// + [JsonProperty("verification_call_sids")] + public List VerificationCallSids { get; private set; } + + private HostedNumberOrderResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionOptions.cs b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionOptions.cs index 73ca002d8..a2d86f578 100644 --- a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionOptions.cs +++ b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionOptions.cs @@ -9,81 +9,81 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Marketplace.AvailableAddOn -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch an instance of an Extension for the Available Add-on. + /// + public class FetchAvailableAddOnExtensionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch an instance of an Extension for the Available Add-on. + /// The SID of the AvailableAddOn resource with the extension to fetch /// - public class FetchAvailableAddOnExtensionOptions : IOptions - { - /// - /// The SID of the AvailableAddOn resource with the extension to fetch - /// - public string PathAvailableAddOnSid { get; } - /// - /// The SID of the AvailableAddOn Extension resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAvailableAddOnExtensionOptions - /// - /// The SID of the AvailableAddOn resource with the extension to fetch - /// The SID of the AvailableAddOn Extension resource to fetch - public FetchAvailableAddOnExtensionOptions(string pathAvailableAddOnSid, string pathSid) - { - PathAvailableAddOnSid = pathAvailableAddOnSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAvailableAddOnSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of Extensions for the Available Add-on. + /// The SID of the AvailableAddOn Extension resource to fetch /// - public class ReadAvailableAddOnExtensionOptions : ReadOptions - { - /// - /// The SID of the AvailableAddOn resource with the extensions to read - /// - public string PathAvailableAddOnSid { get; } - - /// - /// Construct a new ReadAvailableAddOnExtensionOptions - /// - /// The SID of the AvailableAddOn resource with the extensions to read - public ReadAvailableAddOnExtensionOptions(string pathAvailableAddOnSid) - { - PathAvailableAddOnSid = pathAvailableAddOnSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchAvailableAddOnExtensionOptions + /// + /// The SID of the AvailableAddOn resource with the extension to fetch + /// The SID of the AvailableAddOn Extension resource to fetch + public FetchAvailableAddOnExtensionOptions(string pathAvailableAddOnSid, string pathSid) + { + PathAvailableAddOnSid = pathAvailableAddOnSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of Extensions for the Available Add-on. + /// + public class ReadAvailableAddOnExtensionOptions : ReadOptions + { + /// + /// The SID of the AvailableAddOn resource with the extensions to read + /// + public string PathAvailableAddOnSid { get; } + + /// + /// Construct a new ReadAvailableAddOnExtensionOptions + /// + /// The SID of the AvailableAddOn resource with the extensions to read + public ReadAvailableAddOnExtensionOptions(string pathAvailableAddOnSid) + { + PathAvailableAddOnSid = pathAvailableAddOnSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionResource.cs b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionResource.cs index 42dbbaebb..bd74f7473 100644 --- a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionResource.cs +++ b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOn/AvailableAddOnExtensionResource.cs @@ -19,272 +19,272 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Marketplace.AvailableAddOn -{ - - public class AvailableAddOnExtensionResource : Resource - { - private static Request BuildFetchRequest(FetchAvailableAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/AvailableAddOns/" + options.PathAvailableAddOnSid + "/Extensions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Extension for the Available Add-on. - /// - /// Fetch AvailableAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of AvailableAddOnExtension - public static AvailableAddOnExtensionResource Fetch(FetchAvailableAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Available Add-on. - /// - /// Fetch AvailableAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(FetchAvailableAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Extension for the Available Add-on. - /// - /// The SID of the AvailableAddOn resource with the extension to fetch - /// The SID of the AvailableAddOn Extension resource to fetch - /// Client to make requests to Twilio - /// A single instance of AvailableAddOnExtension - public static AvailableAddOnExtensionResource Fetch(string pathAvailableAddOnSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAvailableAddOnExtensionOptions(pathAvailableAddOnSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Available Add-on. - /// - /// The SID of the AvailableAddOn resource with the extension to fetch - /// The SID of the AvailableAddOn Extension resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(string pathAvailableAddOnSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAvailableAddOnExtensionOptions(pathAvailableAddOnSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAvailableAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/AvailableAddOns/" + options.PathAvailableAddOnSid + "/Extensions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Extensions for the Available Add-on. - /// - /// Read AvailableAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of AvailableAddOnExtension - public static ResourceSet Read(ReadAvailableAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Available Add-on. - /// - /// Read AvailableAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailableAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Extensions for the Available Add-on. - /// - /// The SID of the AvailableAddOn resource with the extensions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AvailableAddOnExtension - public static ResourceSet Read(string pathAvailableAddOnSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailableAddOnExtensionOptions(pathAvailableAddOnSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Available Add-on. - /// - /// The SID of the AvailableAddOn resource with the extensions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(string pathAvailableAddOnSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailableAddOnExtensionOptions(pathAvailableAddOnSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Converts a JSON string into a AvailableAddOnExtensionResource object - /// - /// Raw JSON string - /// AvailableAddOnExtensionResource object represented by the provided JSON - public static AvailableAddOnExtensionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the AvailableAddOn resource to which this extension applies - /// - [JsonProperty("available_add_on_sid")] - public string AvailableAddOnSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The name of the Extension's Product - /// - [JsonProperty("product_name")] - public string ProductName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private AvailableAddOnExtensionResource() - { - - } - } +{ + + public class AvailableAddOnExtensionResource : Resource + { + private static Request BuildFetchRequest(FetchAvailableAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/AvailableAddOns/" + options.PathAvailableAddOnSid + "/Extensions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Extension for the Available Add-on. + /// + /// Fetch AvailableAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of AvailableAddOnExtension + public static AvailableAddOnExtensionResource Fetch(FetchAvailableAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Available Add-on. + /// + /// Fetch AvailableAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(FetchAvailableAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Extension for the Available Add-on. + /// + /// The SID of the AvailableAddOn resource with the extension to fetch + /// The SID of the AvailableAddOn Extension resource to fetch + /// Client to make requests to Twilio + /// A single instance of AvailableAddOnExtension + public static AvailableAddOnExtensionResource Fetch(string pathAvailableAddOnSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAvailableAddOnExtensionOptions(pathAvailableAddOnSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Available Add-on. + /// + /// The SID of the AvailableAddOn resource with the extension to fetch + /// The SID of the AvailableAddOn Extension resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(string pathAvailableAddOnSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAvailableAddOnExtensionOptions(pathAvailableAddOnSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAvailableAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/AvailableAddOns/" + options.PathAvailableAddOnSid + "/Extensions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Extensions for the Available Add-on. + /// + /// Read AvailableAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of AvailableAddOnExtension + public static ResourceSet Read(ReadAvailableAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Available Add-on. + /// + /// Read AvailableAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailableAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Extensions for the Available Add-on. + /// + /// The SID of the AvailableAddOn resource with the extensions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AvailableAddOnExtension + public static ResourceSet Read(string pathAvailableAddOnSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailableAddOnExtensionOptions(pathAvailableAddOnSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Available Add-on. + /// + /// The SID of the AvailableAddOn resource with the extensions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(string pathAvailableAddOnSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailableAddOnExtensionOptions(pathAvailableAddOnSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Converts a JSON string into a AvailableAddOnExtensionResource object + /// + /// Raw JSON string + /// AvailableAddOnExtensionResource object represented by the provided JSON + public static AvailableAddOnExtensionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the AvailableAddOn resource to which this extension applies + /// + [JsonProperty("available_add_on_sid")] + public string AvailableAddOnSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The name of the Extension's Product + /// + [JsonProperty("product_name")] + public string ProductName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private AvailableAddOnExtensionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnOptions.cs b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnOptions.cs index 752cfd63b..148499d9c 100644 --- a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnOptions.cs +++ b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnOptions.cs @@ -9,61 +9,61 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Marketplace -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch an instance of an Add-on currently available to be installed. + /// + public class FetchAvailableAddOnOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch an instance of an Add-on currently available to be installed. + /// The SID of the AvailableAddOn resource to fetch /// - public class FetchAvailableAddOnOptions : IOptions - { - /// - /// The SID of the AvailableAddOn resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAvailableAddOnOptions - /// - /// The SID of the AvailableAddOn resource to fetch - public FetchAvailableAddOnOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of Add-ons currently available to be installed. + /// Construct a new FetchAvailableAddOnOptions /// - public class ReadAvailableAddOnOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the AvailableAddOn resource to fetch + public FetchAvailableAddOnOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of Add-ons currently available to be installed. + /// + public class ReadAvailableAddOnOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnResource.cs b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnResource.cs index 8f343efc7..b79b05e6f 100644 --- a/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnResource.cs +++ b/src/Twilio/Rest/Preview/Marketplace/AvailableAddOnResource.cs @@ -19,265 +19,265 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Marketplace -{ - - public class AvailableAddOnResource : Resource - { - private static Request BuildFetchRequest(FetchAvailableAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/AvailableAddOns/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Add-on currently available to be installed. - /// - /// Fetch AvailableAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AvailableAddOn - public static AvailableAddOnResource Fetch(FetchAvailableAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on currently available to be installed. - /// - /// Fetch AvailableAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOn - public static async System.Threading.Tasks.Task FetchAsync(FetchAvailableAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Add-on currently available to be installed. - /// - /// The SID of the AvailableAddOn resource to fetch - /// Client to make requests to Twilio - /// A single instance of AvailableAddOn - public static AvailableAddOnResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAvailableAddOnOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on currently available to be installed. - /// - /// The SID of the AvailableAddOn resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOn - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAvailableAddOnOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAvailableAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/AvailableAddOns", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Add-ons currently available to be installed. - /// - /// Read AvailableAddOn parameters - /// Client to make requests to Twilio - /// A single instance of AvailableAddOn - public static ResourceSet Read(ReadAvailableAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-ons currently available to be installed. - /// - /// Read AvailableAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOn - public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailableAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("available_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Add-ons currently available to be installed. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AvailableAddOn - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailableAddOnOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-ons currently available to be installed. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AvailableAddOn - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAvailableAddOnOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("available_add_ons", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("available_add_ons", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("available_add_ons", response.Content); - } - - /// - /// Converts a JSON string into a AvailableAddOnResource object - /// - /// Raw JSON string - /// AvailableAddOnResource object represented by the provided JSON - public static AvailableAddOnResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A short description of the Add-on's functionality - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// How customers are charged for using this Add-on - /// - [JsonProperty("pricing_type")] - public string PricingType { get; private set; } - /// - /// The JSON object with the configuration that must be provided when installing a given Add-on - /// - [JsonProperty("configuration_schema")] - public object ConfigurationSchema { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private AvailableAddOnResource() - { - - } - } +{ + + public class AvailableAddOnResource : Resource + { + private static Request BuildFetchRequest(FetchAvailableAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/AvailableAddOns/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Add-on currently available to be installed. + /// + /// Fetch AvailableAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AvailableAddOn + public static AvailableAddOnResource Fetch(FetchAvailableAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on currently available to be installed. + /// + /// Fetch AvailableAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOn + public static async System.Threading.Tasks.Task FetchAsync(FetchAvailableAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Add-on currently available to be installed. + /// + /// The SID of the AvailableAddOn resource to fetch + /// Client to make requests to Twilio + /// A single instance of AvailableAddOn + public static AvailableAddOnResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAvailableAddOnOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on currently available to be installed. + /// + /// The SID of the AvailableAddOn resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOn + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAvailableAddOnOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAvailableAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/AvailableAddOns", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Add-ons currently available to be installed. + /// + /// Read AvailableAddOn parameters + /// Client to make requests to Twilio + /// A single instance of AvailableAddOn + public static ResourceSet Read(ReadAvailableAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_add_ons", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-ons currently available to be installed. + /// + /// Read AvailableAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOn + public static async System.Threading.Tasks.Task> ReadAsync(ReadAvailableAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("available_add_ons", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Add-ons currently available to be installed. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AvailableAddOn + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailableAddOnOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-ons currently available to be installed. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AvailableAddOn + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAvailableAddOnOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("available_add_ons", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("available_add_ons", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("available_add_ons", response.Content); + } + + /// + /// Converts a JSON string into a AvailableAddOnResource object + /// + /// Raw JSON string + /// AvailableAddOnResource object represented by the provided JSON + public static AvailableAddOnResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A short description of the Add-on's functionality + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// How customers are charged for using this Add-on + /// + [JsonProperty("pricing_type")] + public string PricingType { get; private set; } + /// + /// The JSON object with the configuration that must be provided when installing a given Add-on + /// + [JsonProperty("configuration_schema")] + public object ConfigurationSchema { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private AvailableAddOnResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionOptions.cs b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionOptions.cs index d0fb0e712..e5ee0d08c 100644 --- a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionOptions.cs +++ b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionOptions.cs @@ -9,130 +9,130 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Marketplace.InstalledAddOn -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch an instance of an Extension for the Installed Add-on. + /// + public class FetchInstalledAddOnExtensionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch an instance of an Extension for the Installed Add-on. + /// The SID of the InstalledAddOn resource with the extension to fetch /// - public class FetchInstalledAddOnExtensionOptions : IOptions - { - /// - /// The SID of the InstalledAddOn resource with the extension to fetch - /// - public string PathInstalledAddOnSid { get; } - /// - /// The SID of the InstalledAddOn Extension resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInstalledAddOnExtensionOptions - /// - /// The SID of the InstalledAddOn resource with the extension to fetch - /// The SID of the InstalledAddOn Extension resource to fetch - public FetchInstalledAddOnExtensionOptions(string pathInstalledAddOnSid, string pathSid) - { - PathInstalledAddOnSid = pathInstalledAddOnSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathInstalledAddOnSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update an Extension for an Add-on installation. + /// The SID of the InstalledAddOn Extension resource to fetch /// - public class UpdateInstalledAddOnExtensionOptions : IOptions - { - /// - /// The SID of the InstalledAddOn resource with the extension to update - /// - public string PathInstalledAddOnSid { get; } - /// - /// The SID of the InstalledAddOn Extension resource to update - /// - public string PathSid { get; } - /// - /// Whether the Extension should be invoked - /// - public bool? Enabled { get; } - - /// - /// Construct a new UpdateInstalledAddOnExtensionOptions - /// - /// The SID of the InstalledAddOn resource with the extension to update - /// The SID of the InstalledAddOn Extension resource to update - /// Whether the Extension should be invoked - public UpdateInstalledAddOnExtensionOptions(string pathInstalledAddOnSid, string pathSid, bool? enabled) - { - PathInstalledAddOnSid = pathInstalledAddOnSid; - PathSid = pathSid; - Enabled = enabled; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of Extensions for the Installed Add-on. + /// Construct a new FetchInstalledAddOnExtensionOptions /// - public class ReadInstalledAddOnExtensionOptions : ReadOptions - { - /// - /// The SID of the InstalledAddOn resource with the extensions to read - /// - public string PathInstalledAddOnSid { get; } - - /// - /// Construct a new ReadInstalledAddOnExtensionOptions - /// - /// The SID of the InstalledAddOn resource with the extensions to read - public ReadInstalledAddOnExtensionOptions(string pathInstalledAddOnSid) - { - PathInstalledAddOnSid = pathInstalledAddOnSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the InstalledAddOn resource with the extension to fetch + /// The SID of the InstalledAddOn Extension resource to fetch + public FetchInstalledAddOnExtensionOptions(string pathInstalledAddOnSid, string pathSid) + { + PathInstalledAddOnSid = pathInstalledAddOnSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update an Extension for an Add-on installation. + /// + public class UpdateInstalledAddOnExtensionOptions : IOptions + { + /// + /// The SID of the InstalledAddOn resource with the extension to update + /// + public string PathInstalledAddOnSid { get; } + /// + /// The SID of the InstalledAddOn Extension resource to update + /// + public string PathSid { get; } + /// + /// Whether the Extension should be invoked + /// + public bool? Enabled { get; } + + /// + /// Construct a new UpdateInstalledAddOnExtensionOptions + /// + /// The SID of the InstalledAddOn resource with the extension to update + /// The SID of the InstalledAddOn Extension resource to update + /// Whether the Extension should be invoked + public UpdateInstalledAddOnExtensionOptions(string pathInstalledAddOnSid, string pathSid, bool? enabled) + { + PathInstalledAddOnSid = pathInstalledAddOnSid; + PathSid = pathSid; + Enabled = enabled; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of Extensions for the Installed Add-on. + /// + public class ReadInstalledAddOnExtensionOptions : ReadOptions + { + /// + /// The SID of the InstalledAddOn resource with the extensions to read + /// + public string PathInstalledAddOnSid { get; } + + /// + /// Construct a new ReadInstalledAddOnExtensionOptions + /// + /// The SID of the InstalledAddOn resource with the extensions to read + public ReadInstalledAddOnExtensionOptions(string pathInstalledAddOnSid) + { + PathInstalledAddOnSid = pathInstalledAddOnSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionResource.cs b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionResource.cs index 61a3d62dd..c765db8b4 100644 --- a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionResource.cs +++ b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOn/InstalledAddOnExtensionResource.cs @@ -19,354 +19,354 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Marketplace.InstalledAddOn -{ - - public class InstalledAddOnExtensionResource : Resource - { - private static Request BuildFetchRequest(FetchInstalledAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Extension for the Installed Add-on. - /// - /// Fetch InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static InstalledAddOnExtensionResource Fetch(FetchInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Installed Add-on. - /// - /// Fetch InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(FetchInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Extension for the Installed Add-on. - /// - /// The SID of the InstalledAddOn resource with the extension to fetch - /// The SID of the InstalledAddOn Extension resource to fetch - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static InstalledAddOnExtensionResource Fetch(string pathInstalledAddOnSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Extension for the Installed Add-on. - /// - /// The SID of the InstalledAddOn resource with the extension to fetch - /// The SID of the InstalledAddOn Extension resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task FetchAsync(string pathInstalledAddOnSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateInstalledAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an Extension for an Add-on installation. - /// - /// Update InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static InstalledAddOnExtensionResource Update(UpdateInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an Extension for an Add-on installation. - /// - /// Update InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task UpdateAsync(UpdateInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an Extension for an Add-on installation. - /// - /// The SID of the InstalledAddOn resource with the extension to update - /// The SID of the InstalledAddOn Extension resource to update - /// Whether the Extension should be invoked - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static InstalledAddOnExtensionResource Update(string pathInstalledAddOnSid, - string pathSid, - bool? enabled, - ITwilioRestClient client = null) - { - var options = new UpdateInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid, enabled); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an Extension for an Add-on installation. - /// - /// The SID of the InstalledAddOn resource with the extension to update - /// The SID of the InstalledAddOn Extension resource to update - /// Whether the Extension should be invoked - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task UpdateAsync(string pathInstalledAddOnSid, - string pathSid, - bool? enabled, - ITwilioRestClient client = null) - { - var options = new UpdateInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid, enabled); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInstalledAddOnExtensionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Extensions for the Installed Add-on. - /// - /// Read InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static ResourceSet Read(ReadInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Installed Add-on. - /// - /// Read InstalledAddOnExtension parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(ReadInstalledAddOnExtensionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("extensions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Extensions for the Installed Add-on. - /// - /// The SID of the InstalledAddOn resource with the extensions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of InstalledAddOnExtension - public static ResourceSet Read(string pathInstalledAddOnSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInstalledAddOnExtensionOptions(pathInstalledAddOnSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Extensions for the Installed Add-on. - /// - /// The SID of the InstalledAddOn resource with the extensions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOnExtension - public static async System.Threading.Tasks.Task> ReadAsync(string pathInstalledAddOnSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInstalledAddOnExtensionOptions(pathInstalledAddOnSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("extensions", response.Content); - } - - /// - /// Converts a JSON string into a InstalledAddOnExtensionResource object - /// - /// Raw JSON string - /// InstalledAddOnExtensionResource object represented by the provided JSON - public static InstalledAddOnExtensionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the InstalledAddOn resource to which this extension applies - /// - [JsonProperty("installed_add_on_sid")] - public string InstalledAddOnSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The name of the Extension's Product - /// - [JsonProperty("product_name")] - public string ProductName { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// Whether the Extension will be invoked - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InstalledAddOnExtensionResource() - { - - } - } +{ + + public class InstalledAddOnExtensionResource : Resource + { + private static Request BuildFetchRequest(FetchInstalledAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Extension for the Installed Add-on. + /// + /// Fetch InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static InstalledAddOnExtensionResource Fetch(FetchInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Installed Add-on. + /// + /// Fetch InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(FetchInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Extension for the Installed Add-on. + /// + /// The SID of the InstalledAddOn resource with the extension to fetch + /// The SID of the InstalledAddOn Extension resource to fetch + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static InstalledAddOnExtensionResource Fetch(string pathInstalledAddOnSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Extension for the Installed Add-on. + /// + /// The SID of the InstalledAddOn resource with the extension to fetch + /// The SID of the InstalledAddOn Extension resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task FetchAsync(string pathInstalledAddOnSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateInstalledAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an Extension for an Add-on installation. + /// + /// Update InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static InstalledAddOnExtensionResource Update(UpdateInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an Extension for an Add-on installation. + /// + /// Update InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task UpdateAsync(UpdateInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an Extension for an Add-on installation. + /// + /// The SID of the InstalledAddOn resource with the extension to update + /// The SID of the InstalledAddOn Extension resource to update + /// Whether the Extension should be invoked + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static InstalledAddOnExtensionResource Update(string pathInstalledAddOnSid, + string pathSid, + bool? enabled, + ITwilioRestClient client = null) + { + var options = new UpdateInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid, enabled); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an Extension for an Add-on installation. + /// + /// The SID of the InstalledAddOn resource with the extension to update + /// The SID of the InstalledAddOn Extension resource to update + /// Whether the Extension should be invoked + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task UpdateAsync(string pathInstalledAddOnSid, + string pathSid, + bool? enabled, + ITwilioRestClient client = null) + { + var options = new UpdateInstalledAddOnExtensionOptions(pathInstalledAddOnSid, pathSid, enabled); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInstalledAddOnExtensionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathInstalledAddOnSid + "/Extensions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Extensions for the Installed Add-on. + /// + /// Read InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static ResourceSet Read(ReadInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Installed Add-on. + /// + /// Read InstalledAddOnExtension parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(ReadInstalledAddOnExtensionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("extensions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Extensions for the Installed Add-on. + /// + /// The SID of the InstalledAddOn resource with the extensions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of InstalledAddOnExtension + public static ResourceSet Read(string pathInstalledAddOnSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInstalledAddOnExtensionOptions(pathInstalledAddOnSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Extensions for the Installed Add-on. + /// + /// The SID of the InstalledAddOn resource with the extensions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOnExtension + public static async System.Threading.Tasks.Task> ReadAsync(string pathInstalledAddOnSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInstalledAddOnExtensionOptions(pathInstalledAddOnSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("extensions", response.Content); + } + + /// + /// Converts a JSON string into a InstalledAddOnExtensionResource object + /// + /// Raw JSON string + /// InstalledAddOnExtensionResource object represented by the provided JSON + public static InstalledAddOnExtensionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the InstalledAddOn resource to which this extension applies + /// + [JsonProperty("installed_add_on_sid")] + public string InstalledAddOnSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The name of the Extension's Product + /// + [JsonProperty("product_name")] + public string ProductName { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// Whether the Extension will be invoked + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InstalledAddOnExtensionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnOptions.cs b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnOptions.cs index c77ce3a0c..5d6c13754 100644 --- a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnOptions.cs +++ b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnOptions.cs @@ -9,209 +9,209 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Marketplace -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Install an Add-on for the Account specified. + /// + public class CreateInstalledAddOnOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Install an Add-on for the Account specified. - /// - public class CreateInstalledAddOnOptions : IOptions - { - /// - /// The SID of the AvaliableAddOn to install - /// - public string AvailableAddOnSid { get; } - /// - /// Whether the Terms of Service were accepted - /// - public bool? AcceptTermsOfService { get; } - /// - /// The JSON object representing the configuration - /// - public object Configuration { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new CreateInstalledAddOnOptions - /// - /// The SID of the AvaliableAddOn to install - /// Whether the Terms of Service were accepted - public CreateInstalledAddOnOptions(string availableAddOnSid, bool? acceptTermsOfService) - { - AvailableAddOnSid = availableAddOnSid; - AcceptTermsOfService = acceptTermsOfService; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AvailableAddOnSid != null) - { - p.Add(new KeyValuePair("AvailableAddOnSid", AvailableAddOnSid.ToString())); - } - - if (AcceptTermsOfService != null) - { - p.Add(new KeyValuePair("AcceptTermsOfService", AcceptTermsOfService.Value.ToString().ToLower())); - } - - if (Configuration != null) - { - p.Add(new KeyValuePair("Configuration", Serializers.JsonObject(Configuration))); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// The SID of the AvaliableAddOn to install + /// + public string AvailableAddOnSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Remove an Add-on installation from your account - /// - public class DeleteInstalledAddOnOptions : IOptions - { - /// - /// The SID of the InstalledAddOn resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInstalledAddOnOptions - /// - /// The SID of the InstalledAddOn resource to delete - public DeleteInstalledAddOnOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Whether the Terms of Service were accepted + /// + public bool? AcceptTermsOfService { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch an instance of an Add-on currently installed on this Account. - /// - public class FetchInstalledAddOnOptions : IOptions - { - /// - /// The SID of the InstalledAddOn resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInstalledAddOnOptions - /// - /// The SID of the InstalledAddOn resource to fetch - public FetchInstalledAddOnOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The JSON object representing the configuration + /// + public object Configuration { get; set; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update an Add-on installation for the Account specified. - /// - public class UpdateInstalledAddOnOptions : IOptions - { - /// - /// The SID of the InstalledAddOn resource to update - /// - public string PathSid { get; } - /// - /// The JSON object representing the configuration - /// - public object Configuration { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateInstalledAddOnOptions - /// - /// The SID of the InstalledAddOn resource to update - public UpdateInstalledAddOnOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Configuration != null) - { - p.Add(new KeyValuePair("Configuration", Serializers.JsonObject(Configuration))); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of Add-ons currently installed on this Account. - /// - public class ReadInstalledAddOnOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Construct a new CreateInstalledAddOnOptions + /// + /// The SID of the AvaliableAddOn to install + /// Whether the Terms of Service were accepted + public CreateInstalledAddOnOptions(string availableAddOnSid, bool? acceptTermsOfService) + { + AvailableAddOnSid = availableAddOnSid; + AcceptTermsOfService = acceptTermsOfService; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AvailableAddOnSid != null) + { + p.Add(new KeyValuePair("AvailableAddOnSid", AvailableAddOnSid.ToString())); + } + + if (AcceptTermsOfService != null) + { + p.Add(new KeyValuePair("AcceptTermsOfService", AcceptTermsOfService.Value.ToString().ToLower())); + } + + if (Configuration != null) + { + p.Add(new KeyValuePair("Configuration", Serializers.JsonObject(Configuration))); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Remove an Add-on installation from your account + /// + public class DeleteInstalledAddOnOptions : IOptions + { + /// + /// The SID of the InstalledAddOn resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInstalledAddOnOptions + /// + /// The SID of the InstalledAddOn resource to delete + public DeleteInstalledAddOnOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch an instance of an Add-on currently installed on this Account. + /// + public class FetchInstalledAddOnOptions : IOptions + { + /// + /// The SID of the InstalledAddOn resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchInstalledAddOnOptions + /// + /// The SID of the InstalledAddOn resource to fetch + public FetchInstalledAddOnOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update an Add-on installation for the Account specified. + /// + public class UpdateInstalledAddOnOptions : IOptions + { + /// + /// The SID of the InstalledAddOn resource to update + /// + public string PathSid { get; } + /// + /// The JSON object representing the configuration + /// + public object Configuration { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateInstalledAddOnOptions + /// + /// The SID of the InstalledAddOn resource to update + public UpdateInstalledAddOnOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Configuration != null) + { + p.Add(new KeyValuePair("Configuration", Serializers.JsonObject(Configuration))); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of Add-ons currently installed on this Account. + /// + public class ReadInstalledAddOnOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnResource.cs b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnResource.cs index 458e182b1..621b7f4b2 100644 --- a/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnResource.cs +++ b/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnResource.cs @@ -19,502 +19,502 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Marketplace -{ - - public class InstalledAddOnResource : Resource - { - private static Request BuildCreateRequest(CreateInstalledAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Install an Add-on for the Account specified. - /// - /// Create InstalledAddOn parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Create(CreateInstalledAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Install an Add-on for the Account specified. - /// - /// Create InstalledAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task CreateAsync(CreateInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Install an Add-on for the Account specified. - /// - /// The SID of the AvaliableAddOn to install - /// Whether the Terms of Service were accepted - /// The JSON object representing the configuration - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Create(string availableAddOnSid, - bool? acceptTermsOfService, - object configuration = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateInstalledAddOnOptions(availableAddOnSid, acceptTermsOfService){Configuration = configuration, UniqueName = uniqueName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Install an Add-on for the Account specified. - /// - /// The SID of the AvaliableAddOn to install - /// Whether the Terms of Service were accepted - /// The JSON object representing the configuration - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task CreateAsync(string availableAddOnSid, - bool? acceptTermsOfService, - object configuration = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateInstalledAddOnOptions(availableAddOnSid, acceptTermsOfService){Configuration = configuration, UniqueName = uniqueName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteInstalledAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Add-on installation from your account - /// - /// Delete InstalledAddOn parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static bool Delete(DeleteInstalledAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Add-on installation from your account - /// - /// Delete InstalledAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Add-on installation from your account - /// - /// The SID of the InstalledAddOn resource to delete - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteInstalledAddOnOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Add-on installation from your account - /// - /// The SID of the InstalledAddOn resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteInstalledAddOnOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchInstalledAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch an instance of an Add-on currently installed on this Account. - /// - /// Fetch InstalledAddOn parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Fetch(FetchInstalledAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on currently installed on this Account. - /// - /// Fetch InstalledAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task FetchAsync(FetchInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch an instance of an Add-on currently installed on this Account. - /// - /// The SID of the InstalledAddOn resource to fetch - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchInstalledAddOnOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch an instance of an Add-on currently installed on this Account. - /// - /// The SID of the InstalledAddOn resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInstalledAddOnOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateInstalledAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an Add-on installation for the Account specified. - /// - /// Update InstalledAddOn parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Update(UpdateInstalledAddOnOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an Add-on installation for the Account specified. - /// - /// Update InstalledAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task UpdateAsync(UpdateInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an Add-on installation for the Account specified. - /// - /// The SID of the InstalledAddOn resource to update - /// The JSON object representing the configuration - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static InstalledAddOnResource Update(string pathSid, - object configuration = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateInstalledAddOnOptions(pathSid){Configuration = configuration, UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an Add-on installation for the Account specified. - /// - /// The SID of the InstalledAddOn resource to update - /// The JSON object representing the configuration - /// An application-defined string that uniquely identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - object configuration = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateInstalledAddOnOptions(pathSid){Configuration = configuration, UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInstalledAddOnOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/marketplace/InstalledAddOns", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Add-ons currently installed on this Account. - /// - /// Read InstalledAddOn parameters - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static ResourceSet Read(ReadInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("installed_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-ons currently installed on this Account. - /// - /// Read InstalledAddOn parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task> ReadAsync(ReadInstalledAddOnOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("installed_add_ons", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Add-ons currently installed on this Account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of InstalledAddOn - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInstalledAddOnOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Add-ons currently installed on this Account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of InstalledAddOn - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInstalledAddOnOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("installed_add_ons", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("installed_add_ons", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("installed_add_ons", response.Content); - } - - /// - /// Converts a JSON string into a InstalledAddOnResource object - /// - /// Raw JSON string - /// InstalledAddOnResource object represented by the provided JSON - public static InstalledAddOnResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A short description of the Add-on's functionality - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The JSON object that represents the current configuration of installed Add-on - /// - [JsonProperty("configuration")] - public object Configuration { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private InstalledAddOnResource() - { - - } - } +{ + + public class InstalledAddOnResource : Resource + { + private static Request BuildCreateRequest(CreateInstalledAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Install an Add-on for the Account specified. + /// + /// Create InstalledAddOn parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Create(CreateInstalledAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Install an Add-on for the Account specified. + /// + /// Create InstalledAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task CreateAsync(CreateInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Install an Add-on for the Account specified. + /// + /// The SID of the AvaliableAddOn to install + /// Whether the Terms of Service were accepted + /// The JSON object representing the configuration + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Create(string availableAddOnSid, + bool? acceptTermsOfService, + object configuration = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateInstalledAddOnOptions(availableAddOnSid, acceptTermsOfService) { Configuration = configuration, UniqueName = uniqueName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Install an Add-on for the Account specified. + /// + /// The SID of the AvaliableAddOn to install + /// Whether the Terms of Service were accepted + /// The JSON object representing the configuration + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task CreateAsync(string availableAddOnSid, + bool? acceptTermsOfService, + object configuration = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateInstalledAddOnOptions(availableAddOnSid, acceptTermsOfService) { Configuration = configuration, UniqueName = uniqueName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteInstalledAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Add-on installation from your account + /// + /// Delete InstalledAddOn parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static bool Delete(DeleteInstalledAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Add-on installation from your account + /// + /// Delete InstalledAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Add-on installation from your account + /// + /// The SID of the InstalledAddOn resource to delete + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteInstalledAddOnOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Add-on installation from your account + /// + /// The SID of the InstalledAddOn resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteInstalledAddOnOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchInstalledAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch an instance of an Add-on currently installed on this Account. + /// + /// Fetch InstalledAddOn parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Fetch(FetchInstalledAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on currently installed on this Account. + /// + /// Fetch InstalledAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task FetchAsync(FetchInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch an instance of an Add-on currently installed on this Account. + /// + /// The SID of the InstalledAddOn resource to fetch + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchInstalledAddOnOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch an instance of an Add-on currently installed on this Account. + /// + /// The SID of the InstalledAddOn resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInstalledAddOnOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateInstalledAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an Add-on installation for the Account specified. + /// + /// Update InstalledAddOn parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Update(UpdateInstalledAddOnOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an Add-on installation for the Account specified. + /// + /// Update InstalledAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task UpdateAsync(UpdateInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an Add-on installation for the Account specified. + /// + /// The SID of the InstalledAddOn resource to update + /// The JSON object representing the configuration + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static InstalledAddOnResource Update(string pathSid, + object configuration = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateInstalledAddOnOptions(pathSid) { Configuration = configuration, UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an Add-on installation for the Account specified. + /// + /// The SID of the InstalledAddOn resource to update + /// The JSON object representing the configuration + /// An application-defined string that uniquely identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + object configuration = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateInstalledAddOnOptions(pathSid) { Configuration = configuration, UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInstalledAddOnOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/marketplace/InstalledAddOns", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Add-ons currently installed on this Account. + /// + /// Read InstalledAddOn parameters + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static ResourceSet Read(ReadInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("installed_add_ons", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-ons currently installed on this Account. + /// + /// Read InstalledAddOn parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task> ReadAsync(ReadInstalledAddOnOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("installed_add_ons", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Add-ons currently installed on this Account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of InstalledAddOn + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInstalledAddOnOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Add-ons currently installed on this Account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of InstalledAddOn + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInstalledAddOnOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("installed_add_ons", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("installed_add_ons", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("installed_add_ons", response.Content); + } + + /// + /// Converts a JSON string into a InstalledAddOnResource object + /// + /// Raw JSON string + /// InstalledAddOnResource object represented by the provided JSON + public static InstalledAddOnResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A short description of the Add-on's functionality + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The JSON object that represents the current configuration of installed Add-on + /// + [JsonProperty("configuration")] + public object Configuration { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private InstalledAddOnResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionOptions.cs index f65c1eac7..4b5debf74 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service.Document -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Sync Document Permission. + /// + public class FetchDocumentPermissionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Sync Document Permission. - /// - public class FetchDocumentPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Document SID or unique name. - /// - public string PathDocumentSid { get; } - /// - /// Identity of the user to whom the Sync Document Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchDocumentPermissionOptions - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - public FetchDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Sync Document Permission. - /// - public class DeleteDocumentPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Document SID or unique name. - /// - public string PathDocumentSid { get; } - /// - /// Identity of the user to whom the Sync Document Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteDocumentPermissionOptions - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - public DeleteDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Sync Document SID or unique name. + /// + public string PathDocumentSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - public class ReadDocumentPermissionOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Document SID or unique name. - /// - public string PathDocumentSid { get; } - - /// - /// Construct a new ReadDocumentPermissionOptions - /// - /// The service_sid - /// Sync Document SID or unique name. - public ReadDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Identity of the user to whom the Sync Document Permission applies. + /// + public string PathIdentity { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update an identity's access to a specific Sync Document. - /// - public class UpdateDocumentPermissionOptions : IOptions - { - /// - /// Sync Service Instance SID. - /// - public string PathServiceSid { get; } - /// - /// Sync Document SID or unique name. - /// - public string PathDocumentSid { get; } - /// - /// Identity of the user to whom the Sync Document Permission applies. - /// - public string PathIdentity { get; } - /// - /// Read access. - /// - public bool? Read { get; } - /// - /// Write access. - /// - public bool? Write { get; } - /// - /// Manage access. - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateDocumentPermissionOptions - /// - /// Sync Service Instance SID. - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Read access. - /// Write access. - /// Manage access. - public UpdateDocumentPermissionOptions(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchDocumentPermissionOptions + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + public FetchDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Sync Document Permission. + /// + public class DeleteDocumentPermissionOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync Document SID or unique name. + /// + public string PathDocumentSid { get; } + /// + /// Identity of the user to whom the Sync Document Permission applies. + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteDocumentPermissionOptions + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + public DeleteDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + public class ReadDocumentPermissionOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync Document SID or unique name. + /// + public string PathDocumentSid { get; } + + /// + /// Construct a new ReadDocumentPermissionOptions + /// + /// The service_sid + /// Sync Document SID or unique name. + public ReadDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update an identity's access to a specific Sync Document. + /// + public class UpdateDocumentPermissionOptions : IOptions + { + /// + /// Sync Service Instance SID. + /// + public string PathServiceSid { get; } + /// + /// Sync Document SID or unique name. + /// + public string PathDocumentSid { get; } + /// + /// Identity of the user to whom the Sync Document Permission applies. + /// + public string PathIdentity { get; } + /// + /// Read access. + /// + public bool? Read { get; } + /// + /// Write access. + /// + public bool? Write { get; } + /// + /// Manage access. + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateDocumentPermissionOptions + /// + /// Sync Service Instance SID. + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Read access. + /// Write access. + /// Manage access. + public UpdateDocumentPermissionOptions(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionResource.cs b/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionResource.cs index d34d76af3..38bb26206 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/Document/DocumentPermissionResource.cs @@ -19,455 +19,455 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service.Document -{ - - public class DocumentPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync Document Permission. - /// - /// Fetch DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Fetch(FetchDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync Document Permission. - /// - /// Fetch DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync Document Permission. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Fetch(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync Document Permission. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync Document Permission. - /// - /// Delete DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static bool Delete(DeleteDocumentPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync Document Permission. - /// - /// Delete DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync Document Permission. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static bool Delete(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync Document Permission. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// Read DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static ResourceSet Read(ReadDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// Read DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static ResourceSet Read(string pathServiceSid, - string pathDocumentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// The service_sid - /// Sync Document SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathDocumentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Update DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Update(UpdateDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Update DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Sync Service Instance SID. - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Update(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Sync Service Instance SID. - /// Sync Document SID or unique name. - /// Identity of the user to whom the Sync Document Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DocumentPermissionResource object - /// - /// Raw JSON string - /// DocumentPermissionResource object represented by the provided JSON - public static DocumentPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Twilio Account SID. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Sync Service Instance SID. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Sync Document SID. - /// - [JsonProperty("document_sid")] - public string DocumentSid { get; private set; } - /// - /// Identity of the user to whom the Sync Document Permission applies. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access. - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access. - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access. - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// URL of this Sync Document Permission. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DocumentPermissionResource() - { - - } - } +{ + + public class DocumentPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync Document Permission. + /// + /// Fetch DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Fetch(FetchDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync Document Permission. + /// + /// Fetch DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync Document Permission. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Fetch(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync Document Permission. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync Document Permission. + /// + /// Delete DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static bool Delete(DeleteDocumentPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync Document Permission. + /// + /// Delete DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync Document Permission. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static bool Delete(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync Document Permission. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// Read DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static ResourceSet Read(ReadDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// Read DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static ResourceSet Read(string pathServiceSid, + string pathDocumentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// The service_sid + /// Sync Document SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathDocumentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Update DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Update(UpdateDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Update DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Sync Service Instance SID. + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Update(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Sync Service Instance SID. + /// Sync Document SID or unique name. + /// Identity of the user to whom the Sync Document Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DocumentPermissionResource object + /// + /// Raw JSON string + /// DocumentPermissionResource object represented by the provided JSON + public static DocumentPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Twilio Account SID. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Sync Service Instance SID. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Sync Document SID. + /// + [JsonProperty("document_sid")] + public string DocumentSid { get; private set; } + /// + /// Identity of the user to whom the Sync Document Permission applies. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access. + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access. + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access. + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// URL of this Sync Document Permission. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DocumentPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/DocumentOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/DocumentOptions.cs index b02a85ccd..23ffcd5a0 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/DocumentOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/DocumentOptions.cs @@ -9,236 +9,236 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchDocumentOptions + /// + public class FetchDocumentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchDocumentOptions - /// - public class FetchDocumentOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDocumentOptions - /// - /// The service_sid - /// The sid - public FetchDocumentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteDocumentOptions - /// - public class DeleteDocumentOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteDocumentOptions - /// - /// The service_sid - /// The sid - public DeleteDocumentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateDocumentOptions - /// - public class CreateDocumentOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The data - /// - public object Data { get; set; } - - /// - /// Construct a new CreateDocumentOptions - /// - /// The service_sid - public CreateDocumentOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - } - + /// Construct a new FetchDocumentOptions + /// + /// The service_sid + /// The sid + public FetchDocumentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadDocumentOptions - /// - public class ReadDocumentOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadDocumentOptions - /// - /// The service_sid - public ReadDocumentOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteDocumentOptions + /// + public class DeleteDocumentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateDocumentOptions - /// - public class UpdateDocumentOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The data - /// - public object Data { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateDocumentOptions - /// - /// The service_sid - /// The sid - /// The data - public UpdateDocumentOptions(string pathServiceSid, string pathSid, object data) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteDocumentOptions + /// + /// The service_sid + /// The sid + public DeleteDocumentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateDocumentOptions + /// + public class CreateDocumentOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The data + /// + public object Data { get; set; } + + /// + /// Construct a new CreateDocumentOptions + /// + /// The service_sid + public CreateDocumentOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadDocumentOptions + /// + public class ReadDocumentOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadDocumentOptions + /// + /// The service_sid + public ReadDocumentOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateDocumentOptions + /// + public class UpdateDocumentOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The data + /// + public object Data { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateDocumentOptions + /// + /// The service_sid + /// The sid + /// The data + public UpdateDocumentOptions(string pathServiceSid, string pathSid, object data) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/DocumentResource.cs b/src/Twilio/Rest/Preview/Sync/Service/DocumentResource.cs index 57f87e2d8..b5c040232 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/DocumentResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/DocumentResource.cs @@ -19,517 +19,517 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service -{ - - public class DocumentResource : Resource - { - private static Request BuildFetchRequest(FetchDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Fetch(FetchDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDocumentOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDocumentOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static bool Delete(DeleteDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Document - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteDocumentOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Create(CreateDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task CreateAsync(CreateDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The unique_name - /// The data - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Create(string pathServiceSid, - string uniqueName = null, - object data = null, - ITwilioRestClient client = null) - { - var options = new CreateDocumentOptions(pathServiceSid){UniqueName = uniqueName, Data = data}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The unique_name - /// The data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - object data = null, - ITwilioRestClient client = null) - { - var options = new CreateDocumentOptions(pathServiceSid){UniqueName = uniqueName, Data = data}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static ResourceSet Read(ReadDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("documents", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("documents", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Document - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Update(UpdateDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The sid - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Update(string pathServiceSid, - string pathSid, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentOptions(pathServiceSid, pathSid, data){IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The sid - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentOptions(pathServiceSid, pathSid, data){IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DocumentResource object - /// - /// Raw JSON string - /// DocumentResource object represented by the provided JSON - public static DocumentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The revision - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private DocumentResource() - { - - } - } +{ + + public class DocumentResource : Resource + { + private static Request BuildFetchRequest(FetchDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Fetch(FetchDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDocumentOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDocumentOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static bool Delete(DeleteDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Document + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteDocumentOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Create(CreateDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task CreateAsync(CreateDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The unique_name + /// The data + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Create(string pathServiceSid, + string uniqueName = null, + object data = null, + ITwilioRestClient client = null) + { + var options = new CreateDocumentOptions(pathServiceSid) { UniqueName = uniqueName, Data = data }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The unique_name + /// The data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + object data = null, + ITwilioRestClient client = null) + { + var options = new CreateDocumentOptions(pathServiceSid) { UniqueName = uniqueName, Data = data }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static ResourceSet Read(ReadDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("documents", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("documents", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Document + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Update(UpdateDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The sid + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Update(string pathServiceSid, + string pathSid, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentOptions(pathServiceSid, pathSid, data) { IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The sid + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentOptions(pathServiceSid, pathSid, data) { IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DocumentResource object + /// + /// Raw JSON string + /// DocumentResource object represented by the provided JSON + public static DocumentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The revision + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private DocumentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemOptions.cs index 4c7b98a45..09830345a 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemOptions.cs @@ -9,304 +9,304 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service.SyncList -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSyncListItemOptions + /// + public class FetchSyncListItemOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSyncListItemOptions - /// - public class FetchSyncListItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The list_sid - /// - public string PathListSid { get; } - /// - /// The index - /// - public int? PathIndex { get; } - - /// - /// Construct a new FetchSyncListItemOptions - /// - /// The service_sid - /// The list_sid - /// The index - public FetchSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSyncListItemOptions - /// - public class DeleteSyncListItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The list_sid - /// - public string PathListSid { get; } - /// - /// The index - /// - public int? PathIndex { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteSyncListItemOptions - /// - /// The service_sid - /// The list_sid - /// The index - public DeleteSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// The list_sid + /// + public string PathListSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSyncListItemOptions - /// - public class CreateSyncListItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The list_sid - /// - public string PathListSid { get; } - /// - /// The data - /// - public object Data { get; } - - /// - /// Construct a new CreateSyncListItemOptions - /// - /// The service_sid - /// The list_sid - /// The data - public CreateSyncListItemOptions(string pathServiceSid, string pathListSid, object data) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - } - + /// The index + /// + public int? PathIndex { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSyncListItemOptions - /// - public class ReadSyncListItemOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The list_sid - /// - public string PathListSid { get; } - /// - /// The order - /// - public SyncListItemResource.QueryResultOrderEnum Order { get; set; } - /// - /// The from - /// - public string From { get; set; } - /// - /// The bounds - /// - public SyncListItemResource.QueryFromBoundTypeEnum Bounds { get; set; } - - /// - /// Construct a new ReadSyncListItemOptions - /// - /// The service_sid - /// The list_sid - public ReadSyncListItemOptions(string pathServiceSid, string pathListSid) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Bounds != null) - { - p.Add(new KeyValuePair("Bounds", Bounds.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncListItemOptions + /// + /// The service_sid + /// The list_sid + /// The index + public FetchSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateSyncListItemOptions - /// - public class UpdateSyncListItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The list_sid - /// - public string PathListSid { get; } - /// - /// The index - /// - public int? PathIndex { get; } - /// - /// The data - /// - public object Data { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateSyncListItemOptions - /// - /// The service_sid - /// The list_sid - /// The index - /// The data - public UpdateSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex, object data) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSyncListItemOptions + /// + public class DeleteSyncListItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The list_sid + /// + public string PathListSid { get; } + /// + /// The index + /// + public int? PathIndex { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteSyncListItemOptions + /// + /// The service_sid + /// The list_sid + /// The index + public DeleteSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSyncListItemOptions + /// + public class CreateSyncListItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The list_sid + /// + public string PathListSid { get; } + /// + /// The data + /// + public object Data { get; } + + /// + /// Construct a new CreateSyncListItemOptions + /// + /// The service_sid + /// The list_sid + /// The data + public CreateSyncListItemOptions(string pathServiceSid, string pathListSid, object data) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSyncListItemOptions + /// + public class ReadSyncListItemOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The list_sid + /// + public string PathListSid { get; } + /// + /// The order + /// + public SyncListItemResource.QueryResultOrderEnum Order { get; set; } + /// + /// The from + /// + public string From { get; set; } + /// + /// The bounds + /// + public SyncListItemResource.QueryFromBoundTypeEnum Bounds { get; set; } + + /// + /// Construct a new ReadSyncListItemOptions + /// + /// The service_sid + /// The list_sid + public ReadSyncListItemOptions(string pathServiceSid, string pathListSid) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Bounds != null) + { + p.Add(new KeyValuePair("Bounds", Bounds.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateSyncListItemOptions + /// + public class UpdateSyncListItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The list_sid + /// + public string PathListSid { get; } + /// + /// The index + /// + public int? PathIndex { get; } + /// + /// The data + /// + public object Data { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateSyncListItemOptions + /// + /// The service_sid + /// The list_sid + /// The index + /// The data + public UpdateSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex, object data) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemResource.cs index f3dc7e1bf..446a172b6 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListItemResource.cs @@ -20,575 +20,575 @@ using Twilio.Types; namespace Twilio.Rest.Preview.Sync.Service.SyncList -{ - - public class SyncListItemResource : Resource - { - public sealed class QueryResultOrderEnum : StringEnum - { - private QueryResultOrderEnum(string value) : base(value) {} - public QueryResultOrderEnum() {} - public static implicit operator QueryResultOrderEnum(string value) - { - return new QueryResultOrderEnum(value); - } - - public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); - public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); - } - - public sealed class QueryFromBoundTypeEnum : StringEnum - { - private QueryFromBoundTypeEnum(string value) : base(value) {} - public QueryFromBoundTypeEnum() {} - public static implicit operator QueryFromBoundTypeEnum(string value) - { - return new QueryFromBoundTypeEnum(value); - } - - public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); - public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); - } - - private static Request BuildFetchRequest(FetchSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Fetch(FetchSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The list_sid - /// The index - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Fetch(string pathServiceSid, - string pathListSid, - int? pathIndex, - ITwilioRestClient client = null) - { - var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The list_sid - /// The index - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - ITwilioRestClient client = null) - { - var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static bool Delete(DeleteSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The list_sid - /// The index - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static bool Delete(string pathServiceSid, - string pathListSid, - int? pathIndex, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The list_sid - /// The index - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Create(CreateSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The list_sid - /// The data - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Create(string pathServiceSid, - string pathListSid, - object data, - ITwilioRestClient client = null) - { - var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The list_sid - /// The data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathListSid, - object data, - ITwilioRestClient client = null) - { - var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static ResourceSet Read(ReadSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The list_sid - /// The order - /// The from - /// The bounds - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static ResourceSet Read(string pathServiceSid, - string pathListSid, - SyncListItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncListItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The list_sid - /// The order - /// The from - /// The bounds - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathListSid, - SyncListItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncListItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Update(UpdateSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The list_sid - /// The index - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Update(string pathServiceSid, - string pathListSid, - int? pathIndex, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex, data){IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The list_sid - /// The index - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex, data){IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncListItemResource object - /// - /// Raw JSON string - /// SyncListItemResource object represented by the provided JSON - public static SyncListItemResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The index - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The list_sid - /// - [JsonProperty("list_sid")] - public string ListSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The revision - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncListItemResource() - { - - } - } +{ + + public class SyncListItemResource : Resource + { + public sealed class QueryResultOrderEnum : StringEnum + { + private QueryResultOrderEnum(string value) : base(value) { } + public QueryResultOrderEnum() { } + public static implicit operator QueryResultOrderEnum(string value) + { + return new QueryResultOrderEnum(value); + } + + public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); + public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); + } + + public sealed class QueryFromBoundTypeEnum : StringEnum + { + private QueryFromBoundTypeEnum(string value) : base(value) { } + public QueryFromBoundTypeEnum() { } + public static implicit operator QueryFromBoundTypeEnum(string value) + { + return new QueryFromBoundTypeEnum(value); + } + + public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); + public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); + } + + private static Request BuildFetchRequest(FetchSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Fetch(FetchSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The list_sid + /// The index + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Fetch(string pathServiceSid, + string pathListSid, + int? pathIndex, + ITwilioRestClient client = null) + { + var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The list_sid + /// The index + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + ITwilioRestClient client = null) + { + var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static bool Delete(DeleteSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The list_sid + /// The index + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static bool Delete(string pathServiceSid, + string pathListSid, + int? pathIndex, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The list_sid + /// The index + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Create(CreateSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The list_sid + /// The data + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Create(string pathServiceSid, + string pathListSid, + object data, + ITwilioRestClient client = null) + { + var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The list_sid + /// The data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathListSid, + object data, + ITwilioRestClient client = null) + { + var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static ResourceSet Read(ReadSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The list_sid + /// The order + /// The from + /// The bounds + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static ResourceSet Read(string pathServiceSid, + string pathListSid, + SyncListItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncListItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The list_sid + /// The order + /// The from + /// The bounds + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathListSid, + SyncListItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncListItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Update(UpdateSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The list_sid + /// The index + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Update(string pathServiceSid, + string pathListSid, + int? pathIndex, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex, data) { IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The list_sid + /// The index + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex, data) { IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncListItemResource object + /// + /// Raw JSON string + /// SyncListItemResource object represented by the provided JSON + public static SyncListItemResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The index + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The list_sid + /// + [JsonProperty("list_sid")] + public string ListSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The revision + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncListItemResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionOptions.cs index 66250b954..3409d88d1 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service.SyncList -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Sync List Permission. + /// + public class FetchSyncListPermissionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Sync List Permission. - /// - public class FetchSyncListPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync List SID or unique name. - /// - public string PathListSid { get; } - /// - /// Identity of the user to whom the Sync List Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchSyncListPermissionOptions - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - public FetchSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Sync List Permission. - /// - public class DeleteSyncListPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync List SID or unique name. - /// - public string PathListSid { get; } - /// - /// Identity of the user to whom the Sync List Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteSyncListPermissionOptions - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - public DeleteSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Sync List SID or unique name. + /// + public string PathListSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - public class ReadSyncListPermissionOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync List SID or unique name. - /// - public string PathListSid { get; } - - /// - /// Construct a new ReadSyncListPermissionOptions - /// - /// The service_sid - /// Sync List SID or unique name. - public ReadSyncListPermissionOptions(string pathServiceSid, string pathListSid) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Identity of the user to whom the Sync List Permission applies. + /// + public string PathIdentity { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update an identity's access to a specific Sync List. - /// - public class UpdateSyncListPermissionOptions : IOptions - { - /// - /// Sync Service Instance SID. - /// - public string PathServiceSid { get; } - /// - /// Sync List SID or unique name. - /// - public string PathListSid { get; } - /// - /// Identity of the user to whom the Sync List Permission applies. - /// - public string PathIdentity { get; } - /// - /// Read access. - /// - public bool? Read { get; } - /// - /// Write access. - /// - public bool? Write { get; } - /// - /// Manage access. - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateSyncListPermissionOptions - /// - /// Sync Service Instance SID. - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Read access. - /// Write access. - /// Manage access. - public UpdateSyncListPermissionOptions(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchSyncListPermissionOptions + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + public FetchSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Sync List Permission. + /// + public class DeleteSyncListPermissionOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync List SID or unique name. + /// + public string PathListSid { get; } + /// + /// Identity of the user to whom the Sync List Permission applies. + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteSyncListPermissionOptions + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + public DeleteSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + public class ReadSyncListPermissionOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync List SID or unique name. + /// + public string PathListSid { get; } + + /// + /// Construct a new ReadSyncListPermissionOptions + /// + /// The service_sid + /// Sync List SID or unique name. + public ReadSyncListPermissionOptions(string pathServiceSid, string pathListSid) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update an identity's access to a specific Sync List. + /// + public class UpdateSyncListPermissionOptions : IOptions + { + /// + /// Sync Service Instance SID. + /// + public string PathServiceSid { get; } + /// + /// Sync List SID or unique name. + /// + public string PathListSid { get; } + /// + /// Identity of the user to whom the Sync List Permission applies. + /// + public string PathIdentity { get; } + /// + /// Read access. + /// + public bool? Read { get; } + /// + /// Write access. + /// + public bool? Write { get; } + /// + /// Manage access. + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateSyncListPermissionOptions + /// + /// Sync Service Instance SID. + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Read access. + /// Write access. + /// Manage access. + public UpdateSyncListPermissionOptions(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionResource.cs index 97930b819..32aa28f63 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncList/SyncListPermissionResource.cs @@ -19,455 +19,455 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service.SyncList -{ - - public class SyncListPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync List Permission. - /// - /// Fetch SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Fetch(FetchSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync List Permission. - /// - /// Fetch SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync List Permission. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Fetch(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync List Permission. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync List Permission. - /// - /// Delete SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static bool Delete(DeleteSyncListPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync List Permission. - /// - /// Delete SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync List Permission. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static bool Delete(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync List Permission. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// Read SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static ResourceSet Read(ReadSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// Read SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static ResourceSet Read(string pathServiceSid, - string pathListSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// The service_sid - /// Sync List SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathListSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync List. - /// - /// Update SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Update(UpdateSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync List. - /// - /// Update SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync List. - /// - /// Sync Service Instance SID. - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Update(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync List. - /// - /// Sync Service Instance SID. - /// Sync List SID or unique name. - /// Identity of the user to whom the Sync List Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncListPermissionResource object - /// - /// Raw JSON string - /// SyncListPermissionResource object represented by the provided JSON - public static SyncListPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Twilio Account SID. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Sync Service Instance SID. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Sync List SID. - /// - [JsonProperty("list_sid")] - public string ListSid { get; private set; } - /// - /// Identity of the user to whom the Sync List Permission applies. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access. - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access. - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access. - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// URL of this Sync List Permission. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SyncListPermissionResource() - { - - } - } +{ + + public class SyncListPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync List Permission. + /// + /// Fetch SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Fetch(FetchSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync List Permission. + /// + /// Fetch SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync List Permission. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Fetch(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync List Permission. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync List Permission. + /// + /// Delete SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static bool Delete(DeleteSyncListPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync List Permission. + /// + /// Delete SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync List Permission. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static bool Delete(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync List Permission. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// Read SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static ResourceSet Read(ReadSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// Read SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static ResourceSet Read(string pathServiceSid, + string pathListSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// The service_sid + /// Sync List SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathListSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync List. + /// + /// Update SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Update(UpdateSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync List. + /// + /// Update SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync List. + /// + /// Sync Service Instance SID. + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Update(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync List. + /// + /// Sync Service Instance SID. + /// Sync List SID or unique name. + /// Identity of the user to whom the Sync List Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncListPermissionResource object + /// + /// Raw JSON string + /// SyncListPermissionResource object represented by the provided JSON + public static SyncListPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Twilio Account SID. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Sync Service Instance SID. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Sync List SID. + /// + [JsonProperty("list_sid")] + public string ListSid { get; private set; } + /// + /// Identity of the user to whom the Sync List Permission applies. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access. + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access. + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access. + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// URL of this Sync List Permission. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SyncListPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncListOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncListOptions.cs index c15cf0002..884ad1de7 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncListOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncListOptions.cs @@ -9,160 +9,160 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSyncListOptions + /// + public class FetchSyncListOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSyncListOptions + /// The service_sid /// - public class FetchSyncListOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSyncListOptions - /// - /// The service_sid - /// The sid - public FetchSyncListOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSyncListOptions + /// The sid /// - public class DeleteSyncListOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSyncListOptions - /// - /// The service_sid - /// The sid - public DeleteSyncListOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSyncListOptions + /// Construct a new FetchSyncListOptions /// - public class CreateSyncListOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - - /// - /// Construct a new CreateSyncListOptions - /// - /// The service_sid - public CreateSyncListOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// The service_sid + /// The sid + public FetchSyncListOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSyncListOptions + /// Generate the necessary parameters /// - public class ReadSyncListOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSyncListOptions - /// - /// The service_sid - public ReadSyncListOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSyncListOptions + /// + public class DeleteSyncListOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSyncListOptions + /// + /// The service_sid + /// The sid + public DeleteSyncListOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSyncListOptions + /// + public class CreateSyncListOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + + /// + /// Construct a new CreateSyncListOptions + /// + /// The service_sid + public CreateSyncListOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSyncListOptions + /// + public class ReadSyncListOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSyncListOptions + /// + /// The service_sid + public ReadSyncListOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncListResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncListResource.cs index 34b15814d..0383dae9a 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncListResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncListResource.cs @@ -19,428 +19,428 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service -{ - - public class SyncListResource : Resource - { - private static Request BuildFetchRequest(FetchSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Fetch(FetchSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSyncListOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSyncListOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static bool Delete(DeleteSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of SyncList - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSyncListOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Create(CreateSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The unique_name - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Create(string pathServiceSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListOptions(pathServiceSid){UniqueName = uniqueName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The unique_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListOptions(pathServiceSid){UniqueName = uniqueName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Lists", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static ResourceSet Read(ReadSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncList - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Converts a JSON string into a SyncListResource object - /// - /// Raw JSON string - /// SyncListResource object represented by the provided JSON - public static SyncListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The revision - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncListResource() - { - - } - } +{ + + public class SyncListResource : Resource + { + private static Request BuildFetchRequest(FetchSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Fetch(FetchSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSyncListOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSyncListOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static bool Delete(DeleteSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of SyncList + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSyncListOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Create(CreateSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The unique_name + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Create(string pathServiceSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListOptions(pathServiceSid) { UniqueName = uniqueName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The unique_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListOptions(pathServiceSid) { UniqueName = uniqueName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Lists", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static ResourceSet Read(ReadSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncList + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Converts a JSON string into a SyncListResource object + /// + /// Raw JSON string + /// SyncListResource object represented by the provided JSON + public static SyncListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The revision + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemOptions.cs index 16b9e659c..8a0890f67 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemOptions.cs @@ -9,315 +9,315 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service.SyncMap -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSyncMapItemOptions + /// + public class FetchSyncMapItemOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSyncMapItemOptions - /// - public class FetchSyncMapItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The map_sid - /// - public string PathMapSid { get; } - /// - /// The key - /// - public string PathKey { get; } - - /// - /// Construct a new FetchSyncMapItemOptions - /// - /// The service_sid - /// The map_sid - /// The key - public FetchSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSyncMapItemOptions - /// - public class DeleteSyncMapItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The map_sid - /// - public string PathMapSid { get; } - /// - /// The key - /// - public string PathKey { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteSyncMapItemOptions - /// - /// The service_sid - /// The map_sid - /// The key - public DeleteSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// The map_sid + /// + public string PathMapSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSyncMapItemOptions - /// - public class CreateSyncMapItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The map_sid - /// - public string PathMapSid { get; } - /// - /// The key - /// - public string Key { get; } - /// - /// The data - /// - public object Data { get; } - - /// - /// Construct a new CreateSyncMapItemOptions - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - public CreateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string key, object data) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - Key = key; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Key != null) - { - p.Add(new KeyValuePair("Key", Key)); - } - - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - } - + /// The key + /// + public string PathKey { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSyncMapItemOptions - /// - public class ReadSyncMapItemOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The map_sid - /// - public string PathMapSid { get; } - /// - /// The order - /// - public SyncMapItemResource.QueryResultOrderEnum Order { get; set; } - /// - /// The from - /// - public string From { get; set; } - /// - /// The bounds - /// - public SyncMapItemResource.QueryFromBoundTypeEnum Bounds { get; set; } - - /// - /// Construct a new ReadSyncMapItemOptions - /// - /// The service_sid - /// The map_sid - public ReadSyncMapItemOptions(string pathServiceSid, string pathMapSid) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Bounds != null) - { - p.Add(new KeyValuePair("Bounds", Bounds.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncMapItemOptions + /// + /// The service_sid + /// The map_sid + /// The key + public FetchSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateSyncMapItemOptions - /// - public class UpdateSyncMapItemOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The map_sid - /// - public string PathMapSid { get; } - /// - /// The key - /// - public string PathKey { get; } - /// - /// The data - /// - public object Data { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateSyncMapItemOptions - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - public UpdateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey, object data) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSyncMapItemOptions + /// + public class DeleteSyncMapItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The map_sid + /// + public string PathMapSid { get; } + /// + /// The key + /// + public string PathKey { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteSyncMapItemOptions + /// + /// The service_sid + /// The map_sid + /// The key + public DeleteSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSyncMapItemOptions + /// + public class CreateSyncMapItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The map_sid + /// + public string PathMapSid { get; } + /// + /// The key + /// + public string Key { get; } + /// + /// The data + /// + public object Data { get; } + + /// + /// Construct a new CreateSyncMapItemOptions + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + public CreateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string key, object data) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + Key = key; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Key != null) + { + p.Add(new KeyValuePair("Key", Key)); + } + + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSyncMapItemOptions + /// + public class ReadSyncMapItemOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The map_sid + /// + public string PathMapSid { get; } + /// + /// The order + /// + public SyncMapItemResource.QueryResultOrderEnum Order { get; set; } + /// + /// The from + /// + public string From { get; set; } + /// + /// The bounds + /// + public SyncMapItemResource.QueryFromBoundTypeEnum Bounds { get; set; } + + /// + /// Construct a new ReadSyncMapItemOptions + /// + /// The service_sid + /// The map_sid + public ReadSyncMapItemOptions(string pathServiceSid, string pathMapSid) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Bounds != null) + { + p.Add(new KeyValuePair("Bounds", Bounds.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateSyncMapItemOptions + /// + public class UpdateSyncMapItemOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The map_sid + /// + public string PathMapSid { get; } + /// + /// The key + /// + public string PathKey { get; } + /// + /// The data + /// + public object Data { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateSyncMapItemOptions + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + public UpdateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey, object data) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemResource.cs index 179a66d55..a99d86d0b 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapItemResource.cs @@ -20,578 +20,578 @@ using Twilio.Types; namespace Twilio.Rest.Preview.Sync.Service.SyncMap -{ - - public class SyncMapItemResource : Resource - { - public sealed class QueryResultOrderEnum : StringEnum - { - private QueryResultOrderEnum(string value) : base(value) {} - public QueryResultOrderEnum() {} - public static implicit operator QueryResultOrderEnum(string value) - { - return new QueryResultOrderEnum(value); - } - - public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); - public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); - } - - public sealed class QueryFromBoundTypeEnum : StringEnum - { - private QueryFromBoundTypeEnum(string value) : base(value) {} - public QueryFromBoundTypeEnum() {} - public static implicit operator QueryFromBoundTypeEnum(string value) - { - return new QueryFromBoundTypeEnum(value); - } - - public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); - public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); - } - - private static Request BuildFetchRequest(FetchSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Fetch(FetchSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The map_sid - /// The key - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Fetch(string pathServiceSid, - string pathMapSid, - string pathKey, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The map_sid - /// The key - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static bool Delete(DeleteSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The map_sid - /// The key - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static bool Delete(string pathServiceSid, - string pathMapSid, - string pathKey, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The map_sid - /// The key - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Create(CreateSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Create(string pathServiceSid, - string pathMapSid, - string key, - object data, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathMapSid, - string key, - object data, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static ResourceSet Read(ReadSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// The map_sid - /// The order - /// The from - /// The bounds - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static ResourceSet Read(string pathServiceSid, - string pathMapSid, - SyncMapItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// The map_sid - /// The order - /// The from - /// The bounds - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathMapSid, - SyncMapItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Update(UpdateSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Update(string pathServiceSid, - string pathMapSid, - string pathKey, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey, data){IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The service_sid - /// The map_sid - /// The key - /// The data - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - object data, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey, data){IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncMapItemResource object - /// - /// Raw JSON string - /// SyncMapItemResource object represented by the provided JSON - public static SyncMapItemResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The key - /// - [JsonProperty("key")] - public string Key { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The map_sid - /// - [JsonProperty("map_sid")] - public string MapSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The revision - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncMapItemResource() - { - - } - } +{ + + public class SyncMapItemResource : Resource + { + public sealed class QueryResultOrderEnum : StringEnum + { + private QueryResultOrderEnum(string value) : base(value) { } + public QueryResultOrderEnum() { } + public static implicit operator QueryResultOrderEnum(string value) + { + return new QueryResultOrderEnum(value); + } + + public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); + public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); + } + + public sealed class QueryFromBoundTypeEnum : StringEnum + { + private QueryFromBoundTypeEnum(string value) : base(value) { } + public QueryFromBoundTypeEnum() { } + public static implicit operator QueryFromBoundTypeEnum(string value) + { + return new QueryFromBoundTypeEnum(value); + } + + public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); + public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); + } + + private static Request BuildFetchRequest(FetchSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Fetch(FetchSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The map_sid + /// The key + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Fetch(string pathServiceSid, + string pathMapSid, + string pathKey, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The map_sid + /// The key + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static bool Delete(DeleteSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The map_sid + /// The key + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static bool Delete(string pathServiceSid, + string pathMapSid, + string pathKey, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The map_sid + /// The key + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Create(CreateSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Create(string pathServiceSid, + string pathMapSid, + string key, + object data, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathMapSid, + string key, + object data, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static ResourceSet Read(ReadSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// The map_sid + /// The order + /// The from + /// The bounds + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static ResourceSet Read(string pathServiceSid, + string pathMapSid, + SyncMapItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// The map_sid + /// The order + /// The from + /// The bounds + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathMapSid, + SyncMapItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Update(UpdateSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Update(string pathServiceSid, + string pathMapSid, + string pathKey, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey, data) { IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The service_sid + /// The map_sid + /// The key + /// The data + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + object data, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey, data) { IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncMapItemResource object + /// + /// Raw JSON string + /// SyncMapItemResource object represented by the provided JSON + public static SyncMapItemResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The key + /// + [JsonProperty("key")] + public string Key { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The map_sid + /// + [JsonProperty("map_sid")] + public string MapSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The revision + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncMapItemResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionOptions.cs index 0b369e203..724c75c89 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service.SyncMap -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Sync Map Permission. + /// + public class FetchSyncMapPermissionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Sync Map Permission. - /// - public class FetchSyncMapPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Map SID or unique name. - /// - public string PathMapSid { get; } - /// - /// Identity of the user to whom the Sync Map Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchSyncMapPermissionOptions - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - public FetchSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The service_sid + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Delete a specific Sync Map Permission. - /// - public class DeleteSyncMapPermissionOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Map SID or unique name. - /// - public string PathMapSid { get; } - /// - /// Identity of the user to whom the Sync Map Permission applies. - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteSyncMapPermissionOptions - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - public DeleteSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Sync Map SID or unique name. + /// + public string PathMapSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - public class ReadSyncMapPermissionOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// Sync Map SID or unique name. - /// - public string PathMapSid { get; } - - /// - /// Construct a new ReadSyncMapPermissionOptions - /// - /// The service_sid - /// Sync Map SID or unique name. - public ReadSyncMapPermissionOptions(string pathServiceSid, string pathMapSid) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Identity of the user to whom the Sync Map Permission applies. + /// + public string PathIdentity { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update an identity's access to a specific Sync Map. - /// - public class UpdateSyncMapPermissionOptions : IOptions - { - /// - /// Sync Service Instance SID. - /// - public string PathServiceSid { get; } - /// - /// Sync Map SID or unique name. - /// - public string PathMapSid { get; } - /// - /// Identity of the user to whom the Sync Map Permission applies. - /// - public string PathIdentity { get; } - /// - /// Read access. - /// - public bool? Read { get; } - /// - /// Write access. - /// - public bool? Write { get; } - /// - /// Manage access. - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateSyncMapPermissionOptions - /// - /// Sync Service Instance SID. - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Read access. - /// Write access. - /// Manage access. - public UpdateSyncMapPermissionOptions(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchSyncMapPermissionOptions + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + public FetchSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Delete a specific Sync Map Permission. + /// + public class DeleteSyncMapPermissionOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync Map SID or unique name. + /// + public string PathMapSid { get; } + /// + /// Identity of the user to whom the Sync Map Permission applies. + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteSyncMapPermissionOptions + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + public DeleteSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + public class ReadSyncMapPermissionOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// Sync Map SID or unique name. + /// + public string PathMapSid { get; } + + /// + /// Construct a new ReadSyncMapPermissionOptions + /// + /// The service_sid + /// Sync Map SID or unique name. + public ReadSyncMapPermissionOptions(string pathServiceSid, string pathMapSid) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update an identity's access to a specific Sync Map. + /// + public class UpdateSyncMapPermissionOptions : IOptions + { + /// + /// Sync Service Instance SID. + /// + public string PathServiceSid { get; } + /// + /// Sync Map SID or unique name. + /// + public string PathMapSid { get; } + /// + /// Identity of the user to whom the Sync Map Permission applies. + /// + public string PathIdentity { get; } + /// + /// Read access. + /// + public bool? Read { get; } + /// + /// Write access. + /// + public bool? Write { get; } + /// + /// Manage access. + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateSyncMapPermissionOptions + /// + /// Sync Service Instance SID. + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Read access. + /// Write access. + /// Manage access. + public UpdateSyncMapPermissionOptions(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionResource.cs index 499f951b5..fdf82e873 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionResource.cs @@ -19,454 +19,454 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service.SyncMap -{ - - public class SyncMapPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync Map Permission. - /// - /// Fetch SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Fetch(FetchSyncMapPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync Map Permission. - /// - /// Fetch SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync Map Permission. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Fetch(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync Map Permission. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync Map Permission. - /// - /// Delete SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static bool Delete(DeleteSyncMapPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync Map Permission. - /// - /// Delete SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync Map Permission. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static bool Delete(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync Map Permission. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// Read SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static ResourceSet Read(ReadSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// Read SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static ResourceSet Read(string pathServiceSid, - string pathMapSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// The service_sid - /// Sync Map SID or unique name. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathMapSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Update SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Update(UpdateSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Update SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Sync Service Instance SID. - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Update(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Sync Service Instance SID. - /// Sync Map SID or unique name. - /// Identity of the user to whom the Sync Map Permission applies. - /// Read access. - /// Write access. - /// Manage access. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncMapPermissionResource object - /// - /// Raw JSON string - /// SyncMapPermissionResource object represented by the provided JSON - public static SyncMapPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Twilio Account SID. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Sync Service Instance SID. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Sync Map SID. - /// - [JsonProperty("map_sid")] - public string MapSid { get; private set; } - /// - /// Identity of the user to whom the Sync Map Permission applies. - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access. - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access. - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access. - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// URL of this Sync Map Permission. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SyncMapPermissionResource() - { - - } - } +{ + + public class SyncMapPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync Map Permission. + /// + /// Fetch SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Fetch(FetchSyncMapPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync Map Permission. + /// + /// Fetch SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync Map Permission. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Fetch(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync Map Permission. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync Map Permission. + /// + /// Delete SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static bool Delete(DeleteSyncMapPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync Map Permission. + /// + /// Delete SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync Map Permission. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static bool Delete(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync Map Permission. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// Read SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static ResourceSet Read(ReadSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// Read SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static ResourceSet Read(string pathServiceSid, + string pathMapSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// The service_sid + /// Sync Map SID or unique name. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathMapSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Update SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Update(UpdateSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Update SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Sync Service Instance SID. + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Update(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Sync Service Instance SID. + /// Sync Map SID or unique name. + /// Identity of the user to whom the Sync Map Permission applies. + /// Read access. + /// Write access. + /// Manage access. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncMapPermissionResource object + /// + /// Raw JSON string + /// SyncMapPermissionResource object represented by the provided JSON + public static SyncMapPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Twilio Account SID. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Sync Service Instance SID. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Sync Map SID. + /// + [JsonProperty("map_sid")] + public string MapSid { get; private set; } + /// + /// Identity of the user to whom the Sync Map Permission applies. + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access. + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access. + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access. + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// URL of this Sync Map Permission. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SyncMapPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMapOptions.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMapOptions.cs index 0b724c47b..7a4a9e0d8 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMapOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMapOptions.cs @@ -9,160 +9,160 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSyncMapOptions + /// + public class FetchSyncMapOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSyncMapOptions + /// The service_sid /// - public class FetchSyncMapOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSyncMapOptions - /// - /// The service_sid - /// The sid - public FetchSyncMapOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSyncMapOptions + /// The sid /// - public class DeleteSyncMapOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSyncMapOptions - /// - /// The service_sid - /// The sid - public DeleteSyncMapOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSyncMapOptions + /// Construct a new FetchSyncMapOptions /// - public class CreateSyncMapOptions : IOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - - /// - /// Construct a new CreateSyncMapOptions - /// - /// The service_sid - public CreateSyncMapOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// The service_sid + /// The sid + public FetchSyncMapOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSyncMapOptions + /// Generate the necessary parameters /// - public class ReadSyncMapOptions : ReadOptions - { - /// - /// The service_sid - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSyncMapOptions - /// - /// The service_sid - public ReadSyncMapOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSyncMapOptions + /// + public class DeleteSyncMapOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSyncMapOptions + /// + /// The service_sid + /// The sid + public DeleteSyncMapOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSyncMapOptions + /// + public class CreateSyncMapOptions : IOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + + /// + /// Construct a new CreateSyncMapOptions + /// + /// The service_sid + public CreateSyncMapOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSyncMapOptions + /// + public class ReadSyncMapOptions : ReadOptions + { + /// + /// The service_sid + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSyncMapOptions + /// + /// The service_sid + public ReadSyncMapOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/Service/SyncMapResource.cs b/src/Twilio/Rest/Preview/Sync/Service/SyncMapResource.cs index 69e73fb84..2db181089 100644 --- a/src/Twilio/Rest/Preview/Sync/Service/SyncMapResource.cs +++ b/src/Twilio/Rest/Preview/Sync/Service/SyncMapResource.cs @@ -19,428 +19,428 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync.Service -{ - - public class SyncMapResource : Resource - { - private static Request BuildFetchRequest(FetchSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Fetch(FetchSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSyncMapOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static bool Delete(DeleteSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The service_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Create(CreateSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The service_sid - /// The unique_name - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Create(string pathServiceSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapOptions(pathServiceSid){UniqueName = uniqueName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The service_sid - /// The unique_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapOptions(pathServiceSid){UniqueName = uniqueName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathServiceSid + "/Maps", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static ResourceSet Read(ReadSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("maps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("maps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The service_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Converts a JSON string into a SyncMapResource object - /// - /// Raw JSON string - /// SyncMapResource object represented by the provided JSON - public static SyncMapResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The revision - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The created_by - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncMapResource() - { - - } - } +{ + + public class SyncMapResource : Resource + { + private static Request BuildFetchRequest(FetchSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Fetch(FetchSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSyncMapOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static bool Delete(DeleteSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The service_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Create(CreateSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The service_sid + /// The unique_name + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Create(string pathServiceSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapOptions(pathServiceSid) { UniqueName = uniqueName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The service_sid + /// The unique_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapOptions(pathServiceSid) { UniqueName = uniqueName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathServiceSid + "/Maps", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static ResourceSet Read(ReadSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("maps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("maps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The service_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Converts a JSON string into a SyncMapResource object + /// + /// Raw JSON string + /// SyncMapResource object represented by the provided JSON + public static SyncMapResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The revision + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The created_by + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncMapResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/ServiceOptions.cs b/src/Twilio/Rest/Preview/Sync/ServiceOptions.cs index 823bec597..d84bee8b3 100644 --- a/src/Twilio/Rest/Preview/Sync/ServiceOptions.cs +++ b/src/Twilio/Rest/Preview/Sync/ServiceOptions.cs @@ -9,216 +9,216 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Sync -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchServiceOptions - /// - public class FetchServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The sid - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteServiceOptions - /// - public class DeleteServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The sid - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchServiceOptions + /// + /// The sid + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateServiceOptions - /// - public class CreateServiceOptions : IOptions - { - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The webhook_url - /// - public Uri WebhookUrl { get; set; } - /// - /// The reachability_webhooks_enabled - /// - public bool? ReachabilityWebhooksEnabled { get; set; } - /// - /// The acl_enabled - /// - public bool? AclEnabled { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (ReachabilityWebhooksEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); - } - - if (AclEnabled != null) - { - p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadServiceOptions - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateServiceOptions - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The webhook_url - /// - public Uri WebhookUrl { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The reachability_webhooks_enabled - /// - public bool? ReachabilityWebhooksEnabled { get; set; } - /// - /// The acl_enabled - /// - public bool? AclEnabled { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The sid - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ReachabilityWebhooksEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); - } - - if (AclEnabled != null) - { - p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new DeleteServiceOptions + /// + /// The sid + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The webhook_url + /// + public Uri WebhookUrl { get; set; } + /// + /// The reachability_webhooks_enabled + /// + public bool? ReachabilityWebhooksEnabled { get; set; } + /// + /// The acl_enabled + /// + public bool? AclEnabled { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (ReachabilityWebhooksEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); + } + + if (AclEnabled != null) + { + p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The webhook_url + /// + public Uri WebhookUrl { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The reachability_webhooks_enabled + /// + public bool? ReachabilityWebhooksEnabled { get; set; } + /// + /// The acl_enabled + /// + public bool? AclEnabled { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The sid + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ReachabilityWebhooksEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); + } + + if (AclEnabled != null) + { + p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Sync/ServiceResource.cs b/src/Twilio/Rest/Preview/Sync/ServiceResource.cs index 668551c80..48f1c3886 100644 --- a/src/Twilio/Rest/Preview/Sync/ServiceResource.cs +++ b/src/Twilio/Rest/Preview/Sync/ServiceResource.cs @@ -19,509 +19,509 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Sync -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The friendly_name - /// The webhook_url - /// The reachability_webhooks_enabled - /// The acl_enabled - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName = null, - Uri webhookUrl = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The friendly_name - /// The webhook_url - /// The reachability_webhooks_enabled - /// The acl_enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - Uri webhookUrl = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/Sync/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/Sync/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The webhook_url - /// The friendly_name - /// The reachability_webhooks_enabled - /// The acl_enabled - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - Uri webhookUrl = null, - string friendlyName = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The webhook_url - /// The friendly_name - /// The reachability_webhooks_enabled - /// The acl_enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - Uri webhookUrl = null, - string friendlyName = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The webhook_url - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// The reachability_webhooks_enabled - /// - [JsonProperty("reachability_webhooks_enabled")] - public bool? ReachabilityWebhooksEnabled { get; private set; } - /// - /// The acl_enabled - /// - [JsonProperty("acl_enabled")] - public bool? AclEnabled { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The friendly_name + /// The webhook_url + /// The reachability_webhooks_enabled + /// The acl_enabled + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName = null, + Uri webhookUrl = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The friendly_name + /// The webhook_url + /// The reachability_webhooks_enabled + /// The acl_enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + Uri webhookUrl = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/Sync/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/Sync/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The webhook_url + /// The friendly_name + /// The reachability_webhooks_enabled + /// The acl_enabled + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + Uri webhookUrl = null, + string friendlyName = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The webhook_url + /// The friendly_name + /// The reachability_webhooks_enabled + /// The acl_enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + Uri webhookUrl = null, + string friendlyName = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The webhook_url + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// The reachability_webhooks_enabled + /// + [JsonProperty("reachability_webhooks_enabled")] + public bool? ReachabilityWebhooksEnabled { get; private set; } + /// + /// The acl_enabled + /// + [JsonProperty("acl_enabled")] + public bool? AclEnabled { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelOptions.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelOptions.cs index 3f3d11377..404d4bab6 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelOptions.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelOptions.cs @@ -9,49 +9,49 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.TrustedComms.BrandedChannel -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Associate a channel to a branded channel + /// + public class CreateChannelOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Associate a channel to a branded channel + /// Branded Channel Sid. /// - public class CreateChannelOptions : IOptions - { - /// - /// Branded Channel Sid. - /// - public string PathBrandedChannelSid { get; } - /// - /// Phone Number Sid to be branded. - /// - public string PhoneNumberSid { get; } - - /// - /// Construct a new CreateChannelOptions - /// - /// Branded Channel Sid. - /// Phone Number Sid to be branded. - public CreateChannelOptions(string pathBrandedChannelSid, string phoneNumberSid) - { - PathBrandedChannelSid = pathBrandedChannelSid; - PhoneNumberSid = phoneNumberSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumberSid != null) - { - p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); - } - - return p; - } - } + public string PathBrandedChannelSid { get; } + /// + /// Phone Number Sid to be branded. + /// + public string PhoneNumberSid { get; } + + /// + /// Construct a new CreateChannelOptions + /// + /// Branded Channel Sid. + /// Phone Number Sid to be branded. + public CreateChannelOptions(string pathBrandedChannelSid, string phoneNumberSid) + { + PathBrandedChannelSid = pathBrandedChannelSid; + PhoneNumberSid = phoneNumberSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumberSid != null) + { + p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelResource.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelResource.cs index 0d42cb456..7a49b8778 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelResource.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannel/ChannelResource.cs @@ -19,140 +19,140 @@ using Twilio.Http; namespace Twilio.Rest.Preview.TrustedComms.BrandedChannel -{ - - public class ChannelResource : Resource - { - private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/TrustedComms/BrandedChannels/" + options.PathBrandedChannelSid + "/Channels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Associate a channel to a branded channel - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Associate a channel to a branded channel - /// - /// Create Channel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Associate a channel to a branded channel - /// - /// Branded Channel Sid. - /// Phone Number Sid to be branded. - /// Client to make requests to Twilio - /// A single instance of Channel - public static ChannelResource Create(string pathBrandedChannelSid, - string phoneNumberSid, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathBrandedChannelSid, phoneNumberSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Associate a channel to a branded channel - /// - /// Branded Channel Sid. - /// Phone Number Sid to be branded. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Channel - public static async System.Threading.Tasks.Task CreateAsync(string pathBrandedChannelSid, - string phoneNumberSid, - ITwilioRestClient client = null) - { - var options = new CreateChannelOptions(pathBrandedChannelSid, phoneNumberSid); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChannelResource object - /// - /// Raw JSON string - /// ChannelResource object represented by the provided JSON - public static ChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Business Sid. - /// - [JsonProperty("business_sid")] - public string BusinessSid { get; private set; } - /// - /// Brand Sid. - /// - [JsonProperty("brand_sid")] - public string BrandSid { get; private set; } - /// - /// Branded Channel Sid. - /// - [JsonProperty("branded_channel_sid")] - public string BrandedChannelSid { get; private set; } - /// - /// Phone Number Sid to be branded. - /// - [JsonProperty("phone_number_sid")] - public string PhoneNumberSid { get; private set; } - /// - /// Twilio number to assign to the Branded Channel - /// - [JsonProperty("phone_number")] - public string PhoneNumber { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ChannelResource() - { - - } - } +{ + + public class ChannelResource : Resource + { + private static Request BuildCreateRequest(CreateChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/TrustedComms/BrandedChannels/" + options.PathBrandedChannelSid + "/Channels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Associate a channel to a branded channel + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(CreateChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Associate a channel to a branded channel + /// + /// Create Channel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(CreateChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Associate a channel to a branded channel + /// + /// Branded Channel Sid. + /// Phone Number Sid to be branded. + /// Client to make requests to Twilio + /// A single instance of Channel + public static ChannelResource Create(string pathBrandedChannelSid, + string phoneNumberSid, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathBrandedChannelSid, phoneNumberSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Associate a channel to a branded channel + /// + /// Branded Channel Sid. + /// Phone Number Sid to be branded. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Channel + public static async System.Threading.Tasks.Task CreateAsync(string pathBrandedChannelSid, + string phoneNumberSid, + ITwilioRestClient client = null) + { + var options = new CreateChannelOptions(pathBrandedChannelSid, phoneNumberSid); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChannelResource object + /// + /// Raw JSON string + /// ChannelResource object represented by the provided JSON + public static ChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Business Sid. + /// + [JsonProperty("business_sid")] + public string BusinessSid { get; private set; } + /// + /// Brand Sid. + /// + [JsonProperty("brand_sid")] + public string BrandSid { get; private set; } + /// + /// Branded Channel Sid. + /// + [JsonProperty("branded_channel_sid")] + public string BrandedChannelSid { get; private set; } + /// + /// Phone Number Sid to be branded. + /// + [JsonProperty("phone_number_sid")] + public string PhoneNumberSid { get; private set; } + /// + /// Twilio number to assign to the Branded Channel + /// + [JsonProperty("phone_number")] + public string PhoneNumber { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelOptions.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelOptions.cs index 567121fe7..3c47bb8be 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelOptions.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelOptions.cs @@ -9,38 +9,38 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.TrustedComms -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Branded Channel. + /// + public class FetchBrandedChannelOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Branded Channel. + /// Branded Channel Sid. /// - public class FetchBrandedChannelOptions : IOptions - { - /// - /// Branded Channel Sid. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBrandedChannelOptions - /// - /// Branded Channel Sid. - public FetchBrandedChannelOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchBrandedChannelOptions + /// + /// Branded Channel Sid. + public FetchBrandedChannelOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelResource.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelResource.cs index 4af23c2ae..2f3829d8b 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelResource.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandedChannelResource.cs @@ -19,130 +19,130 @@ using Twilio.Http; namespace Twilio.Rest.Preview.TrustedComms -{ - - public class BrandedChannelResource : Resource - { - private static Request BuildFetchRequest(FetchBrandedChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/TrustedComms/BrandedChannels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Branded Channel. - /// - /// Fetch BrandedChannel parameters - /// Client to make requests to Twilio - /// A single instance of BrandedChannel - public static BrandedChannelResource Fetch(FetchBrandedChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Branded Channel. - /// - /// Fetch BrandedChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandedChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchBrandedChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Branded Channel. - /// - /// Branded Channel Sid. - /// Client to make requests to Twilio - /// A single instance of BrandedChannel - public static BrandedChannelResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBrandedChannelOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Branded Channel. - /// - /// Branded Channel Sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandedChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBrandedChannelOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BrandedChannelResource object - /// - /// Raw JSON string - /// BrandedChannelResource object represented by the provided JSON - public static BrandedChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Business Sid. - /// - [JsonProperty("business_sid")] - public string BusinessSid { get; private set; } - /// - /// Brand Sid. - /// - [JsonProperty("brand_sid")] - public string BrandSid { get; private set; } - /// - /// Branded Channel Sid. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private BrandedChannelResource() - { - - } - } +{ + + public class BrandedChannelResource : Resource + { + private static Request BuildFetchRequest(FetchBrandedChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/TrustedComms/BrandedChannels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Branded Channel. + /// + /// Fetch BrandedChannel parameters + /// Client to make requests to Twilio + /// A single instance of BrandedChannel + public static BrandedChannelResource Fetch(FetchBrandedChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Branded Channel. + /// + /// Fetch BrandedChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandedChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchBrandedChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Branded Channel. + /// + /// Branded Channel Sid. + /// Client to make requests to Twilio + /// A single instance of BrandedChannel + public static BrandedChannelResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBrandedChannelOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Branded Channel. + /// + /// Branded Channel Sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandedChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBrandedChannelOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BrandedChannelResource object + /// + /// Raw JSON string + /// BrandedChannelResource object represented by the provided JSON + public static BrandedChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Business Sid. + /// + [JsonProperty("business_sid")] + public string BusinessSid { get; private set; } + /// + /// Brand Sid. + /// + [JsonProperty("brand_sid")] + public string BrandSid { get; private set; } + /// + /// Branded Channel Sid. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private BrandedChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationOptions.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationOptions.cs index 3119eb921..918dfeee3 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationOptions.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationOptions.cs @@ -9,43 +9,43 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.TrustedComms -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve the newest available BrandInformation + /// + public class FetchBrandsInformationOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve the newest available BrandInformation + /// Standard `If-None-Match` HTTP header /// - public class FetchBrandsInformationOptions : IOptions - { - /// - /// Standard `If-None-Match` HTTP header - /// - public string IfNoneMatch { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfNoneMatch != null) - { - p.Add(new KeyValuePair("If-None-Match", IfNoneMatch)); - } - - return p; - } - } + public string IfNoneMatch { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfNoneMatch != null) + { + p.Add(new KeyValuePair("If-None-Match", IfNoneMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationResource.cs b/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationResource.cs index d91e88005..ee79660a4 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationResource.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/BrandsInformationResource.cs @@ -19,120 +19,120 @@ using Twilio.Http; namespace Twilio.Rest.Preview.TrustedComms -{ - - public class BrandsInformationResource : Resource - { - private static Request BuildFetchRequest(FetchBrandsInformationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/TrustedComms/BrandsInformation", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Retrieve the newest available BrandInformation - /// - /// Fetch BrandsInformation parameters - /// Client to make requests to Twilio - /// A single instance of BrandsInformation - public static BrandsInformationResource Fetch(FetchBrandsInformationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the newest available BrandInformation - /// - /// Fetch BrandsInformation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandsInformation - public static async System.Threading.Tasks.Task FetchAsync(FetchBrandsInformationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the newest available BrandInformation - /// - /// Standard `If-None-Match` HTTP header - /// Client to make requests to Twilio - /// A single instance of BrandsInformation - public static BrandsInformationResource Fetch(string ifNoneMatch = null, ITwilioRestClient client = null) - { - var options = new FetchBrandsInformationOptions(){IfNoneMatch = ifNoneMatch}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the newest available BrandInformation - /// - /// Standard `If-None-Match` HTTP header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BrandsInformation - public static async System.Threading.Tasks.Task FetchAsync(string ifNoneMatch = null, - ITwilioRestClient client = null) - { - var options = new FetchBrandsInformationOptions(){IfNoneMatch = ifNoneMatch}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BrandsInformationResource object - /// - /// Raw JSON string - /// BrandsInformationResource object represented by the provided JSON - public static BrandsInformationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Creation time of the information retrieved - /// - [JsonProperty("update_time")] - public DateTime? UpdateTime { get; private set; } - /// - /// The URL to the brands information - /// - [JsonProperty("file_link")] - public Uri FileLink { get; private set; } - /// - /// How long will be the `file_link` valid - /// - [JsonProperty("file_link_ttl_in_seconds")] - public string FileLinkTtlInSeconds { get; private set; } - /// - /// The URL of this resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private BrandsInformationResource() - { - - } - } +{ + + public class BrandsInformationResource : Resource + { + private static Request BuildFetchRequest(FetchBrandsInformationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/TrustedComms/BrandsInformation", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Retrieve the newest available BrandInformation + /// + /// Fetch BrandsInformation parameters + /// Client to make requests to Twilio + /// A single instance of BrandsInformation + public static BrandsInformationResource Fetch(FetchBrandsInformationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the newest available BrandInformation + /// + /// Fetch BrandsInformation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandsInformation + public static async System.Threading.Tasks.Task FetchAsync(FetchBrandsInformationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the newest available BrandInformation + /// + /// Standard `If-None-Match` HTTP header + /// Client to make requests to Twilio + /// A single instance of BrandsInformation + public static BrandsInformationResource Fetch(string ifNoneMatch = null, ITwilioRestClient client = null) + { + var options = new FetchBrandsInformationOptions() { IfNoneMatch = ifNoneMatch }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the newest available BrandInformation + /// + /// Standard `If-None-Match` HTTP header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BrandsInformation + public static async System.Threading.Tasks.Task FetchAsync(string ifNoneMatch = null, + ITwilioRestClient client = null) + { + var options = new FetchBrandsInformationOptions() { IfNoneMatch = ifNoneMatch }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BrandsInformationResource object + /// + /// Raw JSON string + /// BrandsInformationResource object represented by the provided JSON + public static BrandsInformationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Creation time of the information retrieved + /// + [JsonProperty("update_time")] + public DateTime? UpdateTime { get; private set; } + /// + /// The URL to the brands information + /// + [JsonProperty("file_link")] + public Uri FileLink { get; private set; } + /// + /// How long will be the `file_link` valid + /// + [JsonProperty("file_link_ttl_in_seconds")] + public string FileLinkTtlInSeconds { get; private set; } + /// + /// The URL of this resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private BrandsInformationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/CpsOptions.cs b/src/Twilio/Rest/Preview/TrustedComms/CpsOptions.cs index 9fd0bb76a..cebfac4d2 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/CpsOptions.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/CpsOptions.cs @@ -9,43 +9,43 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.TrustedComms -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// + public class FetchCpsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// Phone number to retrieve CPS. /// - public class FetchCpsOptions : IOptions - { - /// - /// Phone number to retrieve CPS. - /// - public string XXcnamSensitivePhoneNumber { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XXcnamSensitivePhoneNumber != null) - { - p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number", XXcnamSensitivePhoneNumber)); - } - - return p; - } - } + public string XXcnamSensitivePhoneNumber { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XXcnamSensitivePhoneNumber != null) + { + p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number", XXcnamSensitivePhoneNumber)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/CpsResource.cs b/src/Twilio/Rest/Preview/TrustedComms/CpsResource.cs index 452310764..1baac35de 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/CpsResource.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/CpsResource.cs @@ -19,115 +19,115 @@ using Twilio.Http; namespace Twilio.Rest.Preview.TrustedComms -{ - - public class CpsResource : Resource - { - private static Request BuildFetchRequest(FetchCpsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/TrustedComms/CPS", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. - /// - /// Fetch Cps parameters - /// Client to make requests to Twilio - /// A single instance of Cps - public static CpsResource Fetch(FetchCpsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. - /// - /// Fetch Cps parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Cps - public static async System.Threading.Tasks.Task FetchAsync(FetchCpsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. - /// - /// Phone number to retrieve CPS. - /// Client to make requests to Twilio - /// A single instance of Cps - public static CpsResource Fetch(string xXcnamSensitivePhoneNumber = null, ITwilioRestClient client = null) - { - var options = new FetchCpsOptions(){XXcnamSensitivePhoneNumber = xXcnamSensitivePhoneNumber}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. - /// - /// Phone number to retrieve CPS. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Cps - public static async System.Threading.Tasks.Task FetchAsync(string xXcnamSensitivePhoneNumber = null, - ITwilioRestClient client = null) - { - var options = new FetchCpsOptions(){XXcnamSensitivePhoneNumber = xXcnamSensitivePhoneNumber}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CpsResource object - /// - /// Raw JSON string - /// CpsResource object represented by the provided JSON - public static CpsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// CPS URL of the phone number. - /// - [JsonProperty("cps_url")] - public Uri CpsUrl { get; private set; } - /// - /// Phone number passed. - /// - [JsonProperty("phone_number")] - public string PhoneNumber { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CpsResource() - { - - } - } +{ + + public class CpsResource : Resource + { + private static Request BuildFetchRequest(FetchCpsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/TrustedComms/CPS", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// + /// Fetch Cps parameters + /// Client to make requests to Twilio + /// A single instance of Cps + public static CpsResource Fetch(FetchCpsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// + /// Fetch Cps parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Cps + public static async System.Threading.Tasks.Task FetchAsync(FetchCpsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// + /// Phone number to retrieve CPS. + /// Client to make requests to Twilio + /// A single instance of Cps + public static CpsResource Fetch(string xXcnamSensitivePhoneNumber = null, ITwilioRestClient client = null) + { + var options = new FetchCpsOptions() { XXcnamSensitivePhoneNumber = xXcnamSensitivePhoneNumber }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Call Placement Service (CPS) given a phone number via `X-XCNAM-Sensitive-Phone-Number` header. + /// + /// Phone number to retrieve CPS. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Cps + public static async System.Threading.Tasks.Task FetchAsync(string xXcnamSensitivePhoneNumber = null, + ITwilioRestClient client = null) + { + var options = new FetchCpsOptions() { XXcnamSensitivePhoneNumber = xXcnamSensitivePhoneNumber }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CpsResource object + /// + /// Raw JSON string + /// CpsResource object represented by the provided JSON + public static CpsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// CPS URL of the phone number. + /// + [JsonProperty("cps_url")] + public Uri CpsUrl { get; private set; } + /// + /// Phone number passed. + /// + [JsonProperty("phone_number")] + public string PhoneNumber { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CpsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/CurrentCallOptions.cs b/src/Twilio/Rest/Preview/TrustedComms/CurrentCallOptions.cs index 5e3a62d98..225a21c71 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/CurrentCallOptions.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/CurrentCallOptions.cs @@ -9,53 +9,53 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.TrustedComms -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and + /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// + public class FetchCurrentCallOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and - /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// The originating Phone Number /// - public class FetchCurrentCallOptions : IOptions - { - /// - /// The originating Phone Number - /// - public string XXcnamSensitivePhoneNumberFrom { get; set; } - /// - /// The terminating Phone Number - /// - public string XXcnamSensitivePhoneNumberTo { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (XXcnamSensitivePhoneNumberFrom != null) - { - p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number-From", XXcnamSensitivePhoneNumberFrom)); - } - - if (XXcnamSensitivePhoneNumberTo != null) - { - p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number-To", XXcnamSensitivePhoneNumberTo)); - } - - return p; - } - } + public string XXcnamSensitivePhoneNumberFrom { get; set; } + /// + /// The terminating Phone Number + /// + public string XXcnamSensitivePhoneNumberTo { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (XXcnamSensitivePhoneNumberFrom != null) + { + p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number-From", XXcnamSensitivePhoneNumberFrom)); + } + + if (XXcnamSensitivePhoneNumberTo != null) + { + p.Add(new KeyValuePair("X-Xcnam-Sensitive-Phone-Number-To", XXcnamSensitivePhoneNumberTo)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/TrustedComms/CurrentCallResource.cs b/src/Twilio/Rest/Preview/TrustedComms/CurrentCallResource.cs index 5e10ab9c1..fae3064bd 100644 --- a/src/Twilio/Rest/Preview/TrustedComms/CurrentCallResource.cs +++ b/src/Twilio/Rest/Preview/TrustedComms/CurrentCallResource.cs @@ -19,179 +19,179 @@ using Twilio.Http; namespace Twilio.Rest.Preview.TrustedComms -{ - - public class CurrentCallResource : Resource - { - private static Request BuildFetchRequest(FetchCurrentCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/TrustedComms/CurrentCall", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and - /// `X-XCNAM-Sensitive-Phone-Number-To` headers. - /// - /// Fetch CurrentCall parameters - /// Client to make requests to Twilio - /// A single instance of CurrentCall - public static CurrentCallResource Fetch(FetchCurrentCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and - /// `X-XCNAM-Sensitive-Phone-Number-To` headers. - /// - /// Fetch CurrentCall parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CurrentCall - public static async System.Threading.Tasks.Task FetchAsync(FetchCurrentCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and - /// `X-XCNAM-Sensitive-Phone-Number-To` headers. - /// - /// The originating Phone Number - /// The terminating Phone Number - /// Client to make requests to Twilio - /// A single instance of CurrentCall - public static CurrentCallResource Fetch(string xXcnamSensitivePhoneNumberFrom = null, - string xXcnamSensitivePhoneNumberTo = null, - ITwilioRestClient client = null) - { - var options = new FetchCurrentCallOptions(){XXcnamSensitivePhoneNumberFrom = xXcnamSensitivePhoneNumberFrom, XXcnamSensitivePhoneNumberTo = xXcnamSensitivePhoneNumberTo}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and - /// `X-XCNAM-Sensitive-Phone-Number-To` headers. - /// - /// The originating Phone Number - /// The terminating Phone Number - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CurrentCall - public static async System.Threading.Tasks.Task FetchAsync(string xXcnamSensitivePhoneNumberFrom = null, - string xXcnamSensitivePhoneNumberTo = null, - ITwilioRestClient client = null) - { - var options = new FetchCurrentCallOptions(){XXcnamSensitivePhoneNumberFrom = xXcnamSensitivePhoneNumberFrom, XXcnamSensitivePhoneNumberTo = xXcnamSensitivePhoneNumberTo}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CurrentCallResource object - /// - /// Raw JSON string - /// CurrentCallResource object represented by the provided JSON - public static CurrentCallResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Background color of the current phone call - /// - [JsonProperty("bg_color")] - public string BgColor { get; private set; } - /// - /// Caller name of the current phone call - /// - [JsonProperty("caller")] - public string Caller { get; private set; } - /// - /// The date this current phone call was created - /// - [JsonProperty("created_at")] - public DateTime? CreatedAt { get; private set; } - /// - /// Font color of the current phone call - /// - [JsonProperty("font_color")] - public string FontColor { get; private set; } - /// - /// The originating phone number - /// - [JsonProperty("from")] - public string From { get; private set; } - /// - /// Logo URL of the caller - /// - [JsonProperty("logo")] - public string Logo { get; private set; } - /// - /// The name of the CPS organization - /// - [JsonProperty("manager")] - public string Manager { get; private set; } - /// - /// The business reason for this current phone call - /// - [JsonProperty("reason")] - public string Reason { get; private set; } - /// - /// Shield image URL that serves as authenticity proof of the current phone call - /// - [JsonProperty("shield_img")] - public string ShieldImg { get; private set; } - /// - /// A string that uniquely identifies this current branded phone call. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the current phone call - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// The terminating phone number - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The use case for the current phone call - /// - [JsonProperty("use_case")] - public string UseCase { get; private set; } - - private CurrentCallResource() - { - - } - } +{ + + public class CurrentCallResource : Resource + { + private static Request BuildFetchRequest(FetchCurrentCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/TrustedComms/CurrentCall", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and + /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// + /// Fetch CurrentCall parameters + /// Client to make requests to Twilio + /// A single instance of CurrentCall + public static CurrentCallResource Fetch(FetchCurrentCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and + /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// + /// Fetch CurrentCall parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CurrentCall + public static async System.Threading.Tasks.Task FetchAsync(FetchCurrentCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and + /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// + /// The originating Phone Number + /// The terminating Phone Number + /// Client to make requests to Twilio + /// A single instance of CurrentCall + public static CurrentCallResource Fetch(string xXcnamSensitivePhoneNumberFrom = null, + string xXcnamSensitivePhoneNumberTo = null, + ITwilioRestClient client = null) + { + var options = new FetchCurrentCallOptions() { XXcnamSensitivePhoneNumberFrom = xXcnamSensitivePhoneNumberFrom, XXcnamSensitivePhoneNumberTo = xXcnamSensitivePhoneNumberTo }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a current call given the originating and terminating number via `X-XCNAM-Sensitive-Phone-Number-From` and + /// `X-XCNAM-Sensitive-Phone-Number-To` headers. + /// + /// The originating Phone Number + /// The terminating Phone Number + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CurrentCall + public static async System.Threading.Tasks.Task FetchAsync(string xXcnamSensitivePhoneNumberFrom = null, + string xXcnamSensitivePhoneNumberTo = null, + ITwilioRestClient client = null) + { + var options = new FetchCurrentCallOptions() { XXcnamSensitivePhoneNumberFrom = xXcnamSensitivePhoneNumberFrom, XXcnamSensitivePhoneNumberTo = xXcnamSensitivePhoneNumberTo }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CurrentCallResource object + /// + /// Raw JSON string + /// CurrentCallResource object represented by the provided JSON + public static CurrentCallResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Background color of the current phone call + /// + [JsonProperty("bg_color")] + public string BgColor { get; private set; } + /// + /// Caller name of the current phone call + /// + [JsonProperty("caller")] + public string Caller { get; private set; } + /// + /// The date this current phone call was created + /// + [JsonProperty("created_at")] + public DateTime? CreatedAt { get; private set; } + /// + /// Font color of the current phone call + /// + [JsonProperty("font_color")] + public string FontColor { get; private set; } + /// + /// The originating phone number + /// + [JsonProperty("from")] + public string From { get; private set; } + /// + /// Logo URL of the caller + /// + [JsonProperty("logo")] + public string Logo { get; private set; } + /// + /// The name of the CPS organization + /// + [JsonProperty("manager")] + public string Manager { get; private set; } + /// + /// The business reason for this current phone call + /// + [JsonProperty("reason")] + public string Reason { get; private set; } + /// + /// Shield image URL that serves as authenticity proof of the current phone call + /// + [JsonProperty("shield_img")] + public string ShieldImg { get; private set; } + /// + /// A string that uniquely identifies this current branded phone call. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the current phone call + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// The terminating phone number + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The use case for the current phone call + /// + [JsonProperty("use_case")] + public string UseCase { get; private set; } + + private CurrentCallResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsOptions.cs index 1511a86c0..871c50083 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchAssistantFallbackActionsOptions + /// + public class FetchAssistantFallbackActionsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchAssistantFallbackActionsOptions + /// The assistant_sid /// - public class FetchAssistantFallbackActionsOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new FetchAssistantFallbackActionsOptions - /// - /// The assistant_sid - public FetchAssistantFallbackActionsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateAssistantFallbackActionsOptions + /// Construct a new FetchAssistantFallbackActionsOptions /// - public class UpdateAssistantFallbackActionsOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The fallback_actions - /// - public object FallbackActions { get; set; } - - /// - /// Construct a new UpdateAssistantFallbackActionsOptions - /// - /// The assistant_sid - public UpdateAssistantFallbackActionsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FallbackActions != null) - { - p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); - } - - return p; - } - } + /// The assistant_sid + public FetchAssistantFallbackActionsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateAssistantFallbackActionsOptions + /// + public class UpdateAssistantFallbackActionsOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The fallback_actions + /// + public object FallbackActions { get; set; } + + /// + /// Construct a new UpdateAssistantFallbackActionsOptions + /// + /// The assistant_sid + public UpdateAssistantFallbackActionsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FallbackActions != null) + { + p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsResource.cs index 4274f2375..2fa7d3dc6 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantFallbackActionsResource.cs @@ -19,194 +19,194 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class AssistantFallbackActionsResource : Resource - { - private static Request BuildFetchRequest(FetchAssistantFallbackActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FallbackActions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch AssistantFallbackActions parameters - /// Client to make requests to Twilio - /// A single instance of AssistantFallbackActions - public static AssistantFallbackActionsResource Fetch(FetchAssistantFallbackActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch AssistantFallbackActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantFallbackActions - public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantFallbackActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// Client to make requests to Twilio - /// A single instance of AssistantFallbackActions - public static AssistantFallbackActionsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) - { - var options = new FetchAssistantFallbackActionsOptions(pathAssistantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantFallbackActions - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - ITwilioRestClient client = null) - { - var options = new FetchAssistantFallbackActionsOptions(pathAssistantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAssistantFallbackActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FallbackActions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update AssistantFallbackActions parameters - /// Client to make requests to Twilio - /// A single instance of AssistantFallbackActions - public static AssistantFallbackActionsResource Update(UpdateAssistantFallbackActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update AssistantFallbackActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantFallbackActions - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantFallbackActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The assistant_sid - /// The fallback_actions - /// Client to make requests to Twilio - /// A single instance of AssistantFallbackActions - public static AssistantFallbackActionsResource Update(string pathAssistantSid, - object fallbackActions = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantFallbackActionsOptions(pathAssistantSid){FallbackActions = fallbackActions}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The assistant_sid - /// The fallback_actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantFallbackActions - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - object fallbackActions = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantFallbackActionsOptions(pathAssistantSid){FallbackActions = fallbackActions}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssistantFallbackActionsResource object - /// - /// Raw JSON string - /// AssistantFallbackActionsResource object represented by the provided JSON - public static AssistantFallbackActionsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The assistant_sid - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private AssistantFallbackActionsResource() - { - - } - } +{ + + public class AssistantFallbackActionsResource : Resource + { + private static Request BuildFetchRequest(FetchAssistantFallbackActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FallbackActions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch AssistantFallbackActions parameters + /// Client to make requests to Twilio + /// A single instance of AssistantFallbackActions + public static AssistantFallbackActionsResource Fetch(FetchAssistantFallbackActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch AssistantFallbackActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantFallbackActions + public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantFallbackActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// Client to make requests to Twilio + /// A single instance of AssistantFallbackActions + public static AssistantFallbackActionsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) + { + var options = new FetchAssistantFallbackActionsOptions(pathAssistantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantFallbackActions + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + ITwilioRestClient client = null) + { + var options = new FetchAssistantFallbackActionsOptions(pathAssistantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAssistantFallbackActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FallbackActions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update AssistantFallbackActions parameters + /// Client to make requests to Twilio + /// A single instance of AssistantFallbackActions + public static AssistantFallbackActionsResource Update(UpdateAssistantFallbackActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update AssistantFallbackActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantFallbackActions + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantFallbackActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The assistant_sid + /// The fallback_actions + /// Client to make requests to Twilio + /// A single instance of AssistantFallbackActions + public static AssistantFallbackActionsResource Update(string pathAssistantSid, + object fallbackActions = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantFallbackActionsOptions(pathAssistantSid) { FallbackActions = fallbackActions }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The assistant_sid + /// The fallback_actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantFallbackActions + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + object fallbackActions = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantFallbackActionsOptions(pathAssistantSid) { FallbackActions = fallbackActions }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssistantFallbackActionsResource object + /// + /// Raw JSON string + /// AssistantFallbackActionsResource object represented by the provided JSON + public static AssistantFallbackActionsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The assistant_sid + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private AssistantFallbackActionsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsOptions.cs index 0def2fffd..4704a8ae0 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchAssistantInitiationActionsOptions + /// + public class FetchAssistantInitiationActionsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchAssistantInitiationActionsOptions + /// The assistant_sid /// - public class FetchAssistantInitiationActionsOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new FetchAssistantInitiationActionsOptions - /// - /// The assistant_sid - public FetchAssistantInitiationActionsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateAssistantInitiationActionsOptions + /// Construct a new FetchAssistantInitiationActionsOptions /// - public class UpdateAssistantInitiationActionsOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The initiation_actions - /// - public object InitiationActions { get; set; } - - /// - /// Construct a new UpdateAssistantInitiationActionsOptions - /// - /// The assistant_sid - public UpdateAssistantInitiationActionsOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (InitiationActions != null) - { - p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); - } - - return p; - } - } + /// The assistant_sid + public FetchAssistantInitiationActionsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateAssistantInitiationActionsOptions + /// + public class UpdateAssistantInitiationActionsOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The initiation_actions + /// + public object InitiationActions { get; set; } + + /// + /// Construct a new UpdateAssistantInitiationActionsOptions + /// + /// The assistant_sid + public UpdateAssistantInitiationActionsOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (InitiationActions != null) + { + p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsResource.cs index 1e3f58b8a..4b65f4b41 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/AssistantInitiationActionsResource.cs @@ -19,194 +19,194 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class AssistantInitiationActionsResource : Resource - { - private static Request BuildFetchRequest(FetchAssistantInitiationActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/InitiationActions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch AssistantInitiationActions parameters - /// Client to make requests to Twilio - /// A single instance of AssistantInitiationActions - public static AssistantInitiationActionsResource Fetch(FetchAssistantInitiationActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch AssistantInitiationActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantInitiationActions - public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantInitiationActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// Client to make requests to Twilio - /// A single instance of AssistantInitiationActions - public static AssistantInitiationActionsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) - { - var options = new FetchAssistantInitiationActionsOptions(pathAssistantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantInitiationActions - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - ITwilioRestClient client = null) - { - var options = new FetchAssistantInitiationActionsOptions(pathAssistantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAssistantInitiationActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/InitiationActions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update AssistantInitiationActions parameters - /// Client to make requests to Twilio - /// A single instance of AssistantInitiationActions - public static AssistantInitiationActionsResource Update(UpdateAssistantInitiationActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update AssistantInitiationActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantInitiationActions - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantInitiationActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The assistant_sid - /// The initiation_actions - /// Client to make requests to Twilio - /// A single instance of AssistantInitiationActions - public static AssistantInitiationActionsResource Update(string pathAssistantSid, - object initiationActions = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantInitiationActionsOptions(pathAssistantSid){InitiationActions = initiationActions}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The assistant_sid - /// The initiation_actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssistantInitiationActions - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - object initiationActions = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantInitiationActionsOptions(pathAssistantSid){InitiationActions = initiationActions}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssistantInitiationActionsResource object - /// - /// Raw JSON string - /// AssistantInitiationActionsResource object represented by the provided JSON - public static AssistantInitiationActionsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The assistant_sid - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private AssistantInitiationActionsResource() - { - - } - } +{ + + public class AssistantInitiationActionsResource : Resource + { + private static Request BuildFetchRequest(FetchAssistantInitiationActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/InitiationActions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch AssistantInitiationActions parameters + /// Client to make requests to Twilio + /// A single instance of AssistantInitiationActions + public static AssistantInitiationActionsResource Fetch(FetchAssistantInitiationActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch AssistantInitiationActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantInitiationActions + public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantInitiationActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// Client to make requests to Twilio + /// A single instance of AssistantInitiationActions + public static AssistantInitiationActionsResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) + { + var options = new FetchAssistantInitiationActionsOptions(pathAssistantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantInitiationActions + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + ITwilioRestClient client = null) + { + var options = new FetchAssistantInitiationActionsOptions(pathAssistantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAssistantInitiationActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/InitiationActions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update AssistantInitiationActions parameters + /// Client to make requests to Twilio + /// A single instance of AssistantInitiationActions + public static AssistantInitiationActionsResource Update(UpdateAssistantInitiationActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update AssistantInitiationActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantInitiationActions + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantInitiationActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The assistant_sid + /// The initiation_actions + /// Client to make requests to Twilio + /// A single instance of AssistantInitiationActions + public static AssistantInitiationActionsResource Update(string pathAssistantSid, + object initiationActions = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantInitiationActionsOptions(pathAssistantSid) { InitiationActions = initiationActions }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The assistant_sid + /// The initiation_actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssistantInitiationActions + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + object initiationActions = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantInitiationActionsOptions(pathAssistantSid) { InitiationActions = initiationActions }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssistantInitiationActionsResource object + /// + /// Raw JSON string + /// AssistantInitiationActionsResource object represented by the provided JSON + public static AssistantInitiationActionsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The assistant_sid + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private AssistantInitiationActionsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/DialogueOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/DialogueOptions.cs index bc88eb848..0a4804f67 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/DialogueOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/DialogueOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchDialogueOptions + /// + public class FetchDialogueOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchDialogueOptions + /// The assistant_sid /// - public class FetchDialogueOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDialogueOptions - /// - /// The assistant_sid - /// The sid - public FetchDialogueOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDialogueOptions + /// + /// The assistant_sid + /// The sid + public FetchDialogueOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/DialogueResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/DialogueResource.cs index 255ee021a..96ff0fc9b 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/DialogueResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/DialogueResource.cs @@ -19,128 +19,128 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class DialogueResource : Resource - { - private static Request BuildFetchRequest(FetchDialogueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Dialogues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Dialogue parameters - /// Client to make requests to Twilio - /// A single instance of Dialogue - public static DialogueResource Fetch(FetchDialogueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Dialogue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Dialogue - public static async System.Threading.Tasks.Task FetchAsync(FetchDialogueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of Dialogue - public static DialogueResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDialogueOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Dialogue - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDialogueOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DialogueResource object - /// - /// Raw JSON string - /// DialogueResource object represented by the provided JSON - public static DialogueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique ID of the Dialogue - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The dialogue memory object as json - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DialogueResource() - { - - } - } +{ + + public class DialogueResource : Resource + { + private static Request BuildFetchRequest(FetchDialogueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Dialogues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Dialogue parameters + /// Client to make requests to Twilio + /// A single instance of Dialogue + public static DialogueResource Fetch(FetchDialogueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Dialogue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Dialogue + public static async System.Threading.Tasks.Task FetchAsync(FetchDialogueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of Dialogue + public static DialogueResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDialogueOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Dialogue + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDialogueOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DialogueResource object + /// + /// Raw JSON string + /// DialogueResource object represented by the provided JSON + public static DialogueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique ID of the Dialogue + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The dialogue memory object as json + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DialogueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueOptions.cs index 11846a432..bb9a72786 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueOptions.cs @@ -9,216 +9,216 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant.FieldType -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldValueOptions + /// + public class FetchFieldValueOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldValueOptions - /// - public class FetchFieldValueOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The field_type_sid - /// - public string PathFieldTypeSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldValueOptions - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - public FetchFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The assistant_sid + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldValueOptions - /// - public class ReadFieldValueOptions : ReadOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The field_type_sid - /// - public string PathFieldTypeSid { get; } - /// - /// An ISO language-country string of the value. For example: en-US - /// - public string Language { get; set; } - - /// - /// Construct a new ReadFieldValueOptions - /// - /// The assistant_sid - /// The field_type_sid - public ReadFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The field_type_sid + /// + public string PathFieldTypeSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldValueOptions - /// - public class CreateFieldValueOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The field_type_sid - /// - public string PathFieldTypeSid { get; } - /// - /// An ISO language-country string of the value. - /// - public string Language { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string Value { get; } - /// - /// A value that indicates this field value is a synonym of. Empty if the value is not a synonym. - /// - public string SynonymOf { get; set; } - - /// - /// Construct a new CreateFieldValueOptions - /// - /// The assistant_sid - /// The field_type_sid - /// An ISO language-country string of the value. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. - /// Unique up to 64 characters long. - public CreateFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string language, string value) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - Language = language; - Value = value; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (Value != null) - { - p.Add(new KeyValuePair("Value", Value)); - } - - if (SynonymOf != null) - { - p.Add(new KeyValuePair("SynonymOf", SynonymOf.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldValueOptions - /// - public class DeleteFieldValueOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The field_type_sid - /// - public string PathFieldTypeSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldValueOptions - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - public DeleteFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathFieldTypeSid = pathFieldTypeSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchFieldValueOptions + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + public FetchFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldValueOptions + /// + public class ReadFieldValueOptions : ReadOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The field_type_sid + /// + public string PathFieldTypeSid { get; } + /// + /// An ISO language-country string of the value. For example: en-US + /// + public string Language { get; set; } + + /// + /// Construct a new ReadFieldValueOptions + /// + /// The assistant_sid + /// The field_type_sid + public ReadFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldValueOptions + /// + public class CreateFieldValueOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The field_type_sid + /// + public string PathFieldTypeSid { get; } + /// + /// An ISO language-country string of the value. + /// + public string Language { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string Value { get; } + /// + /// A value that indicates this field value is a synonym of. Empty if the value is not a synonym. + /// + public string SynonymOf { get; set; } + + /// + /// Construct a new CreateFieldValueOptions + /// + /// The assistant_sid + /// The field_type_sid + /// An ISO language-country string of the value. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. + /// Unique up to 64 characters long. + public CreateFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string language, string value) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + Language = language; + Value = value; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (Value != null) + { + p.Add(new KeyValuePair("Value", Value)); + } + + if (SynonymOf != null) + { + p.Add(new KeyValuePair("SynonymOf", SynonymOf.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldValueOptions + /// + public class DeleteFieldValueOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The field_type_sid + /// + public string PathFieldTypeSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldValueOptions + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + public DeleteFieldValueOptions(string pathAssistantSid, string pathFieldTypeSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathFieldTypeSid = pathFieldTypeSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueResource.cs index eb5c07a62..458707671 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/FieldType/FieldValueResource.cs @@ -19,464 +19,464 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant.FieldType -{ - - public class FieldValueResource : Resource - { - private static Request BuildFetchRequest(FetchFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Fetch(FetchFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Fetch(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static ResourceSet Read(ReadFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_values", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_values", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The assistant_sid - /// The field_type_sid - /// An ISO language-country string of the value. For example: en-US - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static ResourceSet Read(string pathAssistantSid, - string pathFieldTypeSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid){Language = language, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The assistant_sid - /// The field_type_sid - /// An ISO language-country string of the value. For example: en-US - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathFieldTypeSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid){Language = language, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("field_values", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Create(CreateFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The assistant_sid - /// The field_type_sid - /// An ISO language-country string of the value. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. - /// Unique up to 64 characters long. - /// A value that indicates this field value is a synonym of. Empty if the value is not a - /// synonym. - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static FieldValueResource Create(string pathAssistantSid, - string pathFieldTypeSid, - string language, - string value, - string synonymOf = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value){SynonymOf = synonymOf}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The assistant_sid - /// The field_type_sid - /// An ISO language-country string of the value. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. - /// Unique up to 64 characters long. - /// A value that indicates this field value is a synonym of. Empty if the value is not a - /// synonym. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathFieldTypeSid, - string language, - string value, - string synonymOf = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value){SynonymOf = synonymOf}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldValueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete FieldValue parameters - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static bool Delete(DeleteFieldValueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete FieldValue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldValueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of FieldValue - public static bool Delete(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The assistant_sid - /// The field_type_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldValue - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathFieldTypeSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldValueResource object - /// - /// Raw JSON string - /// FieldValueResource object represented by the provided JSON - public static FieldValueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field Value. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique ID of the Field Type associated with this Field Value. - /// - [JsonProperty("field_type_sid")] - public string FieldTypeSid { get; private set; } - /// - /// An ISO language-country string of the value. - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The unique ID of the Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The Field Value itself. - /// - [JsonProperty("value")] - public string Value { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A value that indicates this field value is a synonym of. Empty if the value is not a synonym. - /// - [JsonProperty("synonym_of")] - public string SynonymOf { get; private set; } - - private FieldValueResource() - { - - } - } +{ + + public class FieldValueResource : Resource + { + private static Request BuildFetchRequest(FetchFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Fetch(FetchFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Fetch(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static ResourceSet Read(ReadFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_values", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_values", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The assistant_sid + /// The field_type_sid + /// An ISO language-country string of the value. For example: en-US + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static ResourceSet Read(string pathAssistantSid, + string pathFieldTypeSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid) { Language = language, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The assistant_sid + /// The field_type_sid + /// An ISO language-country string of the value. For example: en-US + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathFieldTypeSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldValueOptions(pathAssistantSid, pathFieldTypeSid) { Language = language, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("field_values", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Create(CreateFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The assistant_sid + /// The field_type_sid + /// An ISO language-country string of the value. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. + /// Unique up to 64 characters long. + /// A value that indicates this field value is a synonym of. Empty if the value is not a + /// synonym. + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static FieldValueResource Create(string pathAssistantSid, + string pathFieldTypeSid, + string language, + string value, + string synonymOf = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value) { SynonymOf = synonymOf }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The assistant_sid + /// The field_type_sid + /// An ISO language-country string of the value. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. + /// Unique up to 64 characters long. + /// A value that indicates this field value is a synonym of. Empty if the value is not a + /// synonym. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathFieldTypeSid, + string language, + string value, + string synonymOf = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldValueOptions(pathAssistantSid, pathFieldTypeSid, language, value) { SynonymOf = synonymOf }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldValueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathFieldTypeSid + "/FieldValues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete FieldValue parameters + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static bool Delete(DeleteFieldValueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete FieldValue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldValueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of FieldValue + public static bool Delete(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The assistant_sid + /// The field_type_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldValue + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathFieldTypeSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldValueOptions(pathAssistantSid, pathFieldTypeSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldValueResource object + /// + /// Raw JSON string + /// FieldValueResource object represented by the provided JSON + public static FieldValueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field Value. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique ID of the Field Type associated with this Field Value. + /// + [JsonProperty("field_type_sid")] + public string FieldTypeSid { get; private set; } + /// + /// An ISO language-country string of the value. + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The unique ID of the Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The Field Value itself. + /// + [JsonProperty("value")] + public string Value { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A value that indicates this field value is a synonym of. Empty if the value is not a synonym. + /// + [JsonProperty("synonym_of")] + public string SynonymOf { get; private set; } + + private FieldValueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeOptions.cs index ae8a1e689..8a96eabb7 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeOptions.cs @@ -9,228 +9,228 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldTypeOptions + /// + public class FetchFieldTypeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldTypeOptions - /// - public class FetchFieldTypeOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldTypeOptions - /// - /// The assistant_sid - /// The sid - public FetchFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The assistant_sid + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldTypeOptions - /// - public class ReadFieldTypeOptions : ReadOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadFieldTypeOptions - /// - /// The assistant_sid - public ReadFieldTypeOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldTypeOptions - /// - public class CreateFieldTypeOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new CreateFieldTypeOptions - /// - /// The assistant_sid - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - public CreateFieldTypeOptions(string pathAssistantSid, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Construct a new FetchFieldTypeOptions + /// + /// The assistant_sid + /// The sid + public FetchFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateFieldTypeOptions - /// - public class UpdateFieldTypeOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateFieldTypeOptions - /// - /// The assistant_sid - /// The sid - public UpdateFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldTypeOptions + /// + public class ReadFieldTypeOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldTypeOptions - /// - public class DeleteFieldTypeOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldTypeOptions - /// - /// The assistant_sid - /// The sid - public DeleteFieldTypeOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The assistant_sid + /// + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadFieldTypeOptions + /// + /// The assistant_sid + public ReadFieldTypeOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldTypeOptions + /// + public class CreateFieldTypeOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new CreateFieldTypeOptions + /// + /// The assistant_sid + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + public CreateFieldTypeOptions(string pathAssistantSid, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateFieldTypeOptions + /// + public class UpdateFieldTypeOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + public string FriendlyName { get; set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateFieldTypeOptions + /// + /// The assistant_sid + /// The sid + public UpdateFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldTypeOptions + /// + public class DeleteFieldTypeOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldTypeOptions + /// + /// The assistant_sid + /// The sid + public DeleteFieldTypeOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeResource.cs index ee93ffb73..fc131407f 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/FieldTypeResource.cs @@ -1,533 +1,533 @@ -/// This code was generated by -/// \ / _ _ _| _ _ -/// | (_)\/(_)(_|\/| |(/_ v1.0.0 -/// / / -/// -/// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you -/// currently do not have developer preview access, please contact help@twilio.com. -/// -/// FieldTypeResource -/// - -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using Twilio.Base; -using Twilio.Clients; -using Twilio.Converters; -using Twilio.Exceptions; -using Twilio.Http; - -namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class FieldTypeResource : Resource - { - private static Request BuildFetchRequest(FetchFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Fetch(FetchFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static ResourceSet Read(ReadFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("field_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The assistant_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FieldType - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldTypeOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The assistant_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldTypeOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("field_types", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Create(CreateFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The assistant_sid - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Create(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The assistant_sid - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Update(UpdateFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The assistant_sid - /// The sid - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// Client to make requests to Twilio - /// A single instance of FieldType - public static FieldTypeResource Update(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The assistant_sid - /// The sid - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete FieldType parameters - /// Client to make requests to Twilio - /// A single instance of FieldType - public static bool Delete(DeleteFieldTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete FieldType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of FieldType - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FieldType - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldTypeResource object - /// - /// Raw JSON string - /// FieldTypeResource object represented by the provided JSON - public static FieldTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field Type. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The unique ID of the Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FieldTypeResource() - { - - } - } - +/// This code was generated by +/// \ / _ _ _| _ _ +/// | (_)\/(_)(_|\/| |(/_ v1.0.0 +/// / / +/// +/// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you +/// currently do not have developer preview access, please contact help@twilio.com. +/// +/// FieldTypeResource +/// + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Clients; +using Twilio.Converters; +using Twilio.Exceptions; +using Twilio.Http; + +namespace Twilio.Rest.Preview.Understand.Assistant +{ + + public class FieldTypeResource : Resource + { + private static Request BuildFetchRequest(FetchFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Fetch(FetchFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldTypeOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static ResourceSet Read(ReadFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("field_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The assistant_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FieldType + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldTypeOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The assistant_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldTypeOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("field_types", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Create(CreateFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The assistant_sid + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Create(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The assistant_sid + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateFieldTypeOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Update(UpdateFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The assistant_sid + /// The sid + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// Client to make requests to Twilio + /// A single instance of FieldType + public static FieldTypeResource Update(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The assistant_sid + /// The sid + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateFieldTypeOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/FieldTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete FieldType parameters + /// Client to make requests to Twilio + /// A single instance of FieldType + public static bool Delete(DeleteFieldTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete FieldType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of FieldType + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FieldType + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldTypeOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldTypeResource object + /// + /// Raw JSON string + /// FieldTypeResource object represented by the provided JSON + public static FieldTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field Type. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The unique ID of the Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FieldTypeResource() + { + + } + } + } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildOptions.cs index aef95593d..15503c138 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildOptions.cs @@ -9,216 +9,216 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchModelBuildOptions + /// + public class FetchModelBuildOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchModelBuildOptions - /// - public class FetchModelBuildOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchModelBuildOptions - /// - /// The assistant_sid - /// The sid - public FetchModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The assistant_sid + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadModelBuildOptions - /// - public class ReadModelBuildOptions : ReadOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadModelBuildOptions - /// - /// The assistant_sid - public ReadModelBuildOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateModelBuildOptions - /// - public class CreateModelBuildOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The status_callback - /// - public Uri StatusCallback { get; set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - /// - public string UniqueName { get; set; } - - /// - /// Construct a new CreateModelBuildOptions - /// - /// The assistant_sid - public CreateModelBuildOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Construct a new FetchModelBuildOptions + /// + /// The assistant_sid + /// The sid + public FetchModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateModelBuildOptions - /// - public class UpdateModelBuildOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateModelBuildOptions - /// - /// The assistant_sid - /// The sid - public UpdateModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadModelBuildOptions + /// + public class ReadModelBuildOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteModelBuildOptions - /// - public class DeleteModelBuildOptions : IOptions - { - /// - /// The assistant_sid - /// - public string PathAssistantSid { get; } - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteModelBuildOptions - /// - /// The assistant_sid - /// The sid - public DeleteModelBuildOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The assistant_sid + /// + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadModelBuildOptions + /// + /// The assistant_sid + public ReadModelBuildOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateModelBuildOptions + /// + public class CreateModelBuildOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The status_callback + /// + public Uri StatusCallback { get; set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 + /// + public string UniqueName { get; set; } + + /// + /// Construct a new CreateModelBuildOptions + /// + /// The assistant_sid + public CreateModelBuildOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateModelBuildOptions + /// + public class UpdateModelBuildOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateModelBuildOptions + /// + /// The assistant_sid + /// The sid + public UpdateModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteModelBuildOptions + /// + public class DeleteModelBuildOptions : IOptions + { + /// + /// The assistant_sid + /// + public string PathAssistantSid { get; } + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteModelBuildOptions + /// + /// The assistant_sid + /// The sid + public DeleteModelBuildOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildResource.cs index 572953dd5..13cc76f8e 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/ModelBuildResource.cs @@ -20,529 +20,529 @@ using Twilio.Types; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class ModelBuildResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); - public static readonly StatusEnum Building = new StatusEnum("building"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - } - - private static Request BuildFetchRequest(FetchModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Fetch(FetchModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task FetchAsync(FetchModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ResourceSet Read(ReadModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("model_builds", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task> ReadAsync(ReadModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("model_builds", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The assistant_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadModelBuildOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The assistant_sid - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadModelBuildOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("model_builds", response.Content); - } - - private static Request BuildCreateRequest(CreateModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Create(CreateModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task CreateAsync(CreateModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The assistant_sid - /// The status_callback - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. For example: v0.1 - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Create(string pathAssistantSid, - Uri statusCallback = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateModelBuildOptions(pathAssistantSid){StatusCallback = statusCallback, UniqueName = uniqueName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The assistant_sid - /// The status_callback - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. For example: v0.1 - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - Uri statusCallback = null, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new CreateModelBuildOptions(pathAssistantSid){StatusCallback = statusCallback, UniqueName = uniqueName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Update(UpdateModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task UpdateAsync(UpdateModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The assistant_sid - /// The sid - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. For example: v0.1 - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static ModelBuildResource Update(string pathAssistantSid, - string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid){UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The assistant_sid - /// The sid - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. For example: v0.1 - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid){UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteModelBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ModelBuild parameters - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static bool Delete(DeleteModelBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ModelBuild parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task DeleteAsync(DeleteModelBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// A single instance of ModelBuild - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The assistant_sid - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ModelBuild - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ModelBuildResource object - /// - /// Raw JSON string - /// ModelBuildResource object represented by the provided JSON - public static ModelBuildResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Model Build. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A string that described the model build status. The values can be: enqueued, building, completed, failed - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ModelBuildResource.StatusEnum Status { get; private set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The time in seconds it took to build the model. - /// - [JsonProperty("build_duration")] - public int? BuildDuration { get; private set; } - /// - /// The error_code - /// - [JsonProperty("error_code")] - public int? ErrorCode { get; private set; } - - private ModelBuildResource() - { - - } - } +{ + + public class ModelBuildResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); + public static readonly StatusEnum Building = new StatusEnum("building"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + } + + private static Request BuildFetchRequest(FetchModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Fetch(FetchModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task FetchAsync(FetchModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchModelBuildOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ResourceSet Read(ReadModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("model_builds", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task> ReadAsync(ReadModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("model_builds", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The assistant_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadModelBuildOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The assistant_sid + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadModelBuildOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("model_builds", response.Content); + } + + private static Request BuildCreateRequest(CreateModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Create(CreateModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task CreateAsync(CreateModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The assistant_sid + /// The status_callback + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. For example: v0.1 + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Create(string pathAssistantSid, + Uri statusCallback = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateModelBuildOptions(pathAssistantSid) { StatusCallback = statusCallback, UniqueName = uniqueName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The assistant_sid + /// The status_callback + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. For example: v0.1 + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + Uri statusCallback = null, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new CreateModelBuildOptions(pathAssistantSid) { StatusCallback = statusCallback, UniqueName = uniqueName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Update(UpdateModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task UpdateAsync(UpdateModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The assistant_sid + /// The sid + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. For example: v0.1 + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static ModelBuildResource Update(string pathAssistantSid, + string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The assistant_sid + /// The sid + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. For example: v0.1 + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateModelBuildOptions(pathAssistantSid, pathSid) { UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteModelBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/ModelBuilds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ModelBuild parameters + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static bool Delete(DeleteModelBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ModelBuild parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task DeleteAsync(DeleteModelBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// A single instance of ModelBuild + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The assistant_sid + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ModelBuild + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteModelBuildOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ModelBuildResource object + /// + /// Raw JSON string + /// ModelBuildResource object represented by the provided JSON + public static ModelBuildResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Model Build. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A string that described the model build status. The values can be: enqueued, building, completed, failed + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ModelBuildResource.StatusEnum Status { get; private set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The time in seconds it took to build the model. + /// + [JsonProperty("build_duration")] + public int? BuildDuration { get; private set; } + /// + /// The error_code + /// + [JsonProperty("error_code")] + public int? ErrorCode { get; private set; } + + private ModelBuildResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/QueryOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/QueryOptions.cs index cbd490be3..32b94c85d 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/QueryOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/QueryOptions.cs @@ -9,284 +9,284 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchQueryOptions + /// + public class FetchQueryOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchQueryOptions + /// The unique ID of the Assistant. /// - public class FetchQueryOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchQueryOptions - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - public FetchQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadQueryOptions + /// A 34 character string that uniquely identifies this resource. /// - public class ReadQueryOptions : ReadOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// An ISO language-country string of the sample. - /// - public string Language { get; set; } - /// - /// The Model Build Sid or unique name of the Model Build to be queried. - /// - public string ModelBuild { get; set; } - /// - /// A string that described the query status. The values can be: pending_review, reviewed, discarded - /// - public string Status { get; set; } - - /// - /// Construct a new ReadQueryOptions - /// - /// The unique ID of the parent Assistant. - public ReadQueryOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (ModelBuild != null) - { - p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateQueryOptions + /// Construct a new FetchQueryOptions /// - public class CreateQueryOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// An ISO language-country string of the sample. - /// - public string Language { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long. - /// - public string Query { get; } - /// - /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 - /// - public string Tasks { get; set; } - /// - /// The Model Build Sid or unique name of the Model Build to be queried. - /// - public string ModelBuild { get; set; } - /// - /// Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format task-unique-name-1:field-unique-name - /// - public string Field { get; set; } - - /// - /// Construct a new CreateQueryOptions - /// - /// The unique ID of the parent Assistant. - /// An ISO language-country string of the sample. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It - /// can be up to 2048 characters long. - public CreateQueryOptions(string pathAssistantSid, string language, string query) - { - PathAssistantSid = pathAssistantSid; - Language = language; - Query = query; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (Query != null) - { - p.Add(new KeyValuePair("Query", Query)); - } - - if (Tasks != null) - { - p.Add(new KeyValuePair("Tasks", Tasks)); - } - - if (ModelBuild != null) - { - p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); - } - - if (Field != null) - { - p.Add(new KeyValuePair("Field", Field)); - } - - return p; - } - } - + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + public FetchQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateQueryOptions + /// Generate the necessary parameters /// - public class UpdateQueryOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// An optional reference to the Sample created from this query. - /// - public string SampleSid { get; set; } - /// - /// A string that described the query status. The values can be: pending_review, reviewed, discarded - /// - public string Status { get; set; } - - /// - /// Construct a new UpdateQueryOptions - /// - /// The unique ID of the parent Assistant. - /// A 34 character string that uniquely identifies this resource. - public UpdateQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (SampleSid != null) - { - p.Add(new KeyValuePair("SampleSid", SampleSid.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadQueryOptions + /// + public class ReadQueryOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteQueryOptions + /// The unique ID of the parent Assistant. /// - public class DeleteQueryOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteQueryOptions - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - public DeleteQueryOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// An ISO language-country string of the sample. + /// + public string Language { get; set; } + /// + /// The Model Build Sid or unique name of the Model Build to be queried. + /// + public string ModelBuild { get; set; } + /// + /// A string that described the query status. The values can be: pending_review, reviewed, discarded + /// + public string Status { get; set; } + + /// + /// Construct a new ReadQueryOptions + /// + /// The unique ID of the parent Assistant. + public ReadQueryOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (ModelBuild != null) + { + p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateQueryOptions + /// + public class CreateQueryOptions : IOptions + { + /// + /// The unique ID of the parent Assistant. + /// + public string PathAssistantSid { get; } + /// + /// An ISO language-country string of the sample. + /// + public string Language { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long. + /// + public string Query { get; } + /// + /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 + /// + public string Tasks { get; set; } + /// + /// The Model Build Sid or unique name of the Model Build to be queried. + /// + public string ModelBuild { get; set; } + /// + /// Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format task-unique-name-1:field-unique-name + /// + public string Field { get; set; } + + /// + /// Construct a new CreateQueryOptions + /// + /// The unique ID of the parent Assistant. + /// An ISO language-country string of the sample. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It + /// can be up to 2048 characters long. + public CreateQueryOptions(string pathAssistantSid, string language, string query) + { + PathAssistantSid = pathAssistantSid; + Language = language; + Query = query; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (Query != null) + { + p.Add(new KeyValuePair("Query", Query)); + } + + if (Tasks != null) + { + p.Add(new KeyValuePair("Tasks", Tasks)); + } + + if (ModelBuild != null) + { + p.Add(new KeyValuePair("ModelBuild", ModelBuild.ToString())); + } + + if (Field != null) + { + p.Add(new KeyValuePair("Field", Field)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateQueryOptions + /// + public class UpdateQueryOptions : IOptions + { + /// + /// The unique ID of the parent Assistant. + /// + public string PathAssistantSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// An optional reference to the Sample created from this query. + /// + public string SampleSid { get; set; } + /// + /// A string that described the query status. The values can be: pending_review, reviewed, discarded + /// + public string Status { get; set; } + + /// + /// Construct a new UpdateQueryOptions + /// + /// The unique ID of the parent Assistant. + /// A 34 character string that uniquely identifies this resource. + public UpdateQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (SampleSid != null) + { + p.Add(new KeyValuePair("SampleSid", SampleSid.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteQueryOptions + /// + public class DeleteQueryOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteQueryOptions + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + public DeleteQueryOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/QueryResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/QueryResource.cs index a8ebf5732..cb753d270 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/QueryResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/QueryResource.cs @@ -19,561 +19,561 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class QueryResource : Resource - { - private static Request BuildFetchRequest(FetchQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Fetch(FetchQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task FetchAsync(FetchQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchQueryOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchQueryOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Queries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static ResourceSet Read(ReadQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("queries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task> ReadAsync(ReadQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("queries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The unique ID of the parent Assistant. - /// An ISO language-country string of the sample. - /// The Model Build Sid or unique name of the Model Build to be queried. - /// A string that described the query status. The values can be: pending_review, reviewed, - /// discarded - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Query - public static ResourceSet Read(string pathAssistantSid, - string language = null, - string modelBuild = null, - string status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueryOptions(pathAssistantSid){Language = language, ModelBuild = modelBuild, Status = status, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The unique ID of the parent Assistant. - /// An ISO language-country string of the sample. - /// The Model Build Sid or unique name of the Model Build to be queried. - /// A string that described the query status. The values can be: pending_review, reviewed, - /// discarded - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string language = null, - string modelBuild = null, - string status = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadQueryOptions(pathAssistantSid){Language = language, ModelBuild = modelBuild, Status = status, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("queries", response.Content); - } - - private static Request BuildCreateRequest(CreateQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Queries", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Create(CreateQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task CreateAsync(CreateQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique ID of the parent Assistant. - /// An ISO language-country string of the sample. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It - /// can be up to 2048 characters long. - /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user - /// can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 - /// The Model Build Sid or unique name of the Model Build to be queried. - /// Constraints the query to a given Field with an task. Useful when you know the Field you are - /// expecting. It accepts one field in the format task-unique-name-1:field-unique-name - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Create(string pathAssistantSid, - string language, - string query, - string tasks = null, - string modelBuild = null, - string field = null, - ITwilioRestClient client = null) - { - var options = new CreateQueryOptions(pathAssistantSid, language, query){Tasks = tasks, ModelBuild = modelBuild, Field = field}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique ID of the parent Assistant. - /// An ISO language-country string of the sample. - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It - /// can be up to 2048 characters long. - /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user - /// can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 - /// The Model Build Sid or unique name of the Model Build to be queried. - /// Constraints the query to a given Field with an task. Useful when you know the Field you are - /// expecting. It accepts one field in the format task-unique-name-1:field-unique-name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string language, - string query, - string tasks = null, - string modelBuild = null, - string field = null, - ITwilioRestClient client = null) - { - var options = new CreateQueryOptions(pathAssistantSid, language, query){Tasks = tasks, ModelBuild = modelBuild, Field = field}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Update(UpdateQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique ID of the parent Assistant. - /// A 34 character string that uniquely identifies this resource. - /// An optional reference to the Sample created from this query. - /// A string that described the query status. The values can be: pending_review, reviewed, - /// discarded - /// Client to make requests to Twilio - /// A single instance of Query - public static QueryResource Update(string pathAssistantSid, - string pathSid, - string sampleSid = null, - string status = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueryOptions(pathAssistantSid, pathSid){SampleSid = sampleSid, Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique ID of the parent Assistant. - /// A 34 character string that uniquely identifies this resource. - /// An optional reference to the Sample created from this query. - /// A string that described the query status. The values can be: pending_review, reviewed, - /// discarded - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string sampleSid = null, - string status = null, - ITwilioRestClient client = null) - { - var options = new UpdateQueryOptions(pathAssistantSid, pathSid){SampleSid = sampleSid, Status = status}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteQueryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Query parameters - /// Client to make requests to Twilio - /// A single instance of Query - public static bool Delete(DeleteQueryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Query parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Query - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteQueryOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Query - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteQueryOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a QueryResource object - /// - /// Raw JSON string - /// QueryResource object represented by the provided JSON - public static QueryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Query. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields. - /// - [JsonProperty("results")] - public object Results { get; private set; } - /// - /// An ISO language-country string of the sample. - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The unique ID of the Model Build queried. - /// - [JsonProperty("model_build_sid")] - public string ModelBuildSid { get; private set; } - /// - /// The end-user's natural language input. - /// - [JsonProperty("query")] - public string Query { get; private set; } - /// - /// An optional reference to the Sample created from this query. - /// - [JsonProperty("sample_sid")] - public string SampleSid { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A string that described the query status. The values can be: pending_review, reviewed, discarded - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The communication channel where this end-user input came from - /// - [JsonProperty("source_channel")] - public string SourceChannel { get; private set; } - - private QueryResource() - { - - } - } +{ + + public class QueryResource : Resource + { + private static Request BuildFetchRequest(FetchQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Fetch(FetchQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task FetchAsync(FetchQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchQueryOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchQueryOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Queries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static ResourceSet Read(ReadQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("queries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task> ReadAsync(ReadQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("queries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The unique ID of the parent Assistant. + /// An ISO language-country string of the sample. + /// The Model Build Sid or unique name of the Model Build to be queried. + /// A string that described the query status. The values can be: pending_review, reviewed, + /// discarded + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Query + public static ResourceSet Read(string pathAssistantSid, + string language = null, + string modelBuild = null, + string status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueryOptions(pathAssistantSid) { Language = language, ModelBuild = modelBuild, Status = status, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The unique ID of the parent Assistant. + /// An ISO language-country string of the sample. + /// The Model Build Sid or unique name of the Model Build to be queried. + /// A string that described the query status. The values can be: pending_review, reviewed, + /// discarded + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string language = null, + string modelBuild = null, + string status = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadQueryOptions(pathAssistantSid) { Language = language, ModelBuild = modelBuild, Status = status, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("queries", response.Content); + } + + private static Request BuildCreateRequest(CreateQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Queries", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Create(CreateQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task CreateAsync(CreateQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique ID of the parent Assistant. + /// An ISO language-country string of the sample. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It + /// can be up to 2048 characters long. + /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user + /// can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 + /// The Model Build Sid or unique name of the Model Build to be queried. + /// Constraints the query to a given Field with an task. Useful when you know the Field you are + /// expecting. It accepts one field in the format task-unique-name-1:field-unique-name + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Create(string pathAssistantSid, + string language, + string query, + string tasks = null, + string modelBuild = null, + string field = null, + ITwilioRestClient client = null) + { + var options = new CreateQueryOptions(pathAssistantSid, language, query) { Tasks = tasks, ModelBuild = modelBuild, Field = field }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique ID of the parent Assistant. + /// An ISO language-country string of the sample. + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. It + /// can be up to 2048 characters long. + /// Constraints the query to a set of tasks. Useful when you need to constrain the paths the user + /// can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2 + /// The Model Build Sid or unique name of the Model Build to be queried. + /// Constraints the query to a given Field with an task. Useful when you know the Field you are + /// expecting. It accepts one field in the format task-unique-name-1:field-unique-name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string language, + string query, + string tasks = null, + string modelBuild = null, + string field = null, + ITwilioRestClient client = null) + { + var options = new CreateQueryOptions(pathAssistantSid, language, query) { Tasks = tasks, ModelBuild = modelBuild, Field = field }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Update(UpdateQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task UpdateAsync(UpdateQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique ID of the parent Assistant. + /// A 34 character string that uniquely identifies this resource. + /// An optional reference to the Sample created from this query. + /// A string that described the query status. The values can be: pending_review, reviewed, + /// discarded + /// Client to make requests to Twilio + /// A single instance of Query + public static QueryResource Update(string pathAssistantSid, + string pathSid, + string sampleSid = null, + string status = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueryOptions(pathAssistantSid, pathSid) { SampleSid = sampleSid, Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique ID of the parent Assistant. + /// A 34 character string that uniquely identifies this resource. + /// An optional reference to the Sample created from this query. + /// A string that described the query status. The values can be: pending_review, reviewed, + /// discarded + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string sampleSid = null, + string status = null, + ITwilioRestClient client = null) + { + var options = new UpdateQueryOptions(pathAssistantSid, pathSid) { SampleSid = sampleSid, Status = status }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteQueryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Queries/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Query parameters + /// Client to make requests to Twilio + /// A single instance of Query + public static bool Delete(DeleteQueryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Query parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task DeleteAsync(DeleteQueryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Query + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteQueryOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Query + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteQueryOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a QueryResource object + /// + /// Raw JSON string + /// QueryResource object represented by the provided JSON + public static QueryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Query. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields. + /// + [JsonProperty("results")] + public object Results { get; private set; } + /// + /// An ISO language-country string of the sample. + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The unique ID of the Model Build queried. + /// + [JsonProperty("model_build_sid")] + public string ModelBuildSid { get; private set; } + /// + /// The end-user's natural language input. + /// + [JsonProperty("query")] + public string Query { get; private set; } + /// + /// An optional reference to the Sample created from this query. + /// + [JsonProperty("sample_sid")] + public string SampleSid { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A string that described the query status. The values can be: pending_review, reviewed, discarded + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The communication channel where this end-user input came from + /// + [JsonProperty("source_channel")] + public string SourceChannel { get; private set; } + + private QueryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetOptions.cs index 757037bb3..0a7e512cf 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetOptions.cs @@ -9,79 +9,79 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Returns Style sheet JSON object for this Assistant + /// + public class FetchStyleSheetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Returns Style sheet JSON object for this Assistant + /// The unique ID of the Assistant /// - public class FetchStyleSheetOptions : IOptions - { - /// - /// The unique ID of the Assistant - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new FetchStyleSheetOptions - /// - /// The unique ID of the Assistant - public FetchStyleSheetOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// Construct a new FetchStyleSheetOptions /// - public class UpdateStyleSheetOptions : IOptions - { - /// - /// The unique ID of the Assistant - /// - public string PathAssistantSid { get; } - /// - /// The JSON Style sheet string - /// - public object StyleSheet { get; set; } - - /// - /// Construct a new UpdateStyleSheetOptions - /// - /// The unique ID of the Assistant - public UpdateStyleSheetOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - return p; - } - } + /// The unique ID of the Assistant + public FetchStyleSheetOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// + public class UpdateStyleSheetOptions : IOptions + { + /// + /// The unique ID of the Assistant + /// + public string PathAssistantSid { get; } + /// + /// The JSON Style sheet string + /// + public object StyleSheet { get; set; } + + /// + /// Construct a new UpdateStyleSheetOptions + /// + /// The unique ID of the Assistant + public UpdateStyleSheetOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetResource.cs index beeab5cb6..e5847d76b 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/StyleSheetResource.cs @@ -19,192 +19,192 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class StyleSheetResource : Resource - { - private static Request BuildFetchRequest(FetchStyleSheetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/StyleSheet", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns Style sheet JSON object for this Assistant - /// - /// Fetch StyleSheet parameters - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Fetch(FetchStyleSheetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns Style sheet JSON object for this Assistant - /// - /// Fetch StyleSheet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task FetchAsync(FetchStyleSheetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns Style sheet JSON object for this Assistant - /// - /// The unique ID of the Assistant - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) - { - var options = new FetchStyleSheetOptions(pathAssistantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns Style sheet JSON object for this Assistant - /// - /// The unique ID of the Assistant - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - ITwilioRestClient client = null) - { - var options = new FetchStyleSheetOptions(pathAssistantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateStyleSheetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/StyleSheet", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. - /// - /// Update StyleSheet parameters - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Update(UpdateStyleSheetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. - /// - /// Update StyleSheet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task UpdateAsync(UpdateStyleSheetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. - /// - /// The unique ID of the Assistant - /// The JSON Style sheet string - /// Client to make requests to Twilio - /// A single instance of StyleSheet - public static StyleSheetResource Update(string pathAssistantSid, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateStyleSheetOptions(pathAssistantSid){StyleSheet = styleSheet}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. - /// - /// The unique ID of the Assistant - /// The JSON Style sheet string - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StyleSheet - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateStyleSheetOptions(pathAssistantSid){StyleSheet = styleSheet}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a StyleSheetResource object - /// - /// Raw JSON string - /// StyleSheetResource object represented by the provided JSON - public static StyleSheetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Assistant - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the Assistant - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The JSON style sheet object - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private StyleSheetResource() - { - - } - } +{ + + public class StyleSheetResource : Resource + { + private static Request BuildFetchRequest(FetchStyleSheetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/StyleSheet", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns Style sheet JSON object for this Assistant + /// + /// Fetch StyleSheet parameters + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Fetch(FetchStyleSheetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns Style sheet JSON object for this Assistant + /// + /// Fetch StyleSheet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task FetchAsync(FetchStyleSheetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns Style sheet JSON object for this Assistant + /// + /// The unique ID of the Assistant + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Fetch(string pathAssistantSid, ITwilioRestClient client = null) + { + var options = new FetchStyleSheetOptions(pathAssistantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns Style sheet JSON object for this Assistant + /// + /// The unique ID of the Assistant + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + ITwilioRestClient client = null) + { + var options = new FetchStyleSheetOptions(pathAssistantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateStyleSheetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/StyleSheet", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// + /// Update StyleSheet parameters + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Update(UpdateStyleSheetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// + /// Update StyleSheet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task UpdateAsync(UpdateStyleSheetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// + /// The unique ID of the Assistant + /// The JSON Style sheet string + /// Client to make requests to Twilio + /// A single instance of StyleSheet + public static StyleSheetResource Update(string pathAssistantSid, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateStyleSheetOptions(pathAssistantSid) { StyleSheet = styleSheet }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the style sheet for an assistant identified by {AssistantSid} or {AssistantUniqueName}. + /// + /// The unique ID of the Assistant + /// The JSON Style sheet string + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StyleSheet + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateStyleSheetOptions(pathAssistantSid) { StyleSheet = styleSheet }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a StyleSheetResource object + /// + /// Raw JSON string + /// StyleSheetResource object represented by the provided JSON + public static StyleSheetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Assistant + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the Assistant + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The JSON style sheet object + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private StyleSheetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldOptions.cs index a16844b82..1c5724edd 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldOptions.cs @@ -9,199 +9,199 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchFieldOptions + /// + public class FetchFieldOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchFieldOptions - /// - public class FetchFieldOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Field. - /// - public string PathTaskSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFieldOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - public FetchFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadFieldOptions - /// - public class ReadFieldOptions : ReadOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Field. - /// - public string PathTaskSid { get; } - - /// - /// Construct a new ReadFieldOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - public ReadFieldOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique ID of the Task associated with this Field. + /// + public string PathTaskSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateFieldOptions - /// - public class CreateFieldOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Field. - /// - public string PathTaskSid { get; } - /// - /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the unique_name or sid of a custom Field Type. - /// - public string FieldType { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; } - - /// - /// Construct a new CreateFieldOptions - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the - /// unique_name or sid of a custom Field Type. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - public CreateFieldOptions(string pathAssistantSid, string pathTaskSid, string fieldType, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - FieldType = fieldType; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FieldType != null) - { - p.Add(new KeyValuePair("FieldType", FieldType)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteFieldOptions - /// - public class DeleteFieldOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Field. - /// - public string PathTaskSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFieldOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - public DeleteFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchFieldOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + public FetchFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadFieldOptions + /// + public class ReadFieldOptions : ReadOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Field. + /// + public string PathTaskSid { get; } + + /// + /// Construct a new ReadFieldOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + public ReadFieldOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateFieldOptions + /// + public class CreateFieldOptions : IOptions + { + /// + /// The unique ID of the parent Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Field. + /// + public string PathTaskSid { get; } + /// + /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the unique_name or sid of a custom Field Type. + /// + public string FieldType { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; } + + /// + /// Construct a new CreateFieldOptions + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the + /// unique_name or sid of a custom Field Type. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + public CreateFieldOptions(string pathAssistantSid, string pathTaskSid, string fieldType, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + FieldType = fieldType; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FieldType != null) + { + p.Add(new KeyValuePair("FieldType", FieldType)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteFieldOptions + /// + public class DeleteFieldOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Field. + /// + public string PathTaskSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFieldOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + public DeleteFieldOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldResource.cs index 8764a6785..5ff66e0f3 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/FieldResource.cs @@ -19,451 +19,451 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - - public class FieldResource : Resource - { - private static Request BuildFetchRequest(FetchFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Fetch(FetchFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task FetchAsync(FetchFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Fetch(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static ResourceSet Read(ReadFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("fields", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("fields", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Field - public static ResourceSet Read(string pathAssistantSid, - string pathTaskSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathTaskSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("fields", response.Content); - } - - private static Request BuildCreateRequest(CreateFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Create(CreateFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task CreateAsync(CreateFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the - /// unique_name or sid of a custom Field Type. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// Client to make requests to Twilio - /// A single instance of Field - public static FieldResource Create(string pathAssistantSid, - string pathTaskSid, - string fieldType, - string uniqueName, - ITwilioRestClient client = null) - { - var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the - /// unique_name or sid of a custom Field Type. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathTaskSid, - string fieldType, - string uniqueName, - ITwilioRestClient client = null) - { - var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFieldOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Field parameters - /// Client to make requests to Twilio - /// A single instance of Field - public static bool Delete(DeleteFieldOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Field parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Field - public static bool Delete(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Field. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Field - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FieldResource object - /// - /// Raw JSON string - /// FieldResource object represented by the provided JSON - public static FieldResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Field Type of this field. It can be any Built-in Field Type or unique_name or the Field Type sid of a custom Field Type. - /// - [JsonProperty("field_type")] - public string FieldType { get; private set; } - /// - /// The unique ID of the Task associated with this Field. - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FieldResource() - { - - } - } +{ + + public class FieldResource : Resource + { + private static Request BuildFetchRequest(FetchFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Fetch(FetchFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task FetchAsync(FetchFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Fetch(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static ResourceSet Read(ReadFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("fields", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task> ReadAsync(ReadFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("fields", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Field + public static ResourceSet Read(string pathAssistantSid, + string pathTaskSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathTaskSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFieldOptions(pathAssistantSid, pathTaskSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("fields", response.Content); + } + + private static Request BuildCreateRequest(CreateFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Create(CreateFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task CreateAsync(CreateFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the + /// unique_name or sid of a custom Field Type. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// Client to make requests to Twilio + /// A single instance of Field + public static FieldResource Create(string pathAssistantSid, + string pathTaskSid, + string fieldType, + string uniqueName, + ITwilioRestClient client = null) + { + var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + /// The unique name or sid of the FieldType. It can be any Built-in Field Type or the + /// unique_name or sid of a custom Field Type. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathTaskSid, + string fieldType, + string uniqueName, + ITwilioRestClient client = null) + { + var options = new CreateFieldOptions(pathAssistantSid, pathTaskSid, fieldType, uniqueName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFieldOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Fields/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Field parameters + /// Client to make requests to Twilio + /// A single instance of Field + public static bool Delete(DeleteFieldOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Field parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFieldOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Field + public static bool Delete(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Field. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Field + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFieldOptions(pathAssistantSid, pathTaskSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FieldResource object + /// + /// Raw JSON string + /// FieldResource object represented by the provided JSON + public static FieldResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Field Type of this field. It can be any Built-in Field Type or unique_name or the Field Type sid of a custom Field Type. + /// + [JsonProperty("field_type")] + public string FieldType { get; private set; } + /// + /// The unique ID of the Task associated with this Field. + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FieldResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleOptions.cs index 465f872a7..b774cc881 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleOptions.cs @@ -9,287 +9,287 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSampleOptions + /// + public class FetchSampleOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSampleOptions + /// The unique ID of the Assistant. /// - public class FetchSampleOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Sample. - /// - public string PathTaskSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSampleOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - public FetchSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSampleOptions + /// The unique ID of the Task associated with this Sample. /// - public class ReadSampleOptions : ReadOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Sample. - /// - public string PathTaskSid { get; } - /// - /// An ISO language-country string of the sample. - /// - public string Language { get; set; } - - /// - /// Construct a new ReadSampleOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - public ReadSampleOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathTaskSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateSampleOptions + /// A 34 character string that uniquely identifies this resource. /// - public class CreateSampleOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Sample. - /// - public string PathTaskSid { get; } - /// - /// An ISO language-country string of the sample. - /// - public string Language { get; } - /// - /// The text example of how end-users may express this task. The sample may contain Field tag blocks. - /// - public string TaggedText { get; } - /// - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null - /// - public string SourceChannel { get; set; } - - /// - /// Construct a new CreateSampleOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// An ISO language-country string of the sample. - /// The text example of how end-users may express this task. The sample may contain Field tag - /// blocks. - public CreateSampleOptions(string pathAssistantSid, string pathTaskSid, string language, string taggedText) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - Language = language; - TaggedText = taggedText; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (TaggedText != null) - { - p.Add(new KeyValuePair("TaggedText", TaggedText)); - } - - if (SourceChannel != null) - { - p.Add(new KeyValuePair("SourceChannel", SourceChannel)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateSampleOptions + /// Construct a new FetchSampleOptions /// - public class UpdateSampleOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Sample. - /// - public string PathTaskSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// An ISO language-country string of the sample. - /// - public string Language { get; set; } - /// - /// The text example of how end-users may express this task. The sample may contain Field tag blocks. - /// - public string TaggedText { get; set; } - /// - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null - /// - public string SourceChannel { get; set; } - - /// - /// Construct a new UpdateSampleOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - public UpdateSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Language != null) - { - p.Add(new KeyValuePair("Language", Language)); - } - - if (TaggedText != null) - { - p.Add(new KeyValuePair("TaggedText", TaggedText)); - } - - if (SourceChannel != null) - { - p.Add(new KeyValuePair("SourceChannel", SourceChannel)); - } - - return p; - } - } - + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + public FetchSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteSampleOptions + /// Generate the necessary parameters /// - public class DeleteSampleOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Sample. - /// - public string PathTaskSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSampleOptions - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - public DeleteSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSampleOptions + /// + public class ReadSampleOptions : ReadOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Sample. + /// + public string PathTaskSid { get; } + /// + /// An ISO language-country string of the sample. + /// + public string Language { get; set; } + + /// + /// Construct a new ReadSampleOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + public ReadSampleOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateSampleOptions + /// + public class CreateSampleOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Sample. + /// + public string PathTaskSid { get; } + /// + /// An ISO language-country string of the sample. + /// + public string Language { get; } + /// + /// The text example of how end-users may express this task. The sample may contain Field tag blocks. + /// + public string TaggedText { get; } + /// + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null + /// + public string SourceChannel { get; set; } + + /// + /// Construct a new CreateSampleOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// An ISO language-country string of the sample. + /// The text example of how end-users may express this task. The sample may contain Field tag + /// blocks. + public CreateSampleOptions(string pathAssistantSid, string pathTaskSid, string language, string taggedText) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + Language = language; + TaggedText = taggedText; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (TaggedText != null) + { + p.Add(new KeyValuePair("TaggedText", TaggedText)); + } + + if (SourceChannel != null) + { + p.Add(new KeyValuePair("SourceChannel", SourceChannel)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateSampleOptions + /// + public class UpdateSampleOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Sample. + /// + public string PathTaskSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// An ISO language-country string of the sample. + /// + public string Language { get; set; } + /// + /// The text example of how end-users may express this task. The sample may contain Field tag blocks. + /// + public string TaggedText { get; set; } + /// + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null + /// + public string SourceChannel { get; set; } + + /// + /// Construct a new UpdateSampleOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + public UpdateSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Language != null) + { + p.Add(new KeyValuePair("Language", Language)); + } + + if (TaggedText != null) + { + p.Add(new KeyValuePair("TaggedText", TaggedText)); + } + + if (SourceChannel != null) + { + p.Add(new KeyValuePair("SourceChannel", SourceChannel)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteSampleOptions + /// + public class DeleteSampleOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Sample. + /// + public string PathTaskSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSampleOptions + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + public DeleteSampleOptions(string pathAssistantSid, string pathTaskSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleResource.cs index eca495e4e..470b22651 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/SampleResource.cs @@ -19,556 +19,556 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - - public class SampleResource : Resource - { - private static Request BuildFetchRequest(FetchSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Fetch(FetchSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task FetchAsync(FetchSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Fetch(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static ResourceSet Read(ReadSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("samples", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task> ReadAsync(ReadSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("samples", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// An ISO language-country string of the sample. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sample - public static ResourceSet Read(string pathAssistantSid, - string pathTaskSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid){Language = language, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// An ISO language-country string of the sample. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - string pathTaskSid, - string language = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid){Language = language, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("samples", response.Content); - } - - private static Request BuildCreateRequest(CreateSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Create(CreateSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task CreateAsync(CreateSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// An ISO language-country string of the sample. - /// The text example of how end-users may express this task. The sample may contain Field tag - /// blocks. - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, - /// google-assistant, or slack. If not included the value will be null - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Create(string pathAssistantSid, - string pathTaskSid, - string language, - string taggedText, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText){SourceChannel = sourceChannel}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// An ISO language-country string of the sample. - /// The text example of how end-users may express this task. The sample may contain Field tag - /// blocks. - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, - /// google-assistant, or slack. If not included the value will be null - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string pathTaskSid, - string language, - string taggedText, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText){SourceChannel = sourceChannel}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Update(UpdateSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// An ISO language-country string of the sample. - /// The text example of how end-users may express this task. The sample may contain Field tag - /// blocks. - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, - /// google-assistant, or slack. If not included the value will be null - /// Client to make requests to Twilio - /// A single instance of Sample - public static SampleResource Update(string pathAssistantSid, - string pathTaskSid, - string pathSid, - string language = null, - string taggedText = null, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid){Language = language, TaggedText = taggedText, SourceChannel = sourceChannel}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// An ISO language-country string of the sample. - /// The text example of how end-users may express this task. The sample may contain Field tag - /// blocks. - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, - /// google-assistant, or slack. If not included the value will be null - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - string language = null, - string taggedText = null, - string sourceChannel = null, - ITwilioRestClient client = null) - { - var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid){Language = language, TaggedText = taggedText, SourceChannel = sourceChannel}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSampleOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Sample parameters - /// Client to make requests to Twilio - /// A single instance of Sample - public static bool Delete(DeleteSampleOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Sample parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSampleOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Sample - public static bool Delete(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique ID of the Assistant. - /// The unique ID of the Task associated with this Sample. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sample - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SampleResource object - /// - /// Raw JSON string - /// SampleResource object represented by the provided JSON - public static SampleResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Sample. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique ID of the Task associated with this Sample. - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// An ISO language-country string of the sample. - /// - [JsonProperty("language")] - public string Language { get; private set; } - /// - /// The unique ID of the Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The text example of how end-users may express this task. The sample may contain Field tag blocks. - /// - [JsonProperty("tagged_text")] - public string TaggedText { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null - /// - [JsonProperty("source_channel")] - public string SourceChannel { get; private set; } - - private SampleResource() - { - - } - } +{ + + public class SampleResource : Resource + { + private static Request BuildFetchRequest(FetchSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Fetch(FetchSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task FetchAsync(FetchSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Fetch(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static ResourceSet Read(ReadSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("samples", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task> ReadAsync(ReadSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("samples", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// An ISO language-country string of the sample. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sample + public static ResourceSet Read(string pathAssistantSid, + string pathTaskSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid) { Language = language, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// An ISO language-country string of the sample. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + string pathTaskSid, + string language = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSampleOptions(pathAssistantSid, pathTaskSid) { Language = language, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("samples", response.Content); + } + + private static Request BuildCreateRequest(CreateSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Create(CreateSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task CreateAsync(CreateSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// An ISO language-country string of the sample. + /// The text example of how end-users may express this task. The sample may contain Field tag + /// blocks. + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, + /// google-assistant, or slack. If not included the value will be null + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Create(string pathAssistantSid, + string pathTaskSid, + string language, + string taggedText, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText) { SourceChannel = sourceChannel }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// An ISO language-country string of the sample. + /// The text example of how end-users may express this task. The sample may contain Field tag + /// blocks. + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, + /// google-assistant, or slack. If not included the value will be null + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string pathTaskSid, + string language, + string taggedText, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new CreateSampleOptions(pathAssistantSid, pathTaskSid, language, taggedText) { SourceChannel = sourceChannel }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Update(UpdateSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// An ISO language-country string of the sample. + /// The text example of how end-users may express this task. The sample may contain Field tag + /// blocks. + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, + /// google-assistant, or slack. If not included the value will be null + /// Client to make requests to Twilio + /// A single instance of Sample + public static SampleResource Update(string pathAssistantSid, + string pathTaskSid, + string pathSid, + string language = null, + string taggedText = null, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid) { Language = language, TaggedText = taggedText, SourceChannel = sourceChannel }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// An ISO language-country string of the sample. + /// The text example of how end-users may express this task. The sample may contain Field tag + /// blocks. + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, + /// google-assistant, or slack. If not included the value will be null + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + string language = null, + string taggedText = null, + string sourceChannel = null, + ITwilioRestClient client = null) + { + var options = new UpdateSampleOptions(pathAssistantSid, pathTaskSid, pathSid) { Language = language, TaggedText = taggedText, SourceChannel = sourceChannel }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSampleOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Samples/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Sample parameters + /// Client to make requests to Twilio + /// A single instance of Sample + public static bool Delete(DeleteSampleOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Sample parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSampleOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Sample + public static bool Delete(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique ID of the Assistant. + /// The unique ID of the Task associated with this Sample. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sample + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSampleOptions(pathAssistantSid, pathTaskSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SampleResource object + /// + /// Raw JSON string + /// SampleResource object represented by the provided JSON + public static SampleResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Sample. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique ID of the Task associated with this Sample. + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// An ISO language-country string of the sample. + /// + [JsonProperty("language")] + public string Language { get; private set; } + /// + /// The unique ID of the Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The text example of how end-users may express this task. The sample may contain Field tag blocks. + /// + [JsonProperty("tagged_text")] + public string TaggedText { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null + /// + [JsonProperty("source_channel")] + public string SourceChannel { get; private set; } + + private SampleResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsOptions.cs index 30bb8b87a..ba1428113 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsOptions.cs @@ -9,91 +9,91 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Returns JSON actions for this Task. + /// + public class FetchTaskActionsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Returns JSON actions for this Task. + /// The unique ID of the parent Assistant. /// - public class FetchTaskActionsOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task. - /// - public string PathTaskSid { get; } - - /// - /// Construct a new FetchTaskActionsOptions - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - public FetchTaskActionsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// The unique ID of the Task. /// - public class UpdateTaskActionsOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task. - /// - public string PathTaskSid { get; } - /// - /// The JSON actions that instruct the Assistant how to perform this task. - /// - public object Actions { get; set; } - - /// - /// Construct a new UpdateTaskActionsOptions - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - public UpdateTaskActionsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - return p; - } - } + public string PathTaskSid { get; } + + /// + /// Construct a new FetchTaskActionsOptions + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + public FetchTaskActionsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + public class UpdateTaskActionsOptions : IOptions + { + /// + /// The unique ID of the parent Assistant. + /// + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task. + /// + public string PathTaskSid { get; } + /// + /// The JSON actions that instruct the Assistant how to perform this task. + /// + public object Actions { get; set; } + + /// + /// Construct a new UpdateTaskActionsOptions + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + public UpdateTaskActionsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsResource.cs index 983c92387..3e579746a 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskActionsResource.cs @@ -19,204 +19,204 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - - public class TaskActionsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns JSON actions for this Task. - /// - /// Fetch TaskActions parameters - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Fetch(FetchTaskActionsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns JSON actions for this Task. - /// - /// Fetch TaskActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns JSON actions for this Task. - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Fetch(string pathAssistantSid, string pathTaskSid, ITwilioRestClient client = null) - { - var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns JSON actions for this Task. - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskActionsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// Update TaskActions parameters - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Update(UpdateTaskActionsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// Update TaskActions parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskActionsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - /// The JSON actions that instruct the Assistant how to perform this task. - /// Client to make requests to Twilio - /// A single instance of TaskActions - public static TaskActionsResource Update(string pathAssistantSid, - string pathTaskSid, - object actions = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid){Actions = actions}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task. - /// The JSON actions that instruct the Assistant how to perform this task. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskActions - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathTaskSid, - object actions = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid){Actions = actions}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskActionsResource object - /// - /// Raw JSON string - /// TaskActionsResource object represented by the provided JSON - public static TaskActionsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique ID of the Task. - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The data - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private TaskActionsResource() - { - - } - } +{ + + public class TaskActionsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns JSON actions for this Task. + /// + /// Fetch TaskActions parameters + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Fetch(FetchTaskActionsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns JSON actions for this Task. + /// + /// Fetch TaskActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns JSON actions for this Task. + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Fetch(string pathAssistantSid, string pathTaskSid, ITwilioRestClient client = null) + { + var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns JSON actions for this Task. + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskActionsOptions(pathAssistantSid, pathTaskSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskActionsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Actions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// Update TaskActions parameters + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Update(UpdateTaskActionsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// Update TaskActions parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskActionsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + /// The JSON actions that instruct the Assistant how to perform this task. + /// Client to make requests to Twilio + /// A single instance of TaskActions + public static TaskActionsResource Update(string pathAssistantSid, + string pathTaskSid, + object actions = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid) { Actions = actions }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the actions of an Task identified by {TaskSid} or {TaskUniqueName}. + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task. + /// The JSON actions that instruct the Assistant how to perform this task. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskActions + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathTaskSid, + object actions = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskActionsOptions(pathAssistantSid, pathTaskSid) { Actions = actions }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskActionsResource object + /// + /// Raw JSON string + /// TaskActionsResource object represented by the provided JSON + public static TaskActionsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique ID of the Task. + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The data + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private TaskActionsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsOptions.cs index f3de91027..be1db8fd6 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchTaskStatisticsOptions + /// + public class FetchTaskStatisticsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchTaskStatisticsOptions + /// The unique ID of the parent Assistant. /// - public class FetchTaskStatisticsOptions : IOptions - { - /// - /// The unique ID of the parent Assistant. - /// - public string PathAssistantSid { get; } - /// - /// The unique ID of the Task associated with this Field. - /// - public string PathTaskSid { get; } - - /// - /// Construct a new FetchTaskStatisticsOptions - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - public FetchTaskStatisticsOptions(string pathAssistantSid, string pathTaskSid) - { - PathAssistantSid = pathAssistantSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + /// + /// The unique ID of the Task associated with this Field. + /// + public string PathTaskSid { get; } + + /// + /// Construct a new FetchTaskStatisticsOptions + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + public FetchTaskStatisticsOptions(string pathAssistantSid, string pathTaskSid) + { + PathAssistantSid = pathAssistantSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsResource.cs index a7f1af93e..5388bb687 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/Task/TaskStatisticsResource.cs @@ -19,135 +19,135 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant.Task -{ - - public class TaskStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskStatistics - public static TaskStatisticsResource Fetch(FetchTaskStatisticsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - /// Client to make requests to Twilio - /// A single instance of TaskStatistics - public static TaskStatisticsResource Fetch(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique ID of the parent Assistant. - /// The unique ID of the Task associated with this Field. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathTaskSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskStatisticsResource object - /// - /// Raw JSON string - /// TaskStatisticsResource object represented by the provided JSON - public static TaskStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Field. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique ID of the parent Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// The unique ID of the Task associated with this Field. - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The total number of Samples associated with this Task. - /// - [JsonProperty("samples_count")] - public int? SamplesCount { get; private set; } - /// - /// The total number of Fields associated with this Task. - /// - [JsonProperty("fields_count")] - public int? FieldsCount { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskStatisticsResource() - { - - } - } +{ + + public class TaskStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathTaskSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskStatistics + public static TaskStatisticsResource Fetch(FetchTaskStatisticsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + /// Client to make requests to Twilio + /// A single instance of TaskStatistics + public static TaskStatisticsResource Fetch(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique ID of the parent Assistant. + /// The unique ID of the Task associated with this Field. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathTaskSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskStatisticsOptions(pathAssistantSid, pathTaskSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskStatisticsResource object + /// + /// Raw JSON string + /// TaskStatisticsResource object represented by the provided JSON + public static TaskStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Field. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique ID of the parent Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// The unique ID of the Task associated with this Field. + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The total number of Samples associated with this Task. + /// + [JsonProperty("samples_count")] + public int? SamplesCount { get; private set; } + /// + /// The total number of Fields associated with this Task. + /// + [JsonProperty("fields_count")] + public int? FieldsCount { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/TaskOptions.cs b/src/Twilio/Rest/Preview/Understand/Assistant/TaskOptions.cs index 5486b0e8d..bc54a8789 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/TaskOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/TaskOptions.cs @@ -9,264 +9,264 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand.Assistant -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchTaskOptions + /// + public class FetchTaskOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchTaskOptions + /// The unique ID of the Assistant. /// - public class FetchTaskOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTaskOptions - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - public FetchTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathAssistantSid { get; } /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadTaskOptions + /// A 34 character string that uniquely identifies this resource. /// - public class ReadTaskOptions : ReadOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - - /// - /// Construct a new ReadTaskOptions - /// - /// The unique ID of the Assistant. - public ReadTaskOptions(string pathAssistantSid) - { - PathAssistantSid = pathAssistantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateTaskOptions + /// Construct a new FetchTaskOptions /// - public class CreateTaskOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - /// - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - /// - public object Actions { get; set; } - /// - /// User-provided HTTP endpoint where from the assistant fetches actions - /// - public Uri ActionsUrl { get; set; } - - /// - /// Construct a new CreateTaskOptions - /// - /// The unique ID of the Assistant. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - public CreateTaskOptions(string pathAssistantSid, string uniqueName) - { - PathAssistantSid = pathAssistantSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - if (ActionsUrl != null) - { - p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); - } - - return p; - } - } - + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + public FetchTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateTaskOptions + /// Generate the necessary parameters /// - public class UpdateTaskOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; set; } - /// - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - /// - public object Actions { get; set; } - /// - /// User-provided HTTP endpoint where from the assistant fetches actions - /// - public Uri ActionsUrl { get; set; } - - /// - /// Construct a new UpdateTaskOptions - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - public UpdateTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Actions != null) - { - p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); - } - - if (ActionsUrl != null) - { - p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadTaskOptions + /// + public class ReadTaskOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteTaskOptions + /// The unique ID of the Assistant. /// - public class DeleteTaskOptions : IOptions - { - /// - /// The unique ID of the Assistant. - /// - public string PathAssistantSid { get; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTaskOptions - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - public DeleteTaskOptions(string pathAssistantSid, string pathSid) - { - PathAssistantSid = pathAssistantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssistantSid { get; } + + /// + /// Construct a new ReadTaskOptions + /// + /// The unique ID of the Assistant. + public ReadTaskOptions(string pathAssistantSid) + { + PathAssistantSid = pathAssistantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateTaskOptions + /// + public class CreateTaskOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + public string FriendlyName { get; set; } + /// + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. + /// + public object Actions { get; set; } + /// + /// User-provided HTTP endpoint where from the assistant fetches actions + /// + public Uri ActionsUrl { get; set; } + + /// + /// Construct a new CreateTaskOptions + /// + /// The unique ID of the Assistant. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + public CreateTaskOptions(string pathAssistantSid, string uniqueName) + { + PathAssistantSid = pathAssistantSid; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + if (ActionsUrl != null) + { + p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateTaskOptions + /// + public class UpdateTaskOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + public string FriendlyName { get; set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; set; } + /// + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. + /// + public object Actions { get; set; } + /// + /// User-provided HTTP endpoint where from the assistant fetches actions + /// + public Uri ActionsUrl { get; set; } + + /// + /// Construct a new UpdateTaskOptions + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + public UpdateTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Actions != null) + { + p.Add(new KeyValuePair("Actions", Serializers.JsonObject(Actions))); + } + + if (ActionsUrl != null) + { + p.Add(new KeyValuePair("ActionsUrl", Serializers.Url(ActionsUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteTaskOptions + /// + public class DeleteTaskOptions : IOptions + { + /// + /// The unique ID of the Assistant. + /// + public string PathAssistantSid { get; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTaskOptions + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + public DeleteTaskOptions(string pathAssistantSid, string pathSid) + { + PathAssistantSid = pathAssistantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/Assistant/TaskResource.cs b/src/Twilio/Rest/Preview/Understand/Assistant/TaskResource.cs index f999421ea..5b8a35160 100644 --- a/src/Twilio/Rest/Preview/Understand/Assistant/TaskResource.cs +++ b/src/Twilio/Rest/Preview/Understand/Assistant/TaskResource.cs @@ -19,540 +19,540 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand.Assistant -{ - - public class TaskResource : Resource - { - private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathAssistantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathAssistantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The unique ID of the Assistant. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The unique ID of the Assistant. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathAssistantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique ID of the Assistant. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is - /// optional and non-unique. - /// User-provided HTTP endpoint where from the assistant fetches actions - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique ID of the Assistant. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is - /// optional and non-unique. - /// User-provided HTTP endpoint where from the assistant fetches actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, - string uniqueName, - string friendlyName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathAssistantSid, uniqueName){FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is - /// optional and non-unique. - /// User-provided HTTP endpoint where from the assistant fetches actions - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// A user-provided string that identifies this resource. It is non-unique and can up to - /// 255 characters long. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided JSON object encoded as a string to specify the actions for this task. It is - /// optional and non-unique. - /// User-provided HTTP endpoint where from the assistant fetches actions - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, - string pathSid, - string friendlyName = null, - string uniqueName = null, - object actions = null, - Uri actionsUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathAssistantSid, pathSid){FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathAssistantSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique ID of the Assistant. - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathAssistantSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskResource object - /// - /// Raw JSON string - /// TaskResource object represented by the provided JSON - public static TaskResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Task. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The unique ID of the Assistant. - /// - [JsonProperty("assistant_sid")] - public string AssistantSid { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// User-provided HTTP endpoint where from the assistant fetches actions - /// - [JsonProperty("actions_url")] - public Uri ActionsUrl { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskResource() - { - - } - } +{ + + public class TaskResource : Resource + { + private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathAssistantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathAssistantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The unique ID of the Assistant. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The unique ID of the Assistant. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(string pathAssistantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathAssistantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique ID of the Assistant. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is + /// optional and non-unique. + /// User-provided HTTP endpoint where from the assistant fetches actions + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique ID of the Assistant. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is + /// optional and non-unique. + /// User-provided HTTP endpoint where from the assistant fetches actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(string pathAssistantSid, + string uniqueName, + string friendlyName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathAssistantSid, uniqueName) { FriendlyName = friendlyName, Actions = actions, ActionsUrl = actionsUrl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is + /// optional and non-unique. + /// User-provided HTTP endpoint where from the assistant fetches actions + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// A user-provided string that identifies this resource. It is non-unique and can up to + /// 255 characters long. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided JSON object encoded as a string to specify the actions for this task. It is + /// optional and non-unique. + /// User-provided HTTP endpoint where from the assistant fetches actions + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(string pathAssistantSid, + string pathSid, + string friendlyName = null, + string uniqueName = null, + object actions = null, + Uri actionsUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathAssistantSid, pathSid) { FriendlyName = friendlyName, UniqueName = uniqueName, Actions = actions, ActionsUrl = actionsUrl }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathAssistantSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(string pathAssistantSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathAssistantSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique ID of the Assistant. + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(string pathAssistantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathAssistantSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskResource object + /// + /// Raw JSON string + /// TaskResource object represented by the provided JSON + public static TaskResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Task. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The unique ID of the Assistant. + /// + [JsonProperty("assistant_sid")] + public string AssistantSid { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// User-provided HTTP endpoint where from the assistant fetches actions + /// + [JsonProperty("actions_url")] + public Uri ActionsUrl { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/AssistantOptions.cs b/src/Twilio/Rest/Preview/Understand/AssistantOptions.cs index d461aa8d1..84553724a 100644 --- a/src/Twilio/Rest/Preview/Understand/AssistantOptions.cs +++ b/src/Twilio/Rest/Preview/Understand/AssistantOptions.cs @@ -9,288 +9,288 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Understand -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchAssistantOptions + /// + public class FetchAssistantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchAssistantOptions + /// A 34 character string that uniquely identifies this resource. /// - public class FetchAssistantOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssistantOptions - /// - /// A 34 character string that uniquely identifies this resource. - public FetchAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadAssistantOptions + /// Construct a new FetchAssistantOptions /// - public class ReadAssistantOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// A 34 character string that uniquely identifies this resource. + public FetchAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateAssistantOptions + /// Generate the necessary parameters /// - public class CreateAssistantOptions : IOptions - { - /// - /// A text description for the Assistant. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - /// - /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - /// - public bool? LogQueries { get; set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; set; } - /// - /// A user-provided URL to send event callbacks to. - /// - public Uri CallbackUrl { get; set; } - /// - /// Space-separated list of callback events that will trigger callbacks. - /// - public string CallbackEvents { get; set; } - /// - /// The JSON actions to be executed when the user's input is not recognized as matching any Task. - /// - public object FallbackActions { get; set; } - /// - /// The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - /// - public object InitiationActions { get; set; } - /// - /// The JSON object that holds the style sheet for the assistant - /// - public object StyleSheet { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (LogQueries != null) - { - p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackEvents != null) - { - p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); - } - - if (FallbackActions != null) - { - p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); - } - - if (InitiationActions != null) - { - p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); - } - - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadAssistantOptions + /// + public class ReadAssistantOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateAssistantOptions + /// Generate the necessary parameters /// - public class UpdateAssistantOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - /// - /// A text description for the Assistant. It is non-unique and can up to 255 characters long. - /// - public string FriendlyName { get; set; } - /// - /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - /// - public bool? LogQueries { get; set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - /// - public string UniqueName { get; set; } - /// - /// A user-provided URL to send event callbacks to. - /// - public Uri CallbackUrl { get; set; } - /// - /// Space-separated list of callback events that will trigger callbacks. - /// - public string CallbackEvents { get; set; } - /// - /// The JSON actions to be executed when the user's input is not recognized as matching any Task. - /// - public object FallbackActions { get; set; } - /// - /// The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - /// - public object InitiationActions { get; set; } - /// - /// The JSON object that holds the style sheet for the assistant - /// - public object StyleSheet { get; set; } - - /// - /// Construct a new UpdateAssistantOptions - /// - /// A 34 character string that uniquely identifies this resource. - public UpdateAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (LogQueries != null) - { - p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackEvents != null) - { - p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); - } - - if (FallbackActions != null) - { - p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); - } - - if (InitiationActions != null) - { - p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); - } - - if (StyleSheet != null) - { - p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateAssistantOptions + /// + public class CreateAssistantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteAssistantOptions + /// A text description for the Assistant. It is non-unique and can up to 255 characters long. /// - public class DeleteAssistantOptions : IOptions - { - /// - /// A 34 character string that uniquely identifies this resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAssistantOptions - /// - /// A 34 character string that uniquely identifies this resource. - public DeleteAssistantOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string FriendlyName { get; set; } + /// + /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. + /// + public bool? LogQueries { get; set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; set; } + /// + /// A user-provided URL to send event callbacks to. + /// + public Uri CallbackUrl { get; set; } + /// + /// Space-separated list of callback events that will trigger callbacks. + /// + public string CallbackEvents { get; set; } + /// + /// The JSON actions to be executed when the user's input is not recognized as matching any Task. + /// + public object FallbackActions { get; set; } + /// + /// The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. + /// + public object InitiationActions { get; set; } + /// + /// The JSON object that holds the style sheet for the assistant + /// + public object StyleSheet { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (LogQueries != null) + { + p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackEvents != null) + { + p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); + } + + if (FallbackActions != null) + { + p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); + } + + if (InitiationActions != null) + { + p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); + } + + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateAssistantOptions + /// + public class UpdateAssistantOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + /// + /// A text description for the Assistant. It is non-unique and can up to 255 characters long. + /// + public string FriendlyName { get; set; } + /// + /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. + /// + public bool? LogQueries { get; set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. + /// + public string UniqueName { get; set; } + /// + /// A user-provided URL to send event callbacks to. + /// + public Uri CallbackUrl { get; set; } + /// + /// Space-separated list of callback events that will trigger callbacks. + /// + public string CallbackEvents { get; set; } + /// + /// The JSON actions to be executed when the user's input is not recognized as matching any Task. + /// + public object FallbackActions { get; set; } + /// + /// The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. + /// + public object InitiationActions { get; set; } + /// + /// The JSON object that holds the style sheet for the assistant + /// + public object StyleSheet { get; set; } + + /// + /// Construct a new UpdateAssistantOptions + /// + /// A 34 character string that uniquely identifies this resource. + public UpdateAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (LogQueries != null) + { + p.Add(new KeyValuePair("LogQueries", LogQueries.Value.ToString().ToLower())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackEvents != null) + { + p.Add(new KeyValuePair("CallbackEvents", CallbackEvents)); + } + + if (FallbackActions != null) + { + p.Add(new KeyValuePair("FallbackActions", Serializers.JsonObject(FallbackActions))); + } + + if (InitiationActions != null) + { + p.Add(new KeyValuePair("InitiationActions", Serializers.JsonObject(InitiationActions))); + } + + if (StyleSheet != null) + { + p.Add(new KeyValuePair("StyleSheet", Serializers.JsonObject(StyleSheet))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteAssistantOptions + /// + public class DeleteAssistantOptions : IOptions + { + /// + /// A 34 character string that uniquely identifies this resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAssistantOptions + /// + /// A 34 character string that uniquely identifies this resource. + public DeleteAssistantOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Understand/AssistantResource.cs b/src/Twilio/Rest/Preview/Understand/AssistantResource.cs index 07b0e459a..227ab2bf5 100644 --- a/src/Twilio/Rest/Preview/Understand/AssistantResource.cs +++ b/src/Twilio/Rest/Preview/Understand/AssistantResource.cs @@ -19,575 +19,575 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Understand -{ - - public class AssistantResource : Resource - { - private static Request BuildFetchRequest(FetchAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Fetch(FetchAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAssistantOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAssistantOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/understand/Assistants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static ResourceSet Read(ReadAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("assistants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("assistants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Assistant - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssistantOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssistantOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("assistants", response.Content); - } - - private static Request BuildCreateRequest(CreateAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Create(CreateAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task CreateAsync(CreateAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A text description for the Assistant. It is non-unique and can up to 255 characters - /// long. - /// A boolean that specifies whether queries should be logged for 30 days further training. - /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted - /// thereafter. Defaults to true if no value is provided. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided URL to send event callbacks to. - /// Space-separated list of callback events that will trigger callbacks. - /// The JSON actions to be executed when the user's input is not recognized as matching - /// any Task. - /// The JSON actions to be executed on inbound phone calls when the Assistant has to - /// say something first. - /// The JSON object that holds the style sheet for the assistant - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Create(string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object fallbackActions = null, - object initiationActions = null, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new CreateAssistantOptions(){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A text description for the Assistant. It is non-unique and can up to 255 characters - /// long. - /// A boolean that specifies whether queries should be logged for 30 days further training. - /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted - /// thereafter. Defaults to true if no value is provided. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided URL to send event callbacks to. - /// Space-separated list of callback events that will trigger callbacks. - /// The JSON actions to be executed when the user's input is not recognized as matching - /// any Task. - /// The JSON actions to be executed on inbound phone calls when the Assistant has to - /// say something first. - /// The JSON object that holds the style sheet for the assistant - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object fallbackActions = null, - object initiationActions = null, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new CreateAssistantOptions(){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Update(UpdateAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// A 34 character string that uniquely identifies this resource. - /// A text description for the Assistant. It is non-unique and can up to 255 characters - /// long. - /// A boolean that specifies whether queries should be logged for 30 days further training. - /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted - /// thereafter. Defaults to true if no value is provided. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided URL to send event callbacks to. - /// Space-separated list of callback events that will trigger callbacks. - /// The JSON actions to be executed when the user's input is not recognized as matching - /// any Task. - /// The JSON actions to be executed on inbound phone calls when the Assistant has to - /// say something first. - /// The JSON object that holds the style sheet for the assistant - /// Client to make requests to Twilio - /// A single instance of Assistant - public static AssistantResource Update(string pathSid, - string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object fallbackActions = null, - object initiationActions = null, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantOptions(pathSid){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// A 34 character string that uniquely identifies this resource. - /// A text description for the Assistant. It is non-unique and can up to 255 characters - /// long. - /// A boolean that specifies whether queries should be logged for 30 days further training. - /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted - /// thereafter. Defaults to true if no value is provided. - /// A user-provided string that uniquely identifies this resource as an alternative to the - /// sid. Unique up to 64 characters long. - /// A user-provided URL to send event callbacks to. - /// Space-separated list of callback events that will trigger callbacks. - /// The JSON actions to be executed when the user's input is not recognized as matching - /// any Task. - /// The JSON actions to be executed on inbound phone calls when the Assistant has to - /// say something first. - /// The JSON object that holds the style sheet for the assistant - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - bool? logQueries = null, - string uniqueName = null, - Uri callbackUrl = null, - string callbackEvents = null, - object fallbackActions = null, - object initiationActions = null, - object styleSheet = null, - ITwilioRestClient client = null) - { - var options = new UpdateAssistantOptions(pathSid){FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAssistantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/understand/Assistants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Assistant parameters - /// Client to make requests to Twilio - /// A single instance of Assistant - public static bool Delete(DeleteAssistantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Assistant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssistantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// A single instance of Assistant - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAssistantOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// A 34 character string that uniquely identifies this resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAssistantOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssistantResource object - /// - /// Raw JSON string - /// AssistantResource object represented by the provided JSON - public static AssistantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique ID of the Account that created this Assistant. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The date that this resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date that this resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A text description for the Assistant. It is non-unique and can up to 255 characters long. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique ID (Sid) of the latest model build. Null if no model has been built. - /// - [JsonProperty("latest_model_build_sid")] - public string LatestModelBuildSid { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. - /// - [JsonProperty("log_queries")] - public bool? LogQueries { get; private set; } - /// - /// A 34 character string that uniquely identifies this resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A user-provided string that uniquely identifies this resource as an alternative to the sid. You can use the unique name in the URL path. Unique up to 64 characters long. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A user-provided URL to send event callbacks to. - /// - [JsonProperty("callback_url")] - public Uri CallbackUrl { get; private set; } - /// - /// Space-separated list of callback events that will trigger callbacks. - /// - [JsonProperty("callback_events")] - public string CallbackEvents { get; private set; } - - private AssistantResource() - { - - } - } +{ + + public class AssistantResource : Resource + { + private static Request BuildFetchRequest(FetchAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Fetch(FetchAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task FetchAsync(FetchAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAssistantOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAssistantOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/understand/Assistants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static ResourceSet Read(ReadAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("assistants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("assistants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Assistant + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssistantOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssistantOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("assistants", response.Content); + } + + private static Request BuildCreateRequest(CreateAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Create(CreateAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task CreateAsync(CreateAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A text description for the Assistant. It is non-unique and can up to 255 characters + /// long. + /// A boolean that specifies whether queries should be logged for 30 days further training. + /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted + /// thereafter. Defaults to true if no value is provided. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided URL to send event callbacks to. + /// Space-separated list of callback events that will trigger callbacks. + /// The JSON actions to be executed when the user's input is not recognized as matching + /// any Task. + /// The JSON actions to be executed on inbound phone calls when the Assistant has to + /// say something first. + /// The JSON object that holds the style sheet for the assistant + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Create(string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object fallbackActions = null, + object initiationActions = null, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new CreateAssistantOptions() { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A text description for the Assistant. It is non-unique and can up to 255 characters + /// long. + /// A boolean that specifies whether queries should be logged for 30 days further training. + /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted + /// thereafter. Defaults to true if no value is provided. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided URL to send event callbacks to. + /// Space-separated list of callback events that will trigger callbacks. + /// The JSON actions to be executed when the user's input is not recognized as matching + /// any Task. + /// The JSON actions to be executed on inbound phone calls when the Assistant has to + /// say something first. + /// The JSON object that holds the style sheet for the assistant + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object fallbackActions = null, + object initiationActions = null, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new CreateAssistantOptions() { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Update(UpdateAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// A 34 character string that uniquely identifies this resource. + /// A text description for the Assistant. It is non-unique and can up to 255 characters + /// long. + /// A boolean that specifies whether queries should be logged for 30 days further training. + /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted + /// thereafter. Defaults to true if no value is provided. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided URL to send event callbacks to. + /// Space-separated list of callback events that will trigger callbacks. + /// The JSON actions to be executed when the user's input is not recognized as matching + /// any Task. + /// The JSON actions to be executed on inbound phone calls when the Assistant has to + /// say something first. + /// The JSON object that holds the style sheet for the assistant + /// Client to make requests to Twilio + /// A single instance of Assistant + public static AssistantResource Update(string pathSid, + string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object fallbackActions = null, + object initiationActions = null, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantOptions(pathSid) { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// A 34 character string that uniquely identifies this resource. + /// A text description for the Assistant. It is non-unique and can up to 255 characters + /// long. + /// A boolean that specifies whether queries should be logged for 30 days further training. + /// If false, no queries will be stored, if true, queries will be stored for 30 days and deleted + /// thereafter. Defaults to true if no value is provided. + /// A user-provided string that uniquely identifies this resource as an alternative to the + /// sid. Unique up to 64 characters long. + /// A user-provided URL to send event callbacks to. + /// Space-separated list of callback events that will trigger callbacks. + /// The JSON actions to be executed when the user's input is not recognized as matching + /// any Task. + /// The JSON actions to be executed on inbound phone calls when the Assistant has to + /// say something first. + /// The JSON object that holds the style sheet for the assistant + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + bool? logQueries = null, + string uniqueName = null, + Uri callbackUrl = null, + string callbackEvents = null, + object fallbackActions = null, + object initiationActions = null, + object styleSheet = null, + ITwilioRestClient client = null) + { + var options = new UpdateAssistantOptions(pathSid) { FriendlyName = friendlyName, LogQueries = logQueries, UniqueName = uniqueName, CallbackUrl = callbackUrl, CallbackEvents = callbackEvents, FallbackActions = fallbackActions, InitiationActions = initiationActions, StyleSheet = styleSheet }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAssistantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/understand/Assistants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Assistant parameters + /// Client to make requests to Twilio + /// A single instance of Assistant + public static bool Delete(DeleteAssistantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Assistant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssistantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// A single instance of Assistant + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAssistantOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// A 34 character string that uniquely identifies this resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Assistant + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAssistantOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssistantResource object + /// + /// Raw JSON string + /// AssistantResource object represented by the provided JSON + public static AssistantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique ID of the Account that created this Assistant. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The date that this resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date that this resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A text description for the Assistant. It is non-unique and can up to 255 characters long. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique ID (Sid) of the latest model build. Null if no model has been built. + /// + [JsonProperty("latest_model_build_sid")] + public string LatestModelBuildSid { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. + /// + [JsonProperty("log_queries")] + public bool? LogQueries { get; private set; } + /// + /// A 34 character string that uniquely identifies this resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A user-provided string that uniquely identifies this resource as an alternative to the sid. You can use the unique name in the URL path. Unique up to 64 characters long. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A user-provided URL to send event callbacks to. + /// + [JsonProperty("callback_url")] + public Uri CallbackUrl { get; private set; } + /// + /// Space-separated list of callback events that will trigger callbacks. + /// + [JsonProperty("callback_events")] + public string CallbackEvents { get; private set; } + + private AssistantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/CommandOptions.cs b/src/Twilio/Rest/Preview/Wireless/CommandOptions.cs index 23a207c78..c87230ccd 100644 --- a/src/Twilio/Rest/Preview/Wireless/CommandOptions.cs +++ b/src/Twilio/Rest/Preview/Wireless/CommandOptions.cs @@ -9,189 +9,189 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Wireless -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchCommandOptions + /// + public class FetchCommandOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchCommandOptions - /// - public class FetchCommandOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCommandOptions - /// - /// The sid - public FetchCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadCommandOptions - /// - public class ReadCommandOptions : ReadOptions - { - /// - /// The device - /// - public string Device { get; set; } - /// - /// The sim - /// - public string Sim { get; set; } - /// - /// The status - /// - public string Status { get; set; } - /// - /// The direction - /// - public string Direction { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Device != null) - { - p.Add(new KeyValuePair("Device", Device)); - } - - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchCommandOptions + /// + /// The sid + public FetchCommandOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateCommandOptions - /// - public class CreateCommandOptions : IOptions - { - /// - /// The command - /// - public string Command { get; } - /// - /// The device - /// - public string Device { get; set; } - /// - /// The sim - /// - public string Sim { get; set; } - /// - /// The callback_method - /// - public string CallbackMethod { get; set; } - /// - /// The callback_url - /// - public Uri CallbackUrl { get; set; } - /// - /// The command_mode - /// - public string CommandMode { get; set; } - /// - /// The include_sid - /// - public string IncludeSid { get; set; } - - /// - /// Construct a new CreateCommandOptions - /// - /// The command - public CreateCommandOptions(string command) - { - Command = command; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Command != null) - { - p.Add(new KeyValuePair("Command", Command)); - } - - if (Device != null) - { - p.Add(new KeyValuePair("Device", Device)); - } - - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CommandMode != null) - { - p.Add(new KeyValuePair("CommandMode", CommandMode)); - } - - if (IncludeSid != null) - { - p.Add(new KeyValuePair("IncludeSid", IncludeSid)); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadCommandOptions + /// + public class ReadCommandOptions : ReadOptions + { + /// + /// The device + /// + public string Device { get; set; } + /// + /// The sim + /// + public string Sim { get; set; } + /// + /// The status + /// + public string Status { get; set; } + /// + /// The direction + /// + public string Direction { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Device != null) + { + p.Add(new KeyValuePair("Device", Device)); + } + + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateCommandOptions + /// + public class CreateCommandOptions : IOptions + { + /// + /// The command + /// + public string Command { get; } + /// + /// The device + /// + public string Device { get; set; } + /// + /// The sim + /// + public string Sim { get; set; } + /// + /// The callback_method + /// + public string CallbackMethod { get; set; } + /// + /// The callback_url + /// + public Uri CallbackUrl { get; set; } + /// + /// The command_mode + /// + public string CommandMode { get; set; } + /// + /// The include_sid + /// + public string IncludeSid { get; set; } + + /// + /// Construct a new CreateCommandOptions + /// + /// The command + public CreateCommandOptions(string command) + { + Command = command; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Command != null) + { + p.Add(new KeyValuePair("Command", Command)); + } + + if (Device != null) + { + p.Add(new KeyValuePair("Device", Device)); + } + + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CommandMode != null) + { + p.Add(new KeyValuePair("CommandMode", CommandMode)); + } + + if (IncludeSid != null) + { + p.Add(new KeyValuePair("IncludeSid", IncludeSid)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/CommandResource.cs b/src/Twilio/Rest/Preview/Wireless/CommandResource.cs index ee399613a..38a9da04f 100644 --- a/src/Twilio/Rest/Preview/Wireless/CommandResource.cs +++ b/src/Twilio/Rest/Preview/Wireless/CommandResource.cs @@ -19,392 +19,392 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Wireless -{ - - public class CommandResource : Resource - { - private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/Commands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/Commands", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The device - /// The sim - /// The status - /// The direction - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(string device = null, - string sim = null, - string status = null, - string direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Device = device, Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The device - /// The sim - /// The status - /// The direction - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(string device = null, - string sim = null, - string status = null, - string direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Device = device, Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/wireless/Commands", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The command - /// The device - /// The sim - /// The callback_method - /// The callback_url - /// The command_mode - /// The include_sid - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(string command, - string device = null, - string sim = null, - string callbackMethod = null, - Uri callbackUrl = null, - string commandMode = null, - string includeSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(command){Device = device, Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The command - /// The device - /// The sim - /// The callback_method - /// The callback_url - /// The command_mode - /// The include_sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(string command, - string device = null, - string sim = null, - string callbackMethod = null, - Uri callbackUrl = null, - string commandMode = null, - string includeSid = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(command){Device = device, Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CommandResource object - /// - /// Raw JSON string - /// CommandResource object represented by the provided JSON - public static CommandResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The device_sid - /// - [JsonProperty("device_sid")] - public string DeviceSid { get; private set; } - /// - /// The sim_sid - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The command - /// - [JsonProperty("command")] - public string Command { get; private set; } - /// - /// The command_mode - /// - [JsonProperty("command_mode")] - public string CommandMode { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// The direction - /// - [JsonProperty("direction")] - public string Direction { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CommandResource() - { - - } - } +{ + + public class CommandResource : Resource + { + private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/Commands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/Commands", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The device + /// The sim + /// The status + /// The direction + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(string device = null, + string sim = null, + string status = null, + string direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Device = device, Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The device + /// The sim + /// The status + /// The direction + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(string device = null, + string sim = null, + string status = null, + string direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Device = device, Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/wireless/Commands", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The command + /// The device + /// The sim + /// The callback_method + /// The callback_url + /// The command_mode + /// The include_sid + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(string command, + string device = null, + string sim = null, + string callbackMethod = null, + Uri callbackUrl = null, + string commandMode = null, + string includeSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(command) { Device = device, Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The command + /// The device + /// The sim + /// The callback_method + /// The callback_url + /// The command_mode + /// The include_sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(string command, + string device = null, + string sim = null, + string callbackMethod = null, + Uri callbackUrl = null, + string commandMode = null, + string includeSid = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(command) { Device = device, Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CommandResource object + /// + /// Raw JSON string + /// CommandResource object represented by the provided JSON + public static CommandResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The device_sid + /// + [JsonProperty("device_sid")] + public string DeviceSid { get; private set; } + /// + /// The sim_sid + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The command + /// + [JsonProperty("command")] + public string Command { get; private set; } + /// + /// The command_mode + /// + [JsonProperty("command_mode")] + public string CommandMode { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// The direction + /// + [JsonProperty("direction")] + public string Direction { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CommandResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/RatePlanOptions.cs b/src/Twilio/Rest/Preview/Wireless/RatePlanOptions.cs index c82a8a66d..25f621dcc 100644 --- a/src/Twilio/Rest/Preview/Wireless/RatePlanOptions.cs +++ b/src/Twilio/Rest/Preview/Wireless/RatePlanOptions.cs @@ -10,260 +10,260 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Wireless -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadRatePlanOptions + /// + public class ReadRatePlanOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadRatePlanOptions + /// Generate the necessary parameters /// - public class ReadRatePlanOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchRatePlanOptions + /// + public class FetchRatePlanOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchRatePlanOptions + /// The sid /// - public class FetchRatePlanOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRatePlanOptions - /// - /// The sid - public FetchRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// CreateRatePlanOptions + /// Construct a new FetchRatePlanOptions /// - public class CreateRatePlanOptions : IOptions - { - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The data_enabled - /// - public bool? DataEnabled { get; set; } - /// - /// The data_limit - /// - public int? DataLimit { get; set; } - /// - /// The data_metering - /// - public string DataMetering { get; set; } - /// - /// The messaging_enabled - /// - public bool? MessagingEnabled { get; set; } - /// - /// The voice_enabled - /// - public bool? VoiceEnabled { get; set; } - /// - /// The commands_enabled - /// - public bool? CommandsEnabled { get; set; } - /// - /// The national_roaming_enabled - /// - public bool? NationalRoamingEnabled { get; set; } - /// - /// The international_roaming - /// - public List InternationalRoaming { get; set; } - - /// - /// Construct a new CreateRatePlanOptions - /// - public CreateRatePlanOptions() - { - InternationalRoaming = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DataEnabled != null) - { - p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); - } - - if (DataLimit != null) - { - p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); - } - - if (DataMetering != null) - { - p.Add(new KeyValuePair("DataMetering", DataMetering)); - } - - if (MessagingEnabled != null) - { - p.Add(new KeyValuePair("MessagingEnabled", MessagingEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (CommandsEnabled != null) - { - p.Add(new KeyValuePair("CommandsEnabled", CommandsEnabled.Value.ToString().ToLower())); - } - - if (NationalRoamingEnabled != null) - { - p.Add(new KeyValuePair("NationalRoamingEnabled", NationalRoamingEnabled.Value.ToString().ToLower())); - } - - if (InternationalRoaming != null) - { - p.AddRange(InternationalRoaming.Select(prop => new KeyValuePair("InternationalRoaming", prop))); - } - - return p; - } - } - + /// The sid + public FetchRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateRatePlanOptions + /// Generate the necessary parameters /// - public class UpdateRatePlanOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateRatePlanOptions - /// - /// The sid - public UpdateRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// CreateRatePlanOptions + /// + public class CreateRatePlanOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// DeleteRatePlanOptions + /// The unique_name /// - public class DeleteRatePlanOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRatePlanOptions - /// - /// The sid - public DeleteRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string UniqueName { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The data_enabled + /// + public bool? DataEnabled { get; set; } + /// + /// The data_limit + /// + public int? DataLimit { get; set; } + /// + /// The data_metering + /// + public string DataMetering { get; set; } + /// + /// The messaging_enabled + /// + public bool? MessagingEnabled { get; set; } + /// + /// The voice_enabled + /// + public bool? VoiceEnabled { get; set; } + /// + /// The commands_enabled + /// + public bool? CommandsEnabled { get; set; } + /// + /// The national_roaming_enabled + /// + public bool? NationalRoamingEnabled { get; set; } + /// + /// The international_roaming + /// + public List InternationalRoaming { get; set; } + + /// + /// Construct a new CreateRatePlanOptions + /// + public CreateRatePlanOptions() + { + InternationalRoaming = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DataEnabled != null) + { + p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); + } + + if (DataLimit != null) + { + p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); + } + + if (DataMetering != null) + { + p.Add(new KeyValuePair("DataMetering", DataMetering)); + } + + if (MessagingEnabled != null) + { + p.Add(new KeyValuePair("MessagingEnabled", MessagingEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (CommandsEnabled != null) + { + p.Add(new KeyValuePair("CommandsEnabled", CommandsEnabled.Value.ToString().ToLower())); + } + + if (NationalRoamingEnabled != null) + { + p.Add(new KeyValuePair("NationalRoamingEnabled", NationalRoamingEnabled.Value.ToString().ToLower())); + } + + if (InternationalRoaming != null) + { + p.AddRange(InternationalRoaming.Select(prop => new KeyValuePair("InternationalRoaming", prop))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateRatePlanOptions + /// + public class UpdateRatePlanOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateRatePlanOptions + /// + /// The sid + public UpdateRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// DeleteRatePlanOptions + /// + public class DeleteRatePlanOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRatePlanOptions + /// + /// The sid + public DeleteRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/RatePlanResource.cs b/src/Twilio/Rest/Preview/Wireless/RatePlanResource.cs index 3f18e777f..7335b228a 100644 --- a/src/Twilio/Rest/Preview/Wireless/RatePlanResource.cs +++ b/src/Twilio/Rest/Preview/Wireless/RatePlanResource.cs @@ -19,545 +19,545 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Wireless -{ - - public class RatePlanResource : Resource - { - private static Request BuildReadRequest(ReadRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/RatePlans", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static ResourceSet Read(ReadRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_plans", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task> ReadAsync(ReadRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_plans", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRatePlanOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRatePlanOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - private static Request BuildFetchRequest(FetchRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/RatePlans/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Fetch(FetchRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task FetchAsync(FetchRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRatePlanOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRatePlanOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/wireless/RatePlans", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Create(CreateRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task CreateAsync(CreateRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique_name - /// The friendly_name - /// The data_enabled - /// The data_limit - /// The data_metering - /// The messaging_enabled - /// The voice_enabled - /// The commands_enabled - /// The national_roaming_enabled - /// The international_roaming - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Create(string uniqueName = null, - string friendlyName = null, - bool? dataEnabled = null, - int? dataLimit = null, - string dataMetering = null, - bool? messagingEnabled = null, - bool? voiceEnabled = null, - bool? commandsEnabled = null, - bool? nationalRoamingEnabled = null, - List internationalRoaming = null, - ITwilioRestClient client = null) - { - var options = new CreateRatePlanOptions(){UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, CommandsEnabled = commandsEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique_name - /// The friendly_name - /// The data_enabled - /// The data_limit - /// The data_metering - /// The messaging_enabled - /// The voice_enabled - /// The commands_enabled - /// The national_roaming_enabled - /// The international_roaming - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, - string friendlyName = null, - bool? dataEnabled = null, - int? dataLimit = null, - string dataMetering = null, - bool? messagingEnabled = null, - bool? voiceEnabled = null, - bool? commandsEnabled = null, - bool? nationalRoamingEnabled = null, - List internationalRoaming = null, - ITwilioRestClient client = null) - { - var options = new CreateRatePlanOptions(){UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, CommandsEnabled = commandsEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/wireless/RatePlans/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Update(UpdateRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The unique_name - /// The friendly_name - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Update(string pathSid, - string uniqueName = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateRatePlanOptions(pathSid){UniqueName = uniqueName, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The unique_name - /// The friendly_name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateRatePlanOptions(pathSid){UniqueName = uniqueName, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Preview, - "/wireless/RatePlans/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static bool Delete(DeleteRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRatePlanOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRatePlanOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RatePlanResource object - /// - /// Raw JSON string - /// RatePlanResource object represented by the provided JSON - public static RatePlanResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The data_enabled - /// - [JsonProperty("data_enabled")] - public bool? DataEnabled { get; private set; } - /// - /// The data_metering - /// - [JsonProperty("data_metering")] - public string DataMetering { get; private set; } - /// - /// The data_limit - /// - [JsonProperty("data_limit")] - public int? DataLimit { get; private set; } - /// - /// The messaging_enabled - /// - [JsonProperty("messaging_enabled")] - public bool? MessagingEnabled { get; private set; } - /// - /// The voice_enabled - /// - [JsonProperty("voice_enabled")] - public bool? VoiceEnabled { get; private set; } - /// - /// The national_roaming_enabled - /// - [JsonProperty("national_roaming_enabled")] - public bool? NationalRoamingEnabled { get; private set; } - /// - /// The international_roaming - /// - [JsonProperty("international_roaming")] - public List InternationalRoaming { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RatePlanResource() - { - - } - } +{ + + public class RatePlanResource : Resource + { + private static Request BuildReadRequest(ReadRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/RatePlans", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static ResourceSet Read(ReadRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_plans", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task> ReadAsync(ReadRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_plans", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRatePlanOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRatePlanOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + private static Request BuildFetchRequest(FetchRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/RatePlans/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Fetch(FetchRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task FetchAsync(FetchRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRatePlanOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRatePlanOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/wireless/RatePlans", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Create(CreateRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task CreateAsync(CreateRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique_name + /// The friendly_name + /// The data_enabled + /// The data_limit + /// The data_metering + /// The messaging_enabled + /// The voice_enabled + /// The commands_enabled + /// The national_roaming_enabled + /// The international_roaming + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Create(string uniqueName = null, + string friendlyName = null, + bool? dataEnabled = null, + int? dataLimit = null, + string dataMetering = null, + bool? messagingEnabled = null, + bool? voiceEnabled = null, + bool? commandsEnabled = null, + bool? nationalRoamingEnabled = null, + List internationalRoaming = null, + ITwilioRestClient client = null) + { + var options = new CreateRatePlanOptions() { UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, CommandsEnabled = commandsEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique_name + /// The friendly_name + /// The data_enabled + /// The data_limit + /// The data_metering + /// The messaging_enabled + /// The voice_enabled + /// The commands_enabled + /// The national_roaming_enabled + /// The international_roaming + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, + string friendlyName = null, + bool? dataEnabled = null, + int? dataLimit = null, + string dataMetering = null, + bool? messagingEnabled = null, + bool? voiceEnabled = null, + bool? commandsEnabled = null, + bool? nationalRoamingEnabled = null, + List internationalRoaming = null, + ITwilioRestClient client = null) + { + var options = new CreateRatePlanOptions() { UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, CommandsEnabled = commandsEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/wireless/RatePlans/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Update(UpdateRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The unique_name + /// The friendly_name + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Update(string pathSid, + string uniqueName = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateRatePlanOptions(pathSid) { UniqueName = uniqueName, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The unique_name + /// The friendly_name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateRatePlanOptions(pathSid) { UniqueName = uniqueName, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Preview, + "/wireless/RatePlans/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static bool Delete(DeleteRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRatePlanOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRatePlanOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RatePlanResource object + /// + /// Raw JSON string + /// RatePlanResource object represented by the provided JSON + public static RatePlanResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The data_enabled + /// + [JsonProperty("data_enabled")] + public bool? DataEnabled { get; private set; } + /// + /// The data_metering + /// + [JsonProperty("data_metering")] + public string DataMetering { get; private set; } + /// + /// The data_limit + /// + [JsonProperty("data_limit")] + public int? DataLimit { get; private set; } + /// + /// The messaging_enabled + /// + [JsonProperty("messaging_enabled")] + public bool? MessagingEnabled { get; private set; } + /// + /// The voice_enabled + /// + [JsonProperty("voice_enabled")] + public bool? VoiceEnabled { get; private set; } + /// + /// The national_roaming_enabled + /// + [JsonProperty("national_roaming_enabled")] + public bool? NationalRoamingEnabled { get; private set; } + /// + /// The international_roaming + /// + [JsonProperty("international_roaming")] + public List InternationalRoaming { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RatePlanResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/Sim/UsageOptions.cs b/src/Twilio/Rest/Preview/Wireless/Sim/UsageOptions.cs index aa5a5ec5f..755c8609b 100644 --- a/src/Twilio/Rest/Preview/Wireless/Sim/UsageOptions.cs +++ b/src/Twilio/Rest/Preview/Wireless/Sim/UsageOptions.cs @@ -9,56 +9,56 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Wireless.Sim -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchUsageOptions + /// + public class FetchUsageOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchUsageOptions + /// The sim_sid /// - public class FetchUsageOptions : IOptions - { - /// - /// The sim_sid - /// - public string PathSimSid { get; } - /// - /// The end - /// - public string End { get; set; } - /// - /// The start - /// - public string Start { get; set; } - - /// - /// Construct a new FetchUsageOptions - /// - /// The sim_sid - public FetchUsageOptions(string pathSimSid) - { - PathSimSid = pathSimSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (End != null) - { - p.Add(new KeyValuePair("End", End)); - } - - if (Start != null) - { - p.Add(new KeyValuePair("Start", Start)); - } - - return p; - } - } + public string PathSimSid { get; } + /// + /// The end + /// + public string End { get; set; } + /// + /// The start + /// + public string Start { get; set; } + + /// + /// Construct a new FetchUsageOptions + /// + /// The sim_sid + public FetchUsageOptions(string pathSimSid) + { + PathSimSid = pathSimSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (End != null) + { + p.Add(new KeyValuePair("End", End)); + } + + if (Start != null) + { + p.Add(new KeyValuePair("Start", Start)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/Sim/UsageResource.cs b/src/Twilio/Rest/Preview/Wireless/Sim/UsageResource.cs index 502b458f7..779e79889 100644 --- a/src/Twilio/Rest/Preview/Wireless/Sim/UsageResource.cs +++ b/src/Twilio/Rest/Preview/Wireless/Sim/UsageResource.cs @@ -19,154 +19,154 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Wireless.Sim -{ - - public class UsageResource : Resource - { - private static Request BuildFetchRequest(FetchUsageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/Sims/" + options.PathSimSid + "/Usage", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Usage parameters - /// Client to make requests to Twilio - /// A single instance of Usage - public static UsageResource Fetch(FetchUsageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Usage parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Usage - public static async System.Threading.Tasks.Task FetchAsync(FetchUsageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sim_sid - /// The end - /// The start - /// Client to make requests to Twilio - /// A single instance of Usage - public static UsageResource Fetch(string pathSimSid, - string end = null, - string start = null, - ITwilioRestClient client = null) - { - var options = new FetchUsageOptions(pathSimSid){End = end, Start = start}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sim_sid - /// The end - /// The start - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Usage - public static async System.Threading.Tasks.Task FetchAsync(string pathSimSid, - string end = null, - string start = null, - ITwilioRestClient client = null) - { - var options = new FetchUsageOptions(pathSimSid){End = end, Start = start}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a UsageResource object - /// - /// Raw JSON string - /// UsageResource object represented by the provided JSON - public static UsageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sim_sid - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The sim_unique_name - /// - [JsonProperty("sim_unique_name")] - public string SimUniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The period - /// - [JsonProperty("period")] - public object Period { get; private set; } - /// - /// The commands_usage - /// - [JsonProperty("commands_usage")] - public object CommandsUsage { get; private set; } - /// - /// The commands_costs - /// - [JsonProperty("commands_costs")] - public object CommandsCosts { get; private set; } - /// - /// The data_usage - /// - [JsonProperty("data_usage")] - public object DataUsage { get; private set; } - /// - /// The data_costs - /// - [JsonProperty("data_costs")] - public object DataCosts { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private UsageResource() - { - - } - } +{ + + public class UsageResource : Resource + { + private static Request BuildFetchRequest(FetchUsageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/Sims/" + options.PathSimSid + "/Usage", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Usage parameters + /// Client to make requests to Twilio + /// A single instance of Usage + public static UsageResource Fetch(FetchUsageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Usage parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Usage + public static async System.Threading.Tasks.Task FetchAsync(FetchUsageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sim_sid + /// The end + /// The start + /// Client to make requests to Twilio + /// A single instance of Usage + public static UsageResource Fetch(string pathSimSid, + string end = null, + string start = null, + ITwilioRestClient client = null) + { + var options = new FetchUsageOptions(pathSimSid) { End = end, Start = start }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sim_sid + /// The end + /// The start + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Usage + public static async System.Threading.Tasks.Task FetchAsync(string pathSimSid, + string end = null, + string start = null, + ITwilioRestClient client = null) + { + var options = new FetchUsageOptions(pathSimSid) { End = end, Start = start }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a UsageResource object + /// + /// Raw JSON string + /// UsageResource object represented by the provided JSON + public static UsageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sim_sid + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The sim_unique_name + /// + [JsonProperty("sim_unique_name")] + public string SimUniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The period + /// + [JsonProperty("period")] + public object Period { get; private set; } + /// + /// The commands_usage + /// + [JsonProperty("commands_usage")] + public object CommandsUsage { get; private set; } + /// + /// The commands_costs + /// + [JsonProperty("commands_costs")] + public object CommandsCosts { get; private set; } + /// + /// The data_usage + /// + [JsonProperty("data_usage")] + public object DataUsage { get; private set; } + /// + /// The data_costs + /// + [JsonProperty("data_costs")] + public object DataCosts { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private UsageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/SimOptions.cs b/src/Twilio/Rest/Preview/Wireless/SimOptions.cs index d45e698b8..db6d9a14a 100644 --- a/src/Twilio/Rest/Preview/Wireless/SimOptions.cs +++ b/src/Twilio/Rest/Preview/Wireless/SimOptions.cs @@ -9,283 +9,283 @@ using Twilio.Converters; namespace Twilio.Rest.Preview.Wireless -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// FetchSimOptions + /// + public class FetchSimOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// FetchSimOptions + /// The sid /// - public class FetchSimOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSimOptions - /// - /// The sid - public FetchSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// ReadSimOptions + /// Construct a new FetchSimOptions /// - public class ReadSimOptions : ReadOptions - { - /// - /// The status - /// - public string Status { get; set; } - /// - /// The iccid - /// - public string Iccid { get; set; } - /// - /// The rate_plan - /// - public string RatePlan { get; set; } - /// - /// The e_id - /// - public string EId { get; set; } - /// - /// The sim_registration_code - /// - public string SimRegistrationCode { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (Iccid != null) - { - p.Add(new KeyValuePair("Iccid", Iccid)); - } - - if (RatePlan != null) - { - p.Add(new KeyValuePair("RatePlan", RatePlan)); - } - - if (EId != null) - { - p.Add(new KeyValuePair("EId", EId)); - } - - if (SimRegistrationCode != null) - { - p.Add(new KeyValuePair("SimRegistrationCode", SimRegistrationCode)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The sid + public FetchSimOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// UpdateSimOptions + /// Generate the necessary parameters /// - public class UpdateSimOptions : IOptions - { - /// - /// The sid - /// - public string PathSid { get; } - /// - /// The unique_name - /// - public string UniqueName { get; set; } - /// - /// The callback_method - /// - public string CallbackMethod { get; set; } - /// - /// The callback_url - /// - public Uri CallbackUrl { get; set; } - /// - /// The friendly_name - /// - public string FriendlyName { get; set; } - /// - /// The rate_plan - /// - public string RatePlan { get; set; } - /// - /// The status - /// - public string Status { get; set; } - /// - /// The commands_callback_method - /// - public Twilio.Http.HttpMethod CommandsCallbackMethod { get; set; } - /// - /// The commands_callback_url - /// - public Uri CommandsCallbackUrl { get; set; } - /// - /// The sms_fallback_method - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The sms_fallback_url - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The sms_method - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The sms_url - /// - public Uri SmsUrl { get; set; } - /// - /// The voice_fallback_method - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The voice_fallback_url - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The voice_method - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The voice_url - /// - public Uri VoiceUrl { get; set; } - - /// - /// Construct a new UpdateSimOptions - /// - /// The sid - public UpdateSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod)); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (RatePlan != null) - { - p.Add(new KeyValuePair("RatePlan", RatePlan.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status)); - } - - if (CommandsCallbackMethod != null) - { - p.Add(new KeyValuePair("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); - } - - if (CommandsCallbackUrl != null) - { - p.Add(new KeyValuePair("CommandsCallbackUrl", Serializers.Url(CommandsCallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// ReadSimOptions + /// + public class ReadSimOptions : ReadOptions + { + /// + /// The status + /// + public string Status { get; set; } + /// + /// The iccid + /// + public string Iccid { get; set; } + /// + /// The rate_plan + /// + public string RatePlan { get; set; } + /// + /// The e_id + /// + public string EId { get; set; } + /// + /// The sim_registration_code + /// + public string SimRegistrationCode { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (Iccid != null) + { + p.Add(new KeyValuePair("Iccid", Iccid)); + } + + if (RatePlan != null) + { + p.Add(new KeyValuePair("RatePlan", RatePlan)); + } + + if (EId != null) + { + p.Add(new KeyValuePair("EId", EId)); + } + + if (SimRegistrationCode != null) + { + p.Add(new KeyValuePair("SimRegistrationCode", SimRegistrationCode)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// UpdateSimOptions + /// + public class UpdateSimOptions : IOptions + { + /// + /// The sid + /// + public string PathSid { get; } + /// + /// The unique_name + /// + public string UniqueName { get; set; } + /// + /// The callback_method + /// + public string CallbackMethod { get; set; } + /// + /// The callback_url + /// + public Uri CallbackUrl { get; set; } + /// + /// The friendly_name + /// + public string FriendlyName { get; set; } + /// + /// The rate_plan + /// + public string RatePlan { get; set; } + /// + /// The status + /// + public string Status { get; set; } + /// + /// The commands_callback_method + /// + public Twilio.Http.HttpMethod CommandsCallbackMethod { get; set; } + /// + /// The commands_callback_url + /// + public Uri CommandsCallbackUrl { get; set; } + /// + /// The sms_fallback_method + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The sms_fallback_url + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The sms_method + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The sms_url + /// + public Uri SmsUrl { get; set; } + /// + /// The voice_fallback_method + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The voice_fallback_url + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The voice_method + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The voice_url + /// + public Uri VoiceUrl { get; set; } + + /// + /// Construct a new UpdateSimOptions + /// + /// The sid + public UpdateSimOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod)); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (RatePlan != null) + { + p.Add(new KeyValuePair("RatePlan", RatePlan.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status)); + } + + if (CommandsCallbackMethod != null) + { + p.Add(new KeyValuePair("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); + } + + if (CommandsCallbackUrl != null) + { + p.Add(new KeyValuePair("CommandsCallbackUrl", Serializers.Url(CommandsCallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Preview/Wireless/SimResource.cs b/src/Twilio/Rest/Preview/Wireless/SimResource.cs index 77830c863..83c6017d1 100644 --- a/src/Twilio/Rest/Preview/Wireless/SimResource.cs +++ b/src/Twilio/Rest/Preview/Wireless/SimResource.cs @@ -19,495 +19,495 @@ using Twilio.Http; namespace Twilio.Rest.Preview.Wireless -{ - - public class SimResource : Resource - { - private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/Sims/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The sid - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Preview, - "/wireless/Sims", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The status - /// The iccid - /// The rate_plan - /// The e_id - /// The sim_registration_code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(string status = null, - string iccid = null, - string ratePlan = null, - string eId = null, - string simRegistrationCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The status - /// The iccid - /// The rate_plan - /// The e_id - /// The sim_registration_code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(string status = null, - string iccid = null, - string ratePlan = null, - string eId = null, - string simRegistrationCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Preview) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Preview, - "/wireless/Sims/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The sid - /// The unique_name - /// The callback_method - /// The callback_url - /// The friendly_name - /// The rate_plan - /// The status - /// The commands_callback_method - /// The commands_callback_url - /// The sms_fallback_method - /// The sms_fallback_url - /// The sms_method - /// The sms_url - /// The voice_fallback_method - /// The voice_fallback_url - /// The voice_method - /// The voice_url - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(string pathSid, - string uniqueName = null, - string callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - string ratePlan = null, - string status = null, - Twilio.Http.HttpMethod commandsCallbackMethod = null, - Uri commandsCallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The sid - /// The unique_name - /// The callback_method - /// The callback_url - /// The friendly_name - /// The rate_plan - /// The status - /// The commands_callback_method - /// The commands_callback_url - /// The sms_fallback_method - /// The sms_fallback_url - /// The sms_method - /// The sms_url - /// The voice_fallback_method - /// The voice_fallback_url - /// The voice_method - /// The voice_url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - string callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - string ratePlan = null, - string status = null, - Twilio.Http.HttpMethod commandsCallbackMethod = null, - Uri commandsCallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SimResource object - /// - /// Raw JSON string - /// SimResource object represented by the provided JSON - public static SimResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique_name - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The account_sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The rate_plan_sid - /// - [JsonProperty("rate_plan_sid")] - public string RatePlanSid { get; private set; } - /// - /// The friendly_name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The iccid - /// - [JsonProperty("iccid")] - public string Iccid { get; private set; } - /// - /// The e_id - /// - [JsonProperty("e_id")] - public string EId { get; private set; } - /// - /// The status - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// The commands_callback_url - /// - [JsonProperty("commands_callback_url")] - public Uri CommandsCallbackUrl { get; private set; } - /// - /// The commands_callback_method - /// - [JsonProperty("commands_callback_method")] - public string CommandsCallbackMethod { get; private set; } - /// - /// The sms_fallback_method - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The sms_fallback_url - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The sms_method - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The sms_url - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The voice_fallback_method - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The voice_fallback_url - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The voice_method - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The voice_url - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date_updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private SimResource() - { - - } - } +{ + + public class SimResource : Resource + { + private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/Sims/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The sid + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Preview, + "/wireless/Sims", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The status + /// The iccid + /// The rate_plan + /// The e_id + /// The sim_registration_code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(string status = null, + string iccid = null, + string ratePlan = null, + string eId = null, + string simRegistrationCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The status + /// The iccid + /// The rate_plan + /// The e_id + /// The sim_registration_code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(string status = null, + string iccid = null, + string ratePlan = null, + string eId = null, + string simRegistrationCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Preview) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Preview, + "/wireless/Sims/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The sid + /// The unique_name + /// The callback_method + /// The callback_url + /// The friendly_name + /// The rate_plan + /// The status + /// The commands_callback_method + /// The commands_callback_url + /// The sms_fallback_method + /// The sms_fallback_url + /// The sms_method + /// The sms_url + /// The voice_fallback_method + /// The voice_fallback_url + /// The voice_method + /// The voice_url + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(string pathSid, + string uniqueName = null, + string callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + string ratePlan = null, + string status = null, + Twilio.Http.HttpMethod commandsCallbackMethod = null, + Uri commandsCallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The sid + /// The unique_name + /// The callback_method + /// The callback_url + /// The friendly_name + /// The rate_plan + /// The status + /// The commands_callback_method + /// The commands_callback_url + /// The sms_fallback_method + /// The sms_fallback_url + /// The sms_method + /// The sms_url + /// The voice_fallback_method + /// The voice_fallback_url + /// The voice_method + /// The voice_url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + string callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + string ratePlan = null, + string status = null, + Twilio.Http.HttpMethod commandsCallbackMethod = null, + Uri commandsCallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SimResource object + /// + /// Raw JSON string + /// SimResource object represented by the provided JSON + public static SimResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique_name + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The account_sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The rate_plan_sid + /// + [JsonProperty("rate_plan_sid")] + public string RatePlanSid { get; private set; } + /// + /// The friendly_name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The iccid + /// + [JsonProperty("iccid")] + public string Iccid { get; private set; } + /// + /// The e_id + /// + [JsonProperty("e_id")] + public string EId { get; private set; } + /// + /// The status + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// The commands_callback_url + /// + [JsonProperty("commands_callback_url")] + public Uri CommandsCallbackUrl { get; private set; } + /// + /// The commands_callback_method + /// + [JsonProperty("commands_callback_method")] + public string CommandsCallbackMethod { get; private set; } + /// + /// The sms_fallback_method + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The sms_fallback_url + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The sms_method + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The sms_url + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The voice_fallback_method + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The voice_fallback_url + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The voice_method + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The voice_url + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date_updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private SimResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Messaging/CountryOptions.cs b/src/Twilio/Rest/Pricing/V1/Messaging/CountryOptions.cs index f35548935..765a37423 100644 --- a/src/Twilio/Rest/Pricing/V1/Messaging/CountryOptions.cs +++ b/src/Twilio/Rest/Pricing/V1/Messaging/CountryOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V1.Messaging -{ - +{ + + /// + /// ReadCountryOptions + /// + public class ReadCountryOptions : ReadOptions + { /// - /// ReadCountryOptions + /// Generate the necessary parameters /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchCountryOptions + /// + public class FetchCountryOptions : IOptions + { /// - /// FetchCountryOptions + /// The ISO country code /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code - /// - public string PathIsoCountry { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code - public FetchCountryOptions(string pathIsoCountry) - { - PathIsoCountry = pathIsoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathIsoCountry { get; } + + /// + /// Construct a new FetchCountryOptions + /// + /// The ISO country code + public FetchCountryOptions(string pathIsoCountry) + { + PathIsoCountry = pathIsoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Messaging/CountryResource.cs b/src/Twilio/Rest/Pricing/V1/Messaging/CountryResource.cs index d2232e1ef..350b78dbe 100644 --- a/src/Twilio/Rest/Pricing/V1/Messaging/CountryResource.cs +++ b/src/Twilio/Rest/Pricing/V1/Messaging/CountryResource.cs @@ -17,259 +17,259 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V1.Messaging -{ - - public class CountryResource : Resource - { - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/Messaging/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/Messaging/Countries/" + options.PathIsoCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of OutboundSMSPrice records - /// - [JsonProperty("outbound_sms_prices")] - public List OutboundSmsPrices { get; private set; } - /// - /// The list of InboundPrice records - /// - [JsonProperty("inbound_sms_prices")] - public List InboundSmsPrices { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/Messaging/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/Messaging/Countries/" + options.PathIsoCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of OutboundSMSPrice records + /// + [JsonProperty("outbound_sms_prices")] + public List OutboundSmsPrices { get; private set; } + /// + /// The list of InboundPrice records + /// + [JsonProperty("inbound_sms_prices")] + public List InboundSmsPrices { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryOptions.cs b/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryOptions.cs index c5d6c4efb..ee5999868 100644 --- a/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryOptions.cs +++ b/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V1.PhoneNumber -{ - +{ + + /// + /// ReadCountryOptions + /// + public class ReadCountryOptions : ReadOptions + { /// - /// ReadCountryOptions + /// Generate the necessary parameters /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchCountryOptions + /// + public class FetchCountryOptions : IOptions + { /// - /// FetchCountryOptions + /// The ISO country code /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code - /// - public string PathIsoCountry { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code - public FetchCountryOptions(string pathIsoCountry) - { - PathIsoCountry = pathIsoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathIsoCountry { get; } + + /// + /// Construct a new FetchCountryOptions + /// + /// The ISO country code + public FetchCountryOptions(string pathIsoCountry) + { + PathIsoCountry = pathIsoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryResource.cs b/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryResource.cs index 87b7677e5..f5001179d 100644 --- a/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryResource.cs +++ b/src/Twilio/Rest/Pricing/V1/PhoneNumber/CountryResource.cs @@ -17,254 +17,254 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V1.PhoneNumber -{ - - public class CountryResource : Resource - { - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/PhoneNumbers/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/PhoneNumbers/Countries/" + options.PathIsoCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of PhoneNumberPrices records - /// - [JsonProperty("phone_number_prices")] - public List PhoneNumberPrices { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/PhoneNumbers/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/PhoneNumbers/Countries/" + options.PathIsoCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of PhoneNumberPrices records + /// + [JsonProperty("phone_number_prices")] + public List PhoneNumberPrices { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Voice/CountryOptions.cs b/src/Twilio/Rest/Pricing/V1/Voice/CountryOptions.cs index afb84447b..d1a0c6995 100644 --- a/src/Twilio/Rest/Pricing/V1/Voice/CountryOptions.cs +++ b/src/Twilio/Rest/Pricing/V1/Voice/CountryOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V1.Voice -{ - +{ + + /// + /// ReadCountryOptions + /// + public class ReadCountryOptions : ReadOptions + { /// - /// ReadCountryOptions + /// Generate the necessary parameters /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchCountryOptions + /// + public class FetchCountryOptions : IOptions + { /// - /// FetchCountryOptions + /// The ISO country code /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code - /// - public string PathIsoCountry { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code - public FetchCountryOptions(string pathIsoCountry) - { - PathIsoCountry = pathIsoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathIsoCountry { get; } + + /// + /// Construct a new FetchCountryOptions + /// + /// The ISO country code + public FetchCountryOptions(string pathIsoCountry) + { + PathIsoCountry = pathIsoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Voice/CountryResource.cs b/src/Twilio/Rest/Pricing/V1/Voice/CountryResource.cs index 13c3299dd..b90ea7a01 100644 --- a/src/Twilio/Rest/Pricing/V1/Voice/CountryResource.cs +++ b/src/Twilio/Rest/Pricing/V1/Voice/CountryResource.cs @@ -17,259 +17,259 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V1.Voice -{ - - public class CountryResource : Resource - { - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/Voice/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/Voice/Countries/" + options.PathIsoCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The ISO country code - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of OutboundPrefixPrice records - /// - [JsonProperty("outbound_prefix_prices")] - public List OutboundPrefixPrices { get; private set; } - /// - /// The list of InboundCallPrice records - /// - [JsonProperty("inbound_call_prices")] - public List InboundCallPrices { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/Voice/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/Voice/Countries/" + options.PathIsoCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The ISO country code + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of OutboundPrefixPrice records + /// + [JsonProperty("outbound_prefix_prices")] + public List OutboundPrefixPrices { get; private set; } + /// + /// The list of InboundCallPrice records + /// + [JsonProperty("inbound_call_prices")] + public List InboundCallPrices { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Voice/NumberOptions.cs b/src/Twilio/Rest/Pricing/V1/Voice/NumberOptions.cs index 4306a859e..ab5627655 100644 --- a/src/Twilio/Rest/Pricing/V1/Voice/NumberOptions.cs +++ b/src/Twilio/Rest/Pricing/V1/Voice/NumberOptions.cs @@ -9,35 +9,35 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V1.Voice -{ - +{ + + /// + /// FetchNumberOptions + /// + public class FetchNumberOptions : IOptions + { /// - /// FetchNumberOptions + /// The phone number to fetch /// - public class FetchNumberOptions : IOptions - { - /// - /// The phone number to fetch - /// - public Types.PhoneNumber PathNumber { get; } - - /// - /// Construct a new FetchNumberOptions - /// - /// The phone number to fetch - public FetchNumberOptions(Types.PhoneNumber pathNumber) - { - PathNumber = pathNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public Types.PhoneNumber PathNumber { get; } + + /// + /// Construct a new FetchNumberOptions + /// + /// The phone number to fetch + public FetchNumberOptions(Types.PhoneNumber pathNumber) + { + PathNumber = pathNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V1/Voice/NumberResource.cs b/src/Twilio/Rest/Pricing/V1/Voice/NumberResource.cs index 6cfb54b30..3ca6ca8d1 100644 --- a/src/Twilio/Rest/Pricing/V1/Voice/NumberResource.cs +++ b/src/Twilio/Rest/Pricing/V1/Voice/NumberResource.cs @@ -17,136 +17,136 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V1.Voice -{ - - public class NumberResource : Resource - { - private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v1/Voice/Numbers/" + options.PathNumber + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The phone number to fetch - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(Types.PhoneNumber pathNumber, ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathNumber); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The phone number to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathNumber, - ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathNumber); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NumberResource object - /// - /// Raw JSON string - /// NumberResource object represented by the provided JSON - public static NumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The phone number - /// - [JsonProperty("number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber Number { get; private set; } - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The OutboundCallPrice record - /// - [JsonProperty("outbound_call_price")] - public OutboundCallPrice OutboundCallPrice { get; private set; } - /// - /// The InboundCallPrice record - /// - [JsonProperty("inbound_call_price")] - public InboundCallPrice InboundCallPrice { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NumberResource() - { - - } - } +{ + + public class NumberResource : Resource + { + private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v1/Voice/Numbers/" + options.PathNumber + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The phone number to fetch + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(Types.PhoneNumber pathNumber, ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathNumber); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The phone number to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathNumber, + ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathNumber); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NumberResource object + /// + /// Raw JSON string + /// NumberResource object represented by the provided JSON + public static NumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The phone number + /// + [JsonProperty("number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber Number { get; private set; } + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The OutboundCallPrice record + /// + [JsonProperty("outbound_call_price")] + public OutboundCallPrice OutboundCallPrice { get; private set; } + /// + /// The InboundCallPrice record + /// + [JsonProperty("inbound_call_price")] + public InboundCallPrice InboundCallPrice { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/CountryOptions.cs b/src/Twilio/Rest/Pricing/V2/CountryOptions.cs index ab659f06a..f71222481 100644 --- a/src/Twilio/Rest/Pricing/V2/CountryOptions.cs +++ b/src/Twilio/Rest/Pricing/V2/CountryOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V2 -{ - +{ + + /// + /// ReadCountryOptions + /// + public class ReadCountryOptions : ReadOptions + { /// - /// ReadCountryOptions + /// Generate the necessary parameters /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Country. + /// + public class FetchCountryOptions : IOptions + { /// - /// Fetch a specific Country. + /// The ISO country code of the pricing information to fetch /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code of the pricing information to fetch - /// - public string PathIsoCountry { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code of the pricing information to fetch - public FetchCountryOptions(string pathIsoCountry) - { - PathIsoCountry = pathIsoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathIsoCountry { get; } + + /// + /// Construct a new FetchCountryOptions + /// + /// The ISO country code of the pricing information to fetch + public FetchCountryOptions(string pathIsoCountry) + { + PathIsoCountry = pathIsoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/CountryResource.cs b/src/Twilio/Rest/Pricing/V2/CountryResource.cs index e71d80be9..1beb33c72 100644 --- a/src/Twilio/Rest/Pricing/V2/CountryResource.cs +++ b/src/Twilio/Rest/Pricing/V2/CountryResource.cs @@ -17,259 +17,259 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V2 -{ - - public class CountryResource : Resource - { - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Trunking/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Trunking/Countries/" + options.PathIsoCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Country. - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Country. - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Country. - /// - /// The ISO country code of the pricing information to fetch - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Country. - /// - /// The ISO country code of the pricing information to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of TerminatingPrefixPrice records - /// - [JsonProperty("terminating_prefix_prices")] - public List TerminatingPrefixPrices { get; private set; } - /// - /// The list of OriginatingCallPrice records - /// - [JsonProperty("originating_call_prices")] - public List OriginatingCallPrices { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Trunking/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Trunking/Countries/" + options.PathIsoCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Country. + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Country. + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Country. + /// + /// The ISO country code of the pricing information to fetch + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Country. + /// + /// The ISO country code of the pricing information to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of TerminatingPrefixPrice records + /// + [JsonProperty("terminating_prefix_prices")] + public List TerminatingPrefixPrices { get; private set; } + /// + /// The list of OriginatingCallPrice records + /// + [JsonProperty("originating_call_prices")] + public List OriginatingCallPrices { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/NumberOptions.cs b/src/Twilio/Rest/Pricing/V2/NumberOptions.cs index 6a352f188..3c5660f9e 100644 --- a/src/Twilio/Rest/Pricing/V2/NumberOptions.cs +++ b/src/Twilio/Rest/Pricing/V2/NumberOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V2 -{ - +{ + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + public class FetchNumberOptions : IOptions + { /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// The destination number for which to fetch pricing information /// - public class FetchNumberOptions : IOptions - { - /// - /// The destination number for which to fetch pricing information - /// - public Types.PhoneNumber PathDestinationNumber { get; } - /// - /// The origination number for which to fetch pricing information - /// - public Types.PhoneNumber OriginationNumber { get; set; } - - /// - /// Construct a new FetchNumberOptions - /// - /// The destination number for which to fetch pricing information - public FetchNumberOptions(Types.PhoneNumber pathDestinationNumber) - { - PathDestinationNumber = pathDestinationNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (OriginationNumber != null) - { - p.Add(new KeyValuePair("OriginationNumber", OriginationNumber.ToString())); - } - - return p; - } - } + public Types.PhoneNumber PathDestinationNumber { get; } + /// + /// The origination number for which to fetch pricing information + /// + public Types.PhoneNumber OriginationNumber { get; set; } + + /// + /// Construct a new FetchNumberOptions + /// + /// The destination number for which to fetch pricing information + public FetchNumberOptions(Types.PhoneNumber pathDestinationNumber) + { + PathDestinationNumber = pathDestinationNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (OriginationNumber != null) + { + p.Add(new KeyValuePair("OriginationNumber", OriginationNumber.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/NumberResource.cs b/src/Twilio/Rest/Pricing/V2/NumberResource.cs index b47dd5464..0972ba8af 100644 --- a/src/Twilio/Rest/Pricing/V2/NumberResource.cs +++ b/src/Twilio/Rest/Pricing/V2/NumberResource.cs @@ -17,147 +17,147 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V2 -{ - - public class NumberResource : Resource - { - private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Trunking/Numbers/" + options.PathDestinationNumber + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// The destination number for which to fetch pricing information - /// The origination number for which to fetch pricing information - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(Types.PhoneNumber pathDestinationNumber, - Types.PhoneNumber originationNumber = null, - ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathDestinationNumber){OriginationNumber = originationNumber}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// The destination number for which to fetch pricing information - /// The origination number for which to fetch pricing information - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathDestinationNumber, - Types.PhoneNumber originationNumber = null, - ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathDestinationNumber){OriginationNumber = originationNumber}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NumberResource object - /// - /// Raw JSON string - /// NumberResource object represented by the provided JSON - public static NumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The destination phone number, in E.164 format - /// - [JsonProperty("destination_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber DestinationNumber { get; private set; } - /// - /// The origination phone number, in E.164 format - /// - [JsonProperty("origination_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber OriginationNumber { get; private set; } - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The terminating_prefix_prices - /// - [JsonProperty("terminating_prefix_prices")] - public List TerminatingPrefixPrices { get; private set; } - /// - /// The OriginatingCallPrice record - /// - [JsonProperty("originating_call_price")] - public InboundCallPrice OriginatingCallPrice { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NumberResource() - { - - } - } +{ + + public class NumberResource : Resource + { + private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Trunking/Numbers/" + options.PathDestinationNumber + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// The destination number for which to fetch pricing information + /// The origination number for which to fetch pricing information + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(Types.PhoneNumber pathDestinationNumber, + Types.PhoneNumber originationNumber = null, + ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathDestinationNumber) { OriginationNumber = originationNumber }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// The destination number for which to fetch pricing information + /// The origination number for which to fetch pricing information + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathDestinationNumber, + Types.PhoneNumber originationNumber = null, + ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathDestinationNumber) { OriginationNumber = originationNumber }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NumberResource object + /// + /// Raw JSON string + /// NumberResource object represented by the provided JSON + public static NumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The destination phone number, in E.164 format + /// + [JsonProperty("destination_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber DestinationNumber { get; private set; } + /// + /// The origination phone number, in E.164 format + /// + [JsonProperty("origination_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber OriginationNumber { get; private set; } + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The terminating_prefix_prices + /// + [JsonProperty("terminating_prefix_prices")] + public List TerminatingPrefixPrices { get; private set; } + /// + /// The OriginatingCallPrice record + /// + [JsonProperty("originating_call_price")] + public InboundCallPrice OriginatingCallPrice { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/Voice/CountryOptions.cs b/src/Twilio/Rest/Pricing/V2/Voice/CountryOptions.cs index 11a69637c..05b248f3a 100644 --- a/src/Twilio/Rest/Pricing/V2/Voice/CountryOptions.cs +++ b/src/Twilio/Rest/Pricing/V2/Voice/CountryOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V2.Voice -{ - +{ + + /// + /// ReadCountryOptions + /// + public class ReadCountryOptions : ReadOptions + { /// - /// ReadCountryOptions + /// Generate the necessary parameters /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Country. + /// + public class FetchCountryOptions : IOptions + { /// - /// Fetch a specific Country. + /// The ISO country code of the pricing information to fetch /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code of the pricing information to fetch - /// - public string PathIsoCountry { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code of the pricing information to fetch - public FetchCountryOptions(string pathIsoCountry) - { - PathIsoCountry = pathIsoCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathIsoCountry { get; } + + /// + /// Construct a new FetchCountryOptions + /// + /// The ISO country code of the pricing information to fetch + public FetchCountryOptions(string pathIsoCountry) + { + PathIsoCountry = pathIsoCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/Voice/CountryResource.cs b/src/Twilio/Rest/Pricing/V2/Voice/CountryResource.cs index b91aadb54..b844a9fb4 100644 --- a/src/Twilio/Rest/Pricing/V2/Voice/CountryResource.cs +++ b/src/Twilio/Rest/Pricing/V2/Voice/CountryResource.cs @@ -17,259 +17,259 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V2.Voice -{ - - public class CountryResource : Resource - { - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Voice/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("countries", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Pricing) - ); - - var response = client.Request(request); - return Page.FromJson("countries", response.Content); - } - - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Voice/Countries/" + options.PathIsoCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Country. - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Country. - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Country. - /// - /// The ISO country code of the pricing information to fetch - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Country. - /// - /// The ISO country code of the pricing information to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCountry); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of OutboundPrefixPriceWithOrigin records - /// - [JsonProperty("outbound_prefix_prices")] - public List OutboundPrefixPrices { get; private set; } - /// - /// The list of InboundCallPrice records - /// - [JsonProperty("inbound_call_prices")] - public List InboundCallPrices { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Voice/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("countries", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Pricing) + ); + + var response = client.Request(request); + return Page.FromJson("countries", response.Content); + } + + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Voice/Countries/" + options.PathIsoCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Country. + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Country. + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Country. + /// + /// The ISO country code of the pricing information to fetch + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCountry, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Country. + /// + /// The ISO country code of the pricing information to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCountry, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCountry); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of OutboundPrefixPriceWithOrigin records + /// + [JsonProperty("outbound_prefix_prices")] + public List OutboundPrefixPrices { get; private set; } + /// + /// The list of InboundCallPrice records + /// + [JsonProperty("inbound_call_prices")] + public List InboundCallPrices { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/Voice/NumberOptions.cs b/src/Twilio/Rest/Pricing/V2/Voice/NumberOptions.cs index edb5b4041..6c51f3d33 100644 --- a/src/Twilio/Rest/Pricing/V2/Voice/NumberOptions.cs +++ b/src/Twilio/Rest/Pricing/V2/Voice/NumberOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Pricing.V2.Voice -{ - +{ + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + public class FetchNumberOptions : IOptions + { /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// The destination number for which to fetch pricing information /// - public class FetchNumberOptions : IOptions - { - /// - /// The destination number for which to fetch pricing information - /// - public Types.PhoneNumber PathDestinationNumber { get; } - /// - /// The origination number for which to fetch pricing information - /// - public Types.PhoneNumber OriginationNumber { get; set; } - - /// - /// Construct a new FetchNumberOptions - /// - /// The destination number for which to fetch pricing information - public FetchNumberOptions(Types.PhoneNumber pathDestinationNumber) - { - PathDestinationNumber = pathDestinationNumber; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (OriginationNumber != null) - { - p.Add(new KeyValuePair("OriginationNumber", OriginationNumber.ToString())); - } - - return p; - } - } + public Types.PhoneNumber PathDestinationNumber { get; } + /// + /// The origination number for which to fetch pricing information + /// + public Types.PhoneNumber OriginationNumber { get; set; } + + /// + /// Construct a new FetchNumberOptions + /// + /// The destination number for which to fetch pricing information + public FetchNumberOptions(Types.PhoneNumber pathDestinationNumber) + { + PathDestinationNumber = pathDestinationNumber; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (OriginationNumber != null) + { + p.Add(new KeyValuePair("OriginationNumber", OriginationNumber.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Pricing/V2/Voice/NumberResource.cs b/src/Twilio/Rest/Pricing/V2/Voice/NumberResource.cs index 02082a558..d0adfe4f4 100644 --- a/src/Twilio/Rest/Pricing/V2/Voice/NumberResource.cs +++ b/src/Twilio/Rest/Pricing/V2/Voice/NumberResource.cs @@ -17,147 +17,147 @@ using Twilio.Types; namespace Twilio.Rest.Pricing.V2.Voice -{ - - public class NumberResource : Resource - { - private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Pricing, - "/v2/Voice/Numbers/" + options.PathDestinationNumber + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// Fetch Number parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// The destination number for which to fetch pricing information - /// The origination number for which to fetch pricing information - /// Client to make requests to Twilio - /// A single instance of Number - public static NumberResource Fetch(Types.PhoneNumber pathDestinationNumber, - Types.PhoneNumber originationNumber = null, - ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathDestinationNumber){OriginationNumber = originationNumber}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch pricing information for a specific destination and, optionally, origination phone number. - /// - /// The destination number for which to fetch pricing information - /// The origination number for which to fetch pricing information - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Number - public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathDestinationNumber, - Types.PhoneNumber originationNumber = null, - ITwilioRestClient client = null) - { - var options = new FetchNumberOptions(pathDestinationNumber){OriginationNumber = originationNumber}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NumberResource object - /// - /// Raw JSON string - /// NumberResource object represented by the provided JSON - public static NumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The destination phone number, in E.164 format - /// - [JsonProperty("destination_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber DestinationNumber { get; private set; } - /// - /// The origination phone number, in E.164 format - /// - [JsonProperty("origination_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber OriginationNumber { get; private set; } - /// - /// The name of the country - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The ISO country code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The list of OutboundCallPriceWithOrigin records - /// - [JsonProperty("outbound_call_prices")] - public List OutboundCallPrices { get; private set; } - /// - /// The InboundCallPrice record - /// - [JsonProperty("inbound_call_price")] - public InboundCallPrice InboundCallPrice { get; private set; } - /// - /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) - /// - [JsonProperty("price_unit")] - public string PriceUnit { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NumberResource() - { - - } - } +{ + + public class NumberResource : Resource + { + private static Request BuildFetchRequest(FetchNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Pricing, + "/v2/Voice/Numbers/" + options.PathDestinationNumber + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(FetchNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// Fetch Number parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(FetchNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// The destination number for which to fetch pricing information + /// The origination number for which to fetch pricing information + /// Client to make requests to Twilio + /// A single instance of Number + public static NumberResource Fetch(Types.PhoneNumber pathDestinationNumber, + Types.PhoneNumber originationNumber = null, + ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathDestinationNumber) { OriginationNumber = originationNumber }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch pricing information for a specific destination and, optionally, origination phone number. + /// + /// The destination number for which to fetch pricing information + /// The origination number for which to fetch pricing information + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Number + public static async System.Threading.Tasks.Task FetchAsync(Types.PhoneNumber pathDestinationNumber, + Types.PhoneNumber originationNumber = null, + ITwilioRestClient client = null) + { + var options = new FetchNumberOptions(pathDestinationNumber) { OriginationNumber = originationNumber }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NumberResource object + /// + /// Raw JSON string + /// NumberResource object represented by the provided JSON + public static NumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The destination phone number, in E.164 format + /// + [JsonProperty("destination_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber DestinationNumber { get; private set; } + /// + /// The origination phone number, in E.164 format + /// + [JsonProperty("origination_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber OriginationNumber { get; private set; } + /// + /// The name of the country + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The ISO country code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The list of OutboundCallPriceWithOrigin records + /// + [JsonProperty("outbound_call_prices")] + public List OutboundCallPrices { get; private set; } + /// + /// The InboundCallPrice record + /// + [JsonProperty("inbound_call_price")] + public InboundCallPrice InboundCallPrice { get; private set; } + /// + /// The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy) + /// + [JsonProperty("price_unit")] + public string PriceUnit { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberOptions.cs index ab83730b8..06ea0f577 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberOptions.cs @@ -9,221 +9,221 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Add a Phone Number to a Service's Proxy Number Pool. + /// + public class CreatePhoneNumberOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Add a Phone Number to a Service's Proxy Number Pool. - /// - public class CreatePhoneNumberOptions : IOptions - { - /// - /// The SID of the resource's parent Service - /// - public string PathServiceSid { get; } - /// - /// The SID of a Twilio IncomingPhoneNumber resource - /// - public string Sid { get; set; } - /// - /// The phone number in E.164 format - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// Whether the new phone number should be reserved - /// - public bool? IsReserved { get; set; } - - /// - /// Construct a new CreatePhoneNumberOptions - /// - /// The SID of the resource's parent Service - public CreatePhoneNumberOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Sid != null) - { - p.Add(new KeyValuePair("Sid", Sid.ToString())); - } - - if (PhoneNumber != null) - { - p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); - } - - if (IsReserved != null) - { - p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The SID of the resource's parent Service + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Phone Number from a Service. - /// - public class DeletePhoneNumberOptions : IOptions - { - /// - /// The SID of the parent Service resource of the PhoneNumber resource to delete - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeletePhoneNumberOptions - /// - /// The SID of the parent Service resource of the PhoneNumber resource to delete - /// The unique string that identifies the resource - public DeletePhoneNumberOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of a Twilio IncomingPhoneNumber resource + /// + public string Sid { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be - /// returned per page. - /// - public class ReadPhoneNumberOptions : ReadOptions - { - /// - /// The SID of the parent Service resource of the PhoneNumber resource to read - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadPhoneNumberOptions - /// - /// The SID of the parent Service resource of the PhoneNumber resource to read - public ReadPhoneNumberOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The phone number in E.164 format + /// + public Types.PhoneNumber PhoneNumber { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Phone Number. - /// - public class FetchPhoneNumberOptions : IOptions - { - /// - /// The SID of the parent Service resource of the PhoneNumber resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPhoneNumberOptions - /// - /// The SID of the parent Service resource of the PhoneNumber resource to fetch - /// The unique string that identifies the resource - public FetchPhoneNumberOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Whether the new phone number should be reserved + /// + public bool? IsReserved { get; set; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Proxy Number. - /// - public class UpdatePhoneNumberOptions : IOptions - { - /// - /// The SID of the parent Service resource of the PhoneNumber resource to update - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// Whether the new phone number should be reserved - /// - public bool? IsReserved { get; set; } - - /// - /// Construct a new UpdatePhoneNumberOptions - /// - /// The SID of the parent Service resource of the PhoneNumber resource to update - /// The unique string that identifies the resource - public UpdatePhoneNumberOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IsReserved != null) - { - p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new CreatePhoneNumberOptions + /// + /// The SID of the resource's parent Service + public CreatePhoneNumberOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Sid != null) + { + p.Add(new KeyValuePair("Sid", Sid.ToString())); + } + + if (PhoneNumber != null) + { + p.Add(new KeyValuePair("PhoneNumber", PhoneNumber.ToString())); + } + + if (IsReserved != null) + { + p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Phone Number from a Service. + /// + public class DeletePhoneNumberOptions : IOptions + { + /// + /// The SID of the parent Service resource of the PhoneNumber resource to delete + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeletePhoneNumberOptions + /// + /// The SID of the parent Service resource of the PhoneNumber resource to delete + /// The unique string that identifies the resource + public DeletePhoneNumberOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be + /// returned per page. + /// + public class ReadPhoneNumberOptions : ReadOptions + { + /// + /// The SID of the parent Service resource of the PhoneNumber resource to read + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadPhoneNumberOptions + /// + /// The SID of the parent Service resource of the PhoneNumber resource to read + public ReadPhoneNumberOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Phone Number. + /// + public class FetchPhoneNumberOptions : IOptions + { + /// + /// The SID of the parent Service resource of the PhoneNumber resource to fetch + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPhoneNumberOptions + /// + /// The SID of the parent Service resource of the PhoneNumber resource to fetch + /// The unique string that identifies the resource + public FetchPhoneNumberOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Proxy Number. + /// + public class UpdatePhoneNumberOptions : IOptions + { + /// + /// The SID of the parent Service resource of the PhoneNumber resource to update + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// Whether the new phone number should be reserved + /// + public bool? IsReserved { get; set; } + + /// + /// Construct a new UpdatePhoneNumberOptions + /// + /// The SID of the parent Service resource of the PhoneNumber resource to update + /// The unique string that identifies the resource + public UpdatePhoneNumberOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IsReserved != null) + { + p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberResource.cs b/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberResource.cs index 2eabb0cfd..cae4021da 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberResource.cs @@ -19,527 +19,527 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1.Service -{ - - public class PhoneNumberResource : Resource - { - private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Add a Phone Number to a Service's Proxy Number Pool. - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a Phone Number to a Service's Proxy Number Pool. - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a Phone Number to a Service's Proxy Number Pool. - /// - /// The SID of the resource's parent Service - /// The SID of a Twilio IncomingPhoneNumber resource - /// The phone number in E.164 format - /// Whether the new phone number should be reserved - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(string pathServiceSid, - string sid = null, - Types.PhoneNumber phoneNumber = null, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathServiceSid){Sid = sid, PhoneNumber = phoneNumber, IsReserved = isReserved}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a Phone Number to a Service's Proxy Number Pool. - /// - /// The SID of the resource's parent Service - /// The SID of a Twilio IncomingPhoneNumber resource - /// The phone number in E.164 format - /// Whether the new phone number should be reserved - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string sid = null, - Types.PhoneNumber phoneNumber = null, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathServiceSid){Sid = sid, PhoneNumber = phoneNumber, IsReserved = isReserved}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Phone Number from a Service. - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Phone Number from a Service. - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Phone Number from a Service. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Phone Number from a Service. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be - /// returned per page. - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be - /// returned per page. - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be - /// returned per page. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be - /// returned per page. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Phone Number. - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Phone Number. - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Phone Number. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Phone Number. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdatePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Proxy Number. - /// - /// Update PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Update(UpdatePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Proxy Number. - /// - /// Update PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task UpdateAsync(UpdatePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Proxy Number. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to update - /// The unique string that identifies the resource - /// Whether the new phone number should be reserved - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Update(string pathServiceSid, - string pathSid, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new UpdatePhoneNumberOptions(pathServiceSid, pathSid){IsReserved = isReserved}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Proxy Number. - /// - /// The SID of the parent Service resource of the PhoneNumber resource to update - /// The unique string that identifies the resource - /// Whether the new phone number should be reserved - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new UpdatePhoneNumberOptions(pathServiceSid, pathSid){IsReserved = isReserved}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PhoneNumberResource object - /// - /// Raw JSON string - /// PhoneNumberResource object represented by the provided JSON - public static PhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the PhoneNumber resource's parent Service resource - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO Country Code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The capabilities of the phone number - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The absolute URL of the PhoneNumber resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Reserve the phone number for manual assignment to participants only - /// - [JsonProperty("is_reserved")] - public bool? IsReserved { get; private set; } - /// - /// The number of open session assigned to the number. - /// - [JsonProperty("in_use")] - public int? InUse { get; private set; } - - private PhoneNumberResource() - { - - } - } +{ + + public class PhoneNumberResource : Resource + { + private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Add a Phone Number to a Service's Proxy Number Pool. + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a Phone Number to a Service's Proxy Number Pool. + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a Phone Number to a Service's Proxy Number Pool. + /// + /// The SID of the resource's parent Service + /// The SID of a Twilio IncomingPhoneNumber resource + /// The phone number in E.164 format + /// Whether the new phone number should be reserved + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(string pathServiceSid, + string sid = null, + Types.PhoneNumber phoneNumber = null, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathServiceSid) { Sid = sid, PhoneNumber = phoneNumber, IsReserved = isReserved }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a Phone Number to a Service's Proxy Number Pool. + /// + /// The SID of the resource's parent Service + /// The SID of a Twilio IncomingPhoneNumber resource + /// The phone number in E.164 format + /// Whether the new phone number should be reserved + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string sid = null, + Types.PhoneNumber phoneNumber = null, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathServiceSid) { Sid = sid, PhoneNumber = phoneNumber, IsReserved = isReserved }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Phone Number from a Service. + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Phone Number from a Service. + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Phone Number from a Service. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Phone Number from a Service. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be + /// returned per page. + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be + /// returned per page. + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be + /// returned per page. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Phone Numbers in the Proxy Number Pool for a Service. A maximum of 100 records will be + /// returned per page. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Phone Number. + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Phone Number. + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Phone Number. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Phone Number. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdatePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/PhoneNumbers/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Proxy Number. + /// + /// Update PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Update(UpdatePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Proxy Number. + /// + /// Update PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task UpdateAsync(UpdatePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Proxy Number. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to update + /// The unique string that identifies the resource + /// Whether the new phone number should be reserved + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Update(string pathServiceSid, + string pathSid, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new UpdatePhoneNumberOptions(pathServiceSid, pathSid) { IsReserved = isReserved }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Proxy Number. + /// + /// The SID of the parent Service resource of the PhoneNumber resource to update + /// The unique string that identifies the resource + /// Whether the new phone number should be reserved + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new UpdatePhoneNumberOptions(pathServiceSid, pathSid) { IsReserved = isReserved }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PhoneNumberResource object + /// + /// Raw JSON string + /// PhoneNumberResource object represented by the provided JSON + public static PhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the PhoneNumber resource's parent Service resource + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO Country Code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The capabilities of the phone number + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The absolute URL of the PhoneNumber resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Reserve the phone number for manual assignment to participants only + /// + [JsonProperty("is_reserved")] + public bool? IsReserved { get; private set; } + /// + /// The number of open session assigned to the number. + /// + [JsonProperty("in_use")] + public int? InUse { get; private set; } + + private PhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionOptions.cs index f413b035e..96ae56cee 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionOptions.cs @@ -9,134 +9,134 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service.Session -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// + public class FetchInteractionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// The SID of the parent Service of the resource to fetch /// - public class FetchInteractionOptions : IOptions - { - /// - /// The SID of the parent Service of the resource to fetch - /// - public string PathServiceSid { get; } - /// - /// he SID of the parent Session of the resource to fetch - /// - public string PathSessionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchInteractionOptions - /// - /// The SID of the parent Service of the resource to fetch - /// he SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - public FetchInteractionOptions(string pathServiceSid, string pathSessionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// he SID of the parent Session of the resource to fetch /// - public class ReadInteractionOptions : ReadOptions - { - /// - /// The SID of the parent Service to read the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session to read the resource from - /// - public string PathSessionSid { get; } - - /// - /// Construct a new ReadInteractionOptions - /// - /// The SID of the parent Service to read the resource from - /// The SID of the parent Session to read the resource from - public ReadInteractionOptions(string pathServiceSid, string pathSessionSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSessionSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Interaction. + /// The unique string that identifies the resource /// - public class DeleteInteractionOptions : IOptions - { - /// - /// The SID of the parent Service of the resource to delete - /// - public string PathServiceSid { get; } - /// - /// he SID of the parent Session of the resource to delete - /// - public string PathSessionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteInteractionOptions - /// - /// The SID of the parent Service of the resource to delete - /// he SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - public DeleteInteractionOptions(string pathServiceSid, string pathSessionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchInteractionOptions + /// + /// The SID of the parent Service of the resource to fetch + /// he SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + public FetchInteractionOptions(string pathServiceSid, string pathSessionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// + public class ReadInteractionOptions : ReadOptions + { + /// + /// The SID of the parent Service to read the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session to read the resource from + /// + public string PathSessionSid { get; } + + /// + /// Construct a new ReadInteractionOptions + /// + /// The SID of the parent Service to read the resource from + /// The SID of the parent Session to read the resource from + public ReadInteractionOptions(string pathServiceSid, string pathSessionSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Interaction. + /// + public class DeleteInteractionOptions : IOptions + { + /// + /// The SID of the parent Service of the resource to delete + /// + public string PathServiceSid { get; } + /// + /// he SID of the parent Session of the resource to delete + /// + public string PathSessionSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteInteractionOptions + /// + /// The SID of the parent Service of the resource to delete + /// he SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + public DeleteInteractionOptions(string pathServiceSid, string pathSessionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionResource.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionResource.cs index 79edd8a15..11227db87 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/InteractionResource.cs @@ -19,466 +19,466 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1.Service.Session -{ - - public class InteractionResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Message = new TypeEnum("message"); - public static readonly TypeEnum Voice = new TypeEnum("voice"); - public static readonly TypeEnum Unknown = new TypeEnum("unknown"); - } - - public sealed class ResourceStatusEnum : StringEnum - { - private ResourceStatusEnum(string value) : base(value) {} - public ResourceStatusEnum() {} - public static implicit operator ResourceStatusEnum(string value) - { - return new ResourceStatusEnum(value); - } - - public static readonly ResourceStatusEnum Accepted = new ResourceStatusEnum("accepted"); - public static readonly ResourceStatusEnum Answered = new ResourceStatusEnum("answered"); - public static readonly ResourceStatusEnum Busy = new ResourceStatusEnum("busy"); - public static readonly ResourceStatusEnum Canceled = new ResourceStatusEnum("canceled"); - public static readonly ResourceStatusEnum Completed = new ResourceStatusEnum("completed"); - public static readonly ResourceStatusEnum Deleted = new ResourceStatusEnum("deleted"); - public static readonly ResourceStatusEnum Delivered = new ResourceStatusEnum("delivered"); - public static readonly ResourceStatusEnum DeliveryUnknown = new ResourceStatusEnum("delivery-unknown"); - public static readonly ResourceStatusEnum Failed = new ResourceStatusEnum("failed"); - public static readonly ResourceStatusEnum InProgress = new ResourceStatusEnum("in-progress"); - public static readonly ResourceStatusEnum Initiated = new ResourceStatusEnum("initiated"); - public static readonly ResourceStatusEnum NoAnswer = new ResourceStatusEnum("no-answer"); - public static readonly ResourceStatusEnum Queued = new ResourceStatusEnum("queued"); - public static readonly ResourceStatusEnum Received = new ResourceStatusEnum("received"); - public static readonly ResourceStatusEnum Receiving = new ResourceStatusEnum("receiving"); - public static readonly ResourceStatusEnum Ringing = new ResourceStatusEnum("ringing"); - public static readonly ResourceStatusEnum Scheduled = new ResourceStatusEnum("scheduled"); - public static readonly ResourceStatusEnum Sending = new ResourceStatusEnum("sending"); - public static readonly ResourceStatusEnum Sent = new ResourceStatusEnum("sent"); - public static readonly ResourceStatusEnum Undelivered = new ResourceStatusEnum("undelivered"); - public static readonly ResourceStatusEnum Unknown = new ResourceStatusEnum("unknown"); - } - - private static Request BuildFetchRequest(FetchInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). - /// - /// Fetch Interaction parameters - /// Client to make requests to Twilio - /// A single instance of Interaction - public static InteractionResource Fetch(FetchInteractionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). - /// - /// Fetch Interaction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task FetchAsync(FetchInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). - /// - /// The SID of the parent Service of the resource to fetch - /// he SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Interaction - public static InteractionResource Fetch(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInteractionOptions(pathServiceSid, pathSessionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). - /// - /// The SID of the parent Service of the resource to fetch - /// he SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchInteractionOptions(pathServiceSid, pathSessionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. - /// - /// Read Interaction parameters - /// Client to make requests to Twilio - /// A single instance of Interaction - public static ResourceSet Read(ReadInteractionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("interactions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. - /// - /// Read Interaction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task> ReadAsync(ReadInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("interactions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. - /// - /// The SID of the parent Service to read the resource from - /// The SID of the parent Session to read the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Interaction - public static ResourceSet Read(string pathServiceSid, - string pathSessionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInteractionOptions(pathServiceSid, pathSessionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. - /// - /// The SID of the parent Service to read the resource from - /// The SID of the parent Session to read the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathSessionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadInteractionOptions(pathServiceSid, pathSessionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - private static Request BuildDeleteRequest(DeleteInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Interaction. - /// - /// Delete Interaction parameters - /// Client to make requests to Twilio - /// A single instance of Interaction - public static bool Delete(DeleteInteractionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Interaction. - /// - /// Delete Interaction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task DeleteAsync(DeleteInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Interaction. - /// - /// The SID of the parent Service of the resource to delete - /// he SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Interaction - public static bool Delete(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInteractionOptions(pathServiceSid, pathSessionSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Interaction. - /// - /// The SID of the parent Service of the resource to delete - /// he SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Interaction - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteInteractionOptions(pathServiceSid, pathSessionSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a InteractionResource object - /// - /// Raw JSON string - /// InteractionResource object represented by the provided JSON - public static InteractionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the resource's parent Session - /// - [JsonProperty("session_sid")] - public string SessionSid { get; private set; } - /// - /// The SID of the resource's parent Service - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A JSON string that includes the message body of message interactions - /// - [JsonProperty("data")] - public string Data { get; private set; } - /// - /// The Type of the Interaction - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public InteractionResource.TypeEnum Type { get; private set; } - /// - /// The SID of the inbound Participant resource - /// - [JsonProperty("inbound_participant_sid")] - public string InboundParticipantSid { get; private set; } - /// - /// The SID of the inbound resource - /// - [JsonProperty("inbound_resource_sid")] - public string InboundResourceSid { get; private set; } - /// - /// The inbound resource status of the Interaction - /// - [JsonProperty("inbound_resource_status")] - [JsonConverter(typeof(StringEnumConverter))] - public InteractionResource.ResourceStatusEnum InboundResourceStatus { get; private set; } - /// - /// The inbound resource type - /// - [JsonProperty("inbound_resource_type")] - public string InboundResourceType { get; private set; } - /// - /// The URL of the Twilio inbound resource - /// - [JsonProperty("inbound_resource_url")] - public Uri InboundResourceUrl { get; private set; } - /// - /// The SID of the outbound Participant - /// - [JsonProperty("outbound_participant_sid")] - public string OutboundParticipantSid { get; private set; } - /// - /// The SID of the outbound resource - /// - [JsonProperty("outbound_resource_sid")] - public string OutboundResourceSid { get; private set; } - /// - /// The outbound resource status of the Interaction - /// - [JsonProperty("outbound_resource_status")] - [JsonConverter(typeof(StringEnumConverter))] - public InteractionResource.ResourceStatusEnum OutboundResourceStatus { get; private set; } - /// - /// The outbound resource type - /// - [JsonProperty("outbound_resource_type")] - public string OutboundResourceType { get; private set; } - /// - /// The URL of the Twilio outbound resource - /// - [JsonProperty("outbound_resource_url")] - public Uri OutboundResourceUrl { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Interaction was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Interaction resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private InteractionResource() - { - - } - } +{ + + public class InteractionResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Message = new TypeEnum("message"); + public static readonly TypeEnum Voice = new TypeEnum("voice"); + public static readonly TypeEnum Unknown = new TypeEnum("unknown"); + } + + public sealed class ResourceStatusEnum : StringEnum + { + private ResourceStatusEnum(string value) : base(value) { } + public ResourceStatusEnum() { } + public static implicit operator ResourceStatusEnum(string value) + { + return new ResourceStatusEnum(value); + } + + public static readonly ResourceStatusEnum Accepted = new ResourceStatusEnum("accepted"); + public static readonly ResourceStatusEnum Answered = new ResourceStatusEnum("answered"); + public static readonly ResourceStatusEnum Busy = new ResourceStatusEnum("busy"); + public static readonly ResourceStatusEnum Canceled = new ResourceStatusEnum("canceled"); + public static readonly ResourceStatusEnum Completed = new ResourceStatusEnum("completed"); + public static readonly ResourceStatusEnum Deleted = new ResourceStatusEnum("deleted"); + public static readonly ResourceStatusEnum Delivered = new ResourceStatusEnum("delivered"); + public static readonly ResourceStatusEnum DeliveryUnknown = new ResourceStatusEnum("delivery-unknown"); + public static readonly ResourceStatusEnum Failed = new ResourceStatusEnum("failed"); + public static readonly ResourceStatusEnum InProgress = new ResourceStatusEnum("in-progress"); + public static readonly ResourceStatusEnum Initiated = new ResourceStatusEnum("initiated"); + public static readonly ResourceStatusEnum NoAnswer = new ResourceStatusEnum("no-answer"); + public static readonly ResourceStatusEnum Queued = new ResourceStatusEnum("queued"); + public static readonly ResourceStatusEnum Received = new ResourceStatusEnum("received"); + public static readonly ResourceStatusEnum Receiving = new ResourceStatusEnum("receiving"); + public static readonly ResourceStatusEnum Ringing = new ResourceStatusEnum("ringing"); + public static readonly ResourceStatusEnum Scheduled = new ResourceStatusEnum("scheduled"); + public static readonly ResourceStatusEnum Sending = new ResourceStatusEnum("sending"); + public static readonly ResourceStatusEnum Sent = new ResourceStatusEnum("sent"); + public static readonly ResourceStatusEnum Undelivered = new ResourceStatusEnum("undelivered"); + public static readonly ResourceStatusEnum Unknown = new ResourceStatusEnum("unknown"); + } + + private static Request BuildFetchRequest(FetchInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// + /// Fetch Interaction parameters + /// Client to make requests to Twilio + /// A single instance of Interaction + public static InteractionResource Fetch(FetchInteractionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// + /// Fetch Interaction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task FetchAsync(FetchInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// + /// The SID of the parent Service of the resource to fetch + /// he SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Interaction + public static InteractionResource Fetch(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInteractionOptions(pathServiceSid, pathSessionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Interactions for a given [Session](https://www.twilio.com/docs/proxy/api/session). + /// + /// The SID of the parent Service of the resource to fetch + /// he SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchInteractionOptions(pathServiceSid, pathSessionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// + /// Read Interaction parameters + /// Client to make requests to Twilio + /// A single instance of Interaction + public static ResourceSet Read(ReadInteractionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("interactions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// + /// Read Interaction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task> ReadAsync(ReadInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("interactions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// + /// The SID of the parent Service to read the resource from + /// The SID of the parent Session to read the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Interaction + public static ResourceSet Read(string pathServiceSid, + string pathSessionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInteractionOptions(pathServiceSid, pathSessionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Interactions for a Session. A maximum of 100 records will be returned per page. + /// + /// The SID of the parent Service to read the resource from + /// The SID of the parent Session to read the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathSessionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadInteractionOptions(pathServiceSid, pathSessionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + private static Request BuildDeleteRequest(DeleteInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Interactions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Interaction. + /// + /// Delete Interaction parameters + /// Client to make requests to Twilio + /// A single instance of Interaction + public static bool Delete(DeleteInteractionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Interaction. + /// + /// Delete Interaction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task DeleteAsync(DeleteInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Interaction. + /// + /// The SID of the parent Service of the resource to delete + /// he SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Interaction + public static bool Delete(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInteractionOptions(pathServiceSid, pathSessionSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Interaction. + /// + /// The SID of the parent Service of the resource to delete + /// he SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Interaction + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteInteractionOptions(pathServiceSid, pathSessionSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a InteractionResource object + /// + /// Raw JSON string + /// InteractionResource object represented by the provided JSON + public static InteractionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the resource's parent Session + /// + [JsonProperty("session_sid")] + public string SessionSid { get; private set; } + /// + /// The SID of the resource's parent Service + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A JSON string that includes the message body of message interactions + /// + [JsonProperty("data")] + public string Data { get; private set; } + /// + /// The Type of the Interaction + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public InteractionResource.TypeEnum Type { get; private set; } + /// + /// The SID of the inbound Participant resource + /// + [JsonProperty("inbound_participant_sid")] + public string InboundParticipantSid { get; private set; } + /// + /// The SID of the inbound resource + /// + [JsonProperty("inbound_resource_sid")] + public string InboundResourceSid { get; private set; } + /// + /// The inbound resource status of the Interaction + /// + [JsonProperty("inbound_resource_status")] + [JsonConverter(typeof(StringEnumConverter))] + public InteractionResource.ResourceStatusEnum InboundResourceStatus { get; private set; } + /// + /// The inbound resource type + /// + [JsonProperty("inbound_resource_type")] + public string InboundResourceType { get; private set; } + /// + /// The URL of the Twilio inbound resource + /// + [JsonProperty("inbound_resource_url")] + public Uri InboundResourceUrl { get; private set; } + /// + /// The SID of the outbound Participant + /// + [JsonProperty("outbound_participant_sid")] + public string OutboundParticipantSid { get; private set; } + /// + /// The SID of the outbound resource + /// + [JsonProperty("outbound_resource_sid")] + public string OutboundResourceSid { get; private set; } + /// + /// The outbound resource status of the Interaction + /// + [JsonProperty("outbound_resource_status")] + [JsonConverter(typeof(StringEnumConverter))] + public InteractionResource.ResourceStatusEnum OutboundResourceStatus { get; private set; } + /// + /// The outbound resource type + /// + [JsonProperty("outbound_resource_type")] + public string OutboundResourceType { get; private set; } + /// + /// The URL of the Twilio outbound resource + /// + [JsonProperty("outbound_resource_url")] + public Uri OutboundResourceUrl { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Interaction was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Interaction resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private InteractionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionOptions.cs index 270e32b42..00df3fada 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionOptions.cs @@ -10,170 +10,170 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service.Session.Participant -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new message Interaction to send directly from your system to one + /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will + /// always be empty. + /// + public class CreateMessageInteractionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new message Interaction to send directly from your system to one - /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will - /// always be empty. - /// - public class CreateMessageInteractionOptions : IOptions - { - /// - /// The SID of the parent Service resource - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session resource - /// - public string PathSessionSid { get; } - /// - /// The SID of the Participant resource - /// - public string PathParticipantSid { get; } - /// - /// Message body - /// - public string Body { get; set; } - /// - /// Reserved - /// - public List MediaUrl { get; set; } - - /// - /// Construct a new CreateMessageInteractionOptions - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The SID of the Participant resource - public CreateMessageInteractionOptions(string pathServiceSid, string pathSessionSid, string pathParticipantSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathParticipantSid = pathParticipantSid; - MediaUrl = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Body != null) - { - p.Add(new KeyValuePair("Body", Body)); - } - - if (MediaUrl != null) - { - p.AddRange(MediaUrl.Select(prop => new KeyValuePair("MediaUrl", Serializers.Url(prop)))); - } - - return p; - } - } - + /// The SID of the parent Service resource + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// FetchMessageInteractionOptions - /// - public class FetchMessageInteractionOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session - /// - public string PathSessionSid { get; } - /// - /// The SID of the Participant resource - /// - public string PathParticipantSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchMessageInteractionOptions - /// - /// The SID of the Service to fetch the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - /// The unique string that identifies the resource - public FetchMessageInteractionOptions(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - string pathSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathParticipantSid = pathParticipantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the parent Session resource + /// + public string PathSessionSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// ReadMessageInteractionOptions - /// - public class ReadMessageInteractionOptions : ReadOptions - { - /// - /// The SID of the Service to read the resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session - /// - public string PathSessionSid { get; } - /// - /// The SID of the Participant resource - /// - public string PathParticipantSid { get; } - - /// - /// Construct a new ReadMessageInteractionOptions - /// - /// The SID of the Service to read the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - public ReadMessageInteractionOptions(string pathServiceSid, string pathSessionSid, string pathParticipantSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Participant resource + /// + public string PathParticipantSid { get; } + /// + /// Message body + /// + public string Body { get; set; } + /// + /// Reserved + /// + public List MediaUrl { get; set; } + + /// + /// Construct a new CreateMessageInteractionOptions + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The SID of the Participant resource + public CreateMessageInteractionOptions(string pathServiceSid, string pathSessionSid, string pathParticipantSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathParticipantSid = pathParticipantSid; + MediaUrl = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Body != null) + { + p.Add(new KeyValuePair("Body", Body)); + } + + if (MediaUrl != null) + { + p.AddRange(MediaUrl.Select(prop => new KeyValuePair("MediaUrl", Serializers.Url(prop)))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// FetchMessageInteractionOptions + /// + public class FetchMessageInteractionOptions : IOptions + { + /// + /// The SID of the Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session + /// + public string PathSessionSid { get; } + /// + /// The SID of the Participant resource + /// + public string PathParticipantSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchMessageInteractionOptions + /// + /// The SID of the Service to fetch the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + /// The unique string that identifies the resource + public FetchMessageInteractionOptions(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + string pathSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathParticipantSid = pathParticipantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// ReadMessageInteractionOptions + /// + public class ReadMessageInteractionOptions : ReadOptions + { + /// + /// The SID of the Service to read the resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session + /// + public string PathSessionSid { get; } + /// + /// The SID of the Participant resource + /// + public string PathParticipantSid { get; } + + /// + /// Construct a new ReadMessageInteractionOptions + /// + /// The SID of the Service to read the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + public ReadMessageInteractionOptions(string pathServiceSid, string pathSessionSid, string pathParticipantSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionResource.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionResource.cs index 478bf6f74..17916b0f1 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/Participant/MessageInteractionResource.cs @@ -19,500 +19,500 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1.Service.Session.Participant -{ - - public class MessageInteractionResource : Resource - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Message = new TypeEnum("message"); - public static readonly TypeEnum Voice = new TypeEnum("voice"); - public static readonly TypeEnum Unknown = new TypeEnum("unknown"); - } - - public sealed class ResourceStatusEnum : StringEnum - { - private ResourceStatusEnum(string value) : base(value) {} - public ResourceStatusEnum() {} - public static implicit operator ResourceStatusEnum(string value) - { - return new ResourceStatusEnum(value); - } - - public static readonly ResourceStatusEnum Accepted = new ResourceStatusEnum("accepted"); - public static readonly ResourceStatusEnum Answered = new ResourceStatusEnum("answered"); - public static readonly ResourceStatusEnum Busy = new ResourceStatusEnum("busy"); - public static readonly ResourceStatusEnum Canceled = new ResourceStatusEnum("canceled"); - public static readonly ResourceStatusEnum Completed = new ResourceStatusEnum("completed"); - public static readonly ResourceStatusEnum Deleted = new ResourceStatusEnum("deleted"); - public static readonly ResourceStatusEnum Delivered = new ResourceStatusEnum("delivered"); - public static readonly ResourceStatusEnum DeliveryUnknown = new ResourceStatusEnum("delivery-unknown"); - public static readonly ResourceStatusEnum Failed = new ResourceStatusEnum("failed"); - public static readonly ResourceStatusEnum InProgress = new ResourceStatusEnum("in-progress"); - public static readonly ResourceStatusEnum Initiated = new ResourceStatusEnum("initiated"); - public static readonly ResourceStatusEnum NoAnswer = new ResourceStatusEnum("no-answer"); - public static readonly ResourceStatusEnum Queued = new ResourceStatusEnum("queued"); - public static readonly ResourceStatusEnum Received = new ResourceStatusEnum("received"); - public static readonly ResourceStatusEnum Receiving = new ResourceStatusEnum("receiving"); - public static readonly ResourceStatusEnum Ringing = new ResourceStatusEnum("ringing"); - public static readonly ResourceStatusEnum Scheduled = new ResourceStatusEnum("scheduled"); - public static readonly ResourceStatusEnum Sending = new ResourceStatusEnum("sending"); - public static readonly ResourceStatusEnum Sent = new ResourceStatusEnum("sent"); - public static readonly ResourceStatusEnum Undelivered = new ResourceStatusEnum("undelivered"); - public static readonly ResourceStatusEnum Unknown = new ResourceStatusEnum("unknown"); - } - - private static Request BuildCreateRequest(CreateMessageInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new message Interaction to send directly from your system to one - /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will - /// always be empty. - /// - /// Create MessageInteraction parameters - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static MessageInteractionResource Create(CreateMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new message Interaction to send directly from your system to one - /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will - /// always be empty. - /// - /// Create MessageInteraction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task CreateAsync(CreateMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new message Interaction to send directly from your system to one - /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will - /// always be empty. - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The SID of the Participant resource - /// Message body - /// Reserved - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static MessageInteractionResource Create(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - string body = null, - List mediaUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid){Body = body, MediaUrl = mediaUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new message Interaction to send directly from your system to one - /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will - /// always be empty. - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The SID of the Participant resource - /// Message body - /// Reserved - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - string body = null, - List mediaUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid){Body = body, MediaUrl = mediaUrl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMessageInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch MessageInteraction parameters - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static MessageInteractionResource Fetch(FetchMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch MessageInteraction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task FetchAsync(FetchMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static MessageInteractionResource Fetch(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service to fetch the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessageInteractionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read MessageInteraction parameters - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static ResourceSet Read(ReadMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("interactions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read MessageInteraction parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageInteractionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("interactions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Service to read the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of MessageInteraction - public static ResourceSet Read(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Service to read the resource from - /// The SID of the parent Session - /// The SID of the Participant resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessageInteraction - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathSessionSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("interactions", response.Content); - } - - /// - /// Converts a JSON string into a MessageInteractionResource object - /// - /// Raw JSON string - /// MessageInteractionResource object represented by the provided JSON - public static MessageInteractionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the resource's parent Session - /// - [JsonProperty("session_sid")] - public string SessionSid { get; private set; } - /// - /// The SID of the resource's parent Service - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A JSON string that includes the message body sent to the participant - /// - [JsonProperty("data")] - public string Data { get; private set; } - /// - /// The Type of Message Interaction - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public MessageInteractionResource.TypeEnum Type { get; private set; } - /// - /// The SID of the Participant resource - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// Always empty for Message Interactions - /// - [JsonProperty("inbound_participant_sid")] - public string InboundParticipantSid { get; private set; } - /// - /// Always empty for Message Interactions - /// - [JsonProperty("inbound_resource_sid")] - public string InboundResourceSid { get; private set; } - /// - /// Always empty for Message Interactions - /// - [JsonProperty("inbound_resource_status")] - [JsonConverter(typeof(StringEnumConverter))] - public MessageInteractionResource.ResourceStatusEnum InboundResourceStatus { get; private set; } - /// - /// Always empty for Message Interactions - /// - [JsonProperty("inbound_resource_type")] - public string InboundResourceType { get; private set; } - /// - /// Always empty for Message Interactions - /// - [JsonProperty("inbound_resource_url")] - public Uri InboundResourceUrl { get; private set; } - /// - /// The SID of the outbound Participant resource - /// - [JsonProperty("outbound_participant_sid")] - public string OutboundParticipantSid { get; private set; } - /// - /// The SID of the outbound Message resource - /// - [JsonProperty("outbound_resource_sid")] - public string OutboundResourceSid { get; private set; } - /// - /// The outbound resource status - /// - [JsonProperty("outbound_resource_status")] - [JsonConverter(typeof(StringEnumConverter))] - public MessageInteractionResource.ResourceStatusEnum OutboundResourceStatus { get; private set; } - /// - /// The outbound resource type - /// - [JsonProperty("outbound_resource_type")] - public string OutboundResourceType { get; private set; } - /// - /// The URL of the Twilio message resource - /// - [JsonProperty("outbound_resource_url")] - public Uri OutboundResourceUrl { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the MessageInteraction resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessageInteractionResource() - { - - } - } +{ + + public class MessageInteractionResource : Resource + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Message = new TypeEnum("message"); + public static readonly TypeEnum Voice = new TypeEnum("voice"); + public static readonly TypeEnum Unknown = new TypeEnum("unknown"); + } + + public sealed class ResourceStatusEnum : StringEnum + { + private ResourceStatusEnum(string value) : base(value) { } + public ResourceStatusEnum() { } + public static implicit operator ResourceStatusEnum(string value) + { + return new ResourceStatusEnum(value); + } + + public static readonly ResourceStatusEnum Accepted = new ResourceStatusEnum("accepted"); + public static readonly ResourceStatusEnum Answered = new ResourceStatusEnum("answered"); + public static readonly ResourceStatusEnum Busy = new ResourceStatusEnum("busy"); + public static readonly ResourceStatusEnum Canceled = new ResourceStatusEnum("canceled"); + public static readonly ResourceStatusEnum Completed = new ResourceStatusEnum("completed"); + public static readonly ResourceStatusEnum Deleted = new ResourceStatusEnum("deleted"); + public static readonly ResourceStatusEnum Delivered = new ResourceStatusEnum("delivered"); + public static readonly ResourceStatusEnum DeliveryUnknown = new ResourceStatusEnum("delivery-unknown"); + public static readonly ResourceStatusEnum Failed = new ResourceStatusEnum("failed"); + public static readonly ResourceStatusEnum InProgress = new ResourceStatusEnum("in-progress"); + public static readonly ResourceStatusEnum Initiated = new ResourceStatusEnum("initiated"); + public static readonly ResourceStatusEnum NoAnswer = new ResourceStatusEnum("no-answer"); + public static readonly ResourceStatusEnum Queued = new ResourceStatusEnum("queued"); + public static readonly ResourceStatusEnum Received = new ResourceStatusEnum("received"); + public static readonly ResourceStatusEnum Receiving = new ResourceStatusEnum("receiving"); + public static readonly ResourceStatusEnum Ringing = new ResourceStatusEnum("ringing"); + public static readonly ResourceStatusEnum Scheduled = new ResourceStatusEnum("scheduled"); + public static readonly ResourceStatusEnum Sending = new ResourceStatusEnum("sending"); + public static readonly ResourceStatusEnum Sent = new ResourceStatusEnum("sent"); + public static readonly ResourceStatusEnum Undelivered = new ResourceStatusEnum("undelivered"); + public static readonly ResourceStatusEnum Unknown = new ResourceStatusEnum("unknown"); + } + + private static Request BuildCreateRequest(CreateMessageInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new message Interaction to send directly from your system to one + /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will + /// always be empty. + /// + /// Create MessageInteraction parameters + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static MessageInteractionResource Create(CreateMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new message Interaction to send directly from your system to one + /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will + /// always be empty. + /// + /// Create MessageInteraction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task CreateAsync(CreateMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new message Interaction to send directly from your system to one + /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will + /// always be empty. + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The SID of the Participant resource + /// Message body + /// Reserved + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static MessageInteractionResource Create(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + string body = null, + List mediaUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid) { Body = body, MediaUrl = mediaUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new message Interaction to send directly from your system to one + /// [Participant](https://www.twilio.com/docs/proxy/api/participant). The `inbound` properties for the Interaction will + /// always be empty. + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The SID of the Participant resource + /// Message body + /// Reserved + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + string body = null, + List mediaUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid) { Body = body, MediaUrl = mediaUrl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMessageInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch MessageInteraction parameters + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static MessageInteractionResource Fetch(FetchMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch MessageInteraction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task FetchAsync(FetchMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static MessageInteractionResource Fetch(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service to fetch the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessageInteractionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathParticipantSid + "/MessageInteractions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read MessageInteraction parameters + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static ResourceSet Read(ReadMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("interactions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read MessageInteraction parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessageInteractionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("interactions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Service to read the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of MessageInteraction + public static ResourceSet Read(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Service to read the resource from + /// The SID of the parent Session + /// The SID of the Participant resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessageInteraction + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathSessionSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessageInteractionOptions(pathServiceSid, pathSessionSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("interactions", response.Content); + } + + /// + /// Converts a JSON string into a MessageInteractionResource object + /// + /// Raw JSON string + /// MessageInteractionResource object represented by the provided JSON + public static MessageInteractionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the resource's parent Session + /// + [JsonProperty("session_sid")] + public string SessionSid { get; private set; } + /// + /// The SID of the resource's parent Service + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A JSON string that includes the message body sent to the participant + /// + [JsonProperty("data")] + public string Data { get; private set; } + /// + /// The Type of Message Interaction + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public MessageInteractionResource.TypeEnum Type { get; private set; } + /// + /// The SID of the Participant resource + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// Always empty for Message Interactions + /// + [JsonProperty("inbound_participant_sid")] + public string InboundParticipantSid { get; private set; } + /// + /// Always empty for Message Interactions + /// + [JsonProperty("inbound_resource_sid")] + public string InboundResourceSid { get; private set; } + /// + /// Always empty for Message Interactions + /// + [JsonProperty("inbound_resource_status")] + [JsonConverter(typeof(StringEnumConverter))] + public MessageInteractionResource.ResourceStatusEnum InboundResourceStatus { get; private set; } + /// + /// Always empty for Message Interactions + /// + [JsonProperty("inbound_resource_type")] + public string InboundResourceType { get; private set; } + /// + /// Always empty for Message Interactions + /// + [JsonProperty("inbound_resource_url")] + public Uri InboundResourceUrl { get; private set; } + /// + /// The SID of the outbound Participant resource + /// + [JsonProperty("outbound_participant_sid")] + public string OutboundParticipantSid { get; private set; } + /// + /// The SID of the outbound Message resource + /// + [JsonProperty("outbound_resource_sid")] + public string OutboundResourceSid { get; private set; } + /// + /// The outbound resource status + /// + [JsonProperty("outbound_resource_status")] + [JsonConverter(typeof(StringEnumConverter))] + public MessageInteractionResource.ResourceStatusEnum OutboundResourceStatus { get; private set; } + /// + /// The outbound resource type + /// + [JsonProperty("outbound_resource_type")] + public string OutboundResourceType { get; private set; } + /// + /// The URL of the Twilio message resource + /// + [JsonProperty("outbound_resource_url")] + public Uri OutboundResourceUrl { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the MessageInteraction resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessageInteractionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantOptions.cs index 4f7b6aebf..ae8226cca 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantOptions.cs @@ -9,220 +9,220 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service.Session -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Participant. + /// + public class FetchParticipantOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Participant. - /// - public class FetchParticipantOptions : IOptions - { - /// - /// The SID of the parent Service of the resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session of the resource to fetch - /// - public string PathSessionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The SID of the parent Service of the resource to fetch - /// The SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - public FetchParticipantOptions(string pathServiceSid, string pathSessionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the parent Service of the resource to fetch + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Participants in a Session. - /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The SID of the parent Service of the resource to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session of the resource to read - /// - public string PathSessionSid { get; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The SID of the parent Service of the resource to read - /// The SID of the parent Session of the resource to read - public ReadParticipantOptions(string pathServiceSid, string pathSessionSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the parent Session of the resource to fetch + /// + public string PathSessionSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Add a new Participant to the Session - /// - public class CreateParticipantOptions : IOptions - { - /// - /// The SID of the parent Service resource - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session resource - /// - public string PathSessionSid { get; } - /// - /// The phone number of the Participant - /// - public string Identifier { get; } - /// - /// The string that you assigned to describe the participant - /// - public string FriendlyName { get; set; } - /// - /// The proxy phone number to use for the Participant - /// - public string ProxyIdentifier { get; set; } - /// - /// The Proxy Identifier Sid - /// - public string ProxyIdentifierSid { get; set; } - /// - /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. - /// - public bool? FailOnParticipantConflict { get; set; } - - /// - /// Construct a new CreateParticipantOptions - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The phone number of the Participant - public CreateParticipantOptions(string pathServiceSid, string pathSessionSid, string identifier) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - Identifier = identifier; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identifier != null) - { - p.Add(new KeyValuePair("Identifier", Identifier)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ProxyIdentifier != null) - { - p.Add(new KeyValuePair("ProxyIdentifier", ProxyIdentifier)); - } - - if (ProxyIdentifierSid != null) - { - p.Add(new KeyValuePair("ProxyIdentifierSid", ProxyIdentifierSid.ToString())); - } - - if (FailOnParticipantConflict != null) - { - p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot - /// be re-added. Participants are only permanently deleted when the - /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. - /// - public class DeleteParticipantOptions : IOptions - { - /// - /// The SID of the parent Service of the resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the parent Session of the resource to delete - /// - public string PathSessionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteParticipantOptions - /// - /// The SID of the parent Service of the resource to delete - /// The SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - public DeleteParticipantOptions(string pathServiceSid, string pathSessionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSessionSid = pathSessionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new FetchParticipantOptions + /// + /// The SID of the parent Service of the resource to fetch + /// The SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + public FetchParticipantOptions(string pathServiceSid, string pathSessionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Participants in a Session. + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The SID of the parent Service of the resource to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session of the resource to read + /// + public string PathSessionSid { get; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The SID of the parent Service of the resource to read + /// The SID of the parent Session of the resource to read + public ReadParticipantOptions(string pathServiceSid, string pathSessionSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Add a new Participant to the Session + /// + public class CreateParticipantOptions : IOptions + { + /// + /// The SID of the parent Service resource + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session resource + /// + public string PathSessionSid { get; } + /// + /// The phone number of the Participant + /// + public string Identifier { get; } + /// + /// The string that you assigned to describe the participant + /// + public string FriendlyName { get; set; } + /// + /// The proxy phone number to use for the Participant + /// + public string ProxyIdentifier { get; set; } + /// + /// The Proxy Identifier Sid + /// + public string ProxyIdentifierSid { get; set; } + /// + /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. + /// + public bool? FailOnParticipantConflict { get; set; } + + /// + /// Construct a new CreateParticipantOptions + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The phone number of the Participant + public CreateParticipantOptions(string pathServiceSid, string pathSessionSid, string identifier) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + Identifier = identifier; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identifier != null) + { + p.Add(new KeyValuePair("Identifier", Identifier)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ProxyIdentifier != null) + { + p.Add(new KeyValuePair("ProxyIdentifier", ProxyIdentifier)); + } + + if (ProxyIdentifierSid != null) + { + p.Add(new KeyValuePair("ProxyIdentifierSid", ProxyIdentifierSid.ToString())); + } + + if (FailOnParticipantConflict != null) + { + p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot + /// be re-added. Participants are only permanently deleted when the + /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. + /// + public class DeleteParticipantOptions : IOptions + { + /// + /// The SID of the parent Service of the resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the parent Session of the resource to delete + /// + public string PathSessionSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteParticipantOptions + /// + /// The SID of the parent Service of the resource to delete + /// The SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + public DeleteParticipantOptions(string pathServiceSid, string pathSessionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSessionSid = pathSessionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantResource.cs b/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantResource.cs index 7bfad4084..0a7af42f7 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/Session/ParticipantResource.cs @@ -18,489 +18,489 @@ using Twilio.Http; namespace Twilio.Rest.Proxy.V1.Service.Session -{ - - public class ParticipantResource : Resource - { - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Participant. - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Participant. - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Participant. - /// - /// The SID of the parent Service of the resource to fetch - /// The SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathServiceSid, pathSessionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Participant. - /// - /// The SID of the parent Service of the resource to fetch - /// The SID of the parent Session of the resource to fetch - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathServiceSid, pathSessionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Participants in a Session. - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Participants in a Session. - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Participants in a Session. - /// - /// The SID of the parent Service of the resource to read - /// The SID of the parent Session of the resource to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathServiceSid, - string pathSessionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathServiceSid, pathSessionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Participants in a Session. - /// - /// The SID of the parent Service of the resource to read - /// The SID of the parent Session of the resource to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathSessionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathServiceSid, pathSessionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Add a new Participant to the Session - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a new Participant to the Session - /// - /// Create Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a new Participant to the Session - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The phone number of the Participant - /// The string that you assigned to describe the participant - /// The proxy phone number to use for the Participant - /// The Proxy Identifier Sid - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Create(string pathServiceSid, - string pathSessionSid, - string identifier, - string friendlyName = null, - string proxyIdentifier = null, - string proxyIdentifierSid = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathServiceSid, pathSessionSid, identifier){FriendlyName = friendlyName, ProxyIdentifier = proxyIdentifier, ProxyIdentifierSid = proxyIdentifierSid, FailOnParticipantConflict = failOnParticipantConflict}; - return Create(options, client); - } - - #if !NET35 - /// - /// Add a new Participant to the Session - /// - /// The SID of the parent Service resource - /// The SID of the parent Session resource - /// The phone number of the Participant - /// The string that you assigned to describe the participant - /// The proxy phone number to use for the Participant - /// The Proxy Identifier Sid - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathSessionSid, - string identifier, - string friendlyName = null, - string proxyIdentifier = null, - string proxyIdentifierSid = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new CreateParticipantOptions(pathServiceSid, pathSessionSid, identifier){FriendlyName = friendlyName, ProxyIdentifier = proxyIdentifier, ProxyIdentifierSid = proxyIdentifierSid, FailOnParticipantConflict = failOnParticipantConflict}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot - /// be re-added. Participants are only permanently deleted when the - /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot - /// be re-added. Participants are only permanently deleted when the - /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. - /// - /// Delete Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot - /// be re-added. Participants are only permanently deleted when the - /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. - /// - /// The SID of the parent Service of the resource to delete - /// The SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Participant - public static bool Delete(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathServiceSid, pathSessionSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot - /// be re-added. Participants are only permanently deleted when the - /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. - /// - /// The SID of the parent Service of the resource to delete - /// The SID of the parent Session of the resource to delete - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSessionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteParticipantOptions(pathServiceSid, pathSessionSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the resource's parent Session - /// - [JsonProperty("session_sid")] - public string SessionSid { get; private set; } - /// - /// The SID of the resource's parent Service - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the participant - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The phone number or channel identifier of the Participant - /// - [JsonProperty("identifier")] - public string Identifier { get; private set; } - /// - /// The phone number or short code of the participant's partner - /// - [JsonProperty("proxy_identifier")] - public string ProxyIdentifier { get; private set; } - /// - /// The SID of the Proxy Identifier assigned to the Participant - /// - [JsonProperty("proxy_identifier_sid")] - public string ProxyIdentifierSid { get; private set; } - /// - /// The ISO 8601 date the Participant was removed - /// - [JsonProperty("date_deleted")] - public DateTime? DateDeleted { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Participant resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs to resources related the participant - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Participant. + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Participant. + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Participant. + /// + /// The SID of the parent Service of the resource to fetch + /// The SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathServiceSid, pathSessionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Participant. + /// + /// The SID of the parent Service of the resource to fetch + /// The SID of the parent Session of the resource to fetch + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathServiceSid, pathSessionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Participants in a Session. + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Participants in a Session. + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Participants in a Session. + /// + /// The SID of the parent Service of the resource to read + /// The SID of the parent Session of the resource to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathServiceSid, + string pathSessionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathServiceSid, pathSessionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Participants in a Session. + /// + /// The SID of the parent Service of the resource to read + /// The SID of the parent Session of the resource to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathSessionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathServiceSid, pathSessionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + private static Request BuildCreateRequest(CreateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Add a new Participant to the Session + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(CreateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a new Participant to the Session + /// + /// Create Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(CreateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a new Participant to the Session + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The phone number of the Participant + /// The string that you assigned to describe the participant + /// The proxy phone number to use for the Participant + /// The Proxy Identifier Sid + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Create(string pathServiceSid, + string pathSessionSid, + string identifier, + string friendlyName = null, + string proxyIdentifier = null, + string proxyIdentifierSid = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathServiceSid, pathSessionSid, identifier) { FriendlyName = friendlyName, ProxyIdentifier = proxyIdentifier, ProxyIdentifierSid = proxyIdentifierSid, FailOnParticipantConflict = failOnParticipantConflict }; + return Create(options, client); + } + +#if !NET35 + /// + /// Add a new Participant to the Session + /// + /// The SID of the parent Service resource + /// The SID of the parent Session resource + /// The phone number of the Participant + /// The string that you assigned to describe the participant + /// The proxy phone number to use for the Participant + /// The Proxy Identifier Sid + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathSessionSid, + string identifier, + string friendlyName = null, + string proxyIdentifier = null, + string proxyIdentifierSid = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new CreateParticipantOptions(pathServiceSid, pathSessionSid, identifier) { FriendlyName = friendlyName, ProxyIdentifier = proxyIdentifier, ProxyIdentifierSid = proxyIdentifierSid, FailOnParticipantConflict = failOnParticipantConflict }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSessionSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot + /// be re-added. Participants are only permanently deleted when the + /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(DeleteParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot + /// be re-added. Participants are only permanently deleted when the + /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. + /// + /// Delete Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(DeleteParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot + /// be re-added. Participants are only permanently deleted when the + /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. + /// + /// The SID of the parent Service of the resource to delete + /// The SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Participant + public static bool Delete(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathServiceSid, pathSessionSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Participant. This is a soft-delete. The participant remains associated with the session and cannot + /// be re-added. Participants are only permanently deleted when the + /// [Session](https://www.twilio.com/docs/proxy/api/session) is deleted. + /// + /// The SID of the parent Service of the resource to delete + /// The SID of the parent Session of the resource to delete + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSessionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteParticipantOptions(pathServiceSid, pathSessionSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the resource's parent Session + /// + [JsonProperty("session_sid")] + public string SessionSid { get; private set; } + /// + /// The SID of the resource's parent Service + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the participant + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The phone number or channel identifier of the Participant + /// + [JsonProperty("identifier")] + public string Identifier { get; private set; } + /// + /// The phone number or short code of the participant's partner + /// + [JsonProperty("proxy_identifier")] + public string ProxyIdentifier { get; private set; } + /// + /// The SID of the Proxy Identifier assigned to the Participant + /// + [JsonProperty("proxy_identifier_sid")] + public string ProxyIdentifierSid { get; private set; } + /// + /// The ISO 8601 date the Participant was removed + /// + [JsonProperty("date_deleted")] + public DateTime? DateDeleted { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Participant resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs to resources related the participant + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/SessionOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/SessionOptions.cs index ab9e0a2bb..7aca1d7ce 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/SessionOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/SessionOptions.cs @@ -10,284 +10,284 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Session. + /// + public class FetchSessionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Session. + /// The SID of the Service to fetch the resource from /// - public class FetchSessionOptions : IOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSessionOptions - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - public FetchSessionOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// The unique string that identifies the resource /// - public class ReadSessionOptions : ReadOptions - { - /// - /// The SID of the Service to fetch the resource from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSessionOptions - /// - /// The SID of the Service to fetch the resource from - public ReadSessionOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Session + /// Construct a new FetchSessionOptions /// - public class CreateSessionOptions : IOptions - { - /// - /// The SID of the parent Service resource - /// - public string PathServiceSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The ISO 8601 date when the Session should expire - /// - public DateTime? DateExpiry { get; set; } - /// - /// When the session will expire - /// - public int? Ttl { get; set; } - /// - /// The Mode of the Session - /// - public SessionResource.ModeEnum Mode { get; set; } - /// - /// Session status - /// - public SessionResource.StatusEnum Status { get; set; } - /// - /// The Participant objects to include in the new session - /// - public List Participants { get; set; } - /// - /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. - /// - public bool? FailOnParticipantConflict { get; set; } - - /// - /// Construct a new CreateSessionOptions - /// - /// The SID of the parent Service resource - public CreateSessionOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - Participants = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DateExpiry != null) - { - p.Add(new KeyValuePair("DateExpiry", Serializers.DateTimeIso8601(DateExpiry))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (Mode != null) - { - p.Add(new KeyValuePair("Mode", Mode.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Participants != null) - { - p.AddRange(Participants.Select(prop => new KeyValuePair("Participants", Serializers.JsonObject(prop)))); - } - - if (FailOnParticipantConflict != null) - { - p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); - } - - return p; - } - } - + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + public FetchSessionOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Session. + /// Generate the necessary parameters /// - public class DeleteSessionOptions : IOptions - { - /// - /// The SID of the Service to delete the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSessionOptions - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - public DeleteSessionOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// + public class ReadSessionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Session. + /// The SID of the Service to fetch the resource from /// - public class UpdateSessionOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The ISO 8601 date when the Session should expire - /// - public DateTime? DateExpiry { get; set; } - /// - /// When the session will expire - /// - public int? Ttl { get; set; } - /// - /// The new status of the resource - /// - public SessionResource.StatusEnum Status { get; set; } - /// - /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. - /// - public bool? FailOnParticipantConflict { get; set; } - - /// - /// Construct a new UpdateSessionOptions - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - public UpdateSessionOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DateExpiry != null) - { - p.Add(new KeyValuePair("DateExpiry", Serializers.DateTimeIso8601(DateExpiry))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FailOnParticipantConflict != null) - { - p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); - } - - return p; - } - } + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSessionOptions + /// + /// The SID of the Service to fetch the resource from + public ReadSessionOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Session + /// + public class CreateSessionOptions : IOptions + { + /// + /// The SID of the parent Service resource + /// + public string PathServiceSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The ISO 8601 date when the Session should expire + /// + public DateTime? DateExpiry { get; set; } + /// + /// When the session will expire + /// + public int? Ttl { get; set; } + /// + /// The Mode of the Session + /// + public SessionResource.ModeEnum Mode { get; set; } + /// + /// Session status + /// + public SessionResource.StatusEnum Status { get; set; } + /// + /// The Participant objects to include in the new session + /// + public List Participants { get; set; } + /// + /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. + /// + public bool? FailOnParticipantConflict { get; set; } + + /// + /// Construct a new CreateSessionOptions + /// + /// The SID of the parent Service resource + public CreateSessionOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + Participants = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DateExpiry != null) + { + p.Add(new KeyValuePair("DateExpiry", Serializers.DateTimeIso8601(DateExpiry))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (Mode != null) + { + p.Add(new KeyValuePair("Mode", Mode.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Participants != null) + { + p.AddRange(Participants.Select(prop => new KeyValuePair("Participants", Serializers.JsonObject(prop)))); + } + + if (FailOnParticipantConflict != null) + { + p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Session. + /// + public class DeleteSessionOptions : IOptions + { + /// + /// The SID of the Service to delete the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSessionOptions + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + public DeleteSessionOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Session. + /// + public class UpdateSessionOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The ISO 8601 date when the Session should expire + /// + public DateTime? DateExpiry { get; set; } + /// + /// When the session will expire + /// + public int? Ttl { get; set; } + /// + /// The new status of the resource + /// + public SessionResource.StatusEnum Status { get; set; } + /// + /// An experimental parameter to override the ProxyAllowParticipantConflict account flag on a per-request basis. + /// + public bool? FailOnParticipantConflict { get; set; } + + /// + /// Construct a new UpdateSessionOptions + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + public UpdateSessionOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DateExpiry != null) + { + p.Add(new KeyValuePair("DateExpiry", Serializers.DateTimeIso8601(DateExpiry))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FailOnParticipantConflict != null) + { + p.Add(new KeyValuePair("FailOnParticipantConflict", FailOnParticipantConflict.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/SessionResource.cs b/src/Twilio/Rest/Proxy/V1/Service/SessionResource.cs index d7b266b02..ec899b6c8 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/SessionResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/SessionResource.cs @@ -19,606 +19,606 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1.Service -{ - - public class SessionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Open = new StatusEnum("open"); - public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); - public static readonly StatusEnum Closed = new StatusEnum("closed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - public static readonly StatusEnum Unknown = new StatusEnum("unknown"); - } - - public sealed class ModeEnum : StringEnum - { - private ModeEnum(string value) : base(value) {} - public ModeEnum() {} - public static implicit operator ModeEnum(string value) - { - return new ModeEnum(value); - } - - public static readonly ModeEnum MessageOnly = new ModeEnum("message-only"); - public static readonly ModeEnum VoiceOnly = new ModeEnum("voice-only"); - public static readonly ModeEnum VoiceAndMessage = new ModeEnum("voice-and-message"); - } - - private static Request BuildFetchRequest(FetchSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Session. - /// - /// Fetch Session parameters - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Fetch(FetchSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Session. - /// - /// Fetch Session parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task FetchAsync(FetchSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Session. - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSessionOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Session. - /// - /// The SID of the Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSessionOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. - /// - /// Read Session parameters - /// Client to make requests to Twilio - /// A single instance of Session - public static ResourceSet Read(ReadSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sessions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. - /// - /// Read Session parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task> ReadAsync(ReadSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sessions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. - /// - /// The SID of the Service to fetch the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Session - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSessionOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. - /// - /// The SID of the Service to fetch the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSessionOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sessions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("sessions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("sessions", response.Content); - } - - private static Request BuildCreateRequest(CreateSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Session - /// - /// Create Session parameters - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Create(CreateSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Session - /// - /// Create Session parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task CreateAsync(CreateSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Session - /// - /// The SID of the parent Service resource - /// An application-defined string that uniquely identifies the resource - /// The ISO 8601 date when the Session should expire - /// When the session will expire - /// The Mode of the Session - /// Session status - /// The Participant objects to include in the new session - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Create(string pathServiceSid, - string uniqueName = null, - DateTime? dateExpiry = null, - int? ttl = null, - SessionResource.ModeEnum mode = null, - SessionResource.StatusEnum status = null, - List participants = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new CreateSessionOptions(pathServiceSid){UniqueName = uniqueName, DateExpiry = dateExpiry, Ttl = ttl, Mode = mode, Status = status, Participants = participants, FailOnParticipantConflict = failOnParticipantConflict}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Session - /// - /// The SID of the parent Service resource - /// An application-defined string that uniquely identifies the resource - /// The ISO 8601 date when the Session should expire - /// When the session will expire - /// The Mode of the Session - /// Session status - /// The Participant objects to include in the new session - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - DateTime? dateExpiry = null, - int? ttl = null, - SessionResource.ModeEnum mode = null, - SessionResource.StatusEnum status = null, - List participants = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new CreateSessionOptions(pathServiceSid){UniqueName = uniqueName, DateExpiry = dateExpiry, Ttl = ttl, Mode = mode, Status = status, Participants = participants, FailOnParticipantConflict = failOnParticipantConflict}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Session. - /// - /// Delete Session parameters - /// Client to make requests to Twilio - /// A single instance of Session - public static bool Delete(DeleteSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Session. - /// - /// Delete Session parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Session. - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Session - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSessionOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Session. - /// - /// The SID of the Service to delete the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSessionOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Session. - /// - /// Update Session parameters - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Update(UpdateSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Session. - /// - /// Update Session parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Session. - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// The ISO 8601 date when the Session should expire - /// When the session will expire - /// The new status of the resource - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// A single instance of Session - public static SessionResource Update(string pathServiceSid, - string pathSid, - DateTime? dateExpiry = null, - int? ttl = null, - SessionResource.StatusEnum status = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new UpdateSessionOptions(pathServiceSid, pathSid){DateExpiry = dateExpiry, Ttl = ttl, Status = status, FailOnParticipantConflict = failOnParticipantConflict}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Session. - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// The ISO 8601 date when the Session should expire - /// When the session will expire - /// The new status of the resource - /// An experimental parameter to override the ProxyAllowParticipantConflict - /// account flag on a per-request basis. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Session - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - DateTime? dateExpiry = null, - int? ttl = null, - SessionResource.StatusEnum status = null, - bool? failOnParticipantConflict = null, - ITwilioRestClient client = null) - { - var options = new UpdateSessionOptions(pathServiceSid, pathSid){DateExpiry = dateExpiry, Ttl = ttl, Status = status, FailOnParticipantConflict = failOnParticipantConflict}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SessionResource object - /// - /// Raw JSON string - /// SessionResource object represented by the provided JSON - public static SessionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the resource's parent Service - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date when the Session started - /// - [JsonProperty("date_started")] - public DateTime? DateStarted { get; private set; } - /// - /// The ISO 8601 date when the Session ended - /// - [JsonProperty("date_ended")] - public DateTime? DateEnded { get; private set; } - /// - /// The ISO 8601 date when the Session last had an interaction - /// - [JsonProperty("date_last_interaction")] - public DateTime? DateLastInteraction { get; private set; } - /// - /// The ISO 8601 date when the Session should expire - /// - [JsonProperty("date_expiry")] - public DateTime? DateExpiry { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The status of the Session - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SessionResource.StatusEnum Status { get; private set; } - /// - /// The reason the Session ended - /// - [JsonProperty("closed_reason")] - public string ClosedReason { get; private set; } - /// - /// When the session will expire - /// - [JsonProperty("ttl")] - public int? Ttl { get; private set; } - /// - /// The Mode of the Session - /// - [JsonProperty("mode")] - [JsonConverter(typeof(StringEnumConverter))] - public SessionResource.ModeEnum Mode { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Session resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of resources related to the Session - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private SessionResource() - { - - } - } +{ + + public class SessionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Open = new StatusEnum("open"); + public static readonly StatusEnum InProgress = new StatusEnum("in-progress"); + public static readonly StatusEnum Closed = new StatusEnum("closed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + public static readonly StatusEnum Unknown = new StatusEnum("unknown"); + } + + public sealed class ModeEnum : StringEnum + { + private ModeEnum(string value) : base(value) { } + public ModeEnum() { } + public static implicit operator ModeEnum(string value) + { + return new ModeEnum(value); + } + + public static readonly ModeEnum MessageOnly = new ModeEnum("message-only"); + public static readonly ModeEnum VoiceOnly = new ModeEnum("voice-only"); + public static readonly ModeEnum VoiceAndMessage = new ModeEnum("voice-and-message"); + } + + private static Request BuildFetchRequest(FetchSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Session. + /// + /// Fetch Session parameters + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Fetch(FetchSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Session. + /// + /// Fetch Session parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task FetchAsync(FetchSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Session. + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSessionOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Session. + /// + /// The SID of the Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSessionOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// + /// Read Session parameters + /// Client to make requests to Twilio + /// A single instance of Session + public static ResourceSet Read(ReadSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sessions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// + /// Read Session parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task> ReadAsync(ReadSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sessions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// + /// The SID of the Service to fetch the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Session + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSessionOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Sessions for the Service. A maximum of 100 records will be returned per page. + /// + /// The SID of the Service to fetch the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSessionOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sessions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("sessions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("sessions", response.Content); + } + + private static Request BuildCreateRequest(CreateSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Session + /// + /// Create Session parameters + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Create(CreateSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Session + /// + /// Create Session parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task CreateAsync(CreateSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Session + /// + /// The SID of the parent Service resource + /// An application-defined string that uniquely identifies the resource + /// The ISO 8601 date when the Session should expire + /// When the session will expire + /// The Mode of the Session + /// Session status + /// The Participant objects to include in the new session + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Create(string pathServiceSid, + string uniqueName = null, + DateTime? dateExpiry = null, + int? ttl = null, + SessionResource.ModeEnum mode = null, + SessionResource.StatusEnum status = null, + List participants = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new CreateSessionOptions(pathServiceSid) { UniqueName = uniqueName, DateExpiry = dateExpiry, Ttl = ttl, Mode = mode, Status = status, Participants = participants, FailOnParticipantConflict = failOnParticipantConflict }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Session + /// + /// The SID of the parent Service resource + /// An application-defined string that uniquely identifies the resource + /// The ISO 8601 date when the Session should expire + /// When the session will expire + /// The Mode of the Session + /// Session status + /// The Participant objects to include in the new session + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + DateTime? dateExpiry = null, + int? ttl = null, + SessionResource.ModeEnum mode = null, + SessionResource.StatusEnum status = null, + List participants = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new CreateSessionOptions(pathServiceSid) { UniqueName = uniqueName, DateExpiry = dateExpiry, Ttl = ttl, Mode = mode, Status = status, Participants = participants, FailOnParticipantConflict = failOnParticipantConflict }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Session. + /// + /// Delete Session parameters + /// Client to make requests to Twilio + /// A single instance of Session + public static bool Delete(DeleteSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Session. + /// + /// Delete Session parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Session. + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Session + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSessionOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Session. + /// + /// The SID of the Service to delete the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSessionOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/Sessions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Session. + /// + /// Update Session parameters + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Update(UpdateSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Session. + /// + /// Update Session parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Session. + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// The ISO 8601 date when the Session should expire + /// When the session will expire + /// The new status of the resource + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// A single instance of Session + public static SessionResource Update(string pathServiceSid, + string pathSid, + DateTime? dateExpiry = null, + int? ttl = null, + SessionResource.StatusEnum status = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new UpdateSessionOptions(pathServiceSid, pathSid) { DateExpiry = dateExpiry, Ttl = ttl, Status = status, FailOnParticipantConflict = failOnParticipantConflict }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Session. + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// The ISO 8601 date when the Session should expire + /// When the session will expire + /// The new status of the resource + /// An experimental parameter to override the ProxyAllowParticipantConflict + /// account flag on a per-request basis. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Session + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + DateTime? dateExpiry = null, + int? ttl = null, + SessionResource.StatusEnum status = null, + bool? failOnParticipantConflict = null, + ITwilioRestClient client = null) + { + var options = new UpdateSessionOptions(pathServiceSid, pathSid) { DateExpiry = dateExpiry, Ttl = ttl, Status = status, FailOnParticipantConflict = failOnParticipantConflict }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SessionResource object + /// + /// Raw JSON string + /// SessionResource object represented by the provided JSON + public static SessionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the resource's parent Service + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date when the Session started + /// + [JsonProperty("date_started")] + public DateTime? DateStarted { get; private set; } + /// + /// The ISO 8601 date when the Session ended + /// + [JsonProperty("date_ended")] + public DateTime? DateEnded { get; private set; } + /// + /// The ISO 8601 date when the Session last had an interaction + /// + [JsonProperty("date_last_interaction")] + public DateTime? DateLastInteraction { get; private set; } + /// + /// The ISO 8601 date when the Session should expire + /// + [JsonProperty("date_expiry")] + public DateTime? DateExpiry { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The status of the Session + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SessionResource.StatusEnum Status { get; private set; } + /// + /// The reason the Session ended + /// + [JsonProperty("closed_reason")] + public string ClosedReason { get; private set; } + /// + /// When the session will expire + /// + [JsonProperty("ttl")] + public int? Ttl { get; private set; } + /// + /// The Mode of the Session + /// + [JsonProperty("mode")] + [JsonConverter(typeof(StringEnumConverter))] + public SessionResource.ModeEnum Mode { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Session resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of resources related to the Session + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private SessionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/ShortCodeOptions.cs b/src/Twilio/Rest/Proxy/V1/Service/ShortCodeOptions.cs index 5c8129d54..51b6f2d11 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/ShortCodeOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/ShortCodeOptions.cs @@ -9,205 +9,205 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Add a Short Code to the Proxy Number Pool for the Service. + /// + public class CreateShortCodeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Add a Short Code to the Proxy Number Pool for the Service. - /// - public class CreateShortCodeOptions : IOptions - { - /// - /// The SID of the parent Service resource - /// - public string PathServiceSid { get; } - /// - /// The SID of a Twilio ShortCode resource - /// - public string Sid { get; } - - /// - /// Construct a new CreateShortCodeOptions - /// - /// The SID of the parent Service resource - /// The SID of a Twilio ShortCode resource - public CreateShortCodeOptions(string pathServiceSid, string sid) - { - PathServiceSid = pathServiceSid; - Sid = sid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Sid != null) - { - p.Add(new KeyValuePair("Sid", Sid.ToString())); - } - - return p; - } - } - + /// The SID of the parent Service resource + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Short Code from a Service. - /// - public class DeleteShortCodeOptions : IOptions - { - /// - /// The SID of the parent Service to delete the ShortCode resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteShortCodeOptions - /// - /// The SID of the parent Service to delete the ShortCode resource from - /// The unique string that identifies the resource - public DeleteShortCodeOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of a Twilio ShortCode resource + /// + public string Sid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be - /// returned per page. - /// - public class ReadShortCodeOptions : ReadOptions - { - /// - /// The SID of the parent Service to read the resource from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadShortCodeOptions - /// - /// The SID of the parent Service to read the resource from - public ReadShortCodeOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new CreateShortCodeOptions + /// + /// The SID of the parent Service resource + /// The SID of a Twilio ShortCode resource + public CreateShortCodeOptions(string pathServiceSid, string sid) + { + PathServiceSid = pathServiceSid; + Sid = sid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Short Code. - /// - public class FetchShortCodeOptions : IOptions - { - /// - /// The SID of the parent Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchShortCodeOptions - /// - /// The SID of the parent Service to fetch the resource from - /// The unique string that identifies the resource - public FetchShortCodeOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Sid != null) + { + p.Add(new KeyValuePair("Sid", Sid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Short Code from a Service. + /// + public class DeleteShortCodeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Short Code. - /// - public class UpdateShortCodeOptions : IOptions - { - /// - /// The SID of the Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// Whether the short code should be reserved for manual assignment to participants only - /// - public bool? IsReserved { get; set; } - - /// - /// Construct a new UpdateShortCodeOptions - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - public UpdateShortCodeOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IsReserved != null) - { - p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the parent Service to delete the ShortCode resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteShortCodeOptions + /// + /// The SID of the parent Service to delete the ShortCode resource from + /// The unique string that identifies the resource + public DeleteShortCodeOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be + /// returned per page. + /// + public class ReadShortCodeOptions : ReadOptions + { + /// + /// The SID of the parent Service to read the resource from + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadShortCodeOptions + /// + /// The SID of the parent Service to read the resource from + public ReadShortCodeOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Short Code. + /// + public class FetchShortCodeOptions : IOptions + { + /// + /// The SID of the parent Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchShortCodeOptions + /// + /// The SID of the parent Service to fetch the resource from + /// The unique string that identifies the resource + public FetchShortCodeOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Short Code. + /// + public class UpdateShortCodeOptions : IOptions + { + /// + /// The SID of the Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// Whether the short code should be reserved for manual assignment to participants only + /// + public bool? IsReserved { get; set; } + + /// + /// Construct a new UpdateShortCodeOptions + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + public UpdateShortCodeOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IsReserved != null) + { + p.Add(new KeyValuePair("IsReserved", IsReserved.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/Service/ShortCodeResource.cs b/src/Twilio/Rest/Proxy/V1/Service/ShortCodeResource.cs index 5f21226d0..ba190413f 100644 --- a/src/Twilio/Rest/Proxy/V1/Service/ShortCodeResource.cs +++ b/src/Twilio/Rest/Proxy/V1/Service/ShortCodeResource.cs @@ -19,508 +19,508 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1.Service -{ - - public class ShortCodeResource : Resource - { - private static Request BuildCreateRequest(CreateShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Add a Short Code to the Proxy Number Pool for the Service. - /// - /// Create ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Create(CreateShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a Short Code to the Proxy Number Pool for the Service. - /// - /// Create ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task CreateAsync(CreateShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a Short Code to the Proxy Number Pool for the Service. - /// - /// The SID of the parent Service resource - /// The SID of a Twilio ShortCode resource - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Create(string pathServiceSid, string sid, ITwilioRestClient client = null) - { - var options = new CreateShortCodeOptions(pathServiceSid, sid); - return Create(options, client); - } - - #if !NET35 - /// - /// Add a Short Code to the Proxy Number Pool for the Service. - /// - /// The SID of the parent Service resource - /// The SID of a Twilio ShortCode resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string sid, - ITwilioRestClient client = null) - { - var options = new CreateShortCodeOptions(pathServiceSid, sid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Short Code from a Service. - /// - /// Delete ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static bool Delete(DeleteShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Short Code from a Service. - /// - /// Delete ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task DeleteAsync(DeleteShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Short Code from a Service. - /// - /// The SID of the parent Service to delete the ShortCode resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Short Code from a Service. - /// - /// The SID of the parent Service to delete the ShortCode resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be - /// returned per page. - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be - /// returned per page. - /// - /// Read ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("short_codes", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be - /// returned per page. - /// - /// The SID of the parent Service to read the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be - /// returned per page. - /// - /// The SID of the parent Service to read the resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadShortCodeOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("short_codes", response.Content); - } - - private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Short Code. - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Short Code. - /// - /// Fetch ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Short Code. - /// - /// The SID of the parent Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Short Code. - /// - /// The SID of the parent Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchShortCodeOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateShortCodeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Short Code. - /// - /// Update ShortCode parameters - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Update(UpdateShortCodeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Short Code. - /// - /// Update ShortCode parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task UpdateAsync(UpdateShortCodeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Short Code. - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// Whether the short code should be reserved for manual assignment to participants only - /// - /// Client to make requests to Twilio - /// A single instance of ShortCode - public static ShortCodeResource Update(string pathServiceSid, - string pathSid, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new UpdateShortCodeOptions(pathServiceSid, pathSid){IsReserved = isReserved}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Short Code. - /// - /// The SID of the Service to update the resource from - /// The unique string that identifies the resource - /// Whether the short code should be reserved for manual assignment to participants only - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ShortCode - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - bool? isReserved = null, - ITwilioRestClient client = null) - { - var options = new UpdateShortCodeOptions(pathServiceSid, pathSid){IsReserved = isReserved}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ShortCodeResource object - /// - /// Raw JSON string - /// ShortCodeResource object represented by the provided JSON - public static ShortCodeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the resource's parent Service - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The short code's number - /// - [JsonProperty("short_code")] - public string ShortCode { get; private set; } - /// - /// The ISO Country Code - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The capabilities of the short code - /// - [JsonProperty("capabilities")] - public PhoneNumberCapabilities Capabilities { get; private set; } - /// - /// The absolute URL of the ShortCode resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Whether the short code should be reserved for manual assignment to participants only - /// - [JsonProperty("is_reserved")] - public bool? IsReserved { get; private set; } - - private ShortCodeResource() - { - - } - } +{ + + public class ShortCodeResource : Resource + { + private static Request BuildCreateRequest(CreateShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Add a Short Code to the Proxy Number Pool for the Service. + /// + /// Create ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Create(CreateShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a Short Code to the Proxy Number Pool for the Service. + /// + /// Create ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task CreateAsync(CreateShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a Short Code to the Proxy Number Pool for the Service. + /// + /// The SID of the parent Service resource + /// The SID of a Twilio ShortCode resource + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Create(string pathServiceSid, string sid, ITwilioRestClient client = null) + { + var options = new CreateShortCodeOptions(pathServiceSid, sid); + return Create(options, client); + } + +#if !NET35 + /// + /// Add a Short Code to the Proxy Number Pool for the Service. + /// + /// The SID of the parent Service resource + /// The SID of a Twilio ShortCode resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string sid, + ITwilioRestClient client = null) + { + var options = new CreateShortCodeOptions(pathServiceSid, sid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Short Code from a Service. + /// + /// Delete ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static bool Delete(DeleteShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Short Code from a Service. + /// + /// Delete ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task DeleteAsync(DeleteShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Short Code from a Service. + /// + /// The SID of the parent Service to delete the ShortCode resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Short Code from a Service. + /// + /// The SID of the parent Service to delete the ShortCode resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteShortCodeOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be + /// returned per page. + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(ReadShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be + /// returned per page. + /// + /// Read ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(ReadShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("short_codes", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be + /// returned per page. + /// + /// The SID of the parent Service to read the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Short Codes in the Proxy Number Pool for the Service. A maximum of 100 records will be + /// returned per page. + /// + /// The SID of the parent Service to read the resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadShortCodeOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("short_codes", response.Content); + } + + private static Request BuildFetchRequest(FetchShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Short Code. + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(FetchShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Short Code. + /// + /// Fetch ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(FetchShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Short Code. + /// + /// The SID of the parent Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Short Code. + /// + /// The SID of the parent Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchShortCodeOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateShortCodeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathServiceSid + "/ShortCodes/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Short Code. + /// + /// Update ShortCode parameters + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Update(UpdateShortCodeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Short Code. + /// + /// Update ShortCode parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task UpdateAsync(UpdateShortCodeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Short Code. + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// Whether the short code should be reserved for manual assignment to participants only + /// + /// Client to make requests to Twilio + /// A single instance of ShortCode + public static ShortCodeResource Update(string pathServiceSid, + string pathSid, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new UpdateShortCodeOptions(pathServiceSid, pathSid) { IsReserved = isReserved }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Short Code. + /// + /// The SID of the Service to update the resource from + /// The unique string that identifies the resource + /// Whether the short code should be reserved for manual assignment to participants only + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ShortCode + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + bool? isReserved = null, + ITwilioRestClient client = null) + { + var options = new UpdateShortCodeOptions(pathServiceSid, pathSid) { IsReserved = isReserved }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ShortCodeResource object + /// + /// Raw JSON string + /// ShortCodeResource object represented by the provided JSON + public static ShortCodeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the resource's parent Service + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The short code's number + /// + [JsonProperty("short_code")] + public string ShortCode { get; private set; } + /// + /// The ISO Country Code + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The capabilities of the short code + /// + [JsonProperty("capabilities")] + public PhoneNumberCapabilities Capabilities { get; private set; } + /// + /// The absolute URL of the ShortCode resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Whether the short code should be reserved for manual assignment to participants only + /// + [JsonProperty("is_reserved")] + public bool? IsReserved { get; private set; } + + private ShortCodeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/ServiceOptions.cs b/src/Twilio/Rest/Proxy/V1/ServiceOptions.cs index 1bbb4a8b6..52f2c4351 100644 --- a/src/Twilio/Rest/Proxy/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Proxy/V1/ServiceOptions.cs @@ -9,292 +9,292 @@ using Twilio.Converters; namespace Twilio.Rest.Proxy.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Service. + /// + public class FetchServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Service. + /// The unique string that identifies the resource /// - public class FetchServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The unique string that identifies the resource - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// Construct a new FetchServiceOptions /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Service for Twilio Proxy + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; } - /// - /// Default TTL for a Session, in seconds - /// - public int? DefaultTtl { get; set; } - /// - /// The URL we should call when the interaction status changes - /// - public Uri CallbackUrl { get; set; } - /// - /// Where a proxy number must be located relative to the participant identifier - /// - public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; set; } - /// - /// The preference for Proxy Number selection for the Service instance - /// - public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; set; } - /// - /// The URL we call on each interaction - /// - public Uri InterceptCallbackUrl { get; set; } - /// - /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session - /// - public Uri OutOfSessionCallbackUrl { get; set; } - /// - /// The SID of the Chat Service Instance - /// - public string ChatInstanceSid { get; set; } - - /// - /// Construct a new CreateServiceOptions - /// - /// An application-defined string that uniquely identifies the resource - public CreateServiceOptions(string uniqueName) - { - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DefaultTtl != null) - { - p.Add(new KeyValuePair("DefaultTtl", DefaultTtl.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (GeoMatchLevel != null) - { - p.Add(new KeyValuePair("GeoMatchLevel", GeoMatchLevel.ToString())); - } - - if (NumberSelectionBehavior != null) - { - p.Add(new KeyValuePair("NumberSelectionBehavior", NumberSelectionBehavior.ToString())); - } - - if (InterceptCallbackUrl != null) - { - p.Add(new KeyValuePair("InterceptCallbackUrl", Serializers.Url(InterceptCallbackUrl))); - } - - if (OutOfSessionCallbackUrl != null) - { - p.Add(new KeyValuePair("OutOfSessionCallbackUrl", Serializers.Url(OutOfSessionCallbackUrl))); - } - - if (ChatInstanceSid != null) - { - p.Add(new KeyValuePair("ChatInstanceSid", ChatInstanceSid.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// + public class ReadServiceOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Service. + /// Generate the necessary parameters /// - public class DeleteServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The unique string that identifies the resource - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Service for Twilio Proxy + /// + public class CreateServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Service. + /// An application-defined string that uniquely identifies the resource /// - public class UpdateServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// Default TTL for a Session, in seconds - /// - public int? DefaultTtl { get; set; } - /// - /// The URL we should call when the interaction status changes - /// - public Uri CallbackUrl { get; set; } - /// - /// Where a proxy number must be located relative to the participant identifier - /// - public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; set; } - /// - /// The preference for Proxy Number selection for the Service instance - /// - public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; set; } - /// - /// The URL we call on each interaction - /// - public Uri InterceptCallbackUrl { get; set; } - /// - /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session - /// - public Uri OutOfSessionCallbackUrl { get; set; } - /// - /// The SID of the Chat Service Instance - /// - public string ChatInstanceSid { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The unique string that identifies the resource - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DefaultTtl != null) - { - p.Add(new KeyValuePair("DefaultTtl", DefaultTtl.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (GeoMatchLevel != null) - { - p.Add(new KeyValuePair("GeoMatchLevel", GeoMatchLevel.ToString())); - } - - if (NumberSelectionBehavior != null) - { - p.Add(new KeyValuePair("NumberSelectionBehavior", NumberSelectionBehavior.ToString())); - } - - if (InterceptCallbackUrl != null) - { - p.Add(new KeyValuePair("InterceptCallbackUrl", Serializers.Url(InterceptCallbackUrl))); - } - - if (OutOfSessionCallbackUrl != null) - { - p.Add(new KeyValuePair("OutOfSessionCallbackUrl", Serializers.Url(OutOfSessionCallbackUrl))); - } - - if (ChatInstanceSid != null) - { - p.Add(new KeyValuePair("ChatInstanceSid", ChatInstanceSid.ToString())); - } - - return p; - } - } + public string UniqueName { get; } + /// + /// Default TTL for a Session, in seconds + /// + public int? DefaultTtl { get; set; } + /// + /// The URL we should call when the interaction status changes + /// + public Uri CallbackUrl { get; set; } + /// + /// Where a proxy number must be located relative to the participant identifier + /// + public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; set; } + /// + /// The preference for Proxy Number selection for the Service instance + /// + public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; set; } + /// + /// The URL we call on each interaction + /// + public Uri InterceptCallbackUrl { get; set; } + /// + /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session + /// + public Uri OutOfSessionCallbackUrl { get; set; } + /// + /// The SID of the Chat Service Instance + /// + public string ChatInstanceSid { get; set; } + + /// + /// Construct a new CreateServiceOptions + /// + /// An application-defined string that uniquely identifies the resource + public CreateServiceOptions(string uniqueName) + { + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DefaultTtl != null) + { + p.Add(new KeyValuePair("DefaultTtl", DefaultTtl.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (GeoMatchLevel != null) + { + p.Add(new KeyValuePair("GeoMatchLevel", GeoMatchLevel.ToString())); + } + + if (NumberSelectionBehavior != null) + { + p.Add(new KeyValuePair("NumberSelectionBehavior", NumberSelectionBehavior.ToString())); + } + + if (InterceptCallbackUrl != null) + { + p.Add(new KeyValuePair("InterceptCallbackUrl", Serializers.Url(InterceptCallbackUrl))); + } + + if (OutOfSessionCallbackUrl != null) + { + p.Add(new KeyValuePair("OutOfSessionCallbackUrl", Serializers.Url(OutOfSessionCallbackUrl))); + } + + if (ChatInstanceSid != null) + { + p.Add(new KeyValuePair("ChatInstanceSid", ChatInstanceSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Service. + /// + public class DeleteServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// The unique string that identifies the resource + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Service. + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// Default TTL for a Session, in seconds + /// + public int? DefaultTtl { get; set; } + /// + /// The URL we should call when the interaction status changes + /// + public Uri CallbackUrl { get; set; } + /// + /// Where a proxy number must be located relative to the participant identifier + /// + public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; set; } + /// + /// The preference for Proxy Number selection for the Service instance + /// + public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; set; } + /// + /// The URL we call on each interaction + /// + public Uri InterceptCallbackUrl { get; set; } + /// + /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session + /// + public Uri OutOfSessionCallbackUrl { get; set; } + /// + /// The SID of the Chat Service Instance + /// + public string ChatInstanceSid { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The unique string that identifies the resource + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DefaultTtl != null) + { + p.Add(new KeyValuePair("DefaultTtl", DefaultTtl.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (GeoMatchLevel != null) + { + p.Add(new KeyValuePair("GeoMatchLevel", GeoMatchLevel.ToString())); + } + + if (NumberSelectionBehavior != null) + { + p.Add(new KeyValuePair("NumberSelectionBehavior", NumberSelectionBehavior.ToString())); + } + + if (InterceptCallbackUrl != null) + { + p.Add(new KeyValuePair("InterceptCallbackUrl", Serializers.Url(InterceptCallbackUrl))); + } + + if (OutOfSessionCallbackUrl != null) + { + p.Add(new KeyValuePair("OutOfSessionCallbackUrl", Serializers.Url(OutOfSessionCallbackUrl))); + } + + if (ChatInstanceSid != null) + { + p.Add(new KeyValuePair("ChatInstanceSid", ChatInstanceSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Proxy/V1/ServiceResource.cs b/src/Twilio/Rest/Proxy/V1/ServiceResource.cs index de9b62480..bbaecb40a 100644 --- a/src/Twilio/Rest/Proxy/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Proxy/V1/ServiceResource.cs @@ -19,595 +19,595 @@ using Twilio.Types; namespace Twilio.Rest.Proxy.V1 -{ - - public class ServiceResource : Resource - { - public sealed class GeoMatchLevelEnum : StringEnum - { - private GeoMatchLevelEnum(string value) : base(value) {} - public GeoMatchLevelEnum() {} - public static implicit operator GeoMatchLevelEnum(string value) - { - return new GeoMatchLevelEnum(value); - } - - public static readonly GeoMatchLevelEnum AreaCode = new GeoMatchLevelEnum("area-code"); - public static readonly GeoMatchLevelEnum Overlay = new GeoMatchLevelEnum("overlay"); - public static readonly GeoMatchLevelEnum Radius = new GeoMatchLevelEnum("radius"); - public static readonly GeoMatchLevelEnum Country = new GeoMatchLevelEnum("country"); - } - - public sealed class NumberSelectionBehaviorEnum : StringEnum - { - private NumberSelectionBehaviorEnum(string value) : base(value) {} - public NumberSelectionBehaviorEnum() {} - public static implicit operator NumberSelectionBehaviorEnum(string value) - { - return new NumberSelectionBehaviorEnum(value); - } - - public static readonly NumberSelectionBehaviorEnum AvoidSticky = new NumberSelectionBehaviorEnum("avoid-sticky"); - public static readonly NumberSelectionBehaviorEnum PreferSticky = new NumberSelectionBehaviorEnum("prefer-sticky"); - } - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Service. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Service. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Service. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Service. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Proxy, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Proxy) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Service for Twilio Proxy - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Service for Twilio Proxy - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Service for Twilio Proxy - /// - /// An application-defined string that uniquely identifies the resource - /// Default TTL for a Session, in seconds - /// The URL we should call when the interaction status changes - /// Where a proxy number must be located relative to the participant identifier - /// The preference for Proxy Number selection for the Service instance - /// The URL we call on each interaction - /// The URL we call when an inbound call or SMS action occurs on a closed or - /// non-existent Session - /// The SID of the Chat Service Instance - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string uniqueName, - int? defaultTtl = null, - Uri callbackUrl = null, - ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, - ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, - Uri interceptCallbackUrl = null, - Uri outOfSessionCallbackUrl = null, - string chatInstanceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(uniqueName){DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Service for Twilio Proxy - /// - /// An application-defined string that uniquely identifies the resource - /// Default TTL for a Session, in seconds - /// The URL we should call when the interaction status changes - /// Where a proxy number must be located relative to the participant identifier - /// The preference for Proxy Number selection for the Service instance - /// The URL we call on each interaction - /// The URL we call when an inbound call or SMS action occurs on a closed or - /// non-existent Session - /// The SID of the Chat Service Instance - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string uniqueName, - int? defaultTtl = null, - Uri callbackUrl = null, - ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, - ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, - Uri interceptCallbackUrl = null, - Uri outOfSessionCallbackUrl = null, - string chatInstanceSid = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(uniqueName){DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Service. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Service. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Service. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Service. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Proxy, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Service. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Service. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Service. - /// - /// The unique string that identifies the resource - /// An application-defined string that uniquely identifies the resource - /// Default TTL for a Session, in seconds - /// The URL we should call when the interaction status changes - /// Where a proxy number must be located relative to the participant identifier - /// The preference for Proxy Number selection for the Service instance - /// The URL we call on each interaction - /// The URL we call when an inbound call or SMS action occurs on a closed or - /// non-existent Session - /// The SID of the Chat Service Instance - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string uniqueName = null, - int? defaultTtl = null, - Uri callbackUrl = null, - ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, - ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, - Uri interceptCallbackUrl = null, - Uri outOfSessionCallbackUrl = null, - string chatInstanceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){UniqueName = uniqueName, DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Service. - /// - /// The unique string that identifies the resource - /// An application-defined string that uniquely identifies the resource - /// Default TTL for a Session, in seconds - /// The URL we should call when the interaction status changes - /// Where a proxy number must be located relative to the participant identifier - /// The preference for Proxy Number selection for the Service instance - /// The URL we call on each interaction - /// The URL we call when an inbound call or SMS action occurs on a closed or - /// non-existent Session - /// The SID of the Chat Service Instance - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - int? defaultTtl = null, - Uri callbackUrl = null, - ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, - ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, - Uri interceptCallbackUrl = null, - Uri outOfSessionCallbackUrl = null, - string chatInstanceSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){UniqueName = uniqueName, DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Chat Service Instance - /// - [JsonProperty("chat_instance_sid")] - public string ChatInstanceSid { get; private set; } - /// - /// The URL we call when the interaction status changes - /// - [JsonProperty("callback_url")] - public Uri CallbackUrl { get; private set; } - /// - /// Default TTL for a Session, in seconds - /// - [JsonProperty("default_ttl")] - public int? DefaultTtl { get; private set; } - /// - /// The preference for Proxy Number selection for the Service instance - /// - [JsonProperty("number_selection_behavior")] - [JsonConverter(typeof(StringEnumConverter))] - public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; private set; } - /// - /// Where a proxy number must be located relative to the participant identifier - /// - [JsonProperty("geo_match_level")] - [JsonConverter(typeof(StringEnumConverter))] - public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; private set; } - /// - /// The URL we call on each interaction - /// - [JsonProperty("intercept_callback_url")] - public Uri InterceptCallbackUrl { get; private set; } - /// - /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session - /// - [JsonProperty("out_of_session_callback_url")] - public Uri OutOfSessionCallbackUrl { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of resources related to the Service - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + public sealed class GeoMatchLevelEnum : StringEnum + { + private GeoMatchLevelEnum(string value) : base(value) { } + public GeoMatchLevelEnum() { } + public static implicit operator GeoMatchLevelEnum(string value) + { + return new GeoMatchLevelEnum(value); + } + + public static readonly GeoMatchLevelEnum AreaCode = new GeoMatchLevelEnum("area-code"); + public static readonly GeoMatchLevelEnum Overlay = new GeoMatchLevelEnum("overlay"); + public static readonly GeoMatchLevelEnum Radius = new GeoMatchLevelEnum("radius"); + public static readonly GeoMatchLevelEnum Country = new GeoMatchLevelEnum("country"); + } + + public sealed class NumberSelectionBehaviorEnum : StringEnum + { + private NumberSelectionBehaviorEnum(string value) : base(value) { } + public NumberSelectionBehaviorEnum() { } + public static implicit operator NumberSelectionBehaviorEnum(string value) + { + return new NumberSelectionBehaviorEnum(value); + } + + public static readonly NumberSelectionBehaviorEnum AvoidSticky = new NumberSelectionBehaviorEnum("avoid-sticky"); + public static readonly NumberSelectionBehaviorEnum PreferSticky = new NumberSelectionBehaviorEnum("prefer-sticky"); + } + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Service. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Service. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Service. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Service. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Proxy, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Services for Twilio Proxy. A maximum of 100 records will be returned per page. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Proxy) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Service for Twilio Proxy + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Service for Twilio Proxy + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Service for Twilio Proxy + /// + /// An application-defined string that uniquely identifies the resource + /// Default TTL for a Session, in seconds + /// The URL we should call when the interaction status changes + /// Where a proxy number must be located relative to the participant identifier + /// The preference for Proxy Number selection for the Service instance + /// The URL we call on each interaction + /// The URL we call when an inbound call or SMS action occurs on a closed or + /// non-existent Session + /// The SID of the Chat Service Instance + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string uniqueName, + int? defaultTtl = null, + Uri callbackUrl = null, + ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, + ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, + Uri interceptCallbackUrl = null, + Uri outOfSessionCallbackUrl = null, + string chatInstanceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(uniqueName) { DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Service for Twilio Proxy + /// + /// An application-defined string that uniquely identifies the resource + /// Default TTL for a Session, in seconds + /// The URL we should call when the interaction status changes + /// Where a proxy number must be located relative to the participant identifier + /// The preference for Proxy Number selection for the Service instance + /// The URL we call on each interaction + /// The URL we call when an inbound call or SMS action occurs on a closed or + /// non-existent Session + /// The SID of the Chat Service Instance + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string uniqueName, + int? defaultTtl = null, + Uri callbackUrl = null, + ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, + ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, + Uri interceptCallbackUrl = null, + Uri outOfSessionCallbackUrl = null, + string chatInstanceSid = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(uniqueName) { DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Service. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Service. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Service. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Service. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Proxy, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Service. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Service. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Service. + /// + /// The unique string that identifies the resource + /// An application-defined string that uniquely identifies the resource + /// Default TTL for a Session, in seconds + /// The URL we should call when the interaction status changes + /// Where a proxy number must be located relative to the participant identifier + /// The preference for Proxy Number selection for the Service instance + /// The URL we call on each interaction + /// The URL we call when an inbound call or SMS action occurs on a closed or + /// non-existent Session + /// The SID of the Chat Service Instance + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string uniqueName = null, + int? defaultTtl = null, + Uri callbackUrl = null, + ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, + ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, + Uri interceptCallbackUrl = null, + Uri outOfSessionCallbackUrl = null, + string chatInstanceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { UniqueName = uniqueName, DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Service. + /// + /// The unique string that identifies the resource + /// An application-defined string that uniquely identifies the resource + /// Default TTL for a Session, in seconds + /// The URL we should call when the interaction status changes + /// Where a proxy number must be located relative to the participant identifier + /// The preference for Proxy Number selection for the Service instance + /// The URL we call on each interaction + /// The URL we call when an inbound call or SMS action occurs on a closed or + /// non-existent Session + /// The SID of the Chat Service Instance + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + int? defaultTtl = null, + Uri callbackUrl = null, + ServiceResource.GeoMatchLevelEnum geoMatchLevel = null, + ServiceResource.NumberSelectionBehaviorEnum numberSelectionBehavior = null, + Uri interceptCallbackUrl = null, + Uri outOfSessionCallbackUrl = null, + string chatInstanceSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { UniqueName = uniqueName, DefaultTtl = defaultTtl, CallbackUrl = callbackUrl, GeoMatchLevel = geoMatchLevel, NumberSelectionBehavior = numberSelectionBehavior, InterceptCallbackUrl = interceptCallbackUrl, OutOfSessionCallbackUrl = outOfSessionCallbackUrl, ChatInstanceSid = chatInstanceSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Chat Service Instance + /// + [JsonProperty("chat_instance_sid")] + public string ChatInstanceSid { get; private set; } + /// + /// The URL we call when the interaction status changes + /// + [JsonProperty("callback_url")] + public Uri CallbackUrl { get; private set; } + /// + /// Default TTL for a Session, in seconds + /// + [JsonProperty("default_ttl")] + public int? DefaultTtl { get; private set; } + /// + /// The preference for Proxy Number selection for the Service instance + /// + [JsonProperty("number_selection_behavior")] + [JsonConverter(typeof(StringEnumConverter))] + public ServiceResource.NumberSelectionBehaviorEnum NumberSelectionBehavior { get; private set; } + /// + /// Where a proxy number must be located relative to the participant identifier + /// + [JsonProperty("geo_match_level")] + [JsonConverter(typeof(StringEnumConverter))] + public ServiceResource.GeoMatchLevelEnum GeoMatchLevel { get; private set; } + /// + /// The URL we call on each interaction + /// + [JsonProperty("intercept_callback_url")] + public Uri InterceptCallbackUrl { get; private set; } + /// + /// The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session + /// + [JsonProperty("out_of_session_callback_url")] + public Uri OutOfSessionCallbackUrl { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of resources related to the Service + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionOptions.cs index cb4846b6d..2f337e8e5 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionOptions.cs @@ -9,93 +9,93 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Asset -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Asset Versions. + /// + public class ReadAssetVersionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Asset Versions. + /// The SID of the Service to read the Asset Version resource from /// - public class ReadAssetVersionOptions : ReadOptions - { - /// - /// The SID of the Service to read the Asset Version resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Asset resource that is the parent of the Asset Version resources to read - /// - public string PathAssetSid { get; } - - /// - /// Construct a new ReadAssetVersionOptions - /// - /// The SID of the Service to read the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resources to read - /// - public ReadAssetVersionOptions(string pathServiceSid, string pathAssetSid) - { - PathServiceSid = pathServiceSid; - PathAssetSid = pathAssetSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Asset Version. + /// The SID of the Asset resource that is the parent of the Asset Version resources to read /// - public class FetchAssetVersionOptions : IOptions - { - /// - /// The SID of the Service to fetch the Asset Version resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch - /// - public string PathAssetSid { get; } - /// - /// The SID that identifies the Asset Version resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssetVersionOptions - /// - /// The SID of the Service to fetch the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch - /// - /// The SID that identifies the Asset Version resource to fetch - public FetchAssetVersionOptions(string pathServiceSid, string pathAssetSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathAssetSid = pathAssetSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathAssetSid { get; } + + /// + /// Construct a new ReadAssetVersionOptions + /// + /// The SID of the Service to read the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resources to read + /// + public ReadAssetVersionOptions(string pathServiceSid, string pathAssetSid) + { + PathServiceSid = pathServiceSid; + PathAssetSid = pathAssetSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Asset Version. + /// + public class FetchAssetVersionOptions : IOptions + { + /// + /// The SID of the Service to fetch the Asset Version resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch + /// + public string PathAssetSid { get; } + /// + /// The SID that identifies the Asset Version resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAssetVersionOptions + /// + /// The SID of the Service to fetch the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch + /// + /// The SID that identifies the Asset Version resource to fetch + public FetchAssetVersionOptions(string pathServiceSid, string pathAssetSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathAssetSid = pathAssetSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionResource.cs index f562d8202..05034db96 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Asset/AssetVersionResource.cs @@ -19,306 +19,306 @@ using Twilio.Types; namespace Twilio.Rest.Serverless.V1.Service.Asset -{ - - public class AssetVersionResource : Resource - { - public sealed class VisibilityEnum : StringEnum - { - private VisibilityEnum(string value) : base(value) {} - public VisibilityEnum() {} - public static implicit operator VisibilityEnum(string value) - { - return new VisibilityEnum(value); - } - - public static readonly VisibilityEnum Public = new VisibilityEnum("public"); - public static readonly VisibilityEnum Private = new VisibilityEnum("private"); - public static readonly VisibilityEnum Protected = new VisibilityEnum("protected"); - } - - private static Request BuildReadRequest(ReadAssetVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathAssetSid + "/Versions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Asset Versions. - /// - /// Read AssetVersion parameters - /// Client to make requests to Twilio - /// A single instance of AssetVersion - public static ResourceSet Read(ReadAssetVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("asset_versions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Asset Versions. - /// - /// Read AssetVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssetVersion - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssetVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("asset_versions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Asset Versions. - /// - /// The SID of the Service to read the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resources to read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of AssetVersion - public static ResourceSet Read(string pathServiceSid, - string pathAssetSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssetVersionOptions(pathServiceSid, pathAssetSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Asset Versions. - /// - /// The SID of the Service to read the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resources to read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssetVersion - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathAssetSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssetVersionOptions(pathServiceSid, pathAssetSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("asset_versions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("asset_versions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("asset_versions", response.Content); - } - - private static Request BuildFetchRequest(FetchAssetVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathAssetSid + "/Versions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Asset Version. - /// - /// Fetch AssetVersion parameters - /// Client to make requests to Twilio - /// A single instance of AssetVersion - public static AssetVersionResource Fetch(FetchAssetVersionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Asset Version. - /// - /// Fetch AssetVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssetVersion - public static async System.Threading.Tasks.Task FetchAsync(FetchAssetVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Asset Version. - /// - /// The SID of the Service to fetch the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch - /// - /// The SID that identifies the Asset Version resource to fetch - /// Client to make requests to Twilio - /// A single instance of AssetVersion - public static AssetVersionResource Fetch(string pathServiceSid, - string pathAssetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAssetVersionOptions(pathServiceSid, pathAssetSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Asset Version. - /// - /// The SID of the Service to fetch the Asset Version resource from - /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch - /// - /// The SID that identifies the Asset Version resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AssetVersion - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathAssetSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAssetVersionOptions(pathServiceSid, pathAssetSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssetVersionResource object - /// - /// Raw JSON string - /// AssetVersionResource object represented by the provided JSON - public static AssetVersionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Asset Version resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Asset Version resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Asset Version resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Asset resource that is the parent of the Asset Version - /// - [JsonProperty("asset_sid")] - public string AssetSid { get; private set; } - /// - /// The URL-friendly string by which the Asset Version can be referenced - /// - [JsonProperty("path")] - public string Path { get; private set; } - /// - /// The access control that determines how the Asset Version can be accessed - /// - [JsonProperty("visibility")] - [JsonConverter(typeof(StringEnumConverter))] - public AssetVersionResource.VisibilityEnum Visibility { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Asset Version resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Asset Version resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private AssetVersionResource() - { - - } - } +{ + + public class AssetVersionResource : Resource + { + public sealed class VisibilityEnum : StringEnum + { + private VisibilityEnum(string value) : base(value) { } + public VisibilityEnum() { } + public static implicit operator VisibilityEnum(string value) + { + return new VisibilityEnum(value); + } + + public static readonly VisibilityEnum Public = new VisibilityEnum("public"); + public static readonly VisibilityEnum Private = new VisibilityEnum("private"); + public static readonly VisibilityEnum Protected = new VisibilityEnum("protected"); + } + + private static Request BuildReadRequest(ReadAssetVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathAssetSid + "/Versions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Asset Versions. + /// + /// Read AssetVersion parameters + /// Client to make requests to Twilio + /// A single instance of AssetVersion + public static ResourceSet Read(ReadAssetVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("asset_versions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Asset Versions. + /// + /// Read AssetVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssetVersion + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssetVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("asset_versions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Asset Versions. + /// + /// The SID of the Service to read the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resources to read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of AssetVersion + public static ResourceSet Read(string pathServiceSid, + string pathAssetSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssetVersionOptions(pathServiceSid, pathAssetSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Asset Versions. + /// + /// The SID of the Service to read the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resources to read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssetVersion + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathAssetSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssetVersionOptions(pathServiceSid, pathAssetSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("asset_versions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("asset_versions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("asset_versions", response.Content); + } + + private static Request BuildFetchRequest(FetchAssetVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathAssetSid + "/Versions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Asset Version. + /// + /// Fetch AssetVersion parameters + /// Client to make requests to Twilio + /// A single instance of AssetVersion + public static AssetVersionResource Fetch(FetchAssetVersionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Asset Version. + /// + /// Fetch AssetVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssetVersion + public static async System.Threading.Tasks.Task FetchAsync(FetchAssetVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Asset Version. + /// + /// The SID of the Service to fetch the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch + /// + /// The SID that identifies the Asset Version resource to fetch + /// Client to make requests to Twilio + /// A single instance of AssetVersion + public static AssetVersionResource Fetch(string pathServiceSid, + string pathAssetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAssetVersionOptions(pathServiceSid, pathAssetSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Asset Version. + /// + /// The SID of the Service to fetch the Asset Version resource from + /// The SID of the Asset resource that is the parent of the Asset Version resource to fetch + /// + /// The SID that identifies the Asset Version resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AssetVersion + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathAssetSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAssetVersionOptions(pathServiceSid, pathAssetSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssetVersionResource object + /// + /// Raw JSON string + /// AssetVersionResource object represented by the provided JSON + public static AssetVersionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Asset Version resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Asset Version resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Asset Version resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Asset resource that is the parent of the Asset Version + /// + [JsonProperty("asset_sid")] + public string AssetSid { get; private set; } + /// + /// The URL-friendly string by which the Asset Version can be referenced + /// + [JsonProperty("path")] + public string Path { get; private set; } + /// + /// The access control that determines how the Asset Version can be accessed + /// + [JsonProperty("visibility")] + [JsonConverter(typeof(StringEnumConverter))] + public AssetVersionResource.VisibilityEnum Visibility { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Asset Version resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Asset Version resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private AssetVersionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/AssetOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/AssetOptions.cs index 3e33710db..f7228e08f 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/AssetOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/AssetOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Assets. + /// + public class ReadAssetOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Assets. + /// The SID of the Service to read the Asset resource from /// - public class ReadAssetOptions : ReadOptions - { - /// - /// The SID of the Service to read the Asset resource from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadAssetOptions - /// - /// The SID of the Service to read the Asset resource from - public ReadAssetOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Asset resource. - /// - public class FetchAssetOptions : IOptions - { - /// - /// The SID of the Service to fetch the Asset resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the Asset resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchAssetOptions - /// - /// The SID of the Service to fetch the Asset resource from - /// The SID that identifies the Asset resource to fetch - public FetchAssetOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadAssetOptions + /// + /// The SID of the Service to read the Asset resource from + public ReadAssetOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete an Asset resource. - /// - public class DeleteAssetOptions : IOptions - { - /// - /// The SID of the Service to delete the Asset resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the Asset resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteAssetOptions - /// - /// The SID of the Service to delete the Asset resource from - /// The SID that identifies the Asset resource to delete - public DeleteAssetOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Asset resource. + /// + public class FetchAssetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Asset resource. - /// - public class CreateAssetOptions : IOptions - { - /// - /// The SID of the Service to create the Asset resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the Asset resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateAssetOptions - /// - /// The SID of the Service to create the Asset resource under - /// A string to describe the Asset resource - public CreateAssetOptions(string pathServiceSid, string friendlyName) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The SID of the Service to fetch the Asset resource from + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Asset resource. - /// - public class UpdateAssetOptions : IOptions - { - /// - /// The SID of the Service to update the Asset resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the Asset resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the Asset resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new UpdateAssetOptions - /// - /// The SID of the Service to update the Asset resource from - /// The SID that identifies the Asset resource to update - /// A string to describe the Asset resource - public UpdateAssetOptions(string pathServiceSid, string pathSid, string friendlyName) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + /// The SID that identifies the Asset resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchAssetOptions + /// + /// The SID of the Service to fetch the Asset resource from + /// The SID that identifies the Asset resource to fetch + public FetchAssetOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete an Asset resource. + /// + public class DeleteAssetOptions : IOptions + { + /// + /// The SID of the Service to delete the Asset resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the Asset resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteAssetOptions + /// + /// The SID of the Service to delete the Asset resource from + /// The SID that identifies the Asset resource to delete + public DeleteAssetOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Asset resource. + /// + public class CreateAssetOptions : IOptions + { + /// + /// The SID of the Service to create the Asset resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the Asset resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateAssetOptions + /// + /// The SID of the Service to create the Asset resource under + /// A string to describe the Asset resource + public CreateAssetOptions(string pathServiceSid, string friendlyName) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Asset resource. + /// + public class UpdateAssetOptions : IOptions + { + /// + /// The SID of the Service to update the Asset resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the Asset resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the Asset resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new UpdateAssetOptions + /// + /// The SID of the Service to update the Asset resource from + /// The SID that identifies the Asset resource to update + /// A string to describe the Asset resource + public UpdateAssetOptions(string pathServiceSid, string pathSid, string friendlyName) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/AssetResource.cs b/src/Twilio/Rest/Serverless/V1/Service/AssetResource.cs index 3605c9a9e..fcb0c4b7a 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/AssetResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/AssetResource.cs @@ -18,492 +18,492 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service -{ - - public class AssetResource : Resource - { - private static Request BuildReadRequest(ReadAssetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assets. - /// - /// Read Asset parameters - /// Client to make requests to Twilio - /// A single instance of Asset - public static ResourceSet Read(ReadAssetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("assets", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assets. - /// - /// Read Asset parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("assets", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assets. - /// - /// The SID of the Service to read the Asset resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Asset - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssetOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assets. - /// - /// The SID of the Service to read the Asset resource from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadAssetOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("assets", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("assets", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("assets", response.Content); - } - - private static Request BuildFetchRequest(FetchAssetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Asset resource. - /// - /// Fetch Asset parameters - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Fetch(FetchAssetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Asset resource. - /// - /// Fetch Asset parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task FetchAsync(FetchAssetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Asset resource. - /// - /// The SID of the Service to fetch the Asset resource from - /// The SID that identifies the Asset resource to fetch - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchAssetOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Asset resource. - /// - /// The SID of the Service to fetch the Asset resource from - /// The SID that identifies the Asset resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchAssetOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteAssetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an Asset resource. - /// - /// Delete Asset parameters - /// Client to make requests to Twilio - /// A single instance of Asset - public static bool Delete(DeleteAssetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an Asset resource. - /// - /// Delete Asset parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an Asset resource. - /// - /// The SID of the Service to delete the Asset resource from - /// The SID that identifies the Asset resource to delete - /// Client to make requests to Twilio - /// A single instance of Asset - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteAssetOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an Asset resource. - /// - /// The SID of the Service to delete the Asset resource from - /// The SID that identifies the Asset resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteAssetOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateAssetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Asset resource. - /// - /// Create Asset parameters - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Create(CreateAssetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Asset resource. - /// - /// Create Asset parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task CreateAsync(CreateAssetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Asset resource. - /// - /// The SID of the Service to create the Asset resource under - /// A string to describe the Asset resource - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Create(string pathServiceSid, string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateAssetOptions(pathServiceSid, friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Asset resource. - /// - /// The SID of the Service to create the Asset resource under - /// A string to describe the Asset resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateAssetOptions(pathServiceSid, friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateAssetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Asset resource. - /// - /// Update Asset parameters - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Update(UpdateAssetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Asset resource. - /// - /// Update Asset parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Asset resource. - /// - /// The SID of the Service to update the Asset resource from - /// The SID that identifies the Asset resource to update - /// A string to describe the Asset resource - /// Client to make requests to Twilio - /// A single instance of Asset - public static AssetResource Update(string pathServiceSid, - string pathSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new UpdateAssetOptions(pathServiceSid, pathSid, friendlyName); - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Asset resource. - /// - /// The SID of the Service to update the Asset resource from - /// The SID that identifies the Asset resource to update - /// A string to describe the Asset resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Asset - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new UpdateAssetOptions(pathServiceSid, pathSid, friendlyName); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AssetResource object - /// - /// Raw JSON string - /// AssetResource object represented by the provided JSON - public static AssetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Asset resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Asset resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Asset resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the Asset resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Asset resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Asset resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Asset resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Asset resource's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private AssetResource() - { - - } - } +{ + + public class AssetResource : Resource + { + private static Request BuildReadRequest(ReadAssetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assets. + /// + /// Read Asset parameters + /// Client to make requests to Twilio + /// A single instance of Asset + public static ResourceSet Read(ReadAssetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("assets", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assets. + /// + /// Read Asset parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("assets", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assets. + /// + /// The SID of the Service to read the Asset resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Asset + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssetOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assets. + /// + /// The SID of the Service to read the Asset resource from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadAssetOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("assets", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("assets", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("assets", response.Content); + } + + private static Request BuildFetchRequest(FetchAssetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Asset resource. + /// + /// Fetch Asset parameters + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Fetch(FetchAssetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Asset resource. + /// + /// Fetch Asset parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task FetchAsync(FetchAssetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Asset resource. + /// + /// The SID of the Service to fetch the Asset resource from + /// The SID that identifies the Asset resource to fetch + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchAssetOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Asset resource. + /// + /// The SID of the Service to fetch the Asset resource from + /// The SID that identifies the Asset resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchAssetOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteAssetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an Asset resource. + /// + /// Delete Asset parameters + /// Client to make requests to Twilio + /// A single instance of Asset + public static bool Delete(DeleteAssetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an Asset resource. + /// + /// Delete Asset parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task DeleteAsync(DeleteAssetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an Asset resource. + /// + /// The SID of the Service to delete the Asset resource from + /// The SID that identifies the Asset resource to delete + /// Client to make requests to Twilio + /// A single instance of Asset + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteAssetOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an Asset resource. + /// + /// The SID of the Service to delete the Asset resource from + /// The SID that identifies the Asset resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteAssetOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateAssetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Asset resource. + /// + /// Create Asset parameters + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Create(CreateAssetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Asset resource. + /// + /// Create Asset parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task CreateAsync(CreateAssetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Asset resource. + /// + /// The SID of the Service to create the Asset resource under + /// A string to describe the Asset resource + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Create(string pathServiceSid, string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateAssetOptions(pathServiceSid, friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Asset resource. + /// + /// The SID of the Service to create the Asset resource under + /// A string to describe the Asset resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateAssetOptions(pathServiceSid, friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateAssetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Assets/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Asset resource. + /// + /// Update Asset parameters + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Update(UpdateAssetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Asset resource. + /// + /// Update Asset parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAssetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Asset resource. + /// + /// The SID of the Service to update the Asset resource from + /// The SID that identifies the Asset resource to update + /// A string to describe the Asset resource + /// Client to make requests to Twilio + /// A single instance of Asset + public static AssetResource Update(string pathServiceSid, + string pathSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new UpdateAssetOptions(pathServiceSid, pathSid, friendlyName); + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Asset resource. + /// + /// The SID of the Service to update the Asset resource from + /// The SID that identifies the Asset resource to update + /// A string to describe the Asset resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Asset + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new UpdateAssetOptions(pathServiceSid, pathSid, friendlyName); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AssetResource object + /// + /// Raw JSON string + /// AssetResource object represented by the provided JSON + public static AssetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Asset resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Asset resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Asset resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the Asset resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Asset resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Asset resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Asset resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Asset resource's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private AssetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/BuildOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/BuildOptions.cs index c47225a23..711c907cd 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/BuildOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/BuildOptions.cs @@ -10,185 +10,185 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Builds. + /// + public class ReadBuildOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Builds. + /// The SID of the Service to read the Build resources from /// - public class ReadBuildOptions : ReadOptions - { - /// - /// The SID of the Service to read the Build resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadBuildOptions - /// - /// The SID of the Service to read the Build resources from - public ReadBuildOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Build resource. - /// - public class FetchBuildOptions : IOptions - { - /// - /// The SID of the Service to fetch the Build resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Build resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBuildOptions - /// - /// The SID of the Service to fetch the Build resource from - /// The SID of the Build resource to fetch - public FetchBuildOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadBuildOptions + /// + /// The SID of the Service to read the Build resources from + public ReadBuildOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a Build resource. - /// - public class DeleteBuildOptions : IOptions - { - /// - /// The SID of the Service to delete the Build resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Build resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBuildOptions - /// - /// The SID of the Service to delete the Build resource from - /// The SID of the Build resource to delete - public DeleteBuildOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Build resource. + /// + public class FetchBuildOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Build resource. At least one function version or asset version is required. - /// - public class CreateBuildOptions : IOptions - { - /// - /// The SID of the Service to create the Build resource under - /// - public string PathServiceSid { get; } - /// - /// The list of Asset Version resource SIDs to include in the Build - /// - public List AssetVersions { get; set; } - /// - /// The list of the Function Version resource SIDs to include in the Build - /// - public List FunctionVersions { get; set; } - /// - /// A list of objects that describe the Dependencies included in the Build - /// - public string Dependencies { get; set; } - /// - /// The Runtime version that will be used to run the Build. - /// - public string Runtime { get; set; } - - /// - /// Construct a new CreateBuildOptions - /// - /// The SID of the Service to create the Build resource under - public CreateBuildOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - AssetVersions = new List(); - FunctionVersions = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AssetVersions != null) - { - p.AddRange(AssetVersions.Select(prop => new KeyValuePair("AssetVersions", prop.ToString()))); - } - - if (FunctionVersions != null) - { - p.AddRange(FunctionVersions.Select(prop => new KeyValuePair("FunctionVersions", prop.ToString()))); - } - - if (Dependencies != null) - { - p.Add(new KeyValuePair("Dependencies", Dependencies)); - } - - if (Runtime != null) - { - p.Add(new KeyValuePair("Runtime", Runtime)); - } - - return p; - } - } + /// The SID of the Service to fetch the Build resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Build resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBuildOptions + /// + /// The SID of the Service to fetch the Build resource from + /// The SID of the Build resource to fetch + public FetchBuildOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a Build resource. + /// + public class DeleteBuildOptions : IOptions + { + /// + /// The SID of the Service to delete the Build resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Build resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBuildOptions + /// + /// The SID of the Service to delete the Build resource from + /// The SID of the Build resource to delete + public DeleteBuildOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Build resource. At least one function version or asset version is required. + /// + public class CreateBuildOptions : IOptions + { + /// + /// The SID of the Service to create the Build resource under + /// + public string PathServiceSid { get; } + /// + /// The list of Asset Version resource SIDs to include in the Build + /// + public List AssetVersions { get; set; } + /// + /// The list of the Function Version resource SIDs to include in the Build + /// + public List FunctionVersions { get; set; } + /// + /// A list of objects that describe the Dependencies included in the Build + /// + public string Dependencies { get; set; } + /// + /// The Runtime version that will be used to run the Build. + /// + public string Runtime { get; set; } + + /// + /// Construct a new CreateBuildOptions + /// + /// The SID of the Service to create the Build resource under + public CreateBuildOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + AssetVersions = new List(); + FunctionVersions = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AssetVersions != null) + { + p.AddRange(AssetVersions.Select(prop => new KeyValuePair("AssetVersions", prop.ToString()))); + } + + if (FunctionVersions != null) + { + p.AddRange(FunctionVersions.Select(prop => new KeyValuePair("FunctionVersions", prop.ToString()))); + } + + if (Dependencies != null) + { + p.Add(new KeyValuePair("Dependencies", Dependencies)); + } + + if (Runtime != null) + { + p.Add(new KeyValuePair("Runtime", Runtime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/BuildResource.cs b/src/Twilio/Rest/Serverless/V1/Service/BuildResource.cs index 2502bdbc2..342b30e54 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/BuildResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/BuildResource.cs @@ -19,481 +19,481 @@ using Twilio.Types; namespace Twilio.Rest.Serverless.V1.Service -{ - - public class BuildResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Building = new StatusEnum("building"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class RuntimeEnum : StringEnum - { - private RuntimeEnum(string value) : base(value) {} - public RuntimeEnum() {} - public static implicit operator RuntimeEnum(string value) - { - return new RuntimeEnum(value); - } - - public static readonly RuntimeEnum Node8 = new RuntimeEnum("node8"); - public static readonly RuntimeEnum Node10 = new RuntimeEnum("node10"); - public static readonly RuntimeEnum Node12 = new RuntimeEnum("node12"); - public static readonly RuntimeEnum Node14 = new RuntimeEnum("node14"); - } - - private static Request BuildReadRequest(ReadBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Builds", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Builds. - /// - /// Read Build parameters - /// Client to make requests to Twilio - /// A single instance of Build - public static ResourceSet Read(ReadBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("builds", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Builds. - /// - /// Read Build parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task> ReadAsync(ReadBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("builds", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Builds. - /// - /// The SID of the Service to read the Build resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Build - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBuildOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Builds. - /// - /// The SID of the Service to read the Build resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBuildOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("builds", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("builds", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("builds", response.Content); - } - - private static Request BuildFetchRequest(FetchBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Builds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Build resource. - /// - /// Fetch Build parameters - /// Client to make requests to Twilio - /// A single instance of Build - public static BuildResource Fetch(FetchBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Build resource. - /// - /// Fetch Build parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task FetchAsync(FetchBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Build resource. - /// - /// The SID of the Service to fetch the Build resource from - /// The SID of the Build resource to fetch - /// Client to make requests to Twilio - /// A single instance of Build - public static BuildResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchBuildOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Build resource. - /// - /// The SID of the Service to fetch the Build resource from - /// The SID of the Build resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBuildOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Builds/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Build resource. - /// - /// Delete Build parameters - /// Client to make requests to Twilio - /// A single instance of Build - public static bool Delete(DeleteBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Build resource. - /// - /// Delete Build parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Build resource. - /// - /// The SID of the Service to delete the Build resource from - /// The SID of the Build resource to delete - /// Client to make requests to Twilio - /// A single instance of Build - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteBuildOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Build resource. - /// - /// The SID of the Service to delete the Build resource from - /// The SID of the Build resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBuildOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateBuildOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Builds", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Build resource. At least one function version or asset version is required. - /// - /// Create Build parameters - /// Client to make requests to Twilio - /// A single instance of Build - public static BuildResource Create(CreateBuildOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Build resource. At least one function version or asset version is required. - /// - /// Create Build parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task CreateAsync(CreateBuildOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Build resource. At least one function version or asset version is required. - /// - /// The SID of the Service to create the Build resource under - /// The list of Asset Version resource SIDs to include in the Build - /// The list of the Function Version resource SIDs to include in the Build - /// A list of objects that describe the Dependencies included in the Build - /// The Runtime version that will be used to run the Build. - /// Client to make requests to Twilio - /// A single instance of Build - public static BuildResource Create(string pathServiceSid, - List assetVersions = null, - List functionVersions = null, - string dependencies = null, - string runtime = null, - ITwilioRestClient client = null) - { - var options = new CreateBuildOptions(pathServiceSid){AssetVersions = assetVersions, FunctionVersions = functionVersions, Dependencies = dependencies, Runtime = runtime}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Build resource. At least one function version or asset version is required. - /// - /// The SID of the Service to create the Build resource under - /// The list of Asset Version resource SIDs to include in the Build - /// The list of the Function Version resource SIDs to include in the Build - /// A list of objects that describe the Dependencies included in the Build - /// The Runtime version that will be used to run the Build. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Build - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - List assetVersions = null, - List functionVersions = null, - string dependencies = null, - string runtime = null, - ITwilioRestClient client = null) - { - var options = new CreateBuildOptions(pathServiceSid){AssetVersions = assetVersions, FunctionVersions = functionVersions, Dependencies = dependencies, Runtime = runtime}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BuildResource object - /// - /// Raw JSON string - /// BuildResource object represented by the provided JSON - public static BuildResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Build resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Build resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Build resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The status of the Build - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public BuildResource.StatusEnum Status { get; private set; } - /// - /// The list of Asset Version resource SIDs that are included in the Build - /// - [JsonProperty("asset_versions")] - public List AssetVersions { get; private set; } - /// - /// The list of Function Version resource SIDs that are included in the Build - /// - [JsonProperty("function_versions")] - public List FunctionVersions { get; private set; } - /// - /// A list of objects that describe the Dependencies included in the Build - /// - [JsonProperty("dependencies")] - public List Dependencies { get; private set; } - /// - /// The Runtime version that will be used to run the Build. - /// - [JsonProperty("runtime")] - [JsonConverter(typeof(StringEnumConverter))] - public BuildResource.RuntimeEnum Runtime { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Build resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Build resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Build resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private BuildResource() - { - - } - } +{ + + public class BuildResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Building = new StatusEnum("building"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class RuntimeEnum : StringEnum + { + private RuntimeEnum(string value) : base(value) { } + public RuntimeEnum() { } + public static implicit operator RuntimeEnum(string value) + { + return new RuntimeEnum(value); + } + + public static readonly RuntimeEnum Node8 = new RuntimeEnum("node8"); + public static readonly RuntimeEnum Node10 = new RuntimeEnum("node10"); + public static readonly RuntimeEnum Node12 = new RuntimeEnum("node12"); + public static readonly RuntimeEnum Node14 = new RuntimeEnum("node14"); + } + + private static Request BuildReadRequest(ReadBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Builds", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Builds. + /// + /// Read Build parameters + /// Client to make requests to Twilio + /// A single instance of Build + public static ResourceSet Read(ReadBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("builds", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Builds. + /// + /// Read Build parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task> ReadAsync(ReadBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("builds", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Builds. + /// + /// The SID of the Service to read the Build resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Build + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBuildOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Builds. + /// + /// The SID of the Service to read the Build resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBuildOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("builds", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("builds", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("builds", response.Content); + } + + private static Request BuildFetchRequest(FetchBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Builds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Build resource. + /// + /// Fetch Build parameters + /// Client to make requests to Twilio + /// A single instance of Build + public static BuildResource Fetch(FetchBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Build resource. + /// + /// Fetch Build parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task FetchAsync(FetchBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Build resource. + /// + /// The SID of the Service to fetch the Build resource from + /// The SID of the Build resource to fetch + /// Client to make requests to Twilio + /// A single instance of Build + public static BuildResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchBuildOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Build resource. + /// + /// The SID of the Service to fetch the Build resource from + /// The SID of the Build resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBuildOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Builds/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Build resource. + /// + /// Delete Build parameters + /// Client to make requests to Twilio + /// A single instance of Build + public static bool Delete(DeleteBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Build resource. + /// + /// Delete Build parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Build resource. + /// + /// The SID of the Service to delete the Build resource from + /// The SID of the Build resource to delete + /// Client to make requests to Twilio + /// A single instance of Build + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteBuildOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Build resource. + /// + /// The SID of the Service to delete the Build resource from + /// The SID of the Build resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBuildOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateBuildOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Builds", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Build resource. At least one function version or asset version is required. + /// + /// Create Build parameters + /// Client to make requests to Twilio + /// A single instance of Build + public static BuildResource Create(CreateBuildOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Build resource. At least one function version or asset version is required. + /// + /// Create Build parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task CreateAsync(CreateBuildOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Build resource. At least one function version or asset version is required. + /// + /// The SID of the Service to create the Build resource under + /// The list of Asset Version resource SIDs to include in the Build + /// The list of the Function Version resource SIDs to include in the Build + /// A list of objects that describe the Dependencies included in the Build + /// The Runtime version that will be used to run the Build. + /// Client to make requests to Twilio + /// A single instance of Build + public static BuildResource Create(string pathServiceSid, + List assetVersions = null, + List functionVersions = null, + string dependencies = null, + string runtime = null, + ITwilioRestClient client = null) + { + var options = new CreateBuildOptions(pathServiceSid) { AssetVersions = assetVersions, FunctionVersions = functionVersions, Dependencies = dependencies, Runtime = runtime }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Build resource. At least one function version or asset version is required. + /// + /// The SID of the Service to create the Build resource under + /// The list of Asset Version resource SIDs to include in the Build + /// The list of the Function Version resource SIDs to include in the Build + /// A list of objects that describe the Dependencies included in the Build + /// The Runtime version that will be used to run the Build. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Build + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + List assetVersions = null, + List functionVersions = null, + string dependencies = null, + string runtime = null, + ITwilioRestClient client = null) + { + var options = new CreateBuildOptions(pathServiceSid) { AssetVersions = assetVersions, FunctionVersions = functionVersions, Dependencies = dependencies, Runtime = runtime }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BuildResource object + /// + /// Raw JSON string + /// BuildResource object represented by the provided JSON + public static BuildResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Build resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Build resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Build resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The status of the Build + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public BuildResource.StatusEnum Status { get; private set; } + /// + /// The list of Asset Version resource SIDs that are included in the Build + /// + [JsonProperty("asset_versions")] + public List AssetVersions { get; private set; } + /// + /// The list of Function Version resource SIDs that are included in the Build + /// + [JsonProperty("function_versions")] + public List FunctionVersions { get; private set; } + /// + /// A list of objects that describe the Dependencies included in the Build + /// + [JsonProperty("dependencies")] + public List Dependencies { get; private set; } + /// + /// The Runtime version that will be used to run the Build. + /// + [JsonProperty("runtime")] + [JsonConverter(typeof(StringEnumConverter))] + public BuildResource.RuntimeEnum Runtime { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Build resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Build resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Build resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private BuildResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentOptions.cs index 89dd3d758..ad778af76 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentOptions.cs @@ -9,137 +9,137 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Deployments. + /// + public class ReadDeploymentOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Deployments. + /// The SID of the Service to read the Deployment resources from /// - public class ReadDeploymentOptions : ReadOptions - { - /// - /// The SID of the Service to read the Deployment resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment used by the Deployment resources to read - /// - public string PathEnvironmentSid { get; } - - /// - /// Construct a new ReadDeploymentOptions - /// - /// The SID of the Service to read the Deployment resources from - /// The SID of the Environment used by the Deployment resources to read - public ReadDeploymentOptions(string pathServiceSid, string pathEnvironmentSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Deployment. + /// The SID of the Environment used by the Deployment resources to read /// - public class FetchDeploymentOptions : IOptions - { - /// - /// The SID of the Service to fetch the Deployment resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment used by the Deployment to fetch - /// - public string PathEnvironmentSid { get; } - /// - /// The SID that identifies the Deployment resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDeploymentOptions - /// - /// The SID of the Service to fetch the Deployment resource from - /// The SID of the Environment used by the Deployment to fetch - /// The SID that identifies the Deployment resource to fetch - public FetchDeploymentOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathEnvironmentSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Deployment. + /// Construct a new ReadDeploymentOptions /// - public class CreateDeploymentOptions : IOptions - { - /// - /// The SID of the Service to create the Deployment resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment for the Deployment - /// - public string PathEnvironmentSid { get; } - /// - /// The SID of the Build for the Deployment - /// - public string BuildSid { get; set; } - - /// - /// Construct a new CreateDeploymentOptions - /// - /// The SID of the Service to create the Deployment resource under - /// The SID of the Environment for the Deployment - public CreateDeploymentOptions(string pathServiceSid, string pathEnvironmentSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (BuildSid != null) - { - p.Add(new KeyValuePair("BuildSid", BuildSid.ToString())); - } - - return p; - } - } + /// The SID of the Service to read the Deployment resources from + /// The SID of the Environment used by the Deployment resources to read + public ReadDeploymentOptions(string pathServiceSid, string pathEnvironmentSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Deployment. + /// + public class FetchDeploymentOptions : IOptions + { + /// + /// The SID of the Service to fetch the Deployment resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment used by the Deployment to fetch + /// + public string PathEnvironmentSid { get; } + /// + /// The SID that identifies the Deployment resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchDeploymentOptions + /// + /// The SID of the Service to fetch the Deployment resource from + /// The SID of the Environment used by the Deployment to fetch + /// The SID that identifies the Deployment resource to fetch + public FetchDeploymentOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Deployment. + /// + public class CreateDeploymentOptions : IOptions + { + /// + /// The SID of the Service to create the Deployment resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment for the Deployment + /// + public string PathEnvironmentSid { get; } + /// + /// The SID of the Build for the Deployment + /// + public string BuildSid { get; set; } + + /// + /// Construct a new CreateDeploymentOptions + /// + /// The SID of the Service to create the Deployment resource under + /// The SID of the Environment for the Deployment + public CreateDeploymentOptions(string pathServiceSid, string pathEnvironmentSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (BuildSid != null) + { + p.Add(new KeyValuePair("BuildSid", BuildSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentResource.cs index e64caaf7a..708733df8 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/DeploymentResource.cs @@ -18,362 +18,362 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - - public class DeploymentResource : Resource - { - private static Request BuildReadRequest(ReadDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Deployments. - /// - /// Read Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static ResourceSet Read(ReadDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("deployments", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Deployments. - /// - /// Read Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task> ReadAsync(ReadDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("deployments", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Deployments. - /// - /// The SID of the Service to read the Deployment resources from - /// The SID of the Environment used by the Deployment resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Deployment - public static ResourceSet Read(string pathServiceSid, - string pathEnvironmentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeploymentOptions(pathServiceSid, pathEnvironmentSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Deployments. - /// - /// The SID of the Service to read the Deployment resources from - /// The SID of the Environment used by the Deployment resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathEnvironmentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDeploymentOptions(pathServiceSid, pathEnvironmentSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("deployments", response.Content); - } - - private static Request BuildFetchRequest(FetchDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Deployment. - /// - /// Fetch Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Fetch(FetchDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Deployment. - /// - /// Fetch Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task FetchAsync(FetchDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Deployment. - /// - /// The SID of the Service to fetch the Deployment resource from - /// The SID of the Environment used by the Deployment to fetch - /// The SID that identifies the Deployment resource to fetch - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Fetch(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeploymentOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Deployment. - /// - /// The SID of the Service to fetch the Deployment resource from - /// The SID of the Environment used by the Deployment to fetch - /// The SID that identifies the Deployment resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDeploymentOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateDeploymentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Deployment. - /// - /// Create Deployment parameters - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Create(CreateDeploymentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Deployment. - /// - /// Create Deployment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task CreateAsync(CreateDeploymentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Deployment. - /// - /// The SID of the Service to create the Deployment resource under - /// The SID of the Environment for the Deployment - /// The SID of the Build for the Deployment - /// Client to make requests to Twilio - /// A single instance of Deployment - public static DeploymentResource Create(string pathServiceSid, - string pathEnvironmentSid, - string buildSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDeploymentOptions(pathServiceSid, pathEnvironmentSid){BuildSid = buildSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Deployment. - /// - /// The SID of the Service to create the Deployment resource under - /// The SID of the Environment for the Deployment - /// The SID of the Build for the Deployment - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Deployment - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathEnvironmentSid, - string buildSid = null, - ITwilioRestClient client = null) - { - var options = new CreateDeploymentOptions(pathServiceSid, pathEnvironmentSid){BuildSid = buildSid}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DeploymentResource object - /// - /// Raw JSON string - /// DeploymentResource object represented by the provided JSON - public static DeploymentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Deployment resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Deployment resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Deployment resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Environment for the Deployment - /// - [JsonProperty("environment_sid")] - public string EnvironmentSid { get; private set; } - /// - /// The SID of the Build for the deployment - /// - [JsonProperty("build_sid")] - public string BuildSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Deployment resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Deployment resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Deployment resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DeploymentResource() - { - - } - } +{ + + public class DeploymentResource : Resource + { + private static Request BuildReadRequest(ReadDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Deployments. + /// + /// Read Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static ResourceSet Read(ReadDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("deployments", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Deployments. + /// + /// Read Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task> ReadAsync(ReadDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("deployments", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Deployments. + /// + /// The SID of the Service to read the Deployment resources from + /// The SID of the Environment used by the Deployment resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Deployment + public static ResourceSet Read(string pathServiceSid, + string pathEnvironmentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeploymentOptions(pathServiceSid, pathEnvironmentSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Deployments. + /// + /// The SID of the Service to read the Deployment resources from + /// The SID of the Environment used by the Deployment resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathEnvironmentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDeploymentOptions(pathServiceSid, pathEnvironmentSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("deployments", response.Content); + } + + private static Request BuildFetchRequest(FetchDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Deployment. + /// + /// Fetch Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Fetch(FetchDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Deployment. + /// + /// Fetch Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task FetchAsync(FetchDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Deployment. + /// + /// The SID of the Service to fetch the Deployment resource from + /// The SID of the Environment used by the Deployment to fetch + /// The SID that identifies the Deployment resource to fetch + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Fetch(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeploymentOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Deployment. + /// + /// The SID of the Service to fetch the Deployment resource from + /// The SID of the Environment used by the Deployment to fetch + /// The SID that identifies the Deployment resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDeploymentOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateDeploymentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Deployments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Deployment. + /// + /// Create Deployment parameters + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Create(CreateDeploymentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Deployment. + /// + /// Create Deployment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task CreateAsync(CreateDeploymentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Deployment. + /// + /// The SID of the Service to create the Deployment resource under + /// The SID of the Environment for the Deployment + /// The SID of the Build for the Deployment + /// Client to make requests to Twilio + /// A single instance of Deployment + public static DeploymentResource Create(string pathServiceSid, + string pathEnvironmentSid, + string buildSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDeploymentOptions(pathServiceSid, pathEnvironmentSid) { BuildSid = buildSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Deployment. + /// + /// The SID of the Service to create the Deployment resource under + /// The SID of the Environment for the Deployment + /// The SID of the Build for the Deployment + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Deployment + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathEnvironmentSid, + string buildSid = null, + ITwilioRestClient client = null) + { + var options = new CreateDeploymentOptions(pathServiceSid, pathEnvironmentSid) { BuildSid = buildSid }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DeploymentResource object + /// + /// Raw JSON string + /// DeploymentResource object represented by the provided JSON + public static DeploymentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Deployment resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Deployment resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Deployment resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Environment for the Deployment + /// + [JsonProperty("environment_sid")] + public string EnvironmentSid { get; private set; } + /// + /// The SID of the Build for the deployment + /// + [JsonProperty("build_sid")] + public string BuildSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Deployment resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Deployment resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Deployment resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DeploymentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/LogOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/LogOptions.cs index d2e0c1885..2fb5e80d1 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/LogOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/LogOptions.cs @@ -9,118 +9,118 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all logs. + /// + public class ReadLogOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all logs. + /// The SID of the Service to read the Log resource from /// - public class ReadLogOptions : ReadOptions - { - /// - /// The SID of the Service to read the Log resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the environment with the Log resources to read - /// - public string PathEnvironmentSid { get; } - /// - /// The SID of the function whose invocation produced the Log resources to read - /// - public string FunctionSid { get; set; } - /// - /// The date and time after which the Log resources must have been created. - /// - public DateTime? StartDate { get; set; } - /// - /// The date and time before which the Log resource must have been created. - /// - public DateTime? EndDate { get; set; } - - /// - /// Construct a new ReadLogOptions - /// - /// The SID of the Service to read the Log resource from - /// The SID of the environment with the Log resources to read - public ReadLogOptions(string pathServiceSid, string pathEnvironmentSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FunctionSid != null) - { - p.Add(new KeyValuePair("FunctionSid", FunctionSid.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific log. + /// The SID of the environment with the Log resources to read /// - public class FetchLogOptions : IOptions - { - /// - /// The SID of the Service to fetch the Log resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the environment with the Log resource to fetch - /// - public string PathEnvironmentSid { get; } - /// - /// The SID that identifies the Log resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchLogOptions - /// - /// The SID of the Service to fetch the Log resource from - /// The SID of the environment with the Log resource to fetch - /// The SID that identifies the Log resource to fetch - public FetchLogOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathEnvironmentSid { get; } + /// + /// The SID of the function whose invocation produced the Log resources to read + /// + public string FunctionSid { get; set; } + /// + /// The date and time after which the Log resources must have been created. + /// + public DateTime? StartDate { get; set; } + /// + /// The date and time before which the Log resource must have been created. + /// + public DateTime? EndDate { get; set; } + + /// + /// Construct a new ReadLogOptions + /// + /// The SID of the Service to read the Log resource from + /// The SID of the environment with the Log resources to read + public ReadLogOptions(string pathServiceSid, string pathEnvironmentSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FunctionSid != null) + { + p.Add(new KeyValuePair("FunctionSid", FunctionSid.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific log. + /// + public class FetchLogOptions : IOptions + { + /// + /// The SID of the Service to fetch the Log resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the environment with the Log resource to fetch + /// + public string PathEnvironmentSid { get; } + /// + /// The SID that identifies the Log resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchLogOptions + /// + /// The SID of the Service to fetch the Log resource from + /// The SID of the environment with the Log resource to fetch + /// The SID that identifies the Log resource to fetch + public FetchLogOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/LogResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/LogResource.cs index 63aa3c666..2447fd87f 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/LogResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/LogResource.cs @@ -19,333 +19,333 @@ using Twilio.Types; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - - public class LogResource : Resource - { - public sealed class LevelEnum : StringEnum - { - private LevelEnum(string value) : base(value) {} - public LevelEnum() {} - public static implicit operator LevelEnum(string value) - { - return new LevelEnum(value); - } - - public static readonly LevelEnum Info = new LevelEnum("info"); - public static readonly LevelEnum Warn = new LevelEnum("warn"); - public static readonly LevelEnum Error = new LevelEnum("error"); - } - - private static Request BuildReadRequest(ReadLogOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Logs", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all logs. - /// - /// Read Log parameters - /// Client to make requests to Twilio - /// A single instance of Log - public static ResourceSet Read(ReadLogOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("logs", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all logs. - /// - /// Read Log parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Log - public static async System.Threading.Tasks.Task> ReadAsync(ReadLogOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("logs", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all logs. - /// - /// The SID of the Service to read the Log resource from - /// The SID of the environment with the Log resources to read - /// The SID of the function whose invocation produced the Log resources to read - /// The date and time after which the Log resources must have been created. - /// The date and time before which the Log resource must have been created. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Log - public static ResourceSet Read(string pathServiceSid, - string pathEnvironmentSid, - string functionSid = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLogOptions(pathServiceSid, pathEnvironmentSid){FunctionSid = functionSid, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all logs. - /// - /// The SID of the Service to read the Log resource from - /// The SID of the environment with the Log resources to read - /// The SID of the function whose invocation produced the Log resources to read - /// The date and time after which the Log resources must have been created. - /// The date and time before which the Log resource must have been created. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Log - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathEnvironmentSid, - string functionSid = null, - DateTime? startDate = null, - DateTime? endDate = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadLogOptions(pathServiceSid, pathEnvironmentSid){FunctionSid = functionSid, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("logs", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("logs", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("logs", response.Content); - } - - private static Request BuildFetchRequest(FetchLogOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Logs/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific log. - /// - /// Fetch Log parameters - /// Client to make requests to Twilio - /// A single instance of Log - public static LogResource Fetch(FetchLogOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific log. - /// - /// Fetch Log parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Log - public static async System.Threading.Tasks.Task FetchAsync(FetchLogOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific log. - /// - /// The SID of the Service to fetch the Log resource from - /// The SID of the environment with the Log resource to fetch - /// The SID that identifies the Log resource to fetch - /// Client to make requests to Twilio - /// A single instance of Log - public static LogResource Fetch(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchLogOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific log. - /// - /// The SID of the Service to fetch the Log resource from - /// The SID of the environment with the Log resource to fetch - /// The SID that identifies the Log resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Log - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchLogOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a LogResource object - /// - /// Raw JSON string - /// LogResource object represented by the provided JSON - public static LogResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Log resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Log resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Log resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the environment in which the log occurred - /// - [JsonProperty("environment_sid")] - public string EnvironmentSid { get; private set; } - /// - /// The SID of the build that corresponds to the log - /// - [JsonProperty("build_sid")] - public string BuildSid { get; private set; } - /// - /// The SID of the deployment that corresponds to the log - /// - [JsonProperty("deployment_sid")] - public string DeploymentSid { get; private set; } - /// - /// The SID of the function whose invocation produced the log - /// - [JsonProperty("function_sid")] - public string FunctionSid { get; private set; } - /// - /// The SID of the request associated with the log - /// - [JsonProperty("request_sid")] - public string RequestSid { get; private set; } - /// - /// The log level - /// - [JsonProperty("level")] - [JsonConverter(typeof(StringEnumConverter))] - public LogResource.LevelEnum Level { get; private set; } - /// - /// The log message - /// - [JsonProperty("message")] - public string Message { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Log resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Log resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private LogResource() - { - - } - } +{ + + public class LogResource : Resource + { + public sealed class LevelEnum : StringEnum + { + private LevelEnum(string value) : base(value) { } + public LevelEnum() { } + public static implicit operator LevelEnum(string value) + { + return new LevelEnum(value); + } + + public static readonly LevelEnum Info = new LevelEnum("info"); + public static readonly LevelEnum Warn = new LevelEnum("warn"); + public static readonly LevelEnum Error = new LevelEnum("error"); + } + + private static Request BuildReadRequest(ReadLogOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Logs", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all logs. + /// + /// Read Log parameters + /// Client to make requests to Twilio + /// A single instance of Log + public static ResourceSet Read(ReadLogOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("logs", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all logs. + /// + /// Read Log parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Log + public static async System.Threading.Tasks.Task> ReadAsync(ReadLogOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("logs", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all logs. + /// + /// The SID of the Service to read the Log resource from + /// The SID of the environment with the Log resources to read + /// The SID of the function whose invocation produced the Log resources to read + /// The date and time after which the Log resources must have been created. + /// The date and time before which the Log resource must have been created. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Log + public static ResourceSet Read(string pathServiceSid, + string pathEnvironmentSid, + string functionSid = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLogOptions(pathServiceSid, pathEnvironmentSid) { FunctionSid = functionSid, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all logs. + /// + /// The SID of the Service to read the Log resource from + /// The SID of the environment with the Log resources to read + /// The SID of the function whose invocation produced the Log resources to read + /// The date and time after which the Log resources must have been created. + /// The date and time before which the Log resource must have been created. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Log + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathEnvironmentSid, + string functionSid = null, + DateTime? startDate = null, + DateTime? endDate = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadLogOptions(pathServiceSid, pathEnvironmentSid) { FunctionSid = functionSid, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("logs", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("logs", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("logs", response.Content); + } + + private static Request BuildFetchRequest(FetchLogOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Logs/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific log. + /// + /// Fetch Log parameters + /// Client to make requests to Twilio + /// A single instance of Log + public static LogResource Fetch(FetchLogOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific log. + /// + /// Fetch Log parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Log + public static async System.Threading.Tasks.Task FetchAsync(FetchLogOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific log. + /// + /// The SID of the Service to fetch the Log resource from + /// The SID of the environment with the Log resource to fetch + /// The SID that identifies the Log resource to fetch + /// Client to make requests to Twilio + /// A single instance of Log + public static LogResource Fetch(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchLogOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific log. + /// + /// The SID of the Service to fetch the Log resource from + /// The SID of the environment with the Log resource to fetch + /// The SID that identifies the Log resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Log + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchLogOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a LogResource object + /// + /// Raw JSON string + /// LogResource object represented by the provided JSON + public static LogResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Log resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Log resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Log resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the environment in which the log occurred + /// + [JsonProperty("environment_sid")] + public string EnvironmentSid { get; private set; } + /// + /// The SID of the build that corresponds to the log + /// + [JsonProperty("build_sid")] + public string BuildSid { get; private set; } + /// + /// The SID of the deployment that corresponds to the log + /// + [JsonProperty("deployment_sid")] + public string DeploymentSid { get; private set; } + /// + /// The SID of the function whose invocation produced the log + /// + [JsonProperty("function_sid")] + public string FunctionSid { get; private set; } + /// + /// The SID of the request associated with the log + /// + [JsonProperty("request_sid")] + public string RequestSid { get; private set; } + /// + /// The log level + /// + [JsonProperty("level")] + [JsonConverter(typeof(StringEnumConverter))] + public LogResource.LevelEnum Level { get; private set; } + /// + /// The log message + /// + [JsonProperty("message")] + public string Message { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Log resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Log resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private LogResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableOptions.cs index f788ad778..c8ab6ae43 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableOptions.cs @@ -9,254 +9,254 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Variables. + /// + public class ReadVariableOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Variables. + /// The SID of the Service to read the Variable resources from /// - public class ReadVariableOptions : ReadOptions - { - /// - /// The SID of the Service to read the Variable resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment with the Variable resources to read - /// - public string PathEnvironmentSid { get; } - - /// - /// Construct a new ReadVariableOptions - /// - /// The SID of the Service to read the Variable resources from - /// The SID of the Environment with the Variable resources to read - public ReadVariableOptions(string pathServiceSid, string pathEnvironmentSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Variable. + /// The SID of the Environment with the Variable resources to read /// - public class FetchVariableOptions : IOptions - { - /// - /// The SID of the Service to fetch the Variable resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment with the Variable resource to fetch - /// - public string PathEnvironmentSid { get; } - /// - /// The SID of the Variable resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchVariableOptions - /// - /// The SID of the Service to fetch the Variable resource from - /// The SID of the Environment with the Variable resource to fetch - /// The SID of the Variable resource to fetch - public FetchVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathEnvironmentSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Variable. + /// Construct a new ReadVariableOptions /// - public class CreateVariableOptions : IOptions - { - /// - /// The SID of the Service to create the Variable resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment in which the Variable exists - /// - public string PathEnvironmentSid { get; } - /// - /// A string by which the Variable resource can be referenced - /// - public string Key { get; } - /// - /// A string that contains the actual value of the Variable - /// - public string Value { get; } - - /// - /// Construct a new CreateVariableOptions - /// - /// The SID of the Service to create the Variable resource under - /// The SID of the Environment in which the Variable exists - /// A string by which the Variable resource can be referenced - /// A string that contains the actual value of the Variable - public CreateVariableOptions(string pathServiceSid, string pathEnvironmentSid, string key, string value) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - Key = key; - Value = value; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Key != null) - { - p.Add(new KeyValuePair("Key", Key)); - } - - if (Value != null) - { - p.Add(new KeyValuePair("Value", Value)); - } - - return p; - } - } - + /// The SID of the Service to read the Variable resources from + /// The SID of the Environment with the Variable resources to read + public ReadVariableOptions(string pathServiceSid, string pathEnvironmentSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Variable. + /// Generate the necessary parameters /// - public class UpdateVariableOptions : IOptions - { - /// - /// The SID of the Service to update the Variable resource under - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment with the Variable resource to update - /// - public string PathEnvironmentSid { get; } - /// - /// The SID of the Variable resource to update - /// - public string PathSid { get; } - /// - /// A string by which the Variable resource can be referenced - /// - public string Key { get; set; } - /// - /// A string that contains the actual value of the Variable - /// - public string Value { get; set; } - - /// - /// Construct a new UpdateVariableOptions - /// - /// The SID of the Service to update the Variable resource under - /// The SID of the Environment with the Variable resource to update - /// The SID of the Variable resource to update - public UpdateVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Key != null) - { - p.Add(new KeyValuePair("Key", Key)); - } - - if (Value != null) - { - p.Add(new KeyValuePair("Value", Value)); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Variable. + /// + public class FetchVariableOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Variable. + /// The SID of the Service to fetch the Variable resource from /// - public class DeleteVariableOptions : IOptions - { - /// - /// The SID of the Service to delete the Variable resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment with the Variables to delete - /// - public string PathEnvironmentSid { get; } - /// - /// The SID of the Variable resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteVariableOptions - /// - /// The SID of the Service to delete the Variable resource from - /// The SID of the Environment with the Variables to delete - /// The SID of the Variable resource to delete - public DeleteVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathEnvironmentSid = pathEnvironmentSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Environment with the Variable resource to fetch + /// + public string PathEnvironmentSid { get; } + /// + /// The SID of the Variable resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchVariableOptions + /// + /// The SID of the Service to fetch the Variable resource from + /// The SID of the Environment with the Variable resource to fetch + /// The SID of the Variable resource to fetch + public FetchVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Variable. + /// + public class CreateVariableOptions : IOptions + { + /// + /// The SID of the Service to create the Variable resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment in which the Variable exists + /// + public string PathEnvironmentSid { get; } + /// + /// A string by which the Variable resource can be referenced + /// + public string Key { get; } + /// + /// A string that contains the actual value of the Variable + /// + public string Value { get; } + + /// + /// Construct a new CreateVariableOptions + /// + /// The SID of the Service to create the Variable resource under + /// The SID of the Environment in which the Variable exists + /// A string by which the Variable resource can be referenced + /// A string that contains the actual value of the Variable + public CreateVariableOptions(string pathServiceSid, string pathEnvironmentSid, string key, string value) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + Key = key; + Value = value; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Key != null) + { + p.Add(new KeyValuePair("Key", Key)); + } + + if (Value != null) + { + p.Add(new KeyValuePair("Value", Value)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Variable. + /// + public class UpdateVariableOptions : IOptions + { + /// + /// The SID of the Service to update the Variable resource under + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment with the Variable resource to update + /// + public string PathEnvironmentSid { get; } + /// + /// The SID of the Variable resource to update + /// + public string PathSid { get; } + /// + /// A string by which the Variable resource can be referenced + /// + public string Key { get; set; } + /// + /// A string that contains the actual value of the Variable + /// + public string Value { get; set; } + + /// + /// Construct a new UpdateVariableOptions + /// + /// The SID of the Service to update the Variable resource under + /// The SID of the Environment with the Variable resource to update + /// The SID of the Variable resource to update + public UpdateVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Key != null) + { + p.Add(new KeyValuePair("Key", Key)); + } + + if (Value != null) + { + p.Add(new KeyValuePair("Value", Value)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Variable. + /// + public class DeleteVariableOptions : IOptions + { + /// + /// The SID of the Service to delete the Variable resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment with the Variables to delete + /// + public string PathEnvironmentSid { get; } + /// + /// The SID of the Variable resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteVariableOptions + /// + /// The SID of the Service to delete the Variable resource from + /// The SID of the Environment with the Variables to delete + /// The SID of the Variable resource to delete + public DeleteVariableOptions(string pathServiceSid, string pathEnvironmentSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathEnvironmentSid = pathEnvironmentSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableResource.cs index 5a6d09e2c..9dc75463e 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Environment/VariableResource.cs @@ -18,531 +18,531 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service.Environment -{ - - public class VariableResource : Resource - { - private static Request BuildReadRequest(ReadVariableOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Variables. - /// - /// Read Variable parameters - /// Client to make requests to Twilio - /// A single instance of Variable - public static ResourceSet Read(ReadVariableOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("variables", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Variables. - /// - /// Read Variable parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task> ReadAsync(ReadVariableOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("variables", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Variables. - /// - /// The SID of the Service to read the Variable resources from - /// The SID of the Environment with the Variable resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Variable - public static ResourceSet Read(string pathServiceSid, - string pathEnvironmentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVariableOptions(pathServiceSid, pathEnvironmentSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Variables. - /// - /// The SID of the Service to read the Variable resources from - /// The SID of the Environment with the Variable resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathEnvironmentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVariableOptions(pathServiceSid, pathEnvironmentSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("variables", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("variables", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("variables", response.Content); - } - - private static Request BuildFetchRequest(FetchVariableOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Variable. - /// - /// Fetch Variable parameters - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Fetch(FetchVariableOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Variable. - /// - /// Fetch Variable parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task FetchAsync(FetchVariableOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Variable. - /// - /// The SID of the Service to fetch the Variable resource from - /// The SID of the Environment with the Variable resource to fetch - /// The SID of the Variable resource to fetch - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Fetch(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Variable. - /// - /// The SID of the Service to fetch the Variable resource from - /// The SID of the Environment with the Variable resource to fetch - /// The SID of the Variable resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateVariableOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Variable. - /// - /// Create Variable parameters - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Create(CreateVariableOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Variable. - /// - /// Create Variable parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task CreateAsync(CreateVariableOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Variable. - /// - /// The SID of the Service to create the Variable resource under - /// The SID of the Environment in which the Variable exists - /// A string by which the Variable resource can be referenced - /// A string that contains the actual value of the Variable - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Create(string pathServiceSid, - string pathEnvironmentSid, - string key, - string value, - ITwilioRestClient client = null) - { - var options = new CreateVariableOptions(pathServiceSid, pathEnvironmentSid, key, value); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Variable. - /// - /// The SID of the Service to create the Variable resource under - /// The SID of the Environment in which the Variable exists - /// A string by which the Variable resource can be referenced - /// A string that contains the actual value of the Variable - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathEnvironmentSid, - string key, - string value, - ITwilioRestClient client = null) - { - var options = new CreateVariableOptions(pathServiceSid, pathEnvironmentSid, key, value); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateVariableOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Variable. - /// - /// Update Variable parameters - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Update(UpdateVariableOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Variable. - /// - /// Update Variable parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task UpdateAsync(UpdateVariableOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Variable. - /// - /// The SID of the Service to update the Variable resource under - /// The SID of the Environment with the Variable resource to update - /// The SID of the Variable resource to update - /// A string by which the Variable resource can be referenced - /// A string that contains the actual value of the Variable - /// Client to make requests to Twilio - /// A single instance of Variable - public static VariableResource Update(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - string key = null, - string value = null, - ITwilioRestClient client = null) - { - var options = new UpdateVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid){Key = key, Value = value}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Variable. - /// - /// The SID of the Service to update the Variable resource under - /// The SID of the Environment with the Variable resource to update - /// The SID of the Variable resource to update - /// A string by which the Variable resource can be referenced - /// A string that contains the actual value of the Variable - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - string key = null, - string value = null, - ITwilioRestClient client = null) - { - var options = new UpdateVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid){Key = key, Value = value}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteVariableOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Variable. - /// - /// Delete Variable parameters - /// Client to make requests to Twilio - /// A single instance of Variable - public static bool Delete(DeleteVariableOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Variable. - /// - /// Delete Variable parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task DeleteAsync(DeleteVariableOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Variable. - /// - /// The SID of the Service to delete the Variable resource from - /// The SID of the Environment with the Variables to delete - /// The SID of the Variable resource to delete - /// Client to make requests to Twilio - /// A single instance of Variable - public static bool Delete(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Variable. - /// - /// The SID of the Service to delete the Variable resource from - /// The SID of the Environment with the Variables to delete - /// The SID of the Variable resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Variable - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathEnvironmentSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a VariableResource object - /// - /// Raw JSON string - /// VariableResource object represented by the provided JSON - public static VariableResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Variable resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Variable resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Variable resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Environment in which the Variable exists - /// - [JsonProperty("environment_sid")] - public string EnvironmentSid { get; private set; } - /// - /// A string by which the Variable resource can be referenced - /// - [JsonProperty("key")] - public string Key { get; private set; } - /// - /// A string that contains the actual value of the Variable - /// - [JsonProperty("value")] - public string Value { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Variable resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Variable resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Variable resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private VariableResource() - { - - } - } +{ + + public class VariableResource : Resource + { + private static Request BuildReadRequest(ReadVariableOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Variables. + /// + /// Read Variable parameters + /// Client to make requests to Twilio + /// A single instance of Variable + public static ResourceSet Read(ReadVariableOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("variables", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Variables. + /// + /// Read Variable parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task> ReadAsync(ReadVariableOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("variables", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Variables. + /// + /// The SID of the Service to read the Variable resources from + /// The SID of the Environment with the Variable resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Variable + public static ResourceSet Read(string pathServiceSid, + string pathEnvironmentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVariableOptions(pathServiceSid, pathEnvironmentSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Variables. + /// + /// The SID of the Service to read the Variable resources from + /// The SID of the Environment with the Variable resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathEnvironmentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVariableOptions(pathServiceSid, pathEnvironmentSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("variables", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("variables", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("variables", response.Content); + } + + private static Request BuildFetchRequest(FetchVariableOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Variable. + /// + /// Fetch Variable parameters + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Fetch(FetchVariableOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Variable. + /// + /// Fetch Variable parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task FetchAsync(FetchVariableOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Variable. + /// + /// The SID of the Service to fetch the Variable resource from + /// The SID of the Environment with the Variable resource to fetch + /// The SID of the Variable resource to fetch + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Fetch(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Variable. + /// + /// The SID of the Service to fetch the Variable resource from + /// The SID of the Environment with the Variable resource to fetch + /// The SID of the Variable resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateVariableOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Variable. + /// + /// Create Variable parameters + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Create(CreateVariableOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Variable. + /// + /// Create Variable parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task CreateAsync(CreateVariableOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Variable. + /// + /// The SID of the Service to create the Variable resource under + /// The SID of the Environment in which the Variable exists + /// A string by which the Variable resource can be referenced + /// A string that contains the actual value of the Variable + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Create(string pathServiceSid, + string pathEnvironmentSid, + string key, + string value, + ITwilioRestClient client = null) + { + var options = new CreateVariableOptions(pathServiceSid, pathEnvironmentSid, key, value); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Variable. + /// + /// The SID of the Service to create the Variable resource under + /// The SID of the Environment in which the Variable exists + /// A string by which the Variable resource can be referenced + /// A string that contains the actual value of the Variable + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathEnvironmentSid, + string key, + string value, + ITwilioRestClient client = null) + { + var options = new CreateVariableOptions(pathServiceSid, pathEnvironmentSid, key, value); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateVariableOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Variable. + /// + /// Update Variable parameters + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Update(UpdateVariableOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Variable. + /// + /// Update Variable parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task UpdateAsync(UpdateVariableOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Variable. + /// + /// The SID of the Service to update the Variable resource under + /// The SID of the Environment with the Variable resource to update + /// The SID of the Variable resource to update + /// A string by which the Variable resource can be referenced + /// A string that contains the actual value of the Variable + /// Client to make requests to Twilio + /// A single instance of Variable + public static VariableResource Update(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + string key = null, + string value = null, + ITwilioRestClient client = null) + { + var options = new UpdateVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid) { Key = key, Value = value }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Variable. + /// + /// The SID of the Service to update the Variable resource under + /// The SID of the Environment with the Variable resource to update + /// The SID of the Variable resource to update + /// A string by which the Variable resource can be referenced + /// A string that contains the actual value of the Variable + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + string key = null, + string value = null, + ITwilioRestClient client = null) + { + var options = new UpdateVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid) { Key = key, Value = value }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteVariableOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathEnvironmentSid + "/Variables/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Variable. + /// + /// Delete Variable parameters + /// Client to make requests to Twilio + /// A single instance of Variable + public static bool Delete(DeleteVariableOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Variable. + /// + /// Delete Variable parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task DeleteAsync(DeleteVariableOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Variable. + /// + /// The SID of the Service to delete the Variable resource from + /// The SID of the Environment with the Variables to delete + /// The SID of the Variable resource to delete + /// Client to make requests to Twilio + /// A single instance of Variable + public static bool Delete(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Variable. + /// + /// The SID of the Service to delete the Variable resource from + /// The SID of the Environment with the Variables to delete + /// The SID of the Variable resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Variable + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathEnvironmentSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteVariableOptions(pathServiceSid, pathEnvironmentSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a VariableResource object + /// + /// Raw JSON string + /// VariableResource object represented by the provided JSON + public static VariableResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Variable resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Variable resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Variable resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Environment in which the Variable exists + /// + [JsonProperty("environment_sid")] + public string EnvironmentSid { get; private set; } + /// + /// A string by which the Variable resource can be referenced + /// + [JsonProperty("key")] + public string Key { get; private set; } + /// + /// A string that contains the actual value of the Variable + /// + [JsonProperty("value")] + public string Value { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Variable resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Variable resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Variable resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private VariableResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/EnvironmentOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/EnvironmentOptions.cs index 562db0e47..51de80a25 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/EnvironmentOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/EnvironmentOptions.cs @@ -9,167 +9,167 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all environments. + /// + public class ReadEnvironmentOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all environments. + /// The SID of the Service to read the Environment resources from /// - public class ReadEnvironmentOptions : ReadOptions - { - /// - /// The SID of the Service to read the Environment resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadEnvironmentOptions - /// - /// The SID of the Service to read the Environment resources from - public ReadEnvironmentOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific environment. - /// - public class FetchEnvironmentOptions : IOptions - { - /// - /// The SID of the Service to fetch the Environment resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Environment resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEnvironmentOptions - /// - /// The SID of the Service to fetch the Environment resource from - /// The SID of the Environment resource to fetch - public FetchEnvironmentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadEnvironmentOptions + /// + /// The SID of the Service to read the Environment resources from + public ReadEnvironmentOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new environment. - /// - public class CreateEnvironmentOptions : IOptions - { - /// - /// The SID of the Service to create the Environment resource under - /// - public string PathServiceSid { get; } - /// - /// A user-defined string that uniquely identifies the Environment resource - /// - public string UniqueName { get; } - /// - /// A URL-friendly name that represents the environment - /// - public string DomainSuffix { get; set; } - - /// - /// Construct a new CreateEnvironmentOptions - /// - /// The SID of the Service to create the Environment resource under - /// A user-defined string that uniquely identifies the Environment resource - public CreateEnvironmentOptions(string pathServiceSid, string uniqueName) - { - PathServiceSid = pathServiceSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DomainSuffix != null) - { - p.Add(new KeyValuePair("DomainSuffix", DomainSuffix)); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific environment. + /// + public class FetchEnvironmentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific environment. - /// - public class DeleteEnvironmentOptions : IOptions - { - /// - /// The SID of the Service to delete the Environment resource from - /// - public string PathServiceSid { get; } - /// - /// The SID that identifies the Environment resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteEnvironmentOptions - /// - /// The SID of the Service to delete the Environment resource from - /// The SID that identifies the Environment resource to delete - public DeleteEnvironmentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Service to fetch the Environment resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Environment resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEnvironmentOptions + /// + /// The SID of the Service to fetch the Environment resource from + /// The SID of the Environment resource to fetch + public FetchEnvironmentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new environment. + /// + public class CreateEnvironmentOptions : IOptions + { + /// + /// The SID of the Service to create the Environment resource under + /// + public string PathServiceSid { get; } + /// + /// A user-defined string that uniquely identifies the Environment resource + /// + public string UniqueName { get; } + /// + /// A URL-friendly name that represents the environment + /// + public string DomainSuffix { get; set; } + + /// + /// Construct a new CreateEnvironmentOptions + /// + /// The SID of the Service to create the Environment resource under + /// A user-defined string that uniquely identifies the Environment resource + public CreateEnvironmentOptions(string pathServiceSid, string uniqueName) + { + PathServiceSid = pathServiceSid; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DomainSuffix != null) + { + p.Add(new KeyValuePair("DomainSuffix", DomainSuffix)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific environment. + /// + public class DeleteEnvironmentOptions : IOptions + { + /// + /// The SID of the Service to delete the Environment resource from + /// + public string PathServiceSid { get; } + /// + /// The SID that identifies the Environment resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteEnvironmentOptions + /// + /// The SID of the Service to delete the Environment resource from + /// The SID that identifies the Environment resource to delete + public DeleteEnvironmentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/EnvironmentResource.cs b/src/Twilio/Rest/Serverless/V1/Service/EnvironmentResource.cs index 1fdedec52..f5236784c 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/EnvironmentResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/EnvironmentResource.cs @@ -18,437 +18,437 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service -{ - - public class EnvironmentResource : Resource - { - private static Request BuildReadRequest(ReadEnvironmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all environments. - /// - /// Read Environment parameters - /// Client to make requests to Twilio - /// A single instance of Environment - public static ResourceSet Read(ReadEnvironmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("environments", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all environments. - /// - /// Read Environment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task> ReadAsync(ReadEnvironmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("environments", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all environments. - /// - /// The SID of the Service to read the Environment resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Environment - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEnvironmentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all environments. - /// - /// The SID of the Service to read the Environment resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEnvironmentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("environments", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("environments", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("environments", response.Content); - } - - private static Request BuildFetchRequest(FetchEnvironmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific environment. - /// - /// Fetch Environment parameters - /// Client to make requests to Twilio - /// A single instance of Environment - public static EnvironmentResource Fetch(FetchEnvironmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific environment. - /// - /// Fetch Environment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task FetchAsync(FetchEnvironmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific environment. - /// - /// The SID of the Service to fetch the Environment resource from - /// The SID of the Environment resource to fetch - /// Client to make requests to Twilio - /// A single instance of Environment - public static EnvironmentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEnvironmentOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific environment. - /// - /// The SID of the Service to fetch the Environment resource from - /// The SID of the Environment resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEnvironmentOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateEnvironmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new environment. - /// - /// Create Environment parameters - /// Client to make requests to Twilio - /// A single instance of Environment - public static EnvironmentResource Create(CreateEnvironmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new environment. - /// - /// Create Environment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task CreateAsync(CreateEnvironmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new environment. - /// - /// The SID of the Service to create the Environment resource under - /// A user-defined string that uniquely identifies the Environment resource - /// A URL-friendly name that represents the environment - /// Client to make requests to Twilio - /// A single instance of Environment - public static EnvironmentResource Create(string pathServiceSid, - string uniqueName, - string domainSuffix = null, - ITwilioRestClient client = null) - { - var options = new CreateEnvironmentOptions(pathServiceSid, uniqueName){DomainSuffix = domainSuffix}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new environment. - /// - /// The SID of the Service to create the Environment resource under - /// A user-defined string that uniquely identifies the Environment resource - /// A URL-friendly name that represents the environment - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName, - string domainSuffix = null, - ITwilioRestClient client = null) - { - var options = new CreateEnvironmentOptions(pathServiceSid, uniqueName){DomainSuffix = domainSuffix}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteEnvironmentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific environment. - /// - /// Delete Environment parameters - /// Client to make requests to Twilio - /// A single instance of Environment - public static bool Delete(DeleteEnvironmentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific environment. - /// - /// Delete Environment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task DeleteAsync(DeleteEnvironmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific environment. - /// - /// The SID of the Service to delete the Environment resource from - /// The SID that identifies the Environment resource to delete - /// Client to make requests to Twilio - /// A single instance of Environment - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEnvironmentOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific environment. - /// - /// The SID of the Service to delete the Environment resource from - /// The SID that identifies the Environment resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Environment - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteEnvironmentOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EnvironmentResource object - /// - /// Raw JSON string - /// EnvironmentResource object represented by the provided JSON - public static EnvironmentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Environment resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Environment resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Environment resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the build deployed in the environment - /// - [JsonProperty("build_sid")] - public string BuildSid { get; private set; } - /// - /// A user-defined string that uniquely identifies the Environment resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// A URL-friendly name that represents the environment - /// - [JsonProperty("domain_suffix")] - public string DomainSuffix { get; private set; } - /// - /// The domain name for all Functions and Assets deployed in the Environment - /// - [JsonProperty("domain_name")] - public string DomainName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Environment resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Environment resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Environment resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Environment resource's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private EnvironmentResource() - { - - } - } +{ + + public class EnvironmentResource : Resource + { + private static Request BuildReadRequest(ReadEnvironmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all environments. + /// + /// Read Environment parameters + /// Client to make requests to Twilio + /// A single instance of Environment + public static ResourceSet Read(ReadEnvironmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("environments", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all environments. + /// + /// Read Environment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task> ReadAsync(ReadEnvironmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("environments", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all environments. + /// + /// The SID of the Service to read the Environment resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Environment + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEnvironmentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all environments. + /// + /// The SID of the Service to read the Environment resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEnvironmentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("environments", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("environments", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("environments", response.Content); + } + + private static Request BuildFetchRequest(FetchEnvironmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific environment. + /// + /// Fetch Environment parameters + /// Client to make requests to Twilio + /// A single instance of Environment + public static EnvironmentResource Fetch(FetchEnvironmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific environment. + /// + /// Fetch Environment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task FetchAsync(FetchEnvironmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific environment. + /// + /// The SID of the Service to fetch the Environment resource from + /// The SID of the Environment resource to fetch + /// Client to make requests to Twilio + /// A single instance of Environment + public static EnvironmentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEnvironmentOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific environment. + /// + /// The SID of the Service to fetch the Environment resource from + /// The SID of the Environment resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEnvironmentOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateEnvironmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new environment. + /// + /// Create Environment parameters + /// Client to make requests to Twilio + /// A single instance of Environment + public static EnvironmentResource Create(CreateEnvironmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new environment. + /// + /// Create Environment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task CreateAsync(CreateEnvironmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new environment. + /// + /// The SID of the Service to create the Environment resource under + /// A user-defined string that uniquely identifies the Environment resource + /// A URL-friendly name that represents the environment + /// Client to make requests to Twilio + /// A single instance of Environment + public static EnvironmentResource Create(string pathServiceSid, + string uniqueName, + string domainSuffix = null, + ITwilioRestClient client = null) + { + var options = new CreateEnvironmentOptions(pathServiceSid, uniqueName) { DomainSuffix = domainSuffix }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new environment. + /// + /// The SID of the Service to create the Environment resource under + /// A user-defined string that uniquely identifies the Environment resource + /// A URL-friendly name that represents the environment + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName, + string domainSuffix = null, + ITwilioRestClient client = null) + { + var options = new CreateEnvironmentOptions(pathServiceSid, uniqueName) { DomainSuffix = domainSuffix }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteEnvironmentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Environments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific environment. + /// + /// Delete Environment parameters + /// Client to make requests to Twilio + /// A single instance of Environment + public static bool Delete(DeleteEnvironmentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific environment. + /// + /// Delete Environment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task DeleteAsync(DeleteEnvironmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific environment. + /// + /// The SID of the Service to delete the Environment resource from + /// The SID that identifies the Environment resource to delete + /// Client to make requests to Twilio + /// A single instance of Environment + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEnvironmentOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific environment. + /// + /// The SID of the Service to delete the Environment resource from + /// The SID that identifies the Environment resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Environment + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteEnvironmentOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EnvironmentResource object + /// + /// Raw JSON string + /// EnvironmentResource object represented by the provided JSON + public static EnvironmentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Environment resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Environment resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Environment resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the build deployed in the environment + /// + [JsonProperty("build_sid")] + public string BuildSid { get; private set; } + /// + /// A user-defined string that uniquely identifies the Environment resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// A URL-friendly name that represents the environment + /// + [JsonProperty("domain_suffix")] + public string DomainSuffix { get; private set; } + /// + /// The domain name for all Functions and Assets deployed in the Environment + /// + [JsonProperty("domain_name")] + public string DomainName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Environment resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Environment resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Environment resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Environment resource's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private EnvironmentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentOptions.cs index 5a9aceb64..dc3f47839 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentOptions.cs @@ -9,50 +9,50 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Function.FunctionVersion -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a the content of a specific Function Version resource. + /// + public class FetchFunctionVersionContentOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a the content of a specific Function Version resource. + /// The SID of the Service to fetch the Function Version content from /// - public class FetchFunctionVersionContentOptions : IOptions - { - /// - /// The SID of the Service to fetch the Function Version content from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Function that is the parent of the Function Version content to fetch - /// - public string PathFunctionSid { get; } - /// - /// The SID that identifies the Function Version content to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFunctionVersionContentOptions - /// - /// The SID of the Service to fetch the Function Version content from - /// The SID of the Function that is the parent of the Function Version content to fetch - /// - /// The SID that identifies the Function Version content to fetch - public FetchFunctionVersionContentOptions(string pathServiceSid, string pathFunctionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathFunctionSid = pathFunctionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Function that is the parent of the Function Version content to fetch + /// + public string PathFunctionSid { get; } + /// + /// The SID that identifies the Function Version content to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFunctionVersionContentOptions + /// + /// The SID of the Service to fetch the Function Version content from + /// The SID of the Function that is the parent of the Function Version content to fetch + /// + /// The SID that identifies the Function Version content to fetch + public FetchFunctionVersionContentOptions(string pathServiceSid, string pathFunctionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathFunctionSid = pathFunctionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentResource.cs index f359448da..3033d30f4 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersion/FunctionVersionContentResource.cs @@ -18,142 +18,142 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service.Function.FunctionVersion -{ - - public class FunctionVersionContentResource : Resource - { - private static Request BuildFetchRequest(FetchFunctionVersionContentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions/" + options.PathSid + "/Content", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a the content of a specific Function Version resource. - /// - /// Fetch FunctionVersionContent parameters - /// Client to make requests to Twilio - /// A single instance of FunctionVersionContent - public static FunctionVersionContentResource Fetch(FetchFunctionVersionContentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a the content of a specific Function Version resource. - /// - /// Fetch FunctionVersionContent parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersionContent - public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionVersionContentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a the content of a specific Function Version resource. - /// - /// The SID of the Service to fetch the Function Version content from - /// The SID of the Function that is the parent of the Function Version content to fetch - /// - /// The SID that identifies the Function Version content to fetch - /// Client to make requests to Twilio - /// A single instance of FunctionVersionContent - public static FunctionVersionContentResource Fetch(string pathServiceSid, - string pathFunctionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFunctionVersionContentOptions(pathServiceSid, pathFunctionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a the content of a specific Function Version resource. - /// - /// The SID of the Service to fetch the Function Version content from - /// The SID of the Function that is the parent of the Function Version content to fetch - /// - /// The SID that identifies the Function Version content to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersionContent - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathFunctionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFunctionVersionContentOptions(pathServiceSid, pathFunctionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FunctionVersionContentResource object - /// - /// Raw JSON string - /// FunctionVersionContentResource object represented by the provided JSON - public static FunctionVersionContentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Function Version resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Function Version resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Function Version resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Function that is the parent of the Function Version - /// - [JsonProperty("function_sid")] - public string FunctionSid { get; private set; } - /// - /// The content of the Function Version resource - /// - [JsonProperty("content")] - public string Content { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FunctionVersionContentResource() - { - - } - } +{ + + public class FunctionVersionContentResource : Resource + { + private static Request BuildFetchRequest(FetchFunctionVersionContentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions/" + options.PathSid + "/Content", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a the content of a specific Function Version resource. + /// + /// Fetch FunctionVersionContent parameters + /// Client to make requests to Twilio + /// A single instance of FunctionVersionContent + public static FunctionVersionContentResource Fetch(FetchFunctionVersionContentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a the content of a specific Function Version resource. + /// + /// Fetch FunctionVersionContent parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersionContent + public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionVersionContentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a the content of a specific Function Version resource. + /// + /// The SID of the Service to fetch the Function Version content from + /// The SID of the Function that is the parent of the Function Version content to fetch + /// + /// The SID that identifies the Function Version content to fetch + /// Client to make requests to Twilio + /// A single instance of FunctionVersionContent + public static FunctionVersionContentResource Fetch(string pathServiceSid, + string pathFunctionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFunctionVersionContentOptions(pathServiceSid, pathFunctionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a the content of a specific Function Version resource. + /// + /// The SID of the Service to fetch the Function Version content from + /// The SID of the Function that is the parent of the Function Version content to fetch + /// + /// The SID that identifies the Function Version content to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersionContent + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathFunctionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFunctionVersionContentOptions(pathServiceSid, pathFunctionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FunctionVersionContentResource object + /// + /// Raw JSON string + /// FunctionVersionContentResource object represented by the provided JSON + public static FunctionVersionContentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Function Version resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Function Version resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Function Version resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Function that is the parent of the Function Version + /// + [JsonProperty("function_sid")] + public string FunctionSid { get; private set; } + /// + /// The content of the Function Version resource + /// + [JsonProperty("content")] + public string Content { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FunctionVersionContentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionOptions.cs index 92b9373f8..fc85df21d 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionOptions.cs @@ -9,93 +9,93 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service.Function -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Function Version resources. + /// + public class ReadFunctionVersionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Function Version resources. + /// The SID of the Service to read the Function Version resources from /// - public class ReadFunctionVersionOptions : ReadOptions - { - /// - /// The SID of the Service to read the Function Version resources from - /// - public string PathServiceSid { get; } - /// - /// The SID of the function that is the parent of the Function Version resources to read - /// - public string PathFunctionSid { get; } - - /// - /// Construct a new ReadFunctionVersionOptions - /// - /// The SID of the Service to read the Function Version resources from - /// The SID of the function that is the parent of the Function Version resources to read - /// - public ReadFunctionVersionOptions(string pathServiceSid, string pathFunctionSid) - { - PathServiceSid = pathServiceSid; - PathFunctionSid = pathFunctionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Function Version resource. + /// The SID of the function that is the parent of the Function Version resources to read /// - public class FetchFunctionVersionOptions : IOptions - { - /// - /// The SID of the Service to fetch the Function Version resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the function that is the parent of the Function Version resource to fetch - /// - public string PathFunctionSid { get; } - /// - /// The SID that identifies the Function Version resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFunctionVersionOptions - /// - /// The SID of the Service to fetch the Function Version resource from - /// The SID of the function that is the parent of the Function Version resource to fetch - /// - /// The SID that identifies the Function Version resource to fetch - public FetchFunctionVersionOptions(string pathServiceSid, string pathFunctionSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathFunctionSid = pathFunctionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFunctionSid { get; } + + /// + /// Construct a new ReadFunctionVersionOptions + /// + /// The SID of the Service to read the Function Version resources from + /// The SID of the function that is the parent of the Function Version resources to read + /// + public ReadFunctionVersionOptions(string pathServiceSid, string pathFunctionSid) + { + PathServiceSid = pathServiceSid; + PathFunctionSid = pathFunctionSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Function Version resource. + /// + public class FetchFunctionVersionOptions : IOptions + { + /// + /// The SID of the Service to fetch the Function Version resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the function that is the parent of the Function Version resource to fetch + /// + public string PathFunctionSid { get; } + /// + /// The SID that identifies the Function Version resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFunctionVersionOptions + /// + /// The SID of the Service to fetch the Function Version resource from + /// The SID of the function that is the parent of the Function Version resource to fetch + /// + /// The SID that identifies the Function Version resource to fetch + public FetchFunctionVersionOptions(string pathServiceSid, string pathFunctionSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathFunctionSid = pathFunctionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionResource.cs b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionResource.cs index cefcd3fc3..9ea23e939 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/Function/FunctionVersionResource.cs @@ -19,312 +19,312 @@ using Twilio.Types; namespace Twilio.Rest.Serverless.V1.Service.Function -{ - - public class FunctionVersionResource : Resource - { - public sealed class VisibilityEnum : StringEnum - { - private VisibilityEnum(string value) : base(value) {} - public VisibilityEnum() {} - public static implicit operator VisibilityEnum(string value) - { - return new VisibilityEnum(value); - } - - public static readonly VisibilityEnum Public = new VisibilityEnum("public"); - public static readonly VisibilityEnum Private = new VisibilityEnum("private"); - public static readonly VisibilityEnum Protected = new VisibilityEnum("protected"); - } - - private static Request BuildReadRequest(ReadFunctionVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Function Version resources. - /// - /// Read FunctionVersion parameters - /// Client to make requests to Twilio - /// A single instance of FunctionVersion - public static ResourceSet Read(ReadFunctionVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("function_versions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Function Version resources. - /// - /// Read FunctionVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersion - public static async System.Threading.Tasks.Task> ReadAsync(ReadFunctionVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("function_versions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Function Version resources. - /// - /// The SID of the Service to read the Function Version resources from - /// The SID of the function that is the parent of the Function Version resources to read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FunctionVersion - public static ResourceSet Read(string pathServiceSid, - string pathFunctionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFunctionVersionOptions(pathServiceSid, pathFunctionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Function Version resources. - /// - /// The SID of the Service to read the Function Version resources from - /// The SID of the function that is the parent of the Function Version resources to read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersion - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathFunctionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFunctionVersionOptions(pathServiceSid, pathFunctionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("function_versions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("function_versions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("function_versions", response.Content); - } - - private static Request BuildFetchRequest(FetchFunctionVersionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Function Version resource. - /// - /// Fetch FunctionVersion parameters - /// Client to make requests to Twilio - /// A single instance of FunctionVersion - public static FunctionVersionResource Fetch(FetchFunctionVersionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Function Version resource. - /// - /// Fetch FunctionVersion parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersion - public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionVersionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Function Version resource. - /// - /// The SID of the Service to fetch the Function Version resource from - /// The SID of the function that is the parent of the Function Version resource to fetch - /// - /// The SID that identifies the Function Version resource to fetch - /// Client to make requests to Twilio - /// A single instance of FunctionVersion - public static FunctionVersionResource Fetch(string pathServiceSid, - string pathFunctionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFunctionVersionOptions(pathServiceSid, pathFunctionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Function Version resource. - /// - /// The SID of the Service to fetch the Function Version resource from - /// The SID of the function that is the parent of the Function Version resource to fetch - /// - /// The SID that identifies the Function Version resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FunctionVersion - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathFunctionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFunctionVersionOptions(pathServiceSid, pathFunctionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FunctionVersionResource object - /// - /// Raw JSON string - /// FunctionVersionResource object represented by the provided JSON - public static FunctionVersionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Function Version resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Function Version resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Function Version resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Function resource that is the parent of the Function Version resource - /// - [JsonProperty("function_sid")] - public string FunctionSid { get; private set; } - /// - /// The URL-friendly string by which the Function Version resource can be referenced - /// - [JsonProperty("path")] - public string Path { get; private set; } - /// - /// The access control that determines how the Function Version resource can be accessed - /// - [JsonProperty("visibility")] - [JsonConverter(typeof(StringEnumConverter))] - public FunctionVersionResource.VisibilityEnum Visibility { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Function Version resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Function Version resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private FunctionVersionResource() - { - - } - } +{ + + public class FunctionVersionResource : Resource + { + public sealed class VisibilityEnum : StringEnum + { + private VisibilityEnum(string value) : base(value) { } + public VisibilityEnum() { } + public static implicit operator VisibilityEnum(string value) + { + return new VisibilityEnum(value); + } + + public static readonly VisibilityEnum Public = new VisibilityEnum("public"); + public static readonly VisibilityEnum Private = new VisibilityEnum("private"); + public static readonly VisibilityEnum Protected = new VisibilityEnum("protected"); + } + + private static Request BuildReadRequest(ReadFunctionVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Function Version resources. + /// + /// Read FunctionVersion parameters + /// Client to make requests to Twilio + /// A single instance of FunctionVersion + public static ResourceSet Read(ReadFunctionVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("function_versions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Function Version resources. + /// + /// Read FunctionVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersion + public static async System.Threading.Tasks.Task> ReadAsync(ReadFunctionVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("function_versions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Function Version resources. + /// + /// The SID of the Service to read the Function Version resources from + /// The SID of the function that is the parent of the Function Version resources to read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FunctionVersion + public static ResourceSet Read(string pathServiceSid, + string pathFunctionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFunctionVersionOptions(pathServiceSid, pathFunctionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Function Version resources. + /// + /// The SID of the Service to read the Function Version resources from + /// The SID of the function that is the parent of the Function Version resources to read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersion + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathFunctionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFunctionVersionOptions(pathServiceSid, pathFunctionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("function_versions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("function_versions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("function_versions", response.Content); + } + + private static Request BuildFetchRequest(FetchFunctionVersionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathFunctionSid + "/Versions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Function Version resource. + /// + /// Fetch FunctionVersion parameters + /// Client to make requests to Twilio + /// A single instance of FunctionVersion + public static FunctionVersionResource Fetch(FetchFunctionVersionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Function Version resource. + /// + /// Fetch FunctionVersion parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersion + public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionVersionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Function Version resource. + /// + /// The SID of the Service to fetch the Function Version resource from + /// The SID of the function that is the parent of the Function Version resource to fetch + /// + /// The SID that identifies the Function Version resource to fetch + /// Client to make requests to Twilio + /// A single instance of FunctionVersion + public static FunctionVersionResource Fetch(string pathServiceSid, + string pathFunctionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFunctionVersionOptions(pathServiceSid, pathFunctionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Function Version resource. + /// + /// The SID of the Service to fetch the Function Version resource from + /// The SID of the function that is the parent of the Function Version resource to fetch + /// + /// The SID that identifies the Function Version resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FunctionVersion + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathFunctionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFunctionVersionOptions(pathServiceSid, pathFunctionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FunctionVersionResource object + /// + /// Raw JSON string + /// FunctionVersionResource object represented by the provided JSON + public static FunctionVersionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Function Version resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Function Version resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Function Version resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Function resource that is the parent of the Function Version resource + /// + [JsonProperty("function_sid")] + public string FunctionSid { get; private set; } + /// + /// The URL-friendly string by which the Function Version resource can be referenced + /// + [JsonProperty("path")] + public string Path { get; private set; } + /// + /// The access control that determines how the Function Version resource can be accessed + /// + [JsonProperty("visibility")] + [JsonConverter(typeof(StringEnumConverter))] + public FunctionVersionResource.VisibilityEnum Visibility { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Function Version resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Function Version resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private FunctionVersionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/FunctionOptions.cs b/src/Twilio/Rest/Serverless/V1/Service/FunctionOptions.cs index 72271ad89..e371d736b 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/FunctionOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/FunctionOptions.cs @@ -9,206 +9,206 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Functions. + /// + public class ReadFunctionOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Functions. + /// The SID of the Service to read the Function resources from /// - public class ReadFunctionOptions : ReadOptions - { - /// - /// The SID of the Service to read the Function resources from - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadFunctionOptions - /// - /// The SID of the Service to read the Function resources from - public ReadFunctionOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Function resource. - /// - public class FetchFunctionOptions : IOptions - { - /// - /// The SID of the Service to fetch the Function resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Function resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFunctionOptions - /// - /// The SID of the Service to fetch the Function resource from - /// The SID of the Function resource to fetch - public FetchFunctionOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadFunctionOptions + /// + /// The SID of the Service to read the Function resources from + public ReadFunctionOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a Function resource. - /// - public class DeleteFunctionOptions : IOptions - { - /// - /// The SID of the Service to delete the Function resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Function resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFunctionOptions - /// - /// The SID of the Service to delete the Function resource from - /// The SID of the Function resource to delete - public DeleteFunctionOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Function resource. + /// + public class FetchFunctionOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Function resource. - /// - public class CreateFunctionOptions : IOptions - { - /// - /// The SID of the Service to create the Function resource under - /// - public string PathServiceSid { get; } - /// - /// A string to describe the Function resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new CreateFunctionOptions - /// - /// The SID of the Service to create the Function resource under - /// A string to describe the Function resource - public CreateFunctionOptions(string pathServiceSid, string friendlyName) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The SID of the Service to fetch the Function resource from + /// + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Function resource. - /// - public class UpdateFunctionOptions : IOptions - { - /// - /// The SID of the Service to update the Function resource from - /// - public string PathServiceSid { get; } - /// - /// The SID of the Function resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the Function resource - /// - public string FriendlyName { get; } - - /// - /// Construct a new UpdateFunctionOptions - /// - /// The SID of the Service to update the Function resource from - /// The SID of the Function resource to update - /// A string to describe the Function resource - public UpdateFunctionOptions(string pathServiceSid, string pathSid, string friendlyName) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } + /// The SID of the Function resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFunctionOptions + /// + /// The SID of the Service to fetch the Function resource from + /// The SID of the Function resource to fetch + public FetchFunctionOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a Function resource. + /// + public class DeleteFunctionOptions : IOptions + { + /// + /// The SID of the Service to delete the Function resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Function resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFunctionOptions + /// + /// The SID of the Service to delete the Function resource from + /// The SID of the Function resource to delete + public DeleteFunctionOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Function resource. + /// + public class CreateFunctionOptions : IOptions + { + /// + /// The SID of the Service to create the Function resource under + /// + public string PathServiceSid { get; } + /// + /// A string to describe the Function resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new CreateFunctionOptions + /// + /// The SID of the Service to create the Function resource under + /// A string to describe the Function resource + public CreateFunctionOptions(string pathServiceSid, string friendlyName) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Function resource. + /// + public class UpdateFunctionOptions : IOptions + { + /// + /// The SID of the Service to update the Function resource from + /// + public string PathServiceSid { get; } + /// + /// The SID of the Function resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the Function resource + /// + public string FriendlyName { get; } + + /// + /// Construct a new UpdateFunctionOptions + /// + /// The SID of the Service to update the Function resource from + /// The SID of the Function resource to update + /// A string to describe the Function resource + public UpdateFunctionOptions(string pathServiceSid, string pathSid, string friendlyName) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/Service/FunctionResource.cs b/src/Twilio/Rest/Serverless/V1/Service/FunctionResource.cs index 2c6df4f91..8109df4ed 100644 --- a/src/Twilio/Rest/Serverless/V1/Service/FunctionResource.cs +++ b/src/Twilio/Rest/Serverless/V1/Service/FunctionResource.cs @@ -18,492 +18,492 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1.Service -{ - - public class FunctionResource : Resource - { - private static Request BuildReadRequest(ReadFunctionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Functions. - /// - /// Read Function parameters - /// Client to make requests to Twilio - /// A single instance of Function - public static ResourceSet Read(ReadFunctionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("functions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Functions. - /// - /// Read Function parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task> ReadAsync(ReadFunctionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("functions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Functions. - /// - /// The SID of the Service to read the Function resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Function - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFunctionOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Functions. - /// - /// The SID of the Service to read the Function resources from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFunctionOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("functions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("functions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("functions", response.Content); - } - - private static Request BuildFetchRequest(FetchFunctionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Function resource. - /// - /// Fetch Function parameters - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Fetch(FetchFunctionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Function resource. - /// - /// Fetch Function parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Function resource. - /// - /// The SID of the Service to fetch the Function resource from - /// The SID of the Function resource to fetch - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFunctionOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Function resource. - /// - /// The SID of the Service to fetch the Function resource from - /// The SID of the Function resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFunctionOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFunctionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Function resource. - /// - /// Delete Function parameters - /// Client to make requests to Twilio - /// A single instance of Function - public static bool Delete(DeleteFunctionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Function resource. - /// - /// Delete Function parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFunctionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Function resource. - /// - /// The SID of the Service to delete the Function resource from - /// The SID of the Function resource to delete - /// Client to make requests to Twilio - /// A single instance of Function - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFunctionOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Function resource. - /// - /// The SID of the Service to delete the Function resource from - /// The SID of the Function resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFunctionOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateFunctionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Function resource. - /// - /// Create Function parameters - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Create(CreateFunctionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Function resource. - /// - /// Create Function parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task CreateAsync(CreateFunctionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Function resource. - /// - /// The SID of the Service to create the Function resource under - /// A string to describe the Function resource - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Create(string pathServiceSid, string friendlyName, ITwilioRestClient client = null) - { - var options = new CreateFunctionOptions(pathServiceSid, friendlyName); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Function resource. - /// - /// The SID of the Service to create the Function resource under - /// A string to describe the Function resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new CreateFunctionOptions(pathServiceSid, friendlyName); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFunctionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Function resource. - /// - /// Update Function parameters - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Update(UpdateFunctionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Function resource. - /// - /// Update Function parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFunctionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Function resource. - /// - /// The SID of the Service to update the Function resource from - /// The SID of the Function resource to update - /// A string to describe the Function resource - /// Client to make requests to Twilio - /// A single instance of Function - public static FunctionResource Update(string pathServiceSid, - string pathSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new UpdateFunctionOptions(pathServiceSid, pathSid, friendlyName); - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Function resource. - /// - /// The SID of the Service to update the Function resource from - /// The SID of the Function resource to update - /// A string to describe the Function resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Function - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName, - ITwilioRestClient client = null) - { - var options = new UpdateFunctionOptions(pathServiceSid, pathSid, friendlyName); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FunctionResource object - /// - /// Raw JSON string - /// FunctionResource object represented by the provided JSON - public static FunctionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Function resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Function resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the Function resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The string that you assigned to describe the Function resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Function resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Function resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Function resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of nested resources of the Function resource - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private FunctionResource() - { - - } - } +{ + + public class FunctionResource : Resource + { + private static Request BuildReadRequest(ReadFunctionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Functions. + /// + /// Read Function parameters + /// Client to make requests to Twilio + /// A single instance of Function + public static ResourceSet Read(ReadFunctionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("functions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Functions. + /// + /// Read Function parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task> ReadAsync(ReadFunctionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("functions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Functions. + /// + /// The SID of the Service to read the Function resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Function + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFunctionOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Functions. + /// + /// The SID of the Service to read the Function resources from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFunctionOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("functions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("functions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("functions", response.Content); + } + + private static Request BuildFetchRequest(FetchFunctionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Function resource. + /// + /// Fetch Function parameters + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Fetch(FetchFunctionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Function resource. + /// + /// Fetch Function parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task FetchAsync(FetchFunctionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Function resource. + /// + /// The SID of the Service to fetch the Function resource from + /// The SID of the Function resource to fetch + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFunctionOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Function resource. + /// + /// The SID of the Service to fetch the Function resource from + /// The SID of the Function resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFunctionOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFunctionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Function resource. + /// + /// Delete Function parameters + /// Client to make requests to Twilio + /// A single instance of Function + public static bool Delete(DeleteFunctionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Function resource. + /// + /// Delete Function parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFunctionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Function resource. + /// + /// The SID of the Service to delete the Function resource from + /// The SID of the Function resource to delete + /// Client to make requests to Twilio + /// A single instance of Function + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFunctionOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Function resource. + /// + /// The SID of the Service to delete the Function resource from + /// The SID of the Function resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFunctionOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateFunctionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Function resource. + /// + /// Create Function parameters + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Create(CreateFunctionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Function resource. + /// + /// Create Function parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task CreateAsync(CreateFunctionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Function resource. + /// + /// The SID of the Service to create the Function resource under + /// A string to describe the Function resource + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Create(string pathServiceSid, string friendlyName, ITwilioRestClient client = null) + { + var options = new CreateFunctionOptions(pathServiceSid, friendlyName); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Function resource. + /// + /// The SID of the Service to create the Function resource under + /// A string to describe the Function resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new CreateFunctionOptions(pathServiceSid, friendlyName); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFunctionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathServiceSid + "/Functions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Function resource. + /// + /// Update Function parameters + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Update(UpdateFunctionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Function resource. + /// + /// Update Function parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFunctionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Function resource. + /// + /// The SID of the Service to update the Function resource from + /// The SID of the Function resource to update + /// A string to describe the Function resource + /// Client to make requests to Twilio + /// A single instance of Function + public static FunctionResource Update(string pathServiceSid, + string pathSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new UpdateFunctionOptions(pathServiceSid, pathSid, friendlyName); + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Function resource. + /// + /// The SID of the Service to update the Function resource from + /// The SID of the Function resource to update + /// A string to describe the Function resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Function + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName, + ITwilioRestClient client = null) + { + var options = new UpdateFunctionOptions(pathServiceSid, pathSid, friendlyName); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FunctionResource object + /// + /// Raw JSON string + /// FunctionResource object represented by the provided JSON + public static FunctionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Function resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Function resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the Function resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The string that you assigned to describe the Function resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Function resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Function resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Function resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of nested resources of the Function resource + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private FunctionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/ServiceOptions.cs b/src/Twilio/Rest/Serverless/V1/ServiceOptions.cs index 5bc44bdd8..6f4ca722c 100644 --- a/src/Twilio/Rest/Serverless/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Serverless/V1/ServiceOptions.cs @@ -9,213 +9,213 @@ using Twilio.Converters; namespace Twilio.Rest.Serverless.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Services. + /// + public class ReadServiceOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Services. - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a specific Service resource. + /// + public class FetchServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a specific Service resource. + /// The SID of the Service resource to fetch /// - public class FetchServiceOptions : IOptions - { - /// - /// The SID of the Service resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The SID of the Service resource to fetch - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a Service resource. + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The SID of the Service resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The SID of the Service resource to delete - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service resource to fetch + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Service resource. - /// - public class CreateServiceOptions : IOptions - { - /// - /// A user-defined string that uniquely identifies the Service resource - /// - public string UniqueName { get; } - /// - /// A string to describe the Service resource - /// - public string FriendlyName { get; } - /// - /// Whether to inject Account credentials into a function invocation context - /// - public bool? IncludeCredentials { get; set; } - /// - /// Whether the Service's properties and subresources can be edited via the UI - /// - public bool? UiEditable { get; set; } - - /// - /// Construct a new CreateServiceOptions - /// - /// A user-defined string that uniquely identifies the Service resource - /// A string to describe the Service resource - public CreateServiceOptions(string uniqueName, string friendlyName) - { - UniqueName = uniqueName; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (IncludeCredentials != null) - { - p.Add(new KeyValuePair("IncludeCredentials", IncludeCredentials.Value.ToString().ToLower())); - } - - if (UiEditable != null) - { - p.Add(new KeyValuePair("UiEditable", UiEditable.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a Service resource. + /// + public class DeleteServiceOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Service resource. - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The SID of the Service resource to update - /// - public string PathSid { get; } - /// - /// Whether to inject Account credentials into a function invocation context - /// - public bool? IncludeCredentials { get; set; } - /// - /// A string to describe the Service resource - /// - public string FriendlyName { get; set; } - /// - /// Whether the Service resource's properties and subresources can be edited via the UI - /// - public bool? UiEditable { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The SID of the Service resource to update - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IncludeCredentials != null) - { - p.Add(new KeyValuePair("IncludeCredentials", IncludeCredentials.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UiEditable != null) - { - p.Add(new KeyValuePair("UiEditable", UiEditable.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the Service resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// The SID of the Service resource to delete + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Service resource. + /// + public class CreateServiceOptions : IOptions + { + /// + /// A user-defined string that uniquely identifies the Service resource + /// + public string UniqueName { get; } + /// + /// A string to describe the Service resource + /// + public string FriendlyName { get; } + /// + /// Whether to inject Account credentials into a function invocation context + /// + public bool? IncludeCredentials { get; set; } + /// + /// Whether the Service's properties and subresources can be edited via the UI + /// + public bool? UiEditable { get; set; } + + /// + /// Construct a new CreateServiceOptions + /// + /// A user-defined string that uniquely identifies the Service resource + /// A string to describe the Service resource + public CreateServiceOptions(string uniqueName, string friendlyName) + { + UniqueName = uniqueName; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (IncludeCredentials != null) + { + p.Add(new KeyValuePair("IncludeCredentials", IncludeCredentials.Value.ToString().ToLower())); + } + + if (UiEditable != null) + { + p.Add(new KeyValuePair("UiEditable", UiEditable.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Service resource. + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The SID of the Service resource to update + /// + public string PathSid { get; } + /// + /// Whether to inject Account credentials into a function invocation context + /// + public bool? IncludeCredentials { get; set; } + /// + /// A string to describe the Service resource + /// + public string FriendlyName { get; set; } + /// + /// Whether the Service resource's properties and subresources can be edited via the UI + /// + public bool? UiEditable { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The SID of the Service resource to update + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IncludeCredentials != null) + { + p.Add(new KeyValuePair("IncludeCredentials", IncludeCredentials.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UiEditable != null) + { + p.Add(new KeyValuePair("UiEditable", UiEditable.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Serverless/V1/ServiceResource.cs b/src/Twilio/Rest/Serverless/V1/ServiceResource.cs index 17d276ae1..1689affc2 100644 --- a/src/Twilio/Rest/Serverless/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Serverless/V1/ServiceResource.cs @@ -18,512 +18,512 @@ using Twilio.Http; namespace Twilio.Rest.Serverless.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Services. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Services. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Services. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Services. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Serverless) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Service resource. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Service resource. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Service resource. - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Service resource. - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Service resource. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Service resource. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Service resource. - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Service resource. - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Service resource. - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Service resource. - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Service resource. - /// - /// A user-defined string that uniquely identifies the Service resource - /// A string to describe the Service resource - /// Whether to inject Account credentials into a function invocation context - /// Whether the Service's properties and subresources can be edited via the UI - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string uniqueName, - string friendlyName, - bool? includeCredentials = null, - bool? uiEditable = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(uniqueName, friendlyName){IncludeCredentials = includeCredentials, UiEditable = uiEditable}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Service resource. - /// - /// A user-defined string that uniquely identifies the Service resource - /// A string to describe the Service resource - /// Whether to inject Account credentials into a function invocation context - /// Whether the Service's properties and subresources can be edited via the UI - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string uniqueName, - string friendlyName, - bool? includeCredentials = null, - bool? uiEditable = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(uniqueName, friendlyName){IncludeCredentials = includeCredentials, UiEditable = uiEditable}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Serverless, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Service resource. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Service resource. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Service resource. - /// - /// The SID of the Service resource to update - /// Whether to inject Account credentials into a function invocation context - /// A string to describe the Service resource - /// Whether the Service resource's properties and subresources can be edited via the UI - /// - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - bool? includeCredentials = null, - string friendlyName = null, - bool? uiEditable = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){IncludeCredentials = includeCredentials, FriendlyName = friendlyName, UiEditable = uiEditable}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Service resource. - /// - /// The SID of the Service resource to update - /// Whether to inject Account credentials into a function invocation context - /// A string to describe the Service resource - /// Whether the Service resource's properties and subresources can be edited via the UI - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - bool? includeCredentials = null, - string friendlyName = null, - bool? uiEditable = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){IncludeCredentials = includeCredentials, FriendlyName = friendlyName, UiEditable = uiEditable}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Service resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the Service resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the Service resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A user-defined string that uniquely identifies the Service resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// Whether to inject Account credentials into a function invocation context - /// - [JsonProperty("include_credentials")] - public bool? IncludeCredentials { get; private set; } - /// - /// Whether the Service resource's properties and subresources can be edited via the UI - /// - [JsonProperty("ui_editable")] - public bool? UiEditable { get; private set; } - /// - /// The base domain name for this Service, which is a combination of the unique name and a randomly generated string - /// - [JsonProperty("domain_base")] - public string DomainBase { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Service resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Service resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Service's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Services. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Services. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Services. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Services. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Serverless) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Service resource. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Service resource. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Service resource. + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Service resource. + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Service resource. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Service resource. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Service resource. + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Service resource. + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Service resource. + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Service resource. + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Service resource. + /// + /// A user-defined string that uniquely identifies the Service resource + /// A string to describe the Service resource + /// Whether to inject Account credentials into a function invocation context + /// Whether the Service's properties and subresources can be edited via the UI + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string uniqueName, + string friendlyName, + bool? includeCredentials = null, + bool? uiEditable = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(uniqueName, friendlyName) { IncludeCredentials = includeCredentials, UiEditable = uiEditable }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Service resource. + /// + /// A user-defined string that uniquely identifies the Service resource + /// A string to describe the Service resource + /// Whether to inject Account credentials into a function invocation context + /// Whether the Service's properties and subresources can be edited via the UI + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string uniqueName, + string friendlyName, + bool? includeCredentials = null, + bool? uiEditable = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(uniqueName, friendlyName) { IncludeCredentials = includeCredentials, UiEditable = uiEditable }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Serverless, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Service resource. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Service resource. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Service resource. + /// + /// The SID of the Service resource to update + /// Whether to inject Account credentials into a function invocation context + /// A string to describe the Service resource + /// Whether the Service resource's properties and subresources can be edited via the UI + /// + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + bool? includeCredentials = null, + string friendlyName = null, + bool? uiEditable = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { IncludeCredentials = includeCredentials, FriendlyName = friendlyName, UiEditable = uiEditable }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Service resource. + /// + /// The SID of the Service resource to update + /// Whether to inject Account credentials into a function invocation context + /// A string to describe the Service resource + /// Whether the Service resource's properties and subresources can be edited via the UI + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + bool? includeCredentials = null, + string friendlyName = null, + bool? uiEditable = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { IncludeCredentials = includeCredentials, FriendlyName = friendlyName, UiEditable = uiEditable }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Service resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the Service resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the Service resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A user-defined string that uniquely identifies the Service resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// Whether to inject Account credentials into a function invocation context + /// + [JsonProperty("include_credentials")] + public bool? IncludeCredentials { get; private set; } + /// + /// Whether the Service resource's properties and subresources can be edited via the UI + /// + [JsonProperty("ui_editable")] + public bool? UiEditable { get; private set; } + /// + /// The base domain name for this Service, which is a combination of the unique name and a randomly generated string + /// + [JsonProperty("domain_base")] + public string DomainBase { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Service resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Service resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Service's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextOptions.cs index c0c5fa8ae..b3b96ba56 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextOptions.cs @@ -9,41 +9,41 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Engagement -{ - +{ + + /// + /// Retrieve the most recent context for an Engagement. + /// + public class FetchEngagementContextOptions : IOptions + { /// - /// Retrieve the most recent context for an Engagement. + /// Flow SID /// - public class FetchEngagementContextOptions : IOptions - { - /// - /// Flow SID - /// - public string PathFlowSid { get; } - /// - /// Engagement SID - /// - public string PathEngagementSid { get; } - - /// - /// Construct a new FetchEngagementContextOptions - /// - /// Flow SID - /// Engagement SID - public FetchEngagementContextOptions(string pathFlowSid, string pathEngagementSid) - { - PathFlowSid = pathFlowSid; - PathEngagementSid = pathEngagementSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// Engagement SID + /// + public string PathEngagementSid { get; } + + /// + /// Construct a new FetchEngagementContextOptions + /// + /// Flow SID + /// Engagement SID + public FetchEngagementContextOptions(string pathFlowSid, string pathEngagementSid) + { + PathFlowSid = pathFlowSid; + PathEngagementSid = pathEngagementSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextResource.cs index eebd21b2a..539be70e1 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/EngagementContextResource.cs @@ -16,130 +16,130 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Engagement -{ - - public class EngagementContextResource : Resource - { - private static Request BuildFetchRequest(FetchEngagementContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the most recent context for an Engagement. - /// - /// Fetch EngagementContext parameters - /// Client to make requests to Twilio - /// A single instance of EngagementContext - public static EngagementContextResource Fetch(FetchEngagementContextOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Engagement. - /// - /// Fetch EngagementContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EngagementContext - public static async System.Threading.Tasks.Task FetchAsync(FetchEngagementContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the most recent context for an Engagement. - /// - /// Flow SID - /// Engagement SID - /// Client to make requests to Twilio - /// A single instance of EngagementContext - public static EngagementContextResource Fetch(string pathFlowSid, - string pathEngagementSid, - ITwilioRestClient client = null) - { - var options = new FetchEngagementContextOptions(pathFlowSid, pathEngagementSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Engagement. - /// - /// Flow SID - /// Engagement SID - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EngagementContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathEngagementSid, - ITwilioRestClient client = null) - { - var options = new FetchEngagementContextOptions(pathFlowSid, pathEngagementSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EngagementContextResource object - /// - /// Raw JSON string - /// EngagementContextResource object represented by the provided JSON - public static EngagementContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Account SID - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Flow state - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// Engagement SID - /// - [JsonProperty("engagement_sid")] - public string EngagementSid { get; private set; } - /// - /// Flow SID - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EngagementContextResource() - { - - } - } +{ + + public class EngagementContextResource : Resource + { + private static Request BuildFetchRequest(FetchEngagementContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the most recent context for an Engagement. + /// + /// Fetch EngagementContext parameters + /// Client to make requests to Twilio + /// A single instance of EngagementContext + public static EngagementContextResource Fetch(FetchEngagementContextOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Engagement. + /// + /// Fetch EngagementContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EngagementContext + public static async System.Threading.Tasks.Task FetchAsync(FetchEngagementContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the most recent context for an Engagement. + /// + /// Flow SID + /// Engagement SID + /// Client to make requests to Twilio + /// A single instance of EngagementContext + public static EngagementContextResource Fetch(string pathFlowSid, + string pathEngagementSid, + ITwilioRestClient client = null) + { + var options = new FetchEngagementContextOptions(pathFlowSid, pathEngagementSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Engagement. + /// + /// Flow SID + /// Engagement SID + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EngagementContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathEngagementSid, + ITwilioRestClient client = null) + { + var options = new FetchEngagementContextOptions(pathFlowSid, pathEngagementSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EngagementContextResource object + /// + /// Raw JSON string + /// EngagementContextResource object represented by the provided JSON + public static EngagementContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Account SID + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Flow state + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// Engagement SID + /// + [JsonProperty("engagement_sid")] + public string EngagementSid { get; private set; } + /// + /// Flow SID + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EngagementContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextOptions.cs index b2cc173cc..4d0d89b1f 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextOptions.cs @@ -9,47 +9,47 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Engagement.Step -{ - +{ + + /// + /// Retrieve the context for an Engagement Step. + /// + public class FetchStepContextOptions : IOptions + { /// - /// Retrieve the context for an Engagement Step. + /// The SID of the Flow /// - public class FetchStepContextOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Engagement - /// - public string PathEngagementSid { get; } - /// - /// Step SID - /// - public string PathStepSid { get; } - - /// - /// Construct a new FetchStepContextOptions - /// - /// The SID of the Flow - /// The SID of the Engagement - /// Step SID - public FetchStepContextOptions(string pathFlowSid, string pathEngagementSid, string pathStepSid) - { - PathFlowSid = pathFlowSid; - PathEngagementSid = pathEngagementSid; - PathStepSid = pathStepSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// The SID of the Engagement + /// + public string PathEngagementSid { get; } + /// + /// Step SID + /// + public string PathStepSid { get; } + + /// + /// Construct a new FetchStepContextOptions + /// + /// The SID of the Flow + /// The SID of the Engagement + /// Step SID + public FetchStepContextOptions(string pathFlowSid, string pathEngagementSid, string pathStepSid) + { + PathFlowSid = pathFlowSid; + PathEngagementSid = pathEngagementSid; + PathStepSid = pathStepSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextResource.cs index 6c440e460..7a51dd25f 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/Step/StepContextResource.cs @@ -16,139 +16,139 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Engagement.Step -{ - - public class StepContextResource : Resource - { - private static Request BuildFetchRequest(FetchStepContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps/" + options.PathStepSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the context for an Engagement Step. - /// - /// Fetch StepContext parameters - /// Client to make requests to Twilio - /// A single instance of StepContext - public static StepContextResource Fetch(FetchStepContextOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the context for an Engagement Step. - /// - /// Fetch StepContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StepContext - public static async System.Threading.Tasks.Task FetchAsync(FetchStepContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the context for an Engagement Step. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// Step SID - /// Client to make requests to Twilio - /// A single instance of StepContext - public static StepContextResource Fetch(string pathFlowSid, - string pathEngagementSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchStepContextOptions(pathFlowSid, pathEngagementSid, pathStepSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the context for an Engagement Step. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// Step SID - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StepContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathEngagementSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchStepContextOptions(pathFlowSid, pathEngagementSid, pathStepSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a StepContextResource object - /// - /// Raw JSON string - /// StepContextResource object represented by the provided JSON - public static StepContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The SID of the Engagement - /// - [JsonProperty("engagement_sid")] - public string EngagementSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// Step SID - /// - [JsonProperty("step_sid")] - public string StepSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private StepContextResource() - { - - } - } +{ + + public class StepContextResource : Resource + { + private static Request BuildFetchRequest(FetchStepContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps/" + options.PathStepSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the context for an Engagement Step. + /// + /// Fetch StepContext parameters + /// Client to make requests to Twilio + /// A single instance of StepContext + public static StepContextResource Fetch(FetchStepContextOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the context for an Engagement Step. + /// + /// Fetch StepContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StepContext + public static async System.Threading.Tasks.Task FetchAsync(FetchStepContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the context for an Engagement Step. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// Step SID + /// Client to make requests to Twilio + /// A single instance of StepContext + public static StepContextResource Fetch(string pathFlowSid, + string pathEngagementSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchStepContextOptions(pathFlowSid, pathEngagementSid, pathStepSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the context for an Engagement Step. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// Step SID + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StepContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathEngagementSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchStepContextOptions(pathFlowSid, pathEngagementSid, pathStepSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a StepContextResource object + /// + /// Raw JSON string + /// StepContextResource object represented by the provided JSON + public static StepContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The SID of the Engagement + /// + [JsonProperty("engagement_sid")] + public string EngagementSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// Step SID + /// + [JsonProperty("step_sid")] + public string StepSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private StepContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepOptions.cs index 492ee6913..27703761d 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Engagement -{ - +{ + + /// + /// Retrieve a list of all Steps for an Engagement. + /// + public class ReadStepOptions : ReadOptions + { /// - /// Retrieve a list of all Steps for an Engagement. + /// The SID of the Flow /// - public class ReadStepOptions : ReadOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Engagement - /// - public string PathEngagementSid { get; } - - /// - /// Construct a new ReadStepOptions - /// - /// The SID of the Flow - /// The SID of the Engagement - public ReadStepOptions(string pathFlowSid, string pathEngagementSid) - { - PathFlowSid = pathFlowSid; - PathEngagementSid = pathEngagementSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathFlowSid { get; } /// - /// Retrieve a Step. + /// The SID of the Engagement /// - public class FetchStepOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Engagement - /// - public string PathEngagementSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchStepOptions - /// - /// The SID of the Flow - /// The SID of the Engagement - /// The SID that identifies the resource to fetch - public FetchStepOptions(string pathFlowSid, string pathEngagementSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathEngagementSid = pathEngagementSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathEngagementSid { get; } + + /// + /// Construct a new ReadStepOptions + /// + /// The SID of the Flow + /// The SID of the Engagement + public ReadStepOptions(string pathFlowSid, string pathEngagementSid) + { + PathFlowSid = pathFlowSid; + PathEngagementSid = pathEngagementSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a Step. + /// + public class FetchStepOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Engagement + /// + public string PathEngagementSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchStepOptions + /// + /// The SID of the Flow + /// The SID of the Engagement + /// The SID that identifies the resource to fetch + public FetchStepOptions(string pathFlowSid, string pathEngagementSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathEngagementSid = pathEngagementSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepResource.cs index c04d987b2..f822b586a 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Engagement/StepResource.cs @@ -16,306 +16,306 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Engagement -{ - - public class StepResource : Resource - { - private static Request BuildReadRequest(ReadStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Steps for an Engagement. - /// - /// Read Step parameters - /// Client to make requests to Twilio - /// A single instance of Step - public static ResourceSet Read(ReadStepOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Engagement. - /// - /// Read Step parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Step - public static async System.Threading.Tasks.Task> ReadAsync(ReadStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Steps for an Engagement. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Step - public static ResourceSet Read(string pathFlowSid, - string pathEngagementSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadStepOptions(pathFlowSid, pathEngagementSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Engagement. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Step - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - string pathEngagementSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadStepOptions(pathFlowSid, pathEngagementSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - private static Request BuildFetchRequest(FetchStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a Step. - /// - /// Fetch Step parameters - /// Client to make requests to Twilio - /// A single instance of Step - public static StepResource Fetch(FetchStepOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// Fetch Step parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Step - public static async System.Threading.Tasks.Task FetchAsync(FetchStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Step - public static StepResource Fetch(string pathFlowSid, - string pathEngagementSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchStepOptions(pathFlowSid, pathEngagementSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Engagement - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Step - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathEngagementSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchStepOptions(pathFlowSid, pathEngagementSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a StepResource object - /// - /// Raw JSON string - /// StepResource object represented by the provided JSON - public static StepResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Engagement - /// - [JsonProperty("engagement_sid")] - public string EngagementSid { get; private set; } - /// - /// The event that caused the Flow to transition to the Step - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The Widget that preceded the Widget for the Step - /// - [JsonProperty("transitioned_from")] - public string TransitionedFrom { get; private set; } - /// - /// The Widget that will follow the Widget for the Step - /// - [JsonProperty("transitioned_to")] - public string TransitionedTo { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private StepResource() - { - - } - } +{ + + public class StepResource : Resource + { + private static Request BuildReadRequest(ReadStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Steps for an Engagement. + /// + /// Read Step parameters + /// Client to make requests to Twilio + /// A single instance of Step + public static ResourceSet Read(ReadStepOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Engagement. + /// + /// Read Step parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Step + public static async System.Threading.Tasks.Task> ReadAsync(ReadStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Steps for an Engagement. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Step + public static ResourceSet Read(string pathFlowSid, + string pathEngagementSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadStepOptions(pathFlowSid, pathEngagementSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Engagement. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Step + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + string pathEngagementSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadStepOptions(pathFlowSid, pathEngagementSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + private static Request BuildFetchRequest(FetchStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathEngagementSid + "/Steps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a Step. + /// + /// Fetch Step parameters + /// Client to make requests to Twilio + /// A single instance of Step + public static StepResource Fetch(FetchStepOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// Fetch Step parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Step + public static async System.Threading.Tasks.Task FetchAsync(FetchStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Step + public static StepResource Fetch(string pathFlowSid, + string pathEngagementSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchStepOptions(pathFlowSid, pathEngagementSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Engagement + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Step + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathEngagementSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchStepOptions(pathFlowSid, pathEngagementSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a StepResource object + /// + /// Raw JSON string + /// StepResource object represented by the provided JSON + public static StepResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Engagement + /// + [JsonProperty("engagement_sid")] + public string EngagementSid { get; private set; } + /// + /// The event that caused the Flow to transition to the Step + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The Widget that preceded the Widget for the Step + /// + [JsonProperty("transitioned_from")] + public string TransitionedFrom { get; private set; } + /// + /// The Widget that will follow the Widget for the Step + /// + [JsonProperty("transitioned_to")] + public string TransitionedTo { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private StepResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/EngagementOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/EngagementOptions.cs index ba235b699..276e016ee 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/EngagementOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/EngagementOptions.cs @@ -9,171 +9,171 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow -{ - +{ + + /// + /// Retrieve a list of all Engagements for the Flow. + /// + public class ReadEngagementOptions : ReadOptions + { /// - /// Retrieve a list of all Engagements for the Flow. + /// The SID of the Flow to read Engagements from /// - public class ReadEngagementOptions : ReadOptions - { - /// - /// The SID of the Flow to read Engagements from - /// - public string PathFlowSid { get; } - - /// - /// Construct a new ReadEngagementOptions - /// - /// The SID of the Flow to read Engagements from - public ReadEngagementOptions(string pathFlowSid) - { - PathFlowSid = pathFlowSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathFlowSid { get; } + /// - /// Retrieve an Engagement - /// - public class FetchEngagementOptions : IOptions - { - /// - /// Flow SID - /// - public string PathFlowSid { get; } - /// - /// The SID of the Engagement resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEngagementOptions - /// - /// Flow SID - /// The SID of the Engagement resource to fetch - public FetchEngagementOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadEngagementOptions + /// + /// The SID of the Flow to read Engagements from + public ReadEngagementOptions(string pathFlowSid) + { + PathFlowSid = pathFlowSid; + } + /// - /// Triggers a new Engagement for the Flow - /// - public class CreateEngagementOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The Contact phone number to start a Studio Flow Engagement - /// - public Types.PhoneNumber To { get; } - /// - /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement - /// - public Types.PhoneNumber From { get; } - /// - /// A JSON string we will add to your flow's context and that you can access as variables inside your flow - /// - public object Parameters { get; set; } - - /// - /// Construct a new CreateEngagementOptions - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Engagement - /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement - /// - public CreateEngagementOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) - { - PathFlowSid = pathFlowSid; - To = to; - From = from; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (Parameters != null) - { - p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve an Engagement + /// + public class FetchEngagementOptions : IOptions + { /// - /// Delete this Engagement and all Steps relating to it. - /// - public class DeleteEngagementOptions : IOptions - { - /// - /// The SID of the Flow to delete Engagements from - /// - public string PathFlowSid { get; } - /// - /// The SID of the Engagement resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteEngagementOptions - /// - /// The SID of the Flow to delete Engagements from - /// The SID of the Engagement resource to delete - public DeleteEngagementOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Flow SID + /// + public string PathFlowSid { get; } + /// + /// The SID of the Engagement resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEngagementOptions + /// + /// Flow SID + /// The SID of the Engagement resource to fetch + public FetchEngagementOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Triggers a new Engagement for the Flow + /// + public class CreateEngagementOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The Contact phone number to start a Studio Flow Engagement + /// + public Types.PhoneNumber To { get; } + /// + /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement + /// + public Types.PhoneNumber From { get; } + /// + /// A JSON string we will add to your flow's context and that you can access as variables inside your flow + /// + public object Parameters { get; set; } + + /// + /// Construct a new CreateEngagementOptions + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Engagement + /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement + /// + public CreateEngagementOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) + { + PathFlowSid = pathFlowSid; + To = to; + From = from; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (Parameters != null) + { + p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); + } + + return p; + } + } + + /// + /// Delete this Engagement and all Steps relating to it. + /// + public class DeleteEngagementOptions : IOptions + { + /// + /// The SID of the Flow to delete Engagements from + /// + public string PathFlowSid { get; } + /// + /// The SID of the Engagement resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteEngagementOptions + /// + /// The SID of the Flow to delete Engagements from + /// The SID of the Engagement resource to delete + public DeleteEngagementOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/EngagementResource.cs b/src/Twilio/Rest/Studio/V1/Flow/EngagementResource.cs index 51a5682ac..17f5a5f69 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/EngagementResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/EngagementResource.cs @@ -17,459 +17,459 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V1.Flow -{ - - public class EngagementResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Ended = new StatusEnum("ended"); - } - - private static Request BuildReadRequest(ReadEngagementOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Engagements for the Flow. - /// - /// Read Engagement parameters - /// Client to make requests to Twilio - /// A single instance of Engagement - public static ResourceSet Read(ReadEngagementOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("engagements", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Engagements for the Flow. - /// - /// Read Engagement parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task> ReadAsync(ReadEngagementOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("engagements", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Engagements for the Flow. - /// - /// The SID of the Flow to read Engagements from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Engagement - public static ResourceSet Read(string pathFlowSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEngagementOptions(pathFlowSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Engagements for the Flow. - /// - /// The SID of the Flow to read Engagements from - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEngagementOptions(pathFlowSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("engagements", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("engagements", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("engagements", response.Content); - } - - private static Request BuildFetchRequest(FetchEngagementOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve an Engagement - /// - /// Fetch Engagement parameters - /// Client to make requests to Twilio - /// A single instance of Engagement - public static EngagementResource Fetch(FetchEngagementOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve an Engagement - /// - /// Fetch Engagement parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task FetchAsync(FetchEngagementOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve an Engagement - /// - /// Flow SID - /// The SID of the Engagement resource to fetch - /// Client to make requests to Twilio - /// A single instance of Engagement - public static EngagementResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEngagementOptions(pathFlowSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve an Engagement - /// - /// Flow SID - /// The SID of the Engagement resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEngagementOptions(pathFlowSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateEngagementOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Triggers a new Engagement for the Flow - /// - /// Create Engagement parameters - /// Client to make requests to Twilio - /// A single instance of Engagement - public static EngagementResource Create(CreateEngagementOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Triggers a new Engagement for the Flow - /// - /// Create Engagement parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task CreateAsync(CreateEngagementOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Triggers a new Engagement for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Engagement - /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement - /// - /// A JSON string we will add to your flow's context and that you can access as variables - /// inside your flow - /// Client to make requests to Twilio - /// A single instance of Engagement - public static EngagementResource Create(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateEngagementOptions(pathFlowSid, to, from){Parameters = parameters}; - return Create(options, client); - } - - #if !NET35 - /// - /// Triggers a new Engagement for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Engagement - /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement - /// - /// A JSON string we will add to your flow's context and that you can access as variables - /// inside your flow - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateEngagementOptions(pathFlowSid, to, from){Parameters = parameters}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteEngagementOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete this Engagement and all Steps relating to it. - /// - /// Delete Engagement parameters - /// Client to make requests to Twilio - /// A single instance of Engagement - public static bool Delete(DeleteEngagementOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete this Engagement and all Steps relating to it. - /// - /// Delete Engagement parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task DeleteAsync(DeleteEngagementOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete this Engagement and all Steps relating to it. - /// - /// The SID of the Flow to delete Engagements from - /// The SID of the Engagement resource to delete - /// Client to make requests to Twilio - /// A single instance of Engagement - public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEngagementOptions(pathFlowSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete this Engagement and all Steps relating to it. - /// - /// The SID of the Flow to delete Engagements from - /// The SID of the Engagement resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Engagement - public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteEngagementOptions(pathFlowSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EngagementResource object - /// - /// Raw JSON string - /// EngagementResource object represented by the provided JSON - public static EngagementResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Contact - /// - [JsonProperty("contact_sid")] - public string ContactSid { get; private set; } - /// - /// The phone number, SIP address or Client identifier that triggered this Engagement - /// - [JsonProperty("contact_channel_address")] - public string ContactChannelAddress { get; private set; } - /// - /// The current state of the execution flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The status of the Engagement - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public EngagementResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Engagement was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Engagement was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Engagement's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private EngagementResource() - { - - } - } +{ + + public class EngagementResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Ended = new StatusEnum("ended"); + } + + private static Request BuildReadRequest(ReadEngagementOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Engagements for the Flow. + /// + /// Read Engagement parameters + /// Client to make requests to Twilio + /// A single instance of Engagement + public static ResourceSet Read(ReadEngagementOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("engagements", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Engagements for the Flow. + /// + /// Read Engagement parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task> ReadAsync(ReadEngagementOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("engagements", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Engagements for the Flow. + /// + /// The SID of the Flow to read Engagements from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Engagement + public static ResourceSet Read(string pathFlowSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEngagementOptions(pathFlowSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Engagements for the Flow. + /// + /// The SID of the Flow to read Engagements from + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEngagementOptions(pathFlowSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("engagements", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("engagements", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("engagements", response.Content); + } + + private static Request BuildFetchRequest(FetchEngagementOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve an Engagement + /// + /// Fetch Engagement parameters + /// Client to make requests to Twilio + /// A single instance of Engagement + public static EngagementResource Fetch(FetchEngagementOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve an Engagement + /// + /// Fetch Engagement parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task FetchAsync(FetchEngagementOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve an Engagement + /// + /// Flow SID + /// The SID of the Engagement resource to fetch + /// Client to make requests to Twilio + /// A single instance of Engagement + public static EngagementResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEngagementOptions(pathFlowSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve an Engagement + /// + /// Flow SID + /// The SID of the Engagement resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEngagementOptions(pathFlowSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateEngagementOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Triggers a new Engagement for the Flow + /// + /// Create Engagement parameters + /// Client to make requests to Twilio + /// A single instance of Engagement + public static EngagementResource Create(CreateEngagementOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Triggers a new Engagement for the Flow + /// + /// Create Engagement parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task CreateAsync(CreateEngagementOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Triggers a new Engagement for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Engagement + /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement + /// + /// A JSON string we will add to your flow's context and that you can access as variables + /// inside your flow + /// Client to make requests to Twilio + /// A single instance of Engagement + public static EngagementResource Create(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateEngagementOptions(pathFlowSid, to, from) { Parameters = parameters }; + return Create(options, client); + } + +#if !NET35 + /// + /// Triggers a new Engagement for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Engagement + /// The Twilio phone number to send messages or initiate calls from during the Flow Engagement + /// + /// A JSON string we will add to your flow's context and that you can access as variables + /// inside your flow + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateEngagementOptions(pathFlowSid, to, from) { Parameters = parameters }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteEngagementOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Engagements/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete this Engagement and all Steps relating to it. + /// + /// Delete Engagement parameters + /// Client to make requests to Twilio + /// A single instance of Engagement + public static bool Delete(DeleteEngagementOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete this Engagement and all Steps relating to it. + /// + /// Delete Engagement parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task DeleteAsync(DeleteEngagementOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete this Engagement and all Steps relating to it. + /// + /// The SID of the Flow to delete Engagements from + /// The SID of the Engagement resource to delete + /// Client to make requests to Twilio + /// A single instance of Engagement + public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEngagementOptions(pathFlowSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete this Engagement and all Steps relating to it. + /// + /// The SID of the Flow to delete Engagements from + /// The SID of the Engagement resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Engagement + public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteEngagementOptions(pathFlowSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EngagementResource object + /// + /// Raw JSON string + /// EngagementResource object represented by the provided JSON + public static EngagementResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Contact + /// + [JsonProperty("contact_sid")] + public string ContactSid { get; private set; } + /// + /// The phone number, SIP address or Client identifier that triggered this Engagement + /// + [JsonProperty("contact_channel_address")] + public string ContactChannelAddress { get; private set; } + /// + /// The current state of the execution flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The status of the Engagement + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public EngagementResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Engagement was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Engagement was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Engagement's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private EngagementResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextOptions.cs index 7234efc51..e79ed8b2a 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextOptions.cs @@ -9,41 +9,41 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Execution -{ - +{ + + /// + /// Retrieve the most recent context for an Execution. + /// + public class FetchExecutionContextOptions : IOptions + { /// - /// Retrieve the most recent context for an Execution. + /// The SID of the Flow /// - public class FetchExecutionContextOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - - /// - /// Construct a new FetchExecutionContextOptions - /// - /// The SID of the Flow - /// The SID of the Execution - public FetchExecutionContextOptions(string pathFlowSid, string pathExecutionSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + + /// + /// Construct a new FetchExecutionContextOptions + /// + /// The SID of the Flow + /// The SID of the Execution + public FetchExecutionContextOptions(string pathFlowSid, string pathExecutionSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextResource.cs index 138d5dd64..edd1f1341 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionContextResource.cs @@ -16,130 +16,130 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Execution -{ - - public class ExecutionContextResource : Resource - { - private static Request BuildFetchRequest(FetchExecutionContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the most recent context for an Execution. - /// - /// Fetch ExecutionContext parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionContext - public static ExecutionContextResource Fetch(FetchExecutionContextOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Execution. - /// - /// Fetch ExecutionContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionContext - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the most recent context for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Client to make requests to Twilio - /// A single instance of ExecutionContext - public static ExecutionContextResource Fetch(string pathFlowSid, - string pathExecutionSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionContextResource object - /// - /// Raw JSON string - /// ExecutionContextResource object represented by the provided JSON - public static ExecutionContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExecutionContextResource() - { - - } - } +{ + + public class ExecutionContextResource : Resource + { + private static Request BuildFetchRequest(FetchExecutionContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the most recent context for an Execution. + /// + /// Fetch ExecutionContext parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionContext + public static ExecutionContextResource Fetch(FetchExecutionContextOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Execution. + /// + /// Fetch ExecutionContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionContext + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the most recent context for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Client to make requests to Twilio + /// A single instance of ExecutionContext + public static ExecutionContextResource Fetch(string pathFlowSid, + string pathExecutionSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionContextResource object + /// + /// Raw JSON string + /// ExecutionContextResource object represented by the provided JSON + public static ExecutionContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExecutionContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs index 2559337df..d34551d8b 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs @@ -9,47 +9,47 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Execution.ExecutionStep -{ - +{ + + /// + /// Retrieve the context for an Execution Step. + /// + public class FetchExecutionStepContextOptions : IOptions + { /// - /// Retrieve the context for an Execution Step. + /// The SID of the Flow /// - public class FetchExecutionStepContextOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - /// - /// Step SID - /// - public string PathStepSid { get; } - - /// - /// Construct a new FetchExecutionStepContextOptions - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - public FetchExecutionStepContextOptions(string pathFlowSid, string pathExecutionSid, string pathStepSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - PathStepSid = pathStepSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + /// + /// Step SID + /// + public string PathStepSid { get; } + + /// + /// Construct a new FetchExecutionStepContextOptions + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + public FetchExecutionStepContextOptions(string pathFlowSid, string pathExecutionSid, string pathStepSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + PathStepSid = pathStepSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs index 1b7eee366..3aec259bc 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs @@ -16,140 +16,140 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Execution.ExecutionStep -{ - - public class ExecutionStepContextResource : Resource - { - private static Request BuildFetchRequest(FetchExecutionStepContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathStepSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the context for an Execution Step. - /// - /// Fetch ExecutionStepContext parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStepContext - public static ExecutionStepContextResource Fetch(FetchExecutionStepContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the context for an Execution Step. - /// - /// Fetch ExecutionStepContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStepContext - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the context for an Execution Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - /// Client to make requests to Twilio - /// A single instance of ExecutionStepContext - public static ExecutionStepContextResource Fetch(string pathFlowSid, - string pathExecutionSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the context for an Execution Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStepContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionStepContextResource object - /// - /// Raw JSON string - /// ExecutionStepContextResource object represented by the provided JSON - public static ExecutionStepContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// Step SID - /// - [JsonProperty("step_sid")] - public string StepSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExecutionStepContextResource() - { - - } - } +{ + + public class ExecutionStepContextResource : Resource + { + private static Request BuildFetchRequest(FetchExecutionStepContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathStepSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the context for an Execution Step. + /// + /// Fetch ExecutionStepContext parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStepContext + public static ExecutionStepContextResource Fetch(FetchExecutionStepContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the context for an Execution Step. + /// + /// Fetch ExecutionStepContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStepContext + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the context for an Execution Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + /// Client to make requests to Twilio + /// A single instance of ExecutionStepContext + public static ExecutionStepContextResource Fetch(string pathFlowSid, + string pathExecutionSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the context for an Execution Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStepContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionStepContextResource object + /// + /// Raw JSON string + /// ExecutionStepContextResource object represented by the provided JSON + public static ExecutionStepContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// Step SID + /// + [JsonProperty("step_sid")] + public string StepSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExecutionStepContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepOptions.cs index 829bdff0c..44303974d 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow.Execution -{ - +{ + + /// + /// Retrieve a list of all Steps for an Execution. + /// + public class ReadExecutionStepOptions : ReadOptions + { /// - /// Retrieve a list of all Steps for an Execution. + /// The SID of the Flow /// - public class ReadExecutionStepOptions : ReadOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - - /// - /// Construct a new ReadExecutionStepOptions - /// - /// The SID of the Flow - /// The SID of the Execution - public ReadExecutionStepOptions(string pathFlowSid, string pathExecutionSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathFlowSid { get; } /// - /// Retrieve a Step. + /// The SID of the Execution /// - public class FetchExecutionStepOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchExecutionStepOptions - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - public FetchExecutionStepOptions(string pathFlowSid, string pathExecutionSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathExecutionSid { get; } + + /// + /// Construct a new ReadExecutionStepOptions + /// + /// The SID of the Flow + /// The SID of the Execution + public ReadExecutionStepOptions(string pathFlowSid, string pathExecutionSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a Step. + /// + public class FetchExecutionStepOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchExecutionStepOptions + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + public FetchExecutionStepOptions(string pathFlowSid, string pathExecutionSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepResource.cs b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepResource.cs index 0f3f15048..d1c80d3cc 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/Execution/ExecutionStepResource.cs @@ -16,307 +16,307 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V1.Flow.Execution -{ - - public class ExecutionStepResource : Resource - { - private static Request BuildReadRequest(ReadExecutionStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// Read ExecutionStep parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ResourceSet Read(ReadExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// Read ExecutionStep parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ResourceSet Read(string pathFlowSid, - string pathExecutionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - string pathExecutionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - private static Request BuildFetchRequest(FetchExecutionStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a Step. - /// - /// Fetch ExecutionStep parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ExecutionStepResource Fetch(FetchExecutionStepOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// Fetch ExecutionStep parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ExecutionStepResource Fetch(string pathFlowSid, - string pathExecutionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionStepResource object - /// - /// Raw JSON string - /// ExecutionStepResource object represented by the provided JSON - public static ExecutionStepResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The event that caused the Flow to transition to the Step - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The Widget that preceded the Widget for the Step - /// - [JsonProperty("transitioned_from")] - public string TransitionedFrom { get; private set; } - /// - /// The Widget that will follow the Widget for the Step - /// - [JsonProperty("transitioned_to")] - public string TransitionedTo { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExecutionStepResource() - { - - } - } +{ + + public class ExecutionStepResource : Resource + { + private static Request BuildReadRequest(ReadExecutionStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// Read ExecutionStep parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ResourceSet Read(ReadExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// Read ExecutionStep parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ResourceSet Read(string pathFlowSid, + string pathExecutionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + string pathExecutionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + private static Request BuildFetchRequest(FetchExecutionStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a Step. + /// + /// Fetch ExecutionStep parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ExecutionStepResource Fetch(FetchExecutionStepOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// Fetch ExecutionStep parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ExecutionStepResource Fetch(string pathFlowSid, + string pathExecutionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionStepResource object + /// + /// Raw JSON string + /// ExecutionStepResource object represented by the provided JSON + public static ExecutionStepResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The event that caused the Flow to transition to the Step + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The Widget that preceded the Widget for the Step + /// + [JsonProperty("transitioned_from")] + public string TransitionedFrom { get; private set; } + /// + /// The Widget that will follow the Widget for the Step + /// + [JsonProperty("transitioned_to")] + public string TransitionedTo { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExecutionStepResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/ExecutionOptions.cs b/src/Twilio/Rest/Studio/V1/Flow/ExecutionOptions.cs index 92772ee9e..dcc2e4602 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/ExecutionOptions.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/ExecutionOptions.cs @@ -9,235 +9,235 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1.Flow -{ - +{ + + /// + /// Retrieve a list of all Executions for the Flow. + /// + public class ReadExecutionOptions : ReadOptions + { /// - /// Retrieve a list of all Executions for the Flow. - /// - public class ReadExecutionOptions : ReadOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// Only show Executions that started on or after this ISO 8601 date-time - /// - public DateTime? DateCreatedFrom { get; set; } - /// - /// Only show Executions that started before this ISO 8601 date-time - /// - public DateTime? DateCreatedTo { get; set; } - - /// - /// Construct a new ReadExecutionOptions - /// - /// The SID of the Flow - public ReadExecutionOptions(string pathFlowSid) - { - PathFlowSid = pathFlowSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreatedFrom != null) - { - p.Add(new KeyValuePair("DateCreatedFrom", Serializers.DateTimeIso8601(DateCreatedFrom))); - } - - if (DateCreatedTo != null) - { - p.Add(new KeyValuePair("DateCreatedTo", Serializers.DateTimeIso8601(DateCreatedTo))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Flow + /// + public string PathFlowSid { get; } /// - /// Retrieve an Execution - /// - public class FetchExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - public FetchExecutionOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Only show Executions that started on or after this ISO 8601 date-time + /// + public DateTime? DateCreatedFrom { get; set; } /// - /// Triggers a new Execution for the Flow - /// - public class CreateExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The Contact phone number to start a Studio Flow Execution - /// - public Types.PhoneNumber To { get; } - /// - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution - /// - public Types.PhoneNumber From { get; } - /// - /// JSON data that will be added to the Flow's context - /// - public object Parameters { get; set; } - - /// - /// Construct a new CreateExecutionOptions - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - public CreateExecutionOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) - { - PathFlowSid = pathFlowSid; - To = to; - From = from; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (Parameters != null) - { - p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); - } - - return p; - } - } - + /// Only show Executions that started before this ISO 8601 date-time + /// + public DateTime? DateCreatedTo { get; set; } + /// - /// Delete the Execution and all Steps relating to it. - /// - public class DeleteExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - public DeleteExecutionOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadExecutionOptions + /// + /// The SID of the Flow + public ReadExecutionOptions(string pathFlowSid) + { + PathFlowSid = pathFlowSid; + } + /// - /// Update the status of an Execution to `ended`. - /// - public class UpdateExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to update - /// - public string PathSid { get; } - /// - /// The status of the Execution - /// - public ExecutionResource.StatusEnum Status { get; } - - /// - /// Construct a new UpdateExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - public UpdateExecutionOptions(string pathFlowSid, string pathSid, ExecutionResource.StatusEnum status) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreatedFrom != null) + { + p.Add(new KeyValuePair("DateCreatedFrom", Serializers.DateTimeIso8601(DateCreatedFrom))); + } + + if (DateCreatedTo != null) + { + p.Add(new KeyValuePair("DateCreatedTo", Serializers.DateTimeIso8601(DateCreatedTo))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve an Execution + /// + public class FetchExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + public FetchExecutionOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Triggers a new Execution for the Flow + /// + public class CreateExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The Contact phone number to start a Studio Flow Execution + /// + public Types.PhoneNumber To { get; } + /// + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution + /// + public Types.PhoneNumber From { get; } + /// + /// JSON data that will be added to the Flow's context + /// + public object Parameters { get; set; } + + /// + /// Construct a new CreateExecutionOptions + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + public CreateExecutionOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) + { + PathFlowSid = pathFlowSid; + To = to; + From = from; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (Parameters != null) + { + p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); + } + + return p; + } + } + + /// + /// Delete the Execution and all Steps relating to it. + /// + public class DeleteExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + public DeleteExecutionOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the status of an Execution to `ended`. + /// + public class UpdateExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to update + /// + public string PathSid { get; } + /// + /// The status of the Execution + /// + public ExecutionResource.StatusEnum Status { get; } + + /// + /// Construct a new UpdateExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + public UpdateExecutionOptions(string pathFlowSid, string pathSid, ExecutionResource.StatusEnum status) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/Flow/ExecutionResource.cs b/src/Twilio/Rest/Studio/V1/Flow/ExecutionResource.cs index 07bde698e..2fe70f221 100644 --- a/src/Twilio/Rest/Studio/V1/Flow/ExecutionResource.cs +++ b/src/Twilio/Rest/Studio/V1/Flow/ExecutionResource.cs @@ -17,541 +17,541 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V1.Flow -{ - - public class ExecutionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Ended = new StatusEnum("ended"); - } - - private static Request BuildReadRequest(ReadExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// Read Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ResourceSet Read(ReadExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("executions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// Read Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("executions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// The SID of the Flow - /// Only show Executions that started on or after this ISO 8601 date-time - /// Only show Executions that started before this ISO 8601 date-time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Execution - public static ResourceSet Read(string pathFlowSid, - DateTime? dateCreatedFrom = null, - DateTime? dateCreatedTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionOptions(pathFlowSid){DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// The SID of the Flow - /// Only show Executions that started on or after this ISO 8601 date-time - /// Only show Executions that started before this ISO 8601 date-time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - DateTime? dateCreatedFrom = null, - DateTime? dateCreatedTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionOptions(pathFlowSid){DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - private static Request BuildFetchRequest(FetchExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve an Execution - /// - /// Fetch Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Fetch(FetchExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve an Execution - /// - /// Fetch Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve an Execution - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchExecutionOptions(pathFlowSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve an Execution - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionOptions(pathFlowSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Triggers a new Execution for the Flow - /// - /// Create Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Create(CreateExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Triggers a new Execution for the Flow - /// - /// Create Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task CreateAsync(CreateExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Triggers a new Execution for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - /// JSON data that will be added to the Flow's context - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Create(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateExecutionOptions(pathFlowSid, to, from){Parameters = parameters}; - return Create(options, client); - } - - #if !NET35 - /// - /// Triggers a new Execution for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - /// JSON data that will be added to the Flow's context - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateExecutionOptions(pathFlowSid, to, from){Parameters = parameters}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete the Execution and all Steps relating to it. - /// - /// Delete Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static bool Delete(DeleteExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete the Execution and all Steps relating to it. - /// - /// Delete Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task DeleteAsync(DeleteExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete the Execution and all Steps relating to it. - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - /// Client to make requests to Twilio - /// A single instance of Execution - public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteExecutionOptions(pathFlowSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete the Execution and all Steps relating to it. - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteExecutionOptions(pathFlowSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the status of an Execution to `ended`. - /// - /// Update Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Update(UpdateExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the status of an Execution to `ended`. - /// - /// Update Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task UpdateAsync(UpdateExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the status of an Execution to `ended`. - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Update(string pathFlowSid, - string pathSid, - ExecutionResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// Update the status of an Execution to `ended`. - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task UpdateAsync(string pathFlowSid, - string pathSid, - ExecutionResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionResource object - /// - /// Raw JSON string - /// ExecutionResource object represented by the provided JSON - public static ExecutionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Contact - /// - [JsonProperty("contact_sid")] - public string ContactSid { get; private set; } - /// - /// The phone number, SIP address or Client identifier that triggered the Execution - /// - [JsonProperty("contact_channel_address")] - public string ContactChannelAddress { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The status of the Execution - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ExecutionResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExecutionResource() - { - - } - } +{ + + public class ExecutionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Ended = new StatusEnum("ended"); + } + + private static Request BuildReadRequest(ReadExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// Read Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ResourceSet Read(ReadExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("executions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// Read Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("executions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// The SID of the Flow + /// Only show Executions that started on or after this ISO 8601 date-time + /// Only show Executions that started before this ISO 8601 date-time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Execution + public static ResourceSet Read(string pathFlowSid, + DateTime? dateCreatedFrom = null, + DateTime? dateCreatedTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionOptions(pathFlowSid) { DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// The SID of the Flow + /// Only show Executions that started on or after this ISO 8601 date-time + /// Only show Executions that started before this ISO 8601 date-time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + DateTime? dateCreatedFrom = null, + DateTime? dateCreatedTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionOptions(pathFlowSid) { DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + private static Request BuildFetchRequest(FetchExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve an Execution + /// + /// Fetch Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Fetch(FetchExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve an Execution + /// + /// Fetch Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve an Execution + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchExecutionOptions(pathFlowSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve an Execution + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionOptions(pathFlowSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Triggers a new Execution for the Flow + /// + /// Create Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Create(CreateExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Triggers a new Execution for the Flow + /// + /// Create Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task CreateAsync(CreateExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Triggers a new Execution for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + /// JSON data that will be added to the Flow's context + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Create(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateExecutionOptions(pathFlowSid, to, from) { Parameters = parameters }; + return Create(options, client); + } + +#if !NET35 + /// + /// Triggers a new Execution for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + /// JSON data that will be added to the Flow's context + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateExecutionOptions(pathFlowSid, to, from) { Parameters = parameters }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete the Execution and all Steps relating to it. + /// + /// Delete Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static bool Delete(DeleteExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete the Execution and all Steps relating to it. + /// + /// Delete Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task DeleteAsync(DeleteExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete the Execution and all Steps relating to it. + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + /// Client to make requests to Twilio + /// A single instance of Execution + public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteExecutionOptions(pathFlowSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete the Execution and all Steps relating to it. + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteExecutionOptions(pathFlowSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the status of an Execution to `ended`. + /// + /// Update Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Update(UpdateExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the status of an Execution to `ended`. + /// + /// Update Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task UpdateAsync(UpdateExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the status of an Execution to `ended`. + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Update(string pathFlowSid, + string pathSid, + ExecutionResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// Update the status of an Execution to `ended`. + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task UpdateAsync(string pathFlowSid, + string pathSid, + ExecutionResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionResource object + /// + /// Raw JSON string + /// ExecutionResource object represented by the provided JSON + public static ExecutionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Contact + /// + [JsonProperty("contact_sid")] + public string ContactSid { get; private set; } + /// + /// The phone number, SIP address or Client identifier that triggered the Execution + /// + [JsonProperty("contact_channel_address")] + public string ContactChannelAddress { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The status of the Execution + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ExecutionResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExecutionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/FlowOptions.cs b/src/Twilio/Rest/Studio/V1/FlowOptions.cs index 96023ff9a..8051045d2 100644 --- a/src/Twilio/Rest/Studio/V1/FlowOptions.cs +++ b/src/Twilio/Rest/Studio/V1/FlowOptions.cs @@ -9,84 +9,84 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V1 -{ - +{ + + /// + /// Retrieve a list of all Flows. + /// + public class ReadFlowOptions : ReadOptions + { /// - /// Retrieve a list of all Flows. + /// Generate the necessary parameters /// - public class ReadFlowOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a specific Flow. + /// + public class FetchFlowOptions : IOptions + { /// - /// Retrieve a specific Flow. + /// The SID that identifies the resource to fetch /// - public class FetchFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFlowOptions - /// - /// The SID that identifies the resource to fetch - public FetchFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Delete a specific Flow. + /// Construct a new FetchFlowOptions /// - public class DeleteFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFlowOptions - /// - /// The SID that identifies the resource to delete - public DeleteFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID that identifies the resource to fetch + public FetchFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Flow. + /// + public class DeleteFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFlowOptions + /// + /// The SID that identifies the resource to delete + public DeleteFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V1/FlowResource.cs b/src/Twilio/Rest/Studio/V1/FlowResource.cs index 654bb0863..d7d512a1f 100644 --- a/src/Twilio/Rest/Studio/V1/FlowResource.cs +++ b/src/Twilio/Rest/Studio/V1/FlowResource.cs @@ -17,354 +17,354 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V1 -{ - - public class FlowResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum Published = new StatusEnum("published"); - } - - private static Request BuildReadRequest(ReadFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Flows. - /// - /// Read Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static ResourceSet Read(ReadFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("flows", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows. - /// - /// Read Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("flows", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Flows. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Flow - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - private static Request BuildFetchRequest(FetchFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Flow. - /// - /// Fetch Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Fetch(FetchFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Flow. - /// - /// Fetch Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task FetchAsync(FetchFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Flow. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFlowOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Flow. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFlowOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Studio, - "/v1/Flows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Flow. - /// - /// Delete Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static bool Delete(DeleteFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Flow. - /// - /// Delete Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Flow. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Flow - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlowOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Flow. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlowOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlowResource object - /// - /// Raw JSON string - /// FlowResource object represented by the provided JSON - public static FlowResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the Flow - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The status of the Flow - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FlowResource.StatusEnum Status { get; private set; } - /// - /// The latest version number of the Flow's definition - /// - [JsonProperty("version")] - public int? Version { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private FlowResource() - { - - } - } +{ + + public class FlowResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum Published = new StatusEnum("published"); + } + + private static Request BuildReadRequest(ReadFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Flows. + /// + /// Read Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static ResourceSet Read(ReadFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("flows", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows. + /// + /// Read Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("flows", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Flows. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Flow + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + private static Request BuildFetchRequest(FetchFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Flow. + /// + /// Fetch Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Fetch(FetchFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Flow. + /// + /// Fetch Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task FetchAsync(FetchFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Flow. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFlowOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Flow. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFlowOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Studio, + "/v1/Flows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Flow. + /// + /// Delete Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static bool Delete(DeleteFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Flow. + /// + /// Delete Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Flow. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Flow + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlowOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Flow. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlowOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlowResource object + /// + /// Raw JSON string + /// FlowResource object represented by the provided JSON + public static FlowResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the Flow + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The status of the Flow + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FlowResource.StatusEnum Status { get; private set; } + /// + /// The latest version number of the Flow's definition + /// + [JsonProperty("version")] + public int? Version { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private FlowResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextOptions.cs index ec7879e18..44f4793f2 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextOptions.cs @@ -9,41 +9,41 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow.Execution -{ - +{ + + /// + /// Retrieve the most recent context for an Execution. + /// + public class FetchExecutionContextOptions : IOptions + { /// - /// Retrieve the most recent context for an Execution. + /// The SID of the Flow /// - public class FetchExecutionContextOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - - /// - /// Construct a new FetchExecutionContextOptions - /// - /// The SID of the Flow - /// The SID of the Execution - public FetchExecutionContextOptions(string pathFlowSid, string pathExecutionSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + + /// + /// Construct a new FetchExecutionContextOptions + /// + /// The SID of the Flow + /// The SID of the Execution + public FetchExecutionContextOptions(string pathFlowSid, string pathExecutionSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextResource.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextResource.cs index 05d850306..5a286952a 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextResource.cs @@ -16,130 +16,130 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V2.Flow.Execution -{ - - public class ExecutionContextResource : Resource - { - private static Request BuildFetchRequest(FetchExecutionContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the most recent context for an Execution. - /// - /// Fetch ExecutionContext parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionContext - public static ExecutionContextResource Fetch(FetchExecutionContextOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Execution. - /// - /// Fetch ExecutionContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionContext - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the most recent context for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Client to make requests to Twilio - /// A single instance of ExecutionContext - public static ExecutionContextResource Fetch(string pathFlowSid, - string pathExecutionSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the most recent context for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionContextResource object - /// - /// Raw JSON string - /// ExecutionContextResource object represented by the provided JSON - public static ExecutionContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExecutionContextResource() - { - - } - } +{ + + public class ExecutionContextResource : Resource + { + private static Request BuildFetchRequest(FetchExecutionContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the most recent context for an Execution. + /// + /// Fetch ExecutionContext parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionContext + public static ExecutionContextResource Fetch(FetchExecutionContextOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Execution. + /// + /// Fetch ExecutionContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionContext + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the most recent context for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Client to make requests to Twilio + /// A single instance of ExecutionContext + public static ExecutionContextResource Fetch(string pathFlowSid, + string pathExecutionSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the most recent context for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionContextResource object + /// + /// Raw JSON string + /// ExecutionContextResource object represented by the provided JSON + public static ExecutionContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExecutionContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs index fc959ceed..2812b28b8 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextOptions.cs @@ -9,47 +9,47 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow.Execution.ExecutionStep -{ - +{ + + /// + /// Retrieve the context for an Execution Step. + /// + public class FetchExecutionStepContextOptions : IOptions + { /// - /// Retrieve the context for an Execution Step. + /// The SID of the Flow /// - public class FetchExecutionStepContextOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - /// - /// Step SID - /// - public string PathStepSid { get; } - - /// - /// Construct a new FetchExecutionStepContextOptions - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - public FetchExecutionStepContextOptions(string pathFlowSid, string pathExecutionSid, string pathStepSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - PathStepSid = pathStepSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + /// + /// Step SID + /// + public string PathStepSid { get; } + + /// + /// Construct a new FetchExecutionStepContextOptions + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + public FetchExecutionStepContextOptions(string pathFlowSid, string pathExecutionSid, string pathStepSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + PathStepSid = pathStepSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs index 6862d1ac6..5f3a83c94 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStep/ExecutionStepContextResource.cs @@ -16,140 +16,140 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V2.Flow.Execution.ExecutionStep -{ - - public class ExecutionStepContextResource : Resource - { - private static Request BuildFetchRequest(FetchExecutionStepContextOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathStepSid + "/Context", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve the context for an Execution Step. - /// - /// Fetch ExecutionStepContext parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStepContext - public static ExecutionStepContextResource Fetch(FetchExecutionStepContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve the context for an Execution Step. - /// - /// Fetch ExecutionStepContext parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStepContext - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepContextOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve the context for an Execution Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - /// Client to make requests to Twilio - /// A single instance of ExecutionStepContext - public static ExecutionStepContextResource Fetch(string pathFlowSid, - string pathExecutionSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve the context for an Execution Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Step SID - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStepContext - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - string pathStepSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionStepContextResource object - /// - /// Raw JSON string - /// ExecutionStepContextResource object represented by the provided JSON - public static ExecutionStepContextResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// Step SID - /// - [JsonProperty("step_sid")] - public string StepSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ExecutionStepContextResource() - { - - } - } +{ + + public class ExecutionStepContextResource : Resource + { + private static Request BuildFetchRequest(FetchExecutionStepContextOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathStepSid + "/Context", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve the context for an Execution Step. + /// + /// Fetch ExecutionStepContext parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStepContext + public static ExecutionStepContextResource Fetch(FetchExecutionStepContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve the context for an Execution Step. + /// + /// Fetch ExecutionStepContext parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStepContext + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepContextOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve the context for an Execution Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + /// Client to make requests to Twilio + /// A single instance of ExecutionStepContext + public static ExecutionStepContextResource Fetch(string pathFlowSid, + string pathExecutionSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve the context for an Execution Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Step SID + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStepContext + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + string pathStepSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepContextOptions(pathFlowSid, pathExecutionSid, pathStepSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionStepContextResource object + /// + /// Raw JSON string + /// ExecutionStepContextResource object represented by the provided JSON + public static ExecutionStepContextResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// Step SID + /// + [JsonProperty("step_sid")] + public string StepSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ExecutionStepContextResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepOptions.cs index 1529e6353..48c62c768 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow.Execution -{ - +{ + + /// + /// Retrieve a list of all Steps for an Execution. + /// + public class ReadExecutionStepOptions : ReadOptions + { /// - /// Retrieve a list of all Steps for an Execution. + /// The SID of the Flow /// - public class ReadExecutionStepOptions : ReadOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - - /// - /// Construct a new ReadExecutionStepOptions - /// - /// The SID of the Flow - /// The SID of the Execution - public ReadExecutionStepOptions(string pathFlowSid, string pathExecutionSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathFlowSid { get; } /// - /// Retrieve a Step. + /// The SID of the Execution /// - public class FetchExecutionStepOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution - /// - public string PathExecutionSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchExecutionStepOptions - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - public FetchExecutionStepOptions(string pathFlowSid, string pathExecutionSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathExecutionSid = pathExecutionSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathExecutionSid { get; } + + /// + /// Construct a new ReadExecutionStepOptions + /// + /// The SID of the Flow + /// The SID of the Execution + public ReadExecutionStepOptions(string pathFlowSid, string pathExecutionSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a Step. + /// + public class FetchExecutionStepOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution + /// + public string PathExecutionSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchExecutionStepOptions + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + public FetchExecutionStepOptions(string pathFlowSid, string pathExecutionSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathExecutionSid = pathExecutionSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepResource.cs b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepResource.cs index c61d396f0..51c8da820 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionStepResource.cs @@ -16,307 +16,307 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V2.Flow.Execution -{ - - public class ExecutionStepResource : Resource - { - private static Request BuildReadRequest(ReadExecutionStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// Read ExecutionStep parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ResourceSet Read(ReadExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// Read ExecutionStep parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("steps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ResourceSet Read(string pathFlowSid, - string pathExecutionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Steps for an Execution. - /// - /// The SID of the Flow - /// The SID of the Execution - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - string pathExecutionSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("steps", response.Content); - } - - private static Request BuildFetchRequest(FetchExecutionStepOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a Step. - /// - /// Fetch ExecutionStep parameters - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ExecutionStepResource Fetch(FetchExecutionStepOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// Fetch ExecutionStep parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ExecutionStep - public static ExecutionStepResource Fetch(string pathFlowSid, - string pathExecutionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a Step. - /// - /// The SID of the Flow - /// The SID of the Execution - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ExecutionStep - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathExecutionSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionStepResource object - /// - /// Raw JSON string - /// ExecutionStepResource object represented by the provided JSON - public static ExecutionStepResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The SID of the Execution - /// - [JsonProperty("execution_sid")] - public string ExecutionSid { get; private set; } - /// - /// The event that caused the Flow to transition to the Step - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The Widget that preceded the Widget for the Step - /// - [JsonProperty("transitioned_from")] - public string TransitionedFrom { get; private set; } - /// - /// The Widget that will follow the Widget for the Step - /// - [JsonProperty("transitioned_to")] - public string TransitionedTo { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExecutionStepResource() - { - - } - } +{ + + public class ExecutionStepResource : Resource + { + private static Request BuildReadRequest(ReadExecutionStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// Read ExecutionStep parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ResourceSet Read(ReadExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// Read ExecutionStep parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("steps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ResourceSet Read(string pathFlowSid, + string pathExecutionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Steps for an Execution. + /// + /// The SID of the Flow + /// The SID of the Execution + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + string pathExecutionSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionStepOptions(pathFlowSid, pathExecutionSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("steps", response.Content); + } + + private static Request BuildFetchRequest(FetchExecutionStepOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Steps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a Step. + /// + /// Fetch ExecutionStep parameters + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ExecutionStepResource Fetch(FetchExecutionStepOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// Fetch ExecutionStep parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionStepOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ExecutionStep + public static ExecutionStepResource Fetch(string pathFlowSid, + string pathExecutionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a Step. + /// + /// The SID of the Flow + /// The SID of the Execution + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ExecutionStep + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathExecutionSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionStepOptions(pathFlowSid, pathExecutionSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionStepResource object + /// + /// Raw JSON string + /// ExecutionStepResource object represented by the provided JSON + public static ExecutionStepResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The SID of the Execution + /// + [JsonProperty("execution_sid")] + public string ExecutionSid { get; private set; } + /// + /// The event that caused the Flow to transition to the Step + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The Widget that preceded the Widget for the Step + /// + [JsonProperty("transitioned_from")] + public string TransitionedFrom { get; private set; } + /// + /// The Widget that will follow the Widget for the Step + /// + [JsonProperty("transitioned_to")] + public string TransitionedTo { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExecutionStepResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/ExecutionOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/ExecutionOptions.cs index 6f20b063f..f52eec831 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/ExecutionOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/ExecutionOptions.cs @@ -9,235 +9,235 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow -{ - +{ + + /// + /// Retrieve a list of all Executions for the Flow. + /// + public class ReadExecutionOptions : ReadOptions + { /// - /// Retrieve a list of all Executions for the Flow. - /// - public class ReadExecutionOptions : ReadOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// Only show Executions that started on or after this ISO 8601 date-time - /// - public DateTime? DateCreatedFrom { get; set; } - /// - /// Only show Executions that started before this ISO 8601 date-time - /// - public DateTime? DateCreatedTo { get; set; } - - /// - /// Construct a new ReadExecutionOptions - /// - /// The SID of the Flow - public ReadExecutionOptions(string pathFlowSid) - { - PathFlowSid = pathFlowSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreatedFrom != null) - { - p.Add(new KeyValuePair("DateCreatedFrom", Serializers.DateTimeIso8601(DateCreatedFrom))); - } - - if (DateCreatedTo != null) - { - p.Add(new KeyValuePair("DateCreatedTo", Serializers.DateTimeIso8601(DateCreatedTo))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Flow + /// + public string PathFlowSid { get; } /// - /// Retrieve an Execution - /// - public class FetchExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - public FetchExecutionOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Only show Executions that started on or after this ISO 8601 date-time + /// + public DateTime? DateCreatedFrom { get; set; } /// - /// Triggers a new Execution for the Flow - /// - public class CreateExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The Contact phone number to start a Studio Flow Execution - /// - public Types.PhoneNumber To { get; } - /// - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution - /// - public Types.PhoneNumber From { get; } - /// - /// JSON data that will be added to the Flow's context - /// - public object Parameters { get; set; } - - /// - /// Construct a new CreateExecutionOptions - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - public CreateExecutionOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) - { - PathFlowSid = pathFlowSid; - To = to; - From = from; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From.ToString())); - } - - if (Parameters != null) - { - p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); - } - - return p; - } - } - + /// Only show Executions that started before this ISO 8601 date-time + /// + public DateTime? DateCreatedTo { get; set; } + /// - /// Delete the Execution and all Steps relating to it. - /// - public class DeleteExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - public DeleteExecutionOptions(string pathFlowSid, string pathSid) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new ReadExecutionOptions + /// + /// The SID of the Flow + public ReadExecutionOptions(string pathFlowSid) + { + PathFlowSid = pathFlowSid; + } + /// - /// Update the status of an Execution to `ended`. - /// - public class UpdateExecutionOptions : IOptions - { - /// - /// The SID of the Flow - /// - public string PathFlowSid { get; } - /// - /// The SID of the Execution resource to update - /// - public string PathSid { get; } - /// - /// The status of the Execution - /// - public ExecutionResource.StatusEnum Status { get; } - - /// - /// Construct a new UpdateExecutionOptions - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - public UpdateExecutionOptions(string pathFlowSid, string pathSid, ExecutionResource.StatusEnum status) - { - PathFlowSid = pathFlowSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreatedFrom != null) + { + p.Add(new KeyValuePair("DateCreatedFrom", Serializers.DateTimeIso8601(DateCreatedFrom))); + } + + if (DateCreatedTo != null) + { + p.Add(new KeyValuePair("DateCreatedTo", Serializers.DateTimeIso8601(DateCreatedTo))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve an Execution + /// + public class FetchExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + public FetchExecutionOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Triggers a new Execution for the Flow + /// + public class CreateExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The Contact phone number to start a Studio Flow Execution + /// + public Types.PhoneNumber To { get; } + /// + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution + /// + public Types.PhoneNumber From { get; } + /// + /// JSON data that will be added to the Flow's context + /// + public object Parameters { get; set; } + + /// + /// Construct a new CreateExecutionOptions + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + public CreateExecutionOptions(string pathFlowSid, Types.PhoneNumber to, Types.PhoneNumber from) + { + PathFlowSid = pathFlowSid; + To = to; + From = from; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From.ToString())); + } + + if (Parameters != null) + { + p.Add(new KeyValuePair("Parameters", Serializers.JsonObject(Parameters))); + } + + return p; + } + } + + /// + /// Delete the Execution and all Steps relating to it. + /// + public class DeleteExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + public DeleteExecutionOptions(string pathFlowSid, string pathSid) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the status of an Execution to `ended`. + /// + public class UpdateExecutionOptions : IOptions + { + /// + /// The SID of the Flow + /// + public string PathFlowSid { get; } + /// + /// The SID of the Execution resource to update + /// + public string PathSid { get; } + /// + /// The status of the Execution + /// + public ExecutionResource.StatusEnum Status { get; } + + /// + /// Construct a new UpdateExecutionOptions + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + public UpdateExecutionOptions(string pathFlowSid, string pathSid, ExecutionResource.StatusEnum status) + { + PathFlowSid = pathFlowSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/ExecutionResource.cs b/src/Twilio/Rest/Studio/V2/Flow/ExecutionResource.cs index 814f71d65..0b1503d16 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/ExecutionResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/ExecutionResource.cs @@ -17,536 +17,536 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V2.Flow -{ - - public class ExecutionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Ended = new StatusEnum("ended"); - } - - private static Request BuildReadRequest(ReadExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// Read Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ResourceSet Read(ReadExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("executions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// Read Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("executions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// The SID of the Flow - /// Only show Executions that started on or after this ISO 8601 date-time - /// Only show Executions that started before this ISO 8601 date-time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Execution - public static ResourceSet Read(string pathFlowSid, - DateTime? dateCreatedFrom = null, - DateTime? dateCreatedTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionOptions(pathFlowSid){DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Executions for the Flow. - /// - /// The SID of the Flow - /// Only show Executions that started on or after this ISO 8601 date-time - /// Only show Executions that started before this ISO 8601 date-time - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, - DateTime? dateCreatedFrom = null, - DateTime? dateCreatedTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadExecutionOptions(pathFlowSid){DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("executions", response.Content); - } - - private static Request BuildFetchRequest(FetchExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve an Execution - /// - /// Fetch Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Fetch(FetchExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve an Execution - /// - /// Fetch Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve an Execution - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchExecutionOptions(pathFlowSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve an Execution - /// - /// The SID of the Flow - /// The SID of the Execution resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchExecutionOptions(pathFlowSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Triggers a new Execution for the Flow - /// - /// Create Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Create(CreateExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Triggers a new Execution for the Flow - /// - /// Create Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task CreateAsync(CreateExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Triggers a new Execution for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - /// JSON data that will be added to the Flow's context - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Create(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateExecutionOptions(pathFlowSid, to, from){Parameters = parameters}; - return Create(options, client); - } - - #if !NET35 - /// - /// Triggers a new Execution for the Flow - /// - /// The SID of the Flow - /// The Contact phone number to start a Studio Flow Execution - /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during - /// the Flow Execution - /// JSON data that will be added to the Flow's context - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, - Types.PhoneNumber to, - Types.PhoneNumber from, - object parameters = null, - ITwilioRestClient client = null) - { - var options = new CreateExecutionOptions(pathFlowSid, to, from){Parameters = parameters}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete the Execution and all Steps relating to it. - /// - /// Delete Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static bool Delete(DeleteExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete the Execution and all Steps relating to it. - /// - /// Delete Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task DeleteAsync(DeleteExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete the Execution and all Steps relating to it. - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - /// Client to make requests to Twilio - /// A single instance of Execution - public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteExecutionOptions(pathFlowSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete the Execution and all Steps relating to it. - /// - /// The SID of the Flow - /// The SID of the Execution resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteExecutionOptions(pathFlowSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateExecutionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the status of an Execution to `ended`. - /// - /// Update Execution parameters - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Update(UpdateExecutionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the status of an Execution to `ended`. - /// - /// Update Execution parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task UpdateAsync(UpdateExecutionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the status of an Execution to `ended`. - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - /// Client to make requests to Twilio - /// A single instance of Execution - public static ExecutionResource Update(string pathFlowSid, - string pathSid, - ExecutionResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// Update the status of an Execution to `ended`. - /// - /// The SID of the Flow - /// The SID of the Execution resource to update - /// The status of the Execution - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Execution - public static async System.Threading.Tasks.Task UpdateAsync(string pathFlowSid, - string pathSid, - ExecutionResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ExecutionResource object - /// - /// Raw JSON string - /// ExecutionResource object represented by the provided JSON - public static ExecutionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Flow - /// - [JsonProperty("flow_sid")] - public string FlowSid { get; private set; } - /// - /// The phone number, SIP address or Client identifier that triggered the Execution - /// - [JsonProperty("contact_channel_address")] - public string ContactChannelAddress { get; private set; } - /// - /// The current state of the flow - /// - [JsonProperty("context")] - public object Context { get; private set; } - /// - /// The status of the Execution - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ExecutionResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ExecutionResource() - { - - } - } +{ + + public class ExecutionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Ended = new StatusEnum("ended"); + } + + private static Request BuildReadRequest(ReadExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// Read Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ResourceSet Read(ReadExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("executions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// Read Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task> ReadAsync(ReadExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("executions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// The SID of the Flow + /// Only show Executions that started on or after this ISO 8601 date-time + /// Only show Executions that started before this ISO 8601 date-time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Execution + public static ResourceSet Read(string pathFlowSid, + DateTime? dateCreatedFrom = null, + DateTime? dateCreatedTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionOptions(pathFlowSid) { DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Executions for the Flow. + /// + /// The SID of the Flow + /// Only show Executions that started on or after this ISO 8601 date-time + /// Only show Executions that started before this ISO 8601 date-time + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task> ReadAsync(string pathFlowSid, + DateTime? dateCreatedFrom = null, + DateTime? dateCreatedTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadExecutionOptions(pathFlowSid) { DateCreatedFrom = dateCreatedFrom, DateCreatedTo = dateCreatedTo, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("executions", response.Content); + } + + private static Request BuildFetchRequest(FetchExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve an Execution + /// + /// Fetch Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Fetch(FetchExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve an Execution + /// + /// Fetch Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task FetchAsync(FetchExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve an Execution + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Fetch(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchExecutionOptions(pathFlowSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve an Execution + /// + /// The SID of the Flow + /// The SID of the Execution resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task FetchAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchExecutionOptions(pathFlowSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Triggers a new Execution for the Flow + /// + /// Create Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Create(CreateExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Triggers a new Execution for the Flow + /// + /// Create Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task CreateAsync(CreateExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Triggers a new Execution for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + /// JSON data that will be added to the Flow's context + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Create(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateExecutionOptions(pathFlowSid, to, from) { Parameters = parameters }; + return Create(options, client); + } + +#if !NET35 + /// + /// Triggers a new Execution for the Flow + /// + /// The SID of the Flow + /// The Contact phone number to start a Studio Flow Execution + /// The Twilio phone number or Messaging Service SID to send messages or initiate calls from during + /// the Flow Execution + /// JSON data that will be added to the Flow's context + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task CreateAsync(string pathFlowSid, + Types.PhoneNumber to, + Types.PhoneNumber from, + object parameters = null, + ITwilioRestClient client = null) + { + var options = new CreateExecutionOptions(pathFlowSid, to, from) { Parameters = parameters }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete the Execution and all Steps relating to it. + /// + /// Delete Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static bool Delete(DeleteExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete the Execution and all Steps relating to it. + /// + /// Delete Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task DeleteAsync(DeleteExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete the Execution and all Steps relating to it. + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + /// Client to make requests to Twilio + /// A single instance of Execution + public static bool Delete(string pathFlowSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteExecutionOptions(pathFlowSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete the Execution and all Steps relating to it. + /// + /// The SID of the Flow + /// The SID of the Execution resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task DeleteAsync(string pathFlowSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteExecutionOptions(pathFlowSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateExecutionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the status of an Execution to `ended`. + /// + /// Update Execution parameters + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Update(UpdateExecutionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the status of an Execution to `ended`. + /// + /// Update Execution parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task UpdateAsync(UpdateExecutionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the status of an Execution to `ended`. + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + /// Client to make requests to Twilio + /// A single instance of Execution + public static ExecutionResource Update(string pathFlowSid, + string pathSid, + ExecutionResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// Update the status of an Execution to `ended`. + /// + /// The SID of the Flow + /// The SID of the Execution resource to update + /// The status of the Execution + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Execution + public static async System.Threading.Tasks.Task UpdateAsync(string pathFlowSid, + string pathSid, + ExecutionResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateExecutionOptions(pathFlowSid, pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ExecutionResource object + /// + /// Raw JSON string + /// ExecutionResource object represented by the provided JSON + public static ExecutionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Flow + /// + [JsonProperty("flow_sid")] + public string FlowSid { get; private set; } + /// + /// The phone number, SIP address or Client identifier that triggered the Execution + /// + [JsonProperty("contact_channel_address")] + public string ContactChannelAddress { get; private set; } + /// + /// The current state of the flow + /// + [JsonProperty("context")] + public object Context { get; private set; } + /// + /// The status of the Execution + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ExecutionResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ExecutionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionOptions.cs index 184153a9e..39eba09e0 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionOptions.cs @@ -9,75 +9,75 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow -{ - +{ + + /// + /// Retrieve a list of all Flows revisions. + /// + public class ReadFlowRevisionOptions : ReadOptions + { /// - /// Retrieve a list of all Flows revisions. + /// The SID that identifies the resource to fetch /// - public class ReadFlowRevisionOptions : ReadOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new ReadFlowRevisionOptions - /// - /// The SID that identifies the resource to fetch - public ReadFlowRevisionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a specific Flow revision. + /// Construct a new ReadFlowRevisionOptions /// - public class FetchFlowRevisionOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - /// - /// Specific Revision number or can be `LatestPublished` and `LatestRevision` - /// - public string PathRevision { get; } - - /// - /// Construct a new FetchFlowRevisionOptions - /// - /// The SID that identifies the resource to fetch - /// Specific Revision number or can be `LatestPublished` and `LatestRevision` - public FetchFlowRevisionOptions(string pathSid, string pathRevision) - { - PathSid = pathSid; - PathRevision = pathRevision; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID that identifies the resource to fetch + public ReadFlowRevisionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a specific Flow revision. + /// + public class FetchFlowRevisionOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + /// + /// Specific Revision number or can be `LatestPublished` and `LatestRevision` + /// + public string PathRevision { get; } + + /// + /// Construct a new FetchFlowRevisionOptions + /// + /// The SID that identifies the resource to fetch + /// Specific Revision number or can be `LatestPublished` and `LatestRevision` + public FetchFlowRevisionOptions(string pathSid, string pathRevision) + { + PathSid = pathSid; + PathRevision = pathRevision; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionResource.cs b/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionResource.cs index 8d17570a6..abccd413b 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/FlowRevisionResource.cs @@ -17,311 +17,311 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V2.Flow -{ - - public class FlowRevisionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum Published = new StatusEnum("published"); - } - - private static Request BuildReadRequest(ReadFlowRevisionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "/Revisions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Flows revisions. - /// - /// Read FlowRevision parameters - /// Client to make requests to Twilio - /// A single instance of FlowRevision - public static ResourceSet Read(ReadFlowRevisionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("revisions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows revisions. - /// - /// Read FlowRevision parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowRevision - public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowRevisionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("revisions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Flows revisions. - /// - /// The SID that identifies the resource to fetch - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of FlowRevision - public static ResourceSet Read(string pathSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowRevisionOptions(pathSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows revisions. - /// - /// The SID that identifies the resource to fetch - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowRevision - public static async System.Threading.Tasks.Task> ReadAsync(string pathSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowRevisionOptions(pathSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("revisions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("revisions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("revisions", response.Content); - } - - private static Request BuildFetchRequest(FetchFlowRevisionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "/Revisions/" + options.PathRevision + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Flow revision. - /// - /// Fetch FlowRevision parameters - /// Client to make requests to Twilio - /// A single instance of FlowRevision - public static FlowRevisionResource Fetch(FetchFlowRevisionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Flow revision. - /// - /// Fetch FlowRevision parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowRevision - public static async System.Threading.Tasks.Task FetchAsync(FetchFlowRevisionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Flow revision. - /// - /// The SID that identifies the resource to fetch - /// Specific Revision number or can be `LatestPublished` and `LatestRevision` - /// Client to make requests to Twilio - /// A single instance of FlowRevision - public static FlowRevisionResource Fetch(string pathSid, string pathRevision, ITwilioRestClient client = null) - { - var options = new FetchFlowRevisionOptions(pathSid, pathRevision); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Flow revision. - /// - /// The SID that identifies the resource to fetch - /// Specific Revision number or can be `LatestPublished` and `LatestRevision` - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowRevision - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - string pathRevision, - ITwilioRestClient client = null) - { - var options = new FetchFlowRevisionOptions(pathSid, pathRevision); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlowRevisionResource object - /// - /// Raw JSON string - /// FlowRevisionResource object represented by the provided JSON - public static FlowRevisionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the Flow - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// JSON representation of flow definition - /// - [JsonProperty("definition")] - public object Definition { get; private set; } - /// - /// The status of the Flow - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FlowRevisionResource.StatusEnum Status { get; private set; } - /// - /// The latest revision number of the Flow's definition - /// - [JsonProperty("revision")] - public int? Revision { get; private set; } - /// - /// Description of change made in the revision - /// - [JsonProperty("commit_message")] - public string CommitMessage { get; private set; } - /// - /// Boolean if the flow definition is valid - /// - [JsonProperty("valid")] - public bool? Valid { get; private set; } - /// - /// List of error in the flow definition - /// - [JsonProperty("errors")] - public List Errors { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FlowRevisionResource() - { - - } - } +{ + + public class FlowRevisionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum Published = new StatusEnum("published"); + } + + private static Request BuildReadRequest(ReadFlowRevisionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "/Revisions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Flows revisions. + /// + /// Read FlowRevision parameters + /// Client to make requests to Twilio + /// A single instance of FlowRevision + public static ResourceSet Read(ReadFlowRevisionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("revisions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows revisions. + /// + /// Read FlowRevision parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowRevision + public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowRevisionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("revisions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Flows revisions. + /// + /// The SID that identifies the resource to fetch + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of FlowRevision + public static ResourceSet Read(string pathSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowRevisionOptions(pathSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows revisions. + /// + /// The SID that identifies the resource to fetch + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowRevision + public static async System.Threading.Tasks.Task> ReadAsync(string pathSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowRevisionOptions(pathSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("revisions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("revisions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("revisions", response.Content); + } + + private static Request BuildFetchRequest(FetchFlowRevisionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "/Revisions/" + options.PathRevision + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Flow revision. + /// + /// Fetch FlowRevision parameters + /// Client to make requests to Twilio + /// A single instance of FlowRevision + public static FlowRevisionResource Fetch(FetchFlowRevisionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Flow revision. + /// + /// Fetch FlowRevision parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowRevision + public static async System.Threading.Tasks.Task FetchAsync(FetchFlowRevisionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Flow revision. + /// + /// The SID that identifies the resource to fetch + /// Specific Revision number or can be `LatestPublished` and `LatestRevision` + /// Client to make requests to Twilio + /// A single instance of FlowRevision + public static FlowRevisionResource Fetch(string pathSid, string pathRevision, ITwilioRestClient client = null) + { + var options = new FetchFlowRevisionOptions(pathSid, pathRevision); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Flow revision. + /// + /// The SID that identifies the resource to fetch + /// Specific Revision number or can be `LatestPublished` and `LatestRevision` + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowRevision + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + string pathRevision, + ITwilioRestClient client = null) + { + var options = new FetchFlowRevisionOptions(pathSid, pathRevision); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlowRevisionResource object + /// + /// Raw JSON string + /// FlowRevisionResource object represented by the provided JSON + public static FlowRevisionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the Flow + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// JSON representation of flow definition + /// + [JsonProperty("definition")] + public object Definition { get; private set; } + /// + /// The status of the Flow + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FlowRevisionResource.StatusEnum Status { get; private set; } + /// + /// The latest revision number of the Flow's definition + /// + [JsonProperty("revision")] + public int? Revision { get; private set; } + /// + /// Description of change made in the revision + /// + [JsonProperty("commit_message")] + public string CommitMessage { get; private set; } + /// + /// Boolean if the flow definition is valid + /// + [JsonProperty("valid")] + public bool? Valid { get; private set; } + /// + /// List of error in the flow definition + /// + [JsonProperty("errors")] + public List Errors { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FlowRevisionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserOptions.cs b/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserOptions.cs index 53ab2cab4..039369f55 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserOptions.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserOptions.cs @@ -10,75 +10,75 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2.Flow -{ - +{ + + /// + /// Fetch flow test users + /// + public class FetchFlowTestUserOptions : IOptions + { /// - /// Fetch flow test users + /// Unique identifier of the flow. /// - public class FetchFlowTestUserOptions : IOptions - { - /// - /// Unique identifier of the flow. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFlowTestUserOptions - /// - /// Unique identifier of the flow. - public FetchFlowTestUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Update flow test users + /// Construct a new FetchFlowTestUserOptions /// - public class UpdateFlowTestUserOptions : IOptions - { - /// - /// Unique identifier of the flow. - /// - public string PathSid { get; } - /// - /// List of test user identities that can test draft versions of the flow. - /// - public List TestUsers { get; } - - /// - /// Construct a new UpdateFlowTestUserOptions - /// - /// Unique identifier of the flow. - /// List of test user identities that can test draft versions of the flow. - public UpdateFlowTestUserOptions(string pathSid, List testUsers) - { - PathSid = pathSid; - TestUsers = testUsers; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TestUsers != null) - { - p.AddRange(TestUsers.Select(prop => new KeyValuePair("TestUsers", prop))); - } - - return p; - } - } + /// Unique identifier of the flow. + public FetchFlowTestUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update flow test users + /// + public class UpdateFlowTestUserOptions : IOptions + { + /// + /// Unique identifier of the flow. + /// + public string PathSid { get; } + /// + /// List of test user identities that can test draft versions of the flow. + /// + public List TestUsers { get; } + + /// + /// Construct a new UpdateFlowTestUserOptions + /// + /// Unique identifier of the flow. + /// List of test user identities that can test draft versions of the flow. + public UpdateFlowTestUserOptions(string pathSid, List testUsers) + { + PathSid = pathSid; + TestUsers = testUsers; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TestUsers != null) + { + p.AddRange(TestUsers.Select(prop => new KeyValuePair("TestUsers", prop))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserResource.cs b/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserResource.cs index 9f797bfca..c7ac9cbb4 100644 --- a/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserResource.cs +++ b/src/Twilio/Rest/Studio/V2/Flow/FlowTestUserResource.cs @@ -16,185 +16,185 @@ using Twilio.Http; namespace Twilio.Rest.Studio.V2.Flow -{ - - public class FlowTestUserResource : Resource - { - private static Request BuildFetchRequest(FetchFlowTestUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "/TestUsers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch flow test users - /// - /// Fetch FlowTestUser parameters - /// Client to make requests to Twilio - /// A single instance of FlowTestUser - public static FlowTestUserResource Fetch(FetchFlowTestUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch flow test users - /// - /// Fetch FlowTestUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowTestUser - public static async System.Threading.Tasks.Task FetchAsync(FetchFlowTestUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch flow test users - /// - /// Unique identifier of the flow. - /// Client to make requests to Twilio - /// A single instance of FlowTestUser - public static FlowTestUserResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFlowTestUserOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch flow test users - /// - /// Unique identifier of the flow. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowTestUser - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFlowTestUserOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFlowTestUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "/TestUsers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update flow test users - /// - /// Update FlowTestUser parameters - /// Client to make requests to Twilio - /// A single instance of FlowTestUser - public static FlowTestUserResource Update(UpdateFlowTestUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update flow test users - /// - /// Update FlowTestUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowTestUser - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowTestUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update flow test users - /// - /// Unique identifier of the flow. - /// List of test user identities that can test draft versions of the flow. - /// Client to make requests to Twilio - /// A single instance of FlowTestUser - public static FlowTestUserResource Update(string pathSid, List testUsers, ITwilioRestClient client = null) - { - var options = new UpdateFlowTestUserOptions(pathSid, testUsers); - return Update(options, client); - } - - #if !NET35 - /// - /// Update flow test users - /// - /// Unique identifier of the flow. - /// List of test user identities that can test draft versions of the flow. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowTestUser - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - List testUsers, - ITwilioRestClient client = null) - { - var options = new UpdateFlowTestUserOptions(pathSid, testUsers); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlowTestUserResource object - /// - /// Raw JSON string - /// FlowTestUserResource object represented by the provided JSON - public static FlowTestUserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Unique identifier of the flow. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// List of test user identities that can test draft versions of the flow. - /// - [JsonProperty("test_users")] - public List TestUsers { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FlowTestUserResource() - { - - } - } +{ + + public class FlowTestUserResource : Resource + { + private static Request BuildFetchRequest(FetchFlowTestUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "/TestUsers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch flow test users + /// + /// Fetch FlowTestUser parameters + /// Client to make requests to Twilio + /// A single instance of FlowTestUser + public static FlowTestUserResource Fetch(FetchFlowTestUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch flow test users + /// + /// Fetch FlowTestUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowTestUser + public static async System.Threading.Tasks.Task FetchAsync(FetchFlowTestUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch flow test users + /// + /// Unique identifier of the flow. + /// Client to make requests to Twilio + /// A single instance of FlowTestUser + public static FlowTestUserResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFlowTestUserOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch flow test users + /// + /// Unique identifier of the flow. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowTestUser + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFlowTestUserOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFlowTestUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "/TestUsers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update flow test users + /// + /// Update FlowTestUser parameters + /// Client to make requests to Twilio + /// A single instance of FlowTestUser + public static FlowTestUserResource Update(UpdateFlowTestUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update flow test users + /// + /// Update FlowTestUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowTestUser + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowTestUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update flow test users + /// + /// Unique identifier of the flow. + /// List of test user identities that can test draft versions of the flow. + /// Client to make requests to Twilio + /// A single instance of FlowTestUser + public static FlowTestUserResource Update(string pathSid, List testUsers, ITwilioRestClient client = null) + { + var options = new UpdateFlowTestUserOptions(pathSid, testUsers); + return Update(options, client); + } + +#if !NET35 + /// + /// Update flow test users + /// + /// Unique identifier of the flow. + /// List of test user identities that can test draft versions of the flow. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowTestUser + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + List testUsers, + ITwilioRestClient client = null) + { + var options = new UpdateFlowTestUserOptions(pathSid, testUsers); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlowTestUserResource object + /// + /// Raw JSON string + /// FlowTestUserResource object represented by the provided JSON + public static FlowTestUserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Unique identifier of the flow. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// List of test user identities that can test draft versions of the flow. + /// + [JsonProperty("test_users")] + public List TestUsers { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FlowTestUserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/FlowOptions.cs b/src/Twilio/Rest/Studio/V2/FlowOptions.cs index 86289aeab..4f80f9d8c 100644 --- a/src/Twilio/Rest/Studio/V2/FlowOptions.cs +++ b/src/Twilio/Rest/Studio/V2/FlowOptions.cs @@ -9,216 +9,216 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2 -{ - +{ + + /// + /// Create a Flow. + /// + public class CreateFlowOptions : IOptions + { /// - /// Create a Flow. - /// - public class CreateFlowOptions : IOptions - { - /// - /// The string that you assigned to describe the Flow - /// - public string FriendlyName { get; } - /// - /// The status of the Flow - /// - public FlowResource.StatusEnum Status { get; } - /// - /// JSON representation of flow definition - /// - public object Definition { get; } - /// - /// Description of change made in the revision - /// - public string CommitMessage { get; set; } - - /// - /// Construct a new CreateFlowOptions - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - public CreateFlowOptions(string friendlyName, FlowResource.StatusEnum status, object definition) - { - FriendlyName = friendlyName; - Status = status; - Definition = definition; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Definition != null) - { - p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); - } - - if (CommitMessage != null) - { - p.Add(new KeyValuePair("CommitMessage", CommitMessage)); - } - - return p; - } - } - + /// The string that you assigned to describe the Flow + /// + public string FriendlyName { get; } /// - /// Update a Flow. - /// - public class UpdateFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - /// - /// The status of the Flow - /// - public FlowResource.StatusEnum Status { get; } - /// - /// The string that you assigned to describe the Flow - /// - public string FriendlyName { get; set; } - /// - /// JSON representation of flow definition - /// - public object Definition { get; set; } - /// - /// Description of change made in the revision - /// - public string CommitMessage { get; set; } - - /// - /// Construct a new UpdateFlowOptions - /// - /// The SID that identifies the resource to fetch - /// The status of the Flow - public UpdateFlowOptions(string pathSid, FlowResource.StatusEnum status) - { - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Definition != null) - { - p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); - } - - if (CommitMessage != null) - { - p.Add(new KeyValuePair("CommitMessage", CommitMessage)); - } - - return p; - } - } - + /// The status of the Flow + /// + public FlowResource.StatusEnum Status { get; } /// - /// Retrieve a list of all Flows. - /// - public class ReadFlowOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// JSON representation of flow definition + /// + public object Definition { get; } /// - /// Retrieve a specific Flow. + /// Description of change made in the revision /// - public class FetchFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFlowOptions - /// - /// The SID that identifies the resource to fetch - public FetchFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string CommitMessage { get; set; } + /// - /// Delete a specific Flow. + /// Construct a new CreateFlowOptions /// - public class DeleteFlowOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFlowOptions - /// - /// The SID that identifies the resource to delete - public DeleteFlowOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + public CreateFlowOptions(string friendlyName, FlowResource.StatusEnum status, object definition) + { + FriendlyName = friendlyName; + Status = status; + Definition = definition; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Definition != null) + { + p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); + } + + if (CommitMessage != null) + { + p.Add(new KeyValuePair("CommitMessage", CommitMessage)); + } + + return p; + } + } + + /// + /// Update a Flow. + /// + public class UpdateFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + /// + /// The status of the Flow + /// + public FlowResource.StatusEnum Status { get; } + /// + /// The string that you assigned to describe the Flow + /// + public string FriendlyName { get; set; } + /// + /// JSON representation of flow definition + /// + public object Definition { get; set; } + /// + /// Description of change made in the revision + /// + public string CommitMessage { get; set; } + + /// + /// Construct a new UpdateFlowOptions + /// + /// The SID that identifies the resource to fetch + /// The status of the Flow + public UpdateFlowOptions(string pathSid, FlowResource.StatusEnum status) + { + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Definition != null) + { + p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); + } + + if (CommitMessage != null) + { + p.Add(new KeyValuePair("CommitMessage", CommitMessage)); + } + + return p; + } + } + + /// + /// Retrieve a list of all Flows. + /// + public class ReadFlowOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a specific Flow. + /// + public class FetchFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFlowOptions + /// + /// The SID that identifies the resource to fetch + public FetchFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Flow. + /// + public class DeleteFlowOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteFlowOptions + /// + /// The SID that identifies the resource to delete + public DeleteFlowOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/FlowResource.cs b/src/Twilio/Rest/Studio/V2/FlowResource.cs index b35f7d232..415c0a22f 100644 --- a/src/Twilio/Rest/Studio/V2/FlowResource.cs +++ b/src/Twilio/Rest/Studio/V2/FlowResource.cs @@ -17,548 +17,548 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V2 -{ - - public class FlowResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum Published = new StatusEnum("published"); - } - - private static Request BuildCreateRequest(CreateFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a Flow. - /// - /// Create Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Create(CreateFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a Flow. - /// - /// Create Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task CreateAsync(CreateFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a Flow. - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Create(string friendlyName, - FlowResource.StatusEnum status, - object definition, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new CreateFlowOptions(friendlyName, status, definition){CommitMessage = commitMessage}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a Flow. - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - FlowResource.StatusEnum status, - object definition, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new CreateFlowOptions(friendlyName, status, definition){CommitMessage = commitMessage}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a Flow. - /// - /// Update Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Update(UpdateFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a Flow. - /// - /// Update Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a Flow. - /// - /// The SID that identifies the resource to fetch - /// The status of the Flow - /// The string that you assigned to describe the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Update(string pathSid, - FlowResource.StatusEnum status, - string friendlyName = null, - object definition = null, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlowOptions(pathSid, status){FriendlyName = friendlyName, Definition = definition, CommitMessage = commitMessage}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a Flow. - /// - /// The SID that identifies the resource to fetch - /// The status of the Flow - /// The string that you assigned to describe the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - FlowResource.StatusEnum status, - string friendlyName = null, - object definition = null, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlowOptions(pathSid, status){FriendlyName = friendlyName, Definition = definition, CommitMessage = commitMessage}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Flows. - /// - /// Read Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static ResourceSet Read(ReadFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("flows", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows. - /// - /// Read Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("flows", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Flows. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Flow - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Flows. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFlowOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Studio) - ); - - var response = client.Request(request); - return Page.FromJson("flows", response.Content); - } - - private static Request BuildFetchRequest(FetchFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a specific Flow. - /// - /// Fetch Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Fetch(FetchFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve a specific Flow. - /// - /// Fetch Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task FetchAsync(FetchFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve a specific Flow. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Flow - public static FlowResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFlowOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve a specific Flow. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFlowOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteFlowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Studio, - "/v2/Flows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Flow. - /// - /// Delete Flow parameters - /// Client to make requests to Twilio - /// A single instance of Flow - public static bool Delete(DeleteFlowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Flow. - /// - /// Delete Flow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Flow. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Flow - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlowOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Flow. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Flow - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteFlowOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlowResource object - /// - /// Raw JSON string - /// FlowResource object represented by the provided JSON - public static FlowResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the Flow - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// JSON representation of flow definition - /// - [JsonProperty("definition")] - public object Definition { get; private set; } - /// - /// The status of the Flow - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FlowResource.StatusEnum Status { get; private set; } - /// - /// The latest revision number of the Flow's definition - /// - [JsonProperty("revision")] - public int? Revision { get; private set; } - /// - /// Description of change made in the revision - /// - [JsonProperty("commit_message")] - public string CommitMessage { get; private set; } - /// - /// Boolean if the flow definition is valid - /// - [JsonProperty("valid")] - public bool? Valid { get; private set; } - /// - /// List of error in the flow definition - /// - [JsonProperty("errors")] - public List Errors { get; private set; } - /// - /// List of warnings in the flow definition - /// - [JsonProperty("warnings")] - public List Warnings { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The webhook_url - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private FlowResource() - { - - } - } +{ + + public class FlowResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum Published = new StatusEnum("published"); + } + + private static Request BuildCreateRequest(CreateFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a Flow. + /// + /// Create Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Create(CreateFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a Flow. + /// + /// Create Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task CreateAsync(CreateFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a Flow. + /// + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Create(string friendlyName, + FlowResource.StatusEnum status, + object definition, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new CreateFlowOptions(friendlyName, status, definition) { CommitMessage = commitMessage }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a Flow. + /// + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + FlowResource.StatusEnum status, + object definition, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new CreateFlowOptions(friendlyName, status, definition) { CommitMessage = commitMessage }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a Flow. + /// + /// Update Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Update(UpdateFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a Flow. + /// + /// Update Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a Flow. + /// + /// The SID that identifies the resource to fetch + /// The status of the Flow + /// The string that you assigned to describe the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Update(string pathSid, + FlowResource.StatusEnum status, + string friendlyName = null, + object definition = null, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlowOptions(pathSid, status) { FriendlyName = friendlyName, Definition = definition, CommitMessage = commitMessage }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a Flow. + /// + /// The SID that identifies the resource to fetch + /// The status of the Flow + /// The string that you assigned to describe the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + FlowResource.StatusEnum status, + string friendlyName = null, + object definition = null, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlowOptions(pathSid, status) { FriendlyName = friendlyName, Definition = definition, CommitMessage = commitMessage }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Flows. + /// + /// Read Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static ResourceSet Read(ReadFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("flows", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows. + /// + /// Read Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task> ReadAsync(ReadFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("flows", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Flows. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Flow + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Flows. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFlowOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Studio) + ); + + var response = client.Request(request); + return Page.FromJson("flows", response.Content); + } + + private static Request BuildFetchRequest(FetchFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a specific Flow. + /// + /// Fetch Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Fetch(FetchFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve a specific Flow. + /// + /// Fetch Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task FetchAsync(FetchFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve a specific Flow. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Flow + public static FlowResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFlowOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve a specific Flow. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFlowOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteFlowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Studio, + "/v2/Flows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Flow. + /// + /// Delete Flow parameters + /// Client to make requests to Twilio + /// A single instance of Flow + public static bool Delete(DeleteFlowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Flow. + /// + /// Delete Flow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFlowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Flow. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Flow + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlowOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Flow. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Flow + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteFlowOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlowResource object + /// + /// Raw JSON string + /// FlowResource object represented by the provided JSON + public static FlowResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the Flow + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// JSON representation of flow definition + /// + [JsonProperty("definition")] + public object Definition { get; private set; } + /// + /// The status of the Flow + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FlowResource.StatusEnum Status { get; private set; } + /// + /// The latest revision number of the Flow's definition + /// + [JsonProperty("revision")] + public int? Revision { get; private set; } + /// + /// Description of change made in the revision + /// + [JsonProperty("commit_message")] + public string CommitMessage { get; private set; } + /// + /// Boolean if the flow definition is valid + /// + [JsonProperty("valid")] + public bool? Valid { get; private set; } + /// + /// List of error in the flow definition + /// + [JsonProperty("errors")] + public List Errors { get; private set; } + /// + /// List of warnings in the flow definition + /// + [JsonProperty("warnings")] + public List Warnings { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The webhook_url + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private FlowResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/FlowValidateOptions.cs b/src/Twilio/Rest/Studio/V2/FlowValidateOptions.cs index c05fe6180..d2f099ca5 100644 --- a/src/Twilio/Rest/Studio/V2/FlowValidateOptions.cs +++ b/src/Twilio/Rest/Studio/V2/FlowValidateOptions.cs @@ -9,71 +9,71 @@ using Twilio.Converters; namespace Twilio.Rest.Studio.V2 -{ - +{ + + /// + /// Validate flow JSON definition + /// + public class UpdateFlowValidateOptions : IOptions + { /// - /// Validate flow JSON definition + /// The string that you assigned to describe the Flow /// - public class UpdateFlowValidateOptions : IOptions - { - /// - /// The string that you assigned to describe the Flow - /// - public string FriendlyName { get; } - /// - /// The status of the Flow - /// - public FlowValidateResource.StatusEnum Status { get; } - /// - /// JSON representation of flow definition - /// - public object Definition { get; } - /// - /// Description of change made in the revision - /// - public string CommitMessage { get; set; } - - /// - /// Construct a new UpdateFlowValidateOptions - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - public UpdateFlowValidateOptions(string friendlyName, FlowValidateResource.StatusEnum status, object definition) - { - FriendlyName = friendlyName; - Status = status; - Definition = definition; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Definition != null) - { - p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); - } - - if (CommitMessage != null) - { - p.Add(new KeyValuePair("CommitMessage", CommitMessage)); - } - - return p; - } - } + public string FriendlyName { get; } + /// + /// The status of the Flow + /// + public FlowValidateResource.StatusEnum Status { get; } + /// + /// JSON representation of flow definition + /// + public object Definition { get; } + /// + /// Description of change made in the revision + /// + public string CommitMessage { get; set; } + + /// + /// Construct a new UpdateFlowValidateOptions + /// + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + public UpdateFlowValidateOptions(string friendlyName, FlowValidateResource.StatusEnum status, object definition) + { + FriendlyName = friendlyName; + Status = status; + Definition = definition; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Definition != null) + { + p.Add(new KeyValuePair("Definition", Serializers.JsonObject(Definition))); + } + + if (CommitMessage != null) + { + p.Add(new KeyValuePair("CommitMessage", CommitMessage)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Studio/V2/FlowValidateResource.cs b/src/Twilio/Rest/Studio/V2/FlowValidateResource.cs index 91090516d..ea22714c4 100644 --- a/src/Twilio/Rest/Studio/V2/FlowValidateResource.cs +++ b/src/Twilio/Rest/Studio/V2/FlowValidateResource.cs @@ -17,131 +17,131 @@ using Twilio.Types; namespace Twilio.Rest.Studio.V2 -{ - - public class FlowValidateResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum Published = new StatusEnum("published"); - } - - private static Request BuildUpdateRequest(UpdateFlowValidateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Studio, - "/v2/Flows/Validate", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Validate flow JSON definition - /// - /// Update FlowValidate parameters - /// Client to make requests to Twilio - /// A single instance of FlowValidate - public static FlowValidateResource Update(UpdateFlowValidateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Validate flow JSON definition - /// - /// Update FlowValidate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowValidate - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowValidateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Validate flow JSON definition - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// A single instance of FlowValidate - public static FlowValidateResource Update(string friendlyName, - FlowValidateResource.StatusEnum status, - object definition, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlowValidateOptions(friendlyName, status, definition){CommitMessage = commitMessage}; - return Update(options, client); - } - - #if !NET35 - /// - /// Validate flow JSON definition - /// - /// The string that you assigned to describe the Flow - /// The status of the Flow - /// JSON representation of flow definition - /// Description of change made in the revision - /// Client to make requests to Twilio - /// Task that resolves to A single instance of FlowValidate - public static async System.Threading.Tasks.Task UpdateAsync(string friendlyName, - FlowValidateResource.StatusEnum status, - object definition, - string commitMessage = null, - ITwilioRestClient client = null) - { - var options = new UpdateFlowValidateOptions(friendlyName, status, definition){CommitMessage = commitMessage}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FlowValidateResource object - /// - /// Raw JSON string - /// FlowValidateResource object represented by the provided JSON - public static FlowValidateResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Boolean if the flow definition is valid - /// - [JsonProperty("valid")] - public bool? Valid { get; private set; } - - private FlowValidateResource() - { - - } - } +{ + + public class FlowValidateResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum Published = new StatusEnum("published"); + } + + private static Request BuildUpdateRequest(UpdateFlowValidateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Studio, + "/v2/Flows/Validate", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Validate flow JSON definition + /// + /// Update FlowValidate parameters + /// Client to make requests to Twilio + /// A single instance of FlowValidate + public static FlowValidateResource Update(UpdateFlowValidateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Validate flow JSON definition + /// + /// Update FlowValidate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowValidate + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFlowValidateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Validate flow JSON definition + /// + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// A single instance of FlowValidate + public static FlowValidateResource Update(string friendlyName, + FlowValidateResource.StatusEnum status, + object definition, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlowValidateOptions(friendlyName, status, definition) { CommitMessage = commitMessage }; + return Update(options, client); + } + +#if !NET35 + /// + /// Validate flow JSON definition + /// + /// The string that you assigned to describe the Flow + /// The status of the Flow + /// JSON representation of flow definition + /// Description of change made in the revision + /// Client to make requests to Twilio + /// Task that resolves to A single instance of FlowValidate + public static async System.Threading.Tasks.Task UpdateAsync(string friendlyName, + FlowValidateResource.StatusEnum status, + object definition, + string commitMessage = null, + ITwilioRestClient client = null) + { + var options = new UpdateFlowValidateOptions(friendlyName, status, definition) { CommitMessage = commitMessage }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FlowValidateResource object + /// + /// Raw JSON string + /// FlowValidateResource object represented by the provided JSON + public static FlowValidateResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Boolean if the flow definition is valid + /// + [JsonProperty("valid")] + public bool? Valid { get; private set; } + + private FlowValidateResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/CommandOptions.cs b/src/Twilio/Rest/Supersim/V1/CommandOptions.cs index fbd5487e7..021d7cc41 100644 --- a/src/Twilio/Rest/Supersim/V1/CommandOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/CommandOptions.cs @@ -9,152 +9,152 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Send a Command to a Sim. + /// + public class CreateCommandOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Send a Command to a Sim. + /// The sid or unique_name of the SIM to send the Command to /// - public class CreateCommandOptions : IOptions - { - /// - /// The sid or unique_name of the SIM to send the Command to - /// - public string Sim { get; } - /// - /// The message body of the command - /// - public string Command { get; } - /// - /// The HTTP method we should use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// The URL we should call after we have sent the command - /// - public Uri CallbackUrl { get; set; } - - /// - /// Construct a new CreateCommandOptions - /// - /// The sid or unique_name of the SIM to send the Command to - /// The message body of the command - public CreateCommandOptions(string sim, string command) - { - Sim = sim; - Command = command; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (Command != null) - { - p.Add(new KeyValuePair("Command", Command)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - return p; - } - } - + public string Sim { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Command instance from your account. + /// The message body of the command /// - public class FetchCommandOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCommandOptions - /// - /// The SID that identifies the resource to fetch - public FetchCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Command { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Commands from your account. + /// The HTTP method we should use to call callback_url /// - public class ReadCommandOptions : ReadOptions - { - /// - /// The SID or unique name of the Sim that Command was sent to or from. - /// - public string Sim { get; set; } - /// - /// The status of the Command - /// - public CommandResource.StatusEnum Status { get; set; } - /// - /// The direction of the Command - /// - public CommandResource.DirectionEnum Direction { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// The URL we should call after we have sent the command + /// + public Uri CallbackUrl { get; set; } + + /// + /// Construct a new CreateCommandOptions + /// + /// The sid or unique_name of the SIM to send the Command to + /// The message body of the command + public CreateCommandOptions(string sim, string command) + { + Sim = sim; + Command = command; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (Command != null) + { + p.Add(new KeyValuePair("Command", Command)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Command instance from your account. + /// + public class FetchCommandOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCommandOptions + /// + /// The SID that identifies the resource to fetch + public FetchCommandOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Commands from your account. + /// + public class ReadCommandOptions : ReadOptions + { + /// + /// The SID or unique name of the Sim that Command was sent to or from. + /// + public string Sim { get; set; } + /// + /// The status of the Command + /// + public CommandResource.StatusEnum Status { get; set; } + /// + /// The direction of the Command + /// + public CommandResource.DirectionEnum Direction { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/CommandResource.cs b/src/Twilio/Rest/Supersim/V1/CommandResource.cs index 04607ee43..ea9cc119d 100644 --- a/src/Twilio/Rest/Supersim/V1/CommandResource.cs +++ b/src/Twilio/Rest/Supersim/V1/CommandResource.cs @@ -19,397 +19,397 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class CommandResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Sent = new StatusEnum("sent"); - public static readonly StatusEnum Delivered = new StatusEnum("delivered"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); - public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); - } - - private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/Commands", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Send a Command to a Sim. - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Send a Command to a Sim. - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Send a Command to a Sim. - /// - /// The sid or unique_name of the SIM to send the Command to - /// The message body of the command - /// The HTTP method we should use to call callback_url - /// The URL we should call after we have sent the command - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(string sim, - string command, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(sim, command){CallbackMethod = callbackMethod, CallbackUrl = callbackUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Send a Command to a Sim. - /// - /// The sid or unique_name of the SIM to send the Command to - /// The message body of the command - /// The HTTP method we should use to call callback_url - /// The URL we should call after we have sent the command - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(string sim, - string command, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(sim, command){CallbackMethod = callbackMethod, CallbackUrl = callbackUrl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Commands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Command instance from your account. - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Command instance from your account. - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Commands", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Commands from your account. - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Commands from your account. - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Commands from your account. - /// - /// The SID or unique name of the Sim that Command was sent to or from. - /// The status of the Command - /// The direction of the Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(string sim = null, - CommandResource.StatusEnum status = null, - CommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Commands from your account. - /// - /// The SID or unique name of the Sim that Command was sent to or from. - /// The status of the Command - /// The direction of the Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, - CommandResource.StatusEnum status = null, - CommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Converts a JSON string into a CommandResource object - /// - /// Raw JSON string - /// CommandResource object represented by the provided JSON - public static CommandResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the SIM that this Command was sent to or from - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The message body of the command sent to or from the SIM - /// - [JsonProperty("command")] - public string Command { get; private set; } - /// - /// The status of the Command - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.StatusEnum Status { get; private set; } - /// - /// The direction of the Command - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.DirectionEnum Direction { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Command resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CommandResource() - { - - } - } +{ + + public class CommandResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Sent = new StatusEnum("sent"); + public static readonly StatusEnum Delivered = new StatusEnum("delivered"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); + public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); + } + + private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/Commands", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Send a Command to a Sim. + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Send a Command to a Sim. + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Send a Command to a Sim. + /// + /// The sid or unique_name of the SIM to send the Command to + /// The message body of the command + /// The HTTP method we should use to call callback_url + /// The URL we should call after we have sent the command + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(string sim, + string command, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(sim, command) { CallbackMethod = callbackMethod, CallbackUrl = callbackUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Send a Command to a Sim. + /// + /// The sid or unique_name of the SIM to send the Command to + /// The message body of the command + /// The HTTP method we should use to call callback_url + /// The URL we should call after we have sent the command + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(string sim, + string command, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(sim, command) { CallbackMethod = callbackMethod, CallbackUrl = callbackUrl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Commands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Command instance from your account. + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Command instance from your account. + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Commands", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Commands from your account. + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Commands from your account. + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Commands from your account. + /// + /// The SID or unique name of the Sim that Command was sent to or from. + /// The status of the Command + /// The direction of the Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(string sim = null, + CommandResource.StatusEnum status = null, + CommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Commands from your account. + /// + /// The SID or unique name of the Sim that Command was sent to or from. + /// The status of the Command + /// The direction of the Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, + CommandResource.StatusEnum status = null, + CommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Converts a JSON string into a CommandResource object + /// + /// Raw JSON string + /// CommandResource object represented by the provided JSON + public static CommandResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the SIM that this Command was sent to or from + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The message body of the command sent to or from the SIM + /// + [JsonProperty("command")] + public string Command { get; private set; } + /// + /// The status of the Command + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.StatusEnum Status { get; private set; } + /// + /// The direction of the Command + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.DirectionEnum Direction { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Command resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CommandResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/FleetOptions.cs b/src/Twilio/Rest/Supersim/V1/FleetOptions.cs index 8f02fd73f..c0fa7f642 100644 --- a/src/Twilio/Rest/Supersim/V1/FleetOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/FleetOptions.cs @@ -9,271 +9,271 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a Fleet + /// + public class CreateFleetOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a Fleet + /// The SID or unique name of the Network Access Profile of the Fleet /// - public class CreateFleetOptions : IOptions - { - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// - public string NetworkAccessProfile { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// Defines whether SIMs in the Fleet are capable of using data connectivity - /// - public bool? DataEnabled { get; set; } - /// - /// The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume - /// - public int? DataLimit { get; set; } - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands - /// - public bool? CommandsEnabled { get; set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number - /// - public Uri CommandsUrl { get; set; } - /// - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - public Twilio.Http.HttpMethod CommandsMethod { get; set; } - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands - /// - public bool? SmsCommandsEnabled { get; set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number - /// - public Uri SmsCommandsUrl { get; set; } - /// - /// A string representing the HTTP method to use when making a request to `sms_commands_url` - /// - public Twilio.Http.HttpMethod SmsCommandsMethod { get; set; } - - /// - /// Construct a new CreateFleetOptions - /// - /// The SID or unique name of the Network Access Profile of the Fleet - public CreateFleetOptions(string networkAccessProfile) - { - NetworkAccessProfile = networkAccessProfile; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (NetworkAccessProfile != null) - { - p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DataEnabled != null) - { - p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); - } - - if (DataLimit != null) - { - p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); - } - - if (CommandsEnabled != null) - { - p.Add(new KeyValuePair("CommandsEnabled", CommandsEnabled.Value.ToString().ToLower())); - } - - if (CommandsUrl != null) - { - p.Add(new KeyValuePair("CommandsUrl", Serializers.Url(CommandsUrl))); - } - - if (CommandsMethod != null) - { - p.Add(new KeyValuePair("CommandsMethod", CommandsMethod.ToString())); - } - - if (SmsCommandsEnabled != null) - { - p.Add(new KeyValuePair("SmsCommandsEnabled", SmsCommandsEnabled.Value.ToString().ToLower())); - } - - if (SmsCommandsUrl != null) - { - p.Add(new KeyValuePair("SmsCommandsUrl", Serializers.Url(SmsCommandsUrl))); - } - - if (SmsCommandsMethod != null) - { - p.Add(new KeyValuePair("SmsCommandsMethod", SmsCommandsMethod.ToString())); - } - - return p; - } - } - + public string NetworkAccessProfile { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Fleet instance from your account. + /// An application-defined string that uniquely identifies the resource /// - public class FetchFleetOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFleetOptions - /// - /// The SID that identifies the resource to fetch - public FetchFleetOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string UniqueName { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Fleets from your account. + /// Defines whether SIMs in the Fleet are capable of using data connectivity /// - public class ReadFleetOptions : ReadOptions - { - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// - public string NetworkAccessProfile { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (NetworkAccessProfile != null) - { - p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public bool? DataEnabled { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Updates the given properties of a Super SIM Fleet instance from your account. + /// The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume /// - public class UpdateFleetOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// - public string NetworkAccessProfile { get; set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number - /// - public Uri CommandsUrl { get; set; } - /// - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - public Twilio.Http.HttpMethod CommandsMethod { get; set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number - /// - public Uri SmsCommandsUrl { get; set; } - /// - /// A string representing the HTTP method to use when making a request to `sms_commands_url` - /// - public Twilio.Http.HttpMethod SmsCommandsMethod { get; set; } - - /// - /// Construct a new UpdateFleetOptions - /// - /// The SID that identifies the resource to update - public UpdateFleetOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (NetworkAccessProfile != null) - { - p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); - } - - if (CommandsUrl != null) - { - p.Add(new KeyValuePair("CommandsUrl", Serializers.Url(CommandsUrl))); - } - - if (CommandsMethod != null) - { - p.Add(new KeyValuePair("CommandsMethod", CommandsMethod.ToString())); - } - - if (SmsCommandsUrl != null) - { - p.Add(new KeyValuePair("SmsCommandsUrl", Serializers.Url(SmsCommandsUrl))); - } - - if (SmsCommandsMethod != null) - { - p.Add(new KeyValuePair("SmsCommandsMethod", SmsCommandsMethod.ToString())); - } - - return p; - } - } + public int? DataLimit { get; set; } + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands + /// + public bool? CommandsEnabled { get; set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number + /// + public Uri CommandsUrl { get; set; } + /// + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + public Twilio.Http.HttpMethod CommandsMethod { get; set; } + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands + /// + public bool? SmsCommandsEnabled { get; set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number + /// + public Uri SmsCommandsUrl { get; set; } + /// + /// A string representing the HTTP method to use when making a request to `sms_commands_url` + /// + public Twilio.Http.HttpMethod SmsCommandsMethod { get; set; } + + /// + /// Construct a new CreateFleetOptions + /// + /// The SID or unique name of the Network Access Profile of the Fleet + public CreateFleetOptions(string networkAccessProfile) + { + NetworkAccessProfile = networkAccessProfile; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (NetworkAccessProfile != null) + { + p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DataEnabled != null) + { + p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); + } + + if (DataLimit != null) + { + p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); + } + + if (CommandsEnabled != null) + { + p.Add(new KeyValuePair("CommandsEnabled", CommandsEnabled.Value.ToString().ToLower())); + } + + if (CommandsUrl != null) + { + p.Add(new KeyValuePair("CommandsUrl", Serializers.Url(CommandsUrl))); + } + + if (CommandsMethod != null) + { + p.Add(new KeyValuePair("CommandsMethod", CommandsMethod.ToString())); + } + + if (SmsCommandsEnabled != null) + { + p.Add(new KeyValuePair("SmsCommandsEnabled", SmsCommandsEnabled.Value.ToString().ToLower())); + } + + if (SmsCommandsUrl != null) + { + p.Add(new KeyValuePair("SmsCommandsUrl", Serializers.Url(SmsCommandsUrl))); + } + + if (SmsCommandsMethod != null) + { + p.Add(new KeyValuePair("SmsCommandsMethod", SmsCommandsMethod.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Fleet instance from your account. + /// + public class FetchFleetOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFleetOptions + /// + /// The SID that identifies the resource to fetch + public FetchFleetOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Fleets from your account. + /// + public class ReadFleetOptions : ReadOptions + { + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// + public string NetworkAccessProfile { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (NetworkAccessProfile != null) + { + p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Updates the given properties of a Super SIM Fleet instance from your account. + /// + public class UpdateFleetOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// + public string NetworkAccessProfile { get; set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number + /// + public Uri CommandsUrl { get; set; } + /// + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + public Twilio.Http.HttpMethod CommandsMethod { get; set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number + /// + public Uri SmsCommandsUrl { get; set; } + /// + /// A string representing the HTTP method to use when making a request to `sms_commands_url` + /// + public Twilio.Http.HttpMethod SmsCommandsMethod { get; set; } + + /// + /// Construct a new UpdateFleetOptions + /// + /// The SID that identifies the resource to update + public UpdateFleetOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (NetworkAccessProfile != null) + { + p.Add(new KeyValuePair("NetworkAccessProfile", NetworkAccessProfile.ToString())); + } + + if (CommandsUrl != null) + { + p.Add(new KeyValuePair("CommandsUrl", Serializers.Url(CommandsUrl))); + } + + if (CommandsMethod != null) + { + p.Add(new KeyValuePair("CommandsMethod", CommandsMethod.ToString())); + } + + if (SmsCommandsUrl != null) + { + p.Add(new KeyValuePair("SmsCommandsUrl", Serializers.Url(SmsCommandsUrl))); + } + + if (SmsCommandsMethod != null) + { + p.Add(new KeyValuePair("SmsCommandsMethod", SmsCommandsMethod.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/FleetResource.cs b/src/Twilio/Rest/Supersim/V1/FleetResource.cs index 12961e68f..9f2425c72 100644 --- a/src/Twilio/Rest/Supersim/V1/FleetResource.cs +++ b/src/Twilio/Rest/Supersim/V1/FleetResource.cs @@ -19,546 +19,546 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class FleetResource : Resource - { - public sealed class DataMeteringEnum : StringEnum - { - private DataMeteringEnum(string value) : base(value) {} - public DataMeteringEnum() {} - public static implicit operator DataMeteringEnum(string value) - { - return new DataMeteringEnum(value); - } - - public static readonly DataMeteringEnum Payg = new DataMeteringEnum("payg"); - } - - private static Request BuildCreateRequest(CreateFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/Fleets", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a Fleet - /// - /// Create Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a Fleet - /// - /// Create Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a Fleet - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// An application-defined string that uniquely identifies the resource - /// Defines whether SIMs in the Fleet are capable of using data connectivity - /// The total data usage (download and upload combined) in Megabytes that each Sim resource - /// assigned to the Fleet resource can consume - /// Defines whether SIMs in the Fleet are capable of sending and receiving - /// machine-to-machine SMS via Commands - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS - /// from your device to the Commands number - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving - /// machine-to-machine SMS via Commands - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an - /// SMS from your device to the SMS Commands number - /// A string representing the HTTP method to use when making a request to - /// `sms_commands_url` - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Create(string networkAccessProfile, - string uniqueName = null, - bool? dataEnabled = null, - int? dataLimit = null, - bool? commandsEnabled = null, - Uri commandsUrl = null, - Twilio.Http.HttpMethod commandsMethod = null, - bool? smsCommandsEnabled = null, - Uri smsCommandsUrl = null, - Twilio.Http.HttpMethod smsCommandsMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateFleetOptions(networkAccessProfile){UniqueName = uniqueName, DataEnabled = dataEnabled, DataLimit = dataLimit, CommandsEnabled = commandsEnabled, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsEnabled = smsCommandsEnabled, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a Fleet - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// An application-defined string that uniquely identifies the resource - /// Defines whether SIMs in the Fleet are capable of using data connectivity - /// The total data usage (download and upload combined) in Megabytes that each Sim resource - /// assigned to the Fleet resource can consume - /// Defines whether SIMs in the Fleet are capable of sending and receiving - /// machine-to-machine SMS via Commands - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS - /// from your device to the Commands number - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving - /// machine-to-machine SMS via Commands - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an - /// SMS from your device to the SMS Commands number - /// A string representing the HTTP method to use when making a request to - /// `sms_commands_url` - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(string networkAccessProfile, - string uniqueName = null, - bool? dataEnabled = null, - int? dataLimit = null, - bool? commandsEnabled = null, - Uri commandsUrl = null, - Twilio.Http.HttpMethod commandsMethod = null, - bool? smsCommandsEnabled = null, - Uri smsCommandsUrl = null, - Twilio.Http.HttpMethod smsCommandsMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateFleetOptions(networkAccessProfile){UniqueName = uniqueName, DataEnabled = dataEnabled, DataLimit = dataLimit, CommandsEnabled = commandsEnabled, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsEnabled = smsCommandsEnabled, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Fleets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Fleet instance from your account. - /// - /// Fetch Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Fleet instance from your account. - /// - /// Fetch Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Fleet instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchFleetOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Fleet instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFleetOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Fleets", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Fleets from your account. - /// - /// Read Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static ResourceSet Read(ReadFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("fleets", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Fleets from your account. - /// - /// Read Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task> ReadAsync(ReadFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("fleets", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Fleets from your account. - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Fleet - public static ResourceSet Read(string networkAccessProfile = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFleetOptions(){NetworkAccessProfile = networkAccessProfile, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Fleets from your account. - /// - /// The SID or unique name of the Network Access Profile of the Fleet - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task> ReadAsync(string networkAccessProfile = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFleetOptions(){NetworkAccessProfile = networkAccessProfile, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("fleets", response.Content); - } - - private static Request BuildUpdateRequest(UpdateFleetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/Fleets/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the given properties of a Super SIM Fleet instance from your account. - /// - /// Update Fleet parameters - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Update(UpdateFleetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the given properties of a Super SIM Fleet instance from your account. - /// - /// Update Fleet parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFleetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the given properties of a Super SIM Fleet instance from your account. - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// The SID or unique name of the Network Access Profile of the Fleet - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS - /// from your device to the Commands number - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an - /// SMS from your device to the SMS Commands number - /// A string representing the HTTP method to use when making a request to - /// `sms_commands_url` - /// Client to make requests to Twilio - /// A single instance of Fleet - public static FleetResource Update(string pathSid, - string uniqueName = null, - string networkAccessProfile = null, - Uri commandsUrl = null, - Twilio.Http.HttpMethod commandsMethod = null, - Uri smsCommandsUrl = null, - Twilio.Http.HttpMethod smsCommandsMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateFleetOptions(pathSid){UniqueName = uniqueName, NetworkAccessProfile = networkAccessProfile, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the given properties of a Super SIM Fleet instance from your account. - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// The SID or unique name of the Network Access Profile of the Fleet - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS - /// from your device to the Commands number - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an - /// SMS from your device to the SMS Commands number - /// A string representing the HTTP method to use when making a request to - /// `sms_commands_url` - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - string networkAccessProfile = null, - Uri commandsUrl = null, - Twilio.Http.HttpMethod commandsMethod = null, - Uri smsCommandsUrl = null, - Twilio.Http.HttpMethod smsCommandsMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateFleetOptions(pathSid){UniqueName = uniqueName, NetworkAccessProfile = networkAccessProfile, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FleetResource object - /// - /// Raw JSON string - /// FleetResource object represented by the provided JSON - public static FleetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Fleet resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Defines whether SIMs in the Fleet are capable of using data connectivity - /// - [JsonProperty("data_enabled")] - public bool? DataEnabled { get; private set; } - /// - /// The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume - /// - [JsonProperty("data_limit")] - public int? DataLimit { get; private set; } - /// - /// The model by which a SIM is metered and billed - /// - [JsonProperty("data_metering")] - [JsonConverter(typeof(StringEnumConverter))] - public FleetResource.DataMeteringEnum DataMetering { get; private set; } - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands - /// - [JsonProperty("commands_enabled")] - public bool? CommandsEnabled { get; private set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number - /// - [JsonProperty("commands_url")] - public Uri CommandsUrl { get; private set; } - /// - /// A string representing the HTTP method to use when making a request to `commands_url` - /// - [JsonProperty("commands_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod CommandsMethod { get; private set; } - /// - /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands - /// - [JsonProperty("sms_commands_enabled")] - public bool? SmsCommandsEnabled { get; private set; } - /// - /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number - /// - [JsonProperty("sms_commands_url")] - public Uri SmsCommandsUrl { get; private set; } - /// - /// A string representing the HTTP method to use when making a request to `sms_commands_url` - /// - [JsonProperty("sms_commands_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsCommandsMethod { get; private set; } - /// - /// The SID of the Network Access Profile of the Fleet - /// - [JsonProperty("network_access_profile_sid")] - public string NetworkAccessProfileSid { get; private set; } - - private FleetResource() - { - - } - } +{ + + public class FleetResource : Resource + { + public sealed class DataMeteringEnum : StringEnum + { + private DataMeteringEnum(string value) : base(value) { } + public DataMeteringEnum() { } + public static implicit operator DataMeteringEnum(string value) + { + return new DataMeteringEnum(value); + } + + public static readonly DataMeteringEnum Payg = new DataMeteringEnum("payg"); + } + + private static Request BuildCreateRequest(CreateFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/Fleets", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a Fleet + /// + /// Create Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a Fleet + /// + /// Create Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a Fleet + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// An application-defined string that uniquely identifies the resource + /// Defines whether SIMs in the Fleet are capable of using data connectivity + /// The total data usage (download and upload combined) in Megabytes that each Sim resource + /// assigned to the Fleet resource can consume + /// Defines whether SIMs in the Fleet are capable of sending and receiving + /// machine-to-machine SMS via Commands + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS + /// from your device to the Commands number + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving + /// machine-to-machine SMS via Commands + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an + /// SMS from your device to the SMS Commands number + /// A string representing the HTTP method to use when making a request to + /// `sms_commands_url` + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Create(string networkAccessProfile, + string uniqueName = null, + bool? dataEnabled = null, + int? dataLimit = null, + bool? commandsEnabled = null, + Uri commandsUrl = null, + Twilio.Http.HttpMethod commandsMethod = null, + bool? smsCommandsEnabled = null, + Uri smsCommandsUrl = null, + Twilio.Http.HttpMethod smsCommandsMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateFleetOptions(networkAccessProfile) { UniqueName = uniqueName, DataEnabled = dataEnabled, DataLimit = dataLimit, CommandsEnabled = commandsEnabled, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsEnabled = smsCommandsEnabled, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a Fleet + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// An application-defined string that uniquely identifies the resource + /// Defines whether SIMs in the Fleet are capable of using data connectivity + /// The total data usage (download and upload combined) in Megabytes that each Sim resource + /// assigned to the Fleet resource can consume + /// Defines whether SIMs in the Fleet are capable of sending and receiving + /// machine-to-machine SMS via Commands + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS + /// from your device to the Commands number + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving + /// machine-to-machine SMS via Commands + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an + /// SMS from your device to the SMS Commands number + /// A string representing the HTTP method to use when making a request to + /// `sms_commands_url` + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task CreateAsync(string networkAccessProfile, + string uniqueName = null, + bool? dataEnabled = null, + int? dataLimit = null, + bool? commandsEnabled = null, + Uri commandsUrl = null, + Twilio.Http.HttpMethod commandsMethod = null, + bool? smsCommandsEnabled = null, + Uri smsCommandsUrl = null, + Twilio.Http.HttpMethod smsCommandsMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateFleetOptions(networkAccessProfile) { UniqueName = uniqueName, DataEnabled = dataEnabled, DataLimit = dataLimit, CommandsEnabled = commandsEnabled, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsEnabled = smsCommandsEnabled, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Fleets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Fleet instance from your account. + /// + /// Fetch Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Fleet instance from your account. + /// + /// Fetch Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Fleet instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchFleetOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Fleet instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFleetOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Fleets", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Fleets from your account. + /// + /// Read Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static ResourceSet Read(ReadFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("fleets", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Fleets from your account. + /// + /// Read Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task> ReadAsync(ReadFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("fleets", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Fleets from your account. + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Fleet + public static ResourceSet Read(string networkAccessProfile = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFleetOptions() { NetworkAccessProfile = networkAccessProfile, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Fleets from your account. + /// + /// The SID or unique name of the Network Access Profile of the Fleet + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task> ReadAsync(string networkAccessProfile = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFleetOptions() { NetworkAccessProfile = networkAccessProfile, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("fleets", response.Content); + } + + private static Request BuildUpdateRequest(UpdateFleetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/Fleets/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the given properties of a Super SIM Fleet instance from your account. + /// + /// Update Fleet parameters + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Update(UpdateFleetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the given properties of a Super SIM Fleet instance from your account. + /// + /// Update Fleet parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFleetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the given properties of a Super SIM Fleet instance from your account. + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// The SID or unique name of the Network Access Profile of the Fleet + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS + /// from your device to the Commands number + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an + /// SMS from your device to the SMS Commands number + /// A string representing the HTTP method to use when making a request to + /// `sms_commands_url` + /// Client to make requests to Twilio + /// A single instance of Fleet + public static FleetResource Update(string pathSid, + string uniqueName = null, + string networkAccessProfile = null, + Uri commandsUrl = null, + Twilio.Http.HttpMethod commandsMethod = null, + Uri smsCommandsUrl = null, + Twilio.Http.HttpMethod smsCommandsMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateFleetOptions(pathSid) { UniqueName = uniqueName, NetworkAccessProfile = networkAccessProfile, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the given properties of a Super SIM Fleet instance from your account. + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// The SID or unique name of the Network Access Profile of the Fleet + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS + /// from your device to the Commands number + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an + /// SMS from your device to the SMS Commands number + /// A string representing the HTTP method to use when making a request to + /// `sms_commands_url` + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Fleet + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + string networkAccessProfile = null, + Uri commandsUrl = null, + Twilio.Http.HttpMethod commandsMethod = null, + Uri smsCommandsUrl = null, + Twilio.Http.HttpMethod smsCommandsMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateFleetOptions(pathSid) { UniqueName = uniqueName, NetworkAccessProfile = networkAccessProfile, CommandsUrl = commandsUrl, CommandsMethod = commandsMethod, SmsCommandsUrl = smsCommandsUrl, SmsCommandsMethod = smsCommandsMethod }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FleetResource object + /// + /// Raw JSON string + /// FleetResource object represented by the provided JSON + public static FleetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Fleet resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Defines whether SIMs in the Fleet are capable of using data connectivity + /// + [JsonProperty("data_enabled")] + public bool? DataEnabled { get; private set; } + /// + /// The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume + /// + [JsonProperty("data_limit")] + public int? DataLimit { get; private set; } + /// + /// The model by which a SIM is metered and billed + /// + [JsonProperty("data_metering")] + [JsonConverter(typeof(StringEnumConverter))] + public FleetResource.DataMeteringEnum DataMetering { get; private set; } + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands + /// + [JsonProperty("commands_enabled")] + public bool? CommandsEnabled { get; private set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the Commands number + /// + [JsonProperty("commands_url")] + public Uri CommandsUrl { get; private set; } + /// + /// A string representing the HTTP method to use when making a request to `commands_url` + /// + [JsonProperty("commands_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod CommandsMethod { get; private set; } + /// + /// Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands + /// + [JsonProperty("sms_commands_enabled")] + public bool? SmsCommandsEnabled { get; private set; } + /// + /// The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number + /// + [JsonProperty("sms_commands_url")] + public Uri SmsCommandsUrl { get; private set; } + /// + /// A string representing the HTTP method to use when making a request to `sms_commands_url` + /// + [JsonProperty("sms_commands_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsCommandsMethod { get; private set; } + /// + /// The SID of the Network Access Profile of the Fleet + /// + [JsonProperty("network_access_profile_sid")] + public string NetworkAccessProfileSid { get; private set; } + + private FleetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/IpCommandOptions.cs b/src/Twilio/Rest/Supersim/V1/IpCommandOptions.cs index a0784ff44..d4a7a0e96 100644 --- a/src/Twilio/Rest/Supersim/V1/IpCommandOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/IpCommandOptions.cs @@ -9,181 +9,181 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Send an IP Command to a Super SIM. + /// + public class CreateIpCommandOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Send an IP Command to a Super SIM. - /// - public class CreateIpCommandOptions : IOptions - { - /// - /// The sid or unique_name of the Super SIM to send the IP Command to - /// - public string Sim { get; } - /// - /// The payload to be delivered to the device - /// - public string Payload { get; } - /// - /// The device port to which the IP Command will be sent - /// - public int? DevicePort { get; } - /// - /// Indicates how the payload is encoded - /// - public IpCommandResource.PayloadTypeEnum PayloadType { get; set; } - /// - /// The URL we should call after we have sent the IP Command - /// - public Uri CallbackUrl { get; set; } - /// - /// The HTTP method we should use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - - /// - /// Construct a new CreateIpCommandOptions - /// - /// The sid or unique_name of the Super SIM to send the IP Command to - /// The payload to be delivered to the device - /// The device port to which the IP Command will be sent - public CreateIpCommandOptions(string sim, string payload, int? devicePort) - { - Sim = sim; - Payload = payload; - DevicePort = devicePort; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim)); - } - - if (Payload != null) - { - p.Add(new KeyValuePair("Payload", Payload)); - } - - if (DevicePort != null) - { - p.Add(new KeyValuePair("DevicePort", DevicePort.ToString())); - } - - if (PayloadType != null) - { - p.Add(new KeyValuePair("PayloadType", PayloadType.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - return p; - } - } - + /// The sid or unique_name of the Super SIM to send the IP Command to + /// + public string Sim { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch IP Command instance from your account. + /// The payload to be delivered to the device /// - public class FetchIpCommandOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpCommandOptions - /// - /// The SID that identifies the resource to fetch - public FetchIpCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Payload { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of IP Commands from your account. - /// - public class ReadIpCommandOptions : ReadOptions - { - /// - /// The SID or unique name of the Sim resource that IP Command was sent to or from. - /// - public string Sim { get; set; } - /// - /// The ICCID of the Sim resource that IP Command was sent to or from. - /// - public string SimIccid { get; set; } - /// - /// The status of the IP Command - /// - public IpCommandResource.StatusEnum Status { get; set; } - /// - /// The direction of the IP Command - /// - public IpCommandResource.DirectionEnum Direction { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (SimIccid != null) - { - p.Add(new KeyValuePair("SimIccid", SimIccid)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The device port to which the IP Command will be sent + /// + public int? DevicePort { get; } + /// + /// Indicates how the payload is encoded + /// + public IpCommandResource.PayloadTypeEnum PayloadType { get; set; } + /// + /// The URL we should call after we have sent the IP Command + /// + public Uri CallbackUrl { get; set; } + /// + /// The HTTP method we should use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + + /// + /// Construct a new CreateIpCommandOptions + /// + /// The sid or unique_name of the Super SIM to send the IP Command to + /// The payload to be delivered to the device + /// The device port to which the IP Command will be sent + public CreateIpCommandOptions(string sim, string payload, int? devicePort) + { + Sim = sim; + Payload = payload; + DevicePort = devicePort; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim)); + } + + if (Payload != null) + { + p.Add(new KeyValuePair("Payload", Payload)); + } + + if (DevicePort != null) + { + p.Add(new KeyValuePair("DevicePort", DevicePort.ToString())); + } + + if (PayloadType != null) + { + p.Add(new KeyValuePair("PayloadType", PayloadType.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch IP Command instance from your account. + /// + public class FetchIpCommandOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchIpCommandOptions + /// + /// The SID that identifies the resource to fetch + public FetchIpCommandOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of IP Commands from your account. + /// + public class ReadIpCommandOptions : ReadOptions + { + /// + /// The SID or unique name of the Sim resource that IP Command was sent to or from. + /// + public string Sim { get; set; } + /// + /// The ICCID of the Sim resource that IP Command was sent to or from. + /// + public string SimIccid { get; set; } + /// + /// The status of the IP Command + /// + public IpCommandResource.StatusEnum Status { get; set; } + /// + /// The direction of the IP Command + /// + public IpCommandResource.DirectionEnum Direction { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (SimIccid != null) + { + p.Add(new KeyValuePair("SimIccid", SimIccid)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/IpCommandResource.cs b/src/Twilio/Rest/Supersim/V1/IpCommandResource.cs index b7d209c69..38fb92439 100644 --- a/src/Twilio/Rest/Supersim/V1/IpCommandResource.cs +++ b/src/Twilio/Rest/Supersim/V1/IpCommandResource.cs @@ -19,442 +19,442 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class IpCommandResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Sent = new StatusEnum("sent"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); - public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); - } - - public sealed class PayloadTypeEnum : StringEnum - { - private PayloadTypeEnum(string value) : base(value) {} - public PayloadTypeEnum() {} - public static implicit operator PayloadTypeEnum(string value) - { - return new PayloadTypeEnum(value); - } - - public static readonly PayloadTypeEnum Text = new PayloadTypeEnum("text"); - public static readonly PayloadTypeEnum Binary = new PayloadTypeEnum("binary"); - } - - private static Request BuildCreateRequest(CreateIpCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/IpCommands", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Send an IP Command to a Super SIM. - /// - /// Create IpCommand parameters - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static IpCommandResource Create(CreateIpCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Send an IP Command to a Super SIM. - /// - /// Create IpCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task CreateAsync(CreateIpCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Send an IP Command to a Super SIM. - /// - /// The sid or unique_name of the Super SIM to send the IP Command to - /// The payload to be delivered to the device - /// The device port to which the IP Command will be sent - /// Indicates how the payload is encoded - /// The URL we should call after we have sent the IP Command - /// The HTTP method we should use to call callback_url - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static IpCommandResource Create(string sim, - string payload, - int? devicePort, - IpCommandResource.PayloadTypeEnum payloadType = null, - Uri callbackUrl = null, - Twilio.Http.HttpMethod callbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateIpCommandOptions(sim, payload, devicePort){PayloadType = payloadType, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod}; - return Create(options, client); - } - - #if !NET35 - /// - /// Send an IP Command to a Super SIM. - /// - /// The sid or unique_name of the Super SIM to send the IP Command to - /// The payload to be delivered to the device - /// The device port to which the IP Command will be sent - /// Indicates how the payload is encoded - /// The URL we should call after we have sent the IP Command - /// The HTTP method we should use to call callback_url - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task CreateAsync(string sim, - string payload, - int? devicePort, - IpCommandResource.PayloadTypeEnum payloadType = null, - Uri callbackUrl = null, - Twilio.Http.HttpMethod callbackMethod = null, - ITwilioRestClient client = null) - { - var options = new CreateIpCommandOptions(sim, payload, devicePort){PayloadType = payloadType, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchIpCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/IpCommands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch IP Command instance from your account. - /// - /// Fetch IpCommand parameters - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static IpCommandResource Fetch(FetchIpCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch IP Command instance from your account. - /// - /// Fetch IpCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task FetchAsync(FetchIpCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch IP Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static IpCommandResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchIpCommandOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch IP Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchIpCommandOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadIpCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/IpCommands", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of IP Commands from your account. - /// - /// Read IpCommand parameters - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static ResourceSet Read(ReadIpCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_commands", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IP Commands from your account. - /// - /// Read IpCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_commands", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of IP Commands from your account. - /// - /// The SID or unique name of the Sim resource that IP Command was sent to or from. - /// The ICCID of the Sim resource that IP Command was sent to or from. - /// The status of the IP Command - /// The direction of the IP Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpCommand - public static ResourceSet Read(string sim = null, - string simIccid = null, - IpCommandResource.StatusEnum status = null, - IpCommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpCommandOptions(){Sim = sim, SimIccid = simIccid, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of IP Commands from your account. - /// - /// The SID or unique name of the Sim resource that IP Command was sent to or from. - /// The ICCID of the Sim resource that IP Command was sent to or from. - /// The status of the IP Command - /// The direction of the IP Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpCommand - public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, - string simIccid = null, - IpCommandResource.StatusEnum status = null, - IpCommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpCommandOptions(){Sim = sim, SimIccid = simIccid, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_commands", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("ip_commands", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("ip_commands", response.Content); - } - - /// - /// Converts a JSON string into a IpCommandResource object - /// - /// Raw JSON string - /// IpCommandResource object represented by the provided JSON - public static IpCommandResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Super SIM that this IP Command was sent to or from - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The ICCID of the Super SIM that this IP Command was sent to or from - /// - [JsonProperty("sim_iccid")] - public string SimIccid { get; private set; } - /// - /// The status of the IP Command - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public IpCommandResource.StatusEnum Status { get; private set; } - /// - /// The direction of the IP Command - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public IpCommandResource.DirectionEnum Direction { get; private set; } - /// - /// The IP address of the device that the IP Command was sent to or received from - /// - [JsonProperty("device_ip")] - public string DeviceIp { get; private set; } - /// - /// The port that the IP Command either originated from or was sent to - /// - [JsonProperty("device_port")] - public int? DevicePort { get; private set; } - /// - /// The payload type of the IP Command - /// - [JsonProperty("payload_type")] - [JsonConverter(typeof(StringEnumConverter))] - public IpCommandResource.PayloadTypeEnum PayloadType { get; private set; } - /// - /// The payload of the IP Command sent to or from the Super SIM - /// - [JsonProperty("payload")] - public string Payload { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the IP Command resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private IpCommandResource() - { - - } - } +{ + + public class IpCommandResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Sent = new StatusEnum("sent"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); + public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); + } + + public sealed class PayloadTypeEnum : StringEnum + { + private PayloadTypeEnum(string value) : base(value) { } + public PayloadTypeEnum() { } + public static implicit operator PayloadTypeEnum(string value) + { + return new PayloadTypeEnum(value); + } + + public static readonly PayloadTypeEnum Text = new PayloadTypeEnum("text"); + public static readonly PayloadTypeEnum Binary = new PayloadTypeEnum("binary"); + } + + private static Request BuildCreateRequest(CreateIpCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/IpCommands", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Send an IP Command to a Super SIM. + /// + /// Create IpCommand parameters + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static IpCommandResource Create(CreateIpCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Send an IP Command to a Super SIM. + /// + /// Create IpCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task CreateAsync(CreateIpCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Send an IP Command to a Super SIM. + /// + /// The sid or unique_name of the Super SIM to send the IP Command to + /// The payload to be delivered to the device + /// The device port to which the IP Command will be sent + /// Indicates how the payload is encoded + /// The URL we should call after we have sent the IP Command + /// The HTTP method we should use to call callback_url + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static IpCommandResource Create(string sim, + string payload, + int? devicePort, + IpCommandResource.PayloadTypeEnum payloadType = null, + Uri callbackUrl = null, + Twilio.Http.HttpMethod callbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateIpCommandOptions(sim, payload, devicePort) { PayloadType = payloadType, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod }; + return Create(options, client); + } + +#if !NET35 + /// + /// Send an IP Command to a Super SIM. + /// + /// The sid or unique_name of the Super SIM to send the IP Command to + /// The payload to be delivered to the device + /// The device port to which the IP Command will be sent + /// Indicates how the payload is encoded + /// The URL we should call after we have sent the IP Command + /// The HTTP method we should use to call callback_url + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task CreateAsync(string sim, + string payload, + int? devicePort, + IpCommandResource.PayloadTypeEnum payloadType = null, + Uri callbackUrl = null, + Twilio.Http.HttpMethod callbackMethod = null, + ITwilioRestClient client = null) + { + var options = new CreateIpCommandOptions(sim, payload, devicePort) { PayloadType = payloadType, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchIpCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/IpCommands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch IP Command instance from your account. + /// + /// Fetch IpCommand parameters + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static IpCommandResource Fetch(FetchIpCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch IP Command instance from your account. + /// + /// Fetch IpCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task FetchAsync(FetchIpCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch IP Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static IpCommandResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchIpCommandOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch IP Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchIpCommandOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadIpCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/IpCommands", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of IP Commands from your account. + /// + /// Read IpCommand parameters + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static ResourceSet Read(ReadIpCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_commands", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IP Commands from your account. + /// + /// Read IpCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_commands", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of IP Commands from your account. + /// + /// The SID or unique name of the Sim resource that IP Command was sent to or from. + /// The ICCID of the Sim resource that IP Command was sent to or from. + /// The status of the IP Command + /// The direction of the IP Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpCommand + public static ResourceSet Read(string sim = null, + string simIccid = null, + IpCommandResource.StatusEnum status = null, + IpCommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpCommandOptions() { Sim = sim, SimIccid = simIccid, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of IP Commands from your account. + /// + /// The SID or unique name of the Sim resource that IP Command was sent to or from. + /// The ICCID of the Sim resource that IP Command was sent to or from. + /// The status of the IP Command + /// The direction of the IP Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpCommand + public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, + string simIccid = null, + IpCommandResource.StatusEnum status = null, + IpCommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpCommandOptions() { Sim = sim, SimIccid = simIccid, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_commands", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("ip_commands", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("ip_commands", response.Content); + } + + /// + /// Converts a JSON string into a IpCommandResource object + /// + /// Raw JSON string + /// IpCommandResource object represented by the provided JSON + public static IpCommandResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Super SIM that this IP Command was sent to or from + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The ICCID of the Super SIM that this IP Command was sent to or from + /// + [JsonProperty("sim_iccid")] + public string SimIccid { get; private set; } + /// + /// The status of the IP Command + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public IpCommandResource.StatusEnum Status { get; private set; } + /// + /// The direction of the IP Command + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public IpCommandResource.DirectionEnum Direction { get; private set; } + /// + /// The IP address of the device that the IP Command was sent to or received from + /// + [JsonProperty("device_ip")] + public string DeviceIp { get; private set; } + /// + /// The port that the IP Command either originated from or was sent to + /// + [JsonProperty("device_port")] + public int? DevicePort { get; private set; } + /// + /// The payload type of the IP Command + /// + [JsonProperty("payload_type")] + [JsonConverter(typeof(StringEnumConverter))] + public IpCommandResource.PayloadTypeEnum PayloadType { get; private set; } + /// + /// The payload of the IP Command sent to or from the Super SIM + /// + [JsonProperty("payload")] + public string Payload { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the IP Command resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private IpCommandResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkOptions.cs b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkOptions.cs index bdf82d117..e4d96053d 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkOptions.cs @@ -9,162 +9,162 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1.NetworkAccessProfile -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Network Access Profile resource's Network resource. + /// + public class ReadNetworkAccessProfileNetworkOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Network Access Profile resource's Network resource. + /// The unique string that identifies the Network Access Profile resource /// - public class ReadNetworkAccessProfileNetworkOptions : ReadOptions - { - /// - /// The unique string that identifies the Network Access Profile resource - /// - public string PathNetworkAccessProfileSid { get; } - - /// - /// Construct a new ReadNetworkAccessProfileNetworkOptions - /// - /// The unique string that identifies the Network Access Profile resource - /// - public ReadNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid) - { - PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathNetworkAccessProfileSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Add a Network resource to the Network Access Profile resource. + /// Construct a new ReadNetworkAccessProfileNetworkOptions /// - public class CreateNetworkAccessProfileNetworkOptions : IOptions - { - /// - /// The unique string that identifies the Network Access Profile resource - /// - public string PathNetworkAccessProfileSid { get; } - /// - /// The SID that identifies the Network resource - /// - public string Network { get; } - - /// - /// Construct a new CreateNetworkAccessProfileNetworkOptions - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - public CreateNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string network) - { - PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; - Network = network; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Network != null) - { - p.Add(new KeyValuePair("Network", Network.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the Network Access Profile resource + /// + public ReadNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid) + { + PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Remove a Network resource from the Network Access Profile resource's. + /// Generate the necessary parameters /// - public class DeleteNetworkAccessProfileNetworkOptions : IOptions - { - /// - /// The unique string that identifies the Network Access Profile resource - /// - public string PathNetworkAccessProfileSid { get; } - /// - /// The SID that identifies the Network resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteNetworkAccessProfileNetworkOptions - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - public DeleteNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string pathSid) - { - PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Add a Network resource to the Network Access Profile resource. + /// + public class CreateNetworkAccessProfileNetworkOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Network Access Profile resource's Network resource. + /// The unique string that identifies the Network Access Profile resource /// - public class FetchNetworkAccessProfileNetworkOptions : IOptions - { - /// - /// The unique string that identifies the Network Access Profile resource - /// - public string PathNetworkAccessProfileSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchNetworkAccessProfileNetworkOptions - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID of the resource to fetch - public FetchNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string pathSid) - { - PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathNetworkAccessProfileSid { get; } + /// + /// The SID that identifies the Network resource + /// + public string Network { get; } + + /// + /// Construct a new CreateNetworkAccessProfileNetworkOptions + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + public CreateNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string network) + { + PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; + Network = network; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Network != null) + { + p.Add(new KeyValuePair("Network", Network.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Remove a Network resource from the Network Access Profile resource's. + /// + public class DeleteNetworkAccessProfileNetworkOptions : IOptions + { + /// + /// The unique string that identifies the Network Access Profile resource + /// + public string PathNetworkAccessProfileSid { get; } + /// + /// The SID that identifies the Network resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteNetworkAccessProfileNetworkOptions + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + public DeleteNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string pathSid) + { + PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Network Access Profile resource's Network resource. + /// + public class FetchNetworkAccessProfileNetworkOptions : IOptions + { + /// + /// The unique string that identifies the Network Access Profile resource + /// + public string PathNetworkAccessProfileSid { get; } + /// + /// The SID of the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchNetworkAccessProfileNetworkOptions + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID of the resource to fetch + public FetchNetworkAccessProfileNetworkOptions(string pathNetworkAccessProfileSid, string pathSid) + { + PathNetworkAccessProfileSid = pathNetworkAccessProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkResource.cs b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkResource.cs index c98a4f973..b695ea79d 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkResource.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkResource.cs @@ -18,423 +18,423 @@ using Twilio.Http; namespace Twilio.Rest.Supersim.V1.NetworkAccessProfile -{ - - public class NetworkAccessProfileNetworkResource : Resource - { - private static Request BuildReadRequest(ReadNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Network Access Profile resource's Network resource. - /// - /// Read NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static ResourceSet Read(ReadNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("networks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network Access Profile resource's Network resource. - /// - /// Read NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("networks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Network Access Profile resource's Network resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static ResourceSet Read(string pathNetworkAccessProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network Access Profile resource's Network resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task> ReadAsync(string pathNetworkAccessProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - private static Request BuildCreateRequest(CreateNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Add a Network resource to the Network Access Profile resource. - /// - /// Create NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static NetworkAccessProfileNetworkResource Create(CreateNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Add a Network resource to the Network Access Profile resource. - /// - /// Create NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task CreateAsync(CreateNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Add a Network resource to the Network Access Profile resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static NetworkAccessProfileNetworkResource Create(string pathNetworkAccessProfileSid, - string network, - ITwilioRestClient client = null) - { - var options = new CreateNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, network); - return Create(options, client); - } - - #if !NET35 - /// - /// Add a Network resource to the Network Access Profile resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task CreateAsync(string pathNetworkAccessProfileSid, - string network, - ITwilioRestClient client = null) - { - var options = new CreateNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, network); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove a Network resource from the Network Access Profile resource's. - /// - /// Delete NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static bool Delete(DeleteNetworkAccessProfileNetworkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove a Network resource from the Network Access Profile resource's. - /// - /// Delete NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task DeleteAsync(DeleteNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove a Network resource from the Network Access Profile resource's. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static bool Delete(string pathNetworkAccessProfileSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove a Network resource from the Network Access Profile resource's. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID that identifies the Network resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task DeleteAsync(string pathNetworkAccessProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Network Access Profile resource's Network resource. - /// - /// Fetch NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static NetworkAccessProfileNetworkResource Fetch(FetchNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Network Access Profile resource's Network resource. - /// - /// Fetch NetworkAccessProfileNetwork parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkAccessProfileNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Network Access Profile resource's Network resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfileNetwork - public static NetworkAccessProfileNetworkResource Fetch(string pathNetworkAccessProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Network Access Profile resource's Network resource. - /// - /// The unique string that identifies the Network Access Profile resource - /// - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfileNetwork - public static async System.Threading.Tasks.Task FetchAsync(string pathNetworkAccessProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NetworkAccessProfileNetworkResource object - /// - /// Raw JSON string - /// NetworkAccessProfileNetworkResource object represented by the provided JSON - public static NetworkAccessProfileNetworkResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the Network Access Profile resource - /// - [JsonProperty("network_access_profile_sid")] - public string NetworkAccessProfileSid { get; private set; } - /// - /// A human readable identifier of this resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO country code of the Network resource - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The MCC/MNCs included in the resource - /// - [JsonProperty("identifiers")] - public List Identifiers { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NetworkAccessProfileNetworkResource() - { - - } - } +{ + + public class NetworkAccessProfileNetworkResource : Resource + { + private static Request BuildReadRequest(ReadNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Network Access Profile resource's Network resource. + /// + /// Read NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static ResourceSet Read(ReadNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("networks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network Access Profile resource's Network resource. + /// + /// Read NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("networks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Network Access Profile resource's Network resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static ResourceSet Read(string pathNetworkAccessProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network Access Profile resource's Network resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task> ReadAsync(string pathNetworkAccessProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + private static Request BuildCreateRequest(CreateNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Add a Network resource to the Network Access Profile resource. + /// + /// Create NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static NetworkAccessProfileNetworkResource Create(CreateNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Add a Network resource to the Network Access Profile resource. + /// + /// Create NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task CreateAsync(CreateNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Add a Network resource to the Network Access Profile resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static NetworkAccessProfileNetworkResource Create(string pathNetworkAccessProfileSid, + string network, + ITwilioRestClient client = null) + { + var options = new CreateNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, network); + return Create(options, client); + } + +#if !NET35 + /// + /// Add a Network resource to the Network Access Profile resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task CreateAsync(string pathNetworkAccessProfileSid, + string network, + ITwilioRestClient client = null) + { + var options = new CreateNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, network); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove a Network resource from the Network Access Profile resource's. + /// + /// Delete NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static bool Delete(DeleteNetworkAccessProfileNetworkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove a Network resource from the Network Access Profile resource's. + /// + /// Delete NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task DeleteAsync(DeleteNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove a Network resource from the Network Access Profile resource's. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static bool Delete(string pathNetworkAccessProfileSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove a Network resource from the Network Access Profile resource's. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID that identifies the Network resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task DeleteAsync(string pathNetworkAccessProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchNetworkAccessProfileNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathNetworkAccessProfileSid + "/Networks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Network Access Profile resource's Network resource. + /// + /// Fetch NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static NetworkAccessProfileNetworkResource Fetch(FetchNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Network Access Profile resource's Network resource. + /// + /// Fetch NetworkAccessProfileNetwork parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkAccessProfileNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Network Access Profile resource's Network resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfileNetwork + public static NetworkAccessProfileNetworkResource Fetch(string pathNetworkAccessProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Network Access Profile resource's Network resource. + /// + /// The unique string that identifies the Network Access Profile resource + /// + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfileNetwork + public static async System.Threading.Tasks.Task FetchAsync(string pathNetworkAccessProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchNetworkAccessProfileNetworkOptions(pathNetworkAccessProfileSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NetworkAccessProfileNetworkResource object + /// + /// Raw JSON string + /// NetworkAccessProfileNetworkResource object represented by the provided JSON + public static NetworkAccessProfileNetworkResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the Network Access Profile resource + /// + [JsonProperty("network_access_profile_sid")] + public string NetworkAccessProfileSid { get; private set; } + /// + /// A human readable identifier of this resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO country code of the Network resource + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The MCC/MNCs included in the resource + /// + [JsonProperty("identifiers")] + public List Identifiers { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NetworkAccessProfileNetworkResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileOptions.cs b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileOptions.cs index 7e8d3e3ee..026516fd8 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileOptions.cs @@ -10,143 +10,143 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Network Access Profile + /// + public class CreateNetworkAccessProfileOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Network Access Profile + /// An application-defined string that uniquely identifies the resource /// - public class CreateNetworkAccessProfileOptions : IOptions - { - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// List of Network SIDs that this Network Access Profile will allow connections to - /// - public List Networks { get; set; } - - /// - /// Construct a new CreateNetworkAccessProfileOptions - /// - public CreateNetworkAccessProfileOptions() - { - Networks = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Networks != null) - { - p.AddRange(Networks.Select(prop => new KeyValuePair("Networks", prop.ToString()))); - } - - return p; - } - } - + public string UniqueName { get; set; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Network Access Profile instance from your account. + /// List of Network SIDs that this Network Access Profile will allow connections to /// - public class FetchNetworkAccessProfileOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchNetworkAccessProfileOptions - /// - /// The SID that identifies the resource to fetch - public FetchNetworkAccessProfileOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List Networks { get; set; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Updates the given properties of a Network Access Profile in your account. + /// Construct a new CreateNetworkAccessProfileOptions /// - public class UpdateNetworkAccessProfileOptions : IOptions - { - /// - /// The SID of the resource to update - /// - public string PathSid { get; } - /// - /// The new unique name of the resource - /// - public string UniqueName { get; set; } - - /// - /// Construct a new UpdateNetworkAccessProfileOptions - /// - /// The SID of the resource to update - public UpdateNetworkAccessProfileOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - return p; - } - } - + public CreateNetworkAccessProfileOptions() + { + Networks = new List(); + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Network Access Profiles from your account. + /// Generate the necessary parameters /// - public class ReadNetworkAccessProfileOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Networks != null) + { + p.AddRange(Networks.Select(prop => new KeyValuePair("Networks", prop.ToString()))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Network Access Profile instance from your account. + /// + public class FetchNetworkAccessProfileOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchNetworkAccessProfileOptions + /// + /// The SID that identifies the resource to fetch + public FetchNetworkAccessProfileOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Updates the given properties of a Network Access Profile in your account. + /// + public class UpdateNetworkAccessProfileOptions : IOptions + { + /// + /// The SID of the resource to update + /// + public string PathSid { get; } + /// + /// The new unique name of the resource + /// + public string UniqueName { get; set; } + + /// + /// Construct a new UpdateNetworkAccessProfileOptions + /// + /// The SID of the resource to update + public UpdateNetworkAccessProfileOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Network Access Profiles from your account. + /// + public class ReadNetworkAccessProfileOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileResource.cs b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileResource.cs index ae9d7fff1..179a1d592 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileResource.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkAccessProfileResource.cs @@ -18,414 +18,414 @@ using Twilio.Http; namespace Twilio.Rest.Supersim.V1 -{ - - public class NetworkAccessProfileResource : Resource - { - private static Request BuildCreateRequest(CreateNetworkAccessProfileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Network Access Profile - /// - /// Create NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Create(CreateNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Network Access Profile - /// - /// Create NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task CreateAsync(CreateNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Network Access Profile - /// - /// An application-defined string that uniquely identifies the resource - /// List of Network SIDs that this Network Access Profile will allow connections to - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Create(string uniqueName = null, - List networks = null, - ITwilioRestClient client = null) - { - var options = new CreateNetworkAccessProfileOptions(){UniqueName = uniqueName, Networks = networks}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Network Access Profile - /// - /// An application-defined string that uniquely identifies the resource - /// List of Network SIDs that this Network Access Profile will allow connections to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, - List networks = null, - ITwilioRestClient client = null) - { - var options = new CreateNetworkAccessProfileOptions(){UniqueName = uniqueName, Networks = networks}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchNetworkAccessProfileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Network Access Profile instance from your account. - /// - /// Fetch NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Fetch(FetchNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Network Access Profile instance from your account. - /// - /// Fetch NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Network Access Profile instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchNetworkAccessProfileOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Network Access Profile instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchNetworkAccessProfileOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateNetworkAccessProfileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the given properties of a Network Access Profile in your account. - /// - /// Update NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Update(UpdateNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the given properties of a Network Access Profile in your account. - /// - /// Update NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task UpdateAsync(UpdateNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the given properties of a Network Access Profile in your account. - /// - /// The SID of the resource to update - /// The new unique name of the resource - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static NetworkAccessProfileResource Update(string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateNetworkAccessProfileOptions(pathSid){UniqueName = uniqueName}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the given properties of a Network Access Profile in your account. - /// - /// The SID of the resource to update - /// The new unique name of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - ITwilioRestClient client = null) - { - var options = new UpdateNetworkAccessProfileOptions(pathSid){UniqueName = uniqueName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadNetworkAccessProfileOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/NetworkAccessProfiles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Network Access Profiles from your account. - /// - /// Read NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static ResourceSet Read(ReadNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("network_access_profiles", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network Access Profiles from your account. - /// - /// Read NetworkAccessProfile parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkAccessProfileOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("network_access_profiles", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Network Access Profiles from your account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of NetworkAccessProfile - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkAccessProfileOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network Access Profiles from your account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NetworkAccessProfile - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkAccessProfileOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("network_access_profiles", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("network_access_profiles", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("network_access_profiles", response.Content); - } - - /// - /// Converts a JSON string into a NetworkAccessProfileResource object - /// - /// Raw JSON string - /// NetworkAccessProfileResource object represented by the provided JSON - public static NetworkAccessProfileResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that the Network Access Profile belongs to - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private NetworkAccessProfileResource() - { - - } - } +{ + + public class NetworkAccessProfileResource : Resource + { + private static Request BuildCreateRequest(CreateNetworkAccessProfileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Network Access Profile + /// + /// Create NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Create(CreateNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Network Access Profile + /// + /// Create NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task CreateAsync(CreateNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Network Access Profile + /// + /// An application-defined string that uniquely identifies the resource + /// List of Network SIDs that this Network Access Profile will allow connections to + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Create(string uniqueName = null, + List networks = null, + ITwilioRestClient client = null) + { + var options = new CreateNetworkAccessProfileOptions() { UniqueName = uniqueName, Networks = networks }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Network Access Profile + /// + /// An application-defined string that uniquely identifies the resource + /// List of Network SIDs that this Network Access Profile will allow connections to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, + List networks = null, + ITwilioRestClient client = null) + { + var options = new CreateNetworkAccessProfileOptions() { UniqueName = uniqueName, Networks = networks }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchNetworkAccessProfileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Network Access Profile instance from your account. + /// + /// Fetch NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Fetch(FetchNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Network Access Profile instance from your account. + /// + /// Fetch NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Network Access Profile instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchNetworkAccessProfileOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Network Access Profile instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchNetworkAccessProfileOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateNetworkAccessProfileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the given properties of a Network Access Profile in your account. + /// + /// Update NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Update(UpdateNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the given properties of a Network Access Profile in your account. + /// + /// Update NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task UpdateAsync(UpdateNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the given properties of a Network Access Profile in your account. + /// + /// The SID of the resource to update + /// The new unique name of the resource + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static NetworkAccessProfileResource Update(string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateNetworkAccessProfileOptions(pathSid) { UniqueName = uniqueName }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the given properties of a Network Access Profile in your account. + /// + /// The SID of the resource to update + /// The new unique name of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + ITwilioRestClient client = null) + { + var options = new UpdateNetworkAccessProfileOptions(pathSid) { UniqueName = uniqueName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadNetworkAccessProfileOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/NetworkAccessProfiles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Network Access Profiles from your account. + /// + /// Read NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static ResourceSet Read(ReadNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("network_access_profiles", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network Access Profiles from your account. + /// + /// Read NetworkAccessProfile parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkAccessProfileOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("network_access_profiles", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Network Access Profiles from your account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of NetworkAccessProfile + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkAccessProfileOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network Access Profiles from your account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NetworkAccessProfile + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkAccessProfileOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("network_access_profiles", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("network_access_profiles", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("network_access_profiles", response.Content); + } + + /// + /// Converts a JSON string into a NetworkAccessProfileResource object + /// + /// Raw JSON string + /// NetworkAccessProfileResource object represented by the provided JSON + public static NetworkAccessProfileResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that the Network Access Profile belongs to + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private NetworkAccessProfileResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkOptions.cs b/src/Twilio/Rest/Supersim/V1/NetworkOptions.cs index 48be0ff43..70f742472 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Network resource. + /// + public class FetchNetworkOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Network resource. + /// The SID of the Network resource to fetch /// - public class FetchNetworkOptions : IOptions - { - /// - /// The SID of the Network resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchNetworkOptions - /// - /// The SID of the Network resource to fetch - public FetchNetworkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Network resources. + /// Construct a new FetchNetworkOptions /// - public class ReadNetworkOptions : ReadOptions - { - /// - /// The ISO country code of the Network resources to read - /// - public string IsoCountry { get; set; } - /// - /// The MCC of Network resource identifiers to be read - /// - public string Mcc { get; set; } - /// - /// The MNC of Network resource identifiers to be read - /// - public string Mnc { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry)); - } - - if (Mcc != null) - { - p.Add(new KeyValuePair("Mcc", Mcc)); - } - - if (Mnc != null) - { - p.Add(new KeyValuePair("Mnc", Mnc)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the Network resource to fetch + public FetchNetworkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Network resources. + /// + public class ReadNetworkOptions : ReadOptions + { + /// + /// The ISO country code of the Network resources to read + /// + public string IsoCountry { get; set; } + /// + /// The MCC of Network resource identifiers to be read + /// + public string Mcc { get; set; } + /// + /// The MNC of Network resource identifiers to be read + /// + public string Mnc { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry)); + } + + if (Mcc != null) + { + p.Add(new KeyValuePair("Mcc", Mcc)); + } + + if (Mnc != null) + { + p.Add(new KeyValuePair("Mnc", Mnc)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/NetworkResource.cs b/src/Twilio/Rest/Supersim/V1/NetworkResource.cs index 13ed3606e..43310ab52 100644 --- a/src/Twilio/Rest/Supersim/V1/NetworkResource.cs +++ b/src/Twilio/Rest/Supersim/V1/NetworkResource.cs @@ -18,266 +18,266 @@ using Twilio.Http; namespace Twilio.Rest.Supersim.V1 -{ - - public class NetworkResource : Resource - { - private static Request BuildFetchRequest(FetchNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Networks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Network resource. - /// - /// Fetch Network parameters - /// Client to make requests to Twilio - /// A single instance of Network - public static NetworkResource Fetch(FetchNetworkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Network resource. - /// - /// Fetch Network parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Network - public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Network resource. - /// - /// The SID of the Network resource to fetch - /// Client to make requests to Twilio - /// A single instance of Network - public static NetworkResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchNetworkOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Network resource. - /// - /// The SID of the Network resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Network - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchNetworkOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadNetworkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Networks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Network resources. - /// - /// Read Network parameters - /// Client to make requests to Twilio - /// A single instance of Network - public static ResourceSet Read(ReadNetworkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("networks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network resources. - /// - /// Read Network parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Network - public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("networks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Network resources. - /// - /// The ISO country code of the Network resources to read - /// The MCC of Network resource identifiers to be read - /// The MNC of Network resource identifiers to be read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Network - public static ResourceSet Read(string isoCountry = null, - string mcc = null, - string mnc = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkOptions(){IsoCountry = isoCountry, Mcc = mcc, Mnc = mnc, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Network resources. - /// - /// The ISO country code of the Network resources to read - /// The MCC of Network resource identifiers to be read - /// The MNC of Network resource identifiers to be read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Network - public static async System.Threading.Tasks.Task> ReadAsync(string isoCountry = null, - string mcc = null, - string mnc = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadNetworkOptions(){IsoCountry = isoCountry, Mcc = mcc, Mnc = mnc, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("networks", response.Content); - } - - /// - /// Converts a JSON string into a NetworkResource object - /// - /// Raw JSON string - /// NetworkResource object represented by the provided JSON - public static NetworkResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human readable identifier of this resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The absolute URL of the Network resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The ISO country code of the Network resource - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The MCC/MNCs included in the Network resource - /// - [JsonProperty("identifiers")] - public List Identifiers { get; private set; } - - private NetworkResource() - { - - } - } +{ + + public class NetworkResource : Resource + { + private static Request BuildFetchRequest(FetchNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Networks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Network resource. + /// + /// Fetch Network parameters + /// Client to make requests to Twilio + /// A single instance of Network + public static NetworkResource Fetch(FetchNetworkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Network resource. + /// + /// Fetch Network parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Network + public static async System.Threading.Tasks.Task FetchAsync(FetchNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Network resource. + /// + /// The SID of the Network resource to fetch + /// Client to make requests to Twilio + /// A single instance of Network + public static NetworkResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchNetworkOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Network resource. + /// + /// The SID of the Network resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Network + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchNetworkOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadNetworkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Networks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Network resources. + /// + /// Read Network parameters + /// Client to make requests to Twilio + /// A single instance of Network + public static ResourceSet Read(ReadNetworkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("networks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network resources. + /// + /// Read Network parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Network + public static async System.Threading.Tasks.Task> ReadAsync(ReadNetworkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("networks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Network resources. + /// + /// The ISO country code of the Network resources to read + /// The MCC of Network resource identifiers to be read + /// The MNC of Network resource identifiers to be read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Network + public static ResourceSet Read(string isoCountry = null, + string mcc = null, + string mnc = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkOptions() { IsoCountry = isoCountry, Mcc = mcc, Mnc = mnc, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Network resources. + /// + /// The ISO country code of the Network resources to read + /// The MCC of Network resource identifiers to be read + /// The MNC of Network resource identifiers to be read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Network + public static async System.Threading.Tasks.Task> ReadAsync(string isoCountry = null, + string mcc = null, + string mnc = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadNetworkOptions() { IsoCountry = isoCountry, Mcc = mcc, Mnc = mnc, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("networks", response.Content); + } + + /// + /// Converts a JSON string into a NetworkResource object + /// + /// Raw JSON string + /// NetworkResource object represented by the provided JSON + public static NetworkResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human readable identifier of this resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The absolute URL of the Network resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The ISO country code of the Network resource + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The MCC/MNCs included in the Network resource + /// + [JsonProperty("identifiers")] + public List Identifiers { get; private set; } + + private NetworkResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodOptions.cs b/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodOptions.cs index 87fd77519..7836ed30b 100644 --- a/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodOptions.cs @@ -9,40 +9,40 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1.Sim -{ - +{ + + /// + /// Retrieve a list of Billing Periods for a Super SIM. + /// + public class ReadBillingPeriodOptions : ReadOptions + { /// - /// Retrieve a list of Billing Periods for a Super SIM. + /// The SID of the Super SIM to list Billing Periods for. /// - public class ReadBillingPeriodOptions : ReadOptions - { - /// - /// The SID of the Super SIM to list Billing Periods for. - /// - public string PathSimSid { get; } - - /// - /// Construct a new ReadBillingPeriodOptions - /// - /// The SID of the Super SIM to list Billing Periods for. - public ReadBillingPeriodOptions(string pathSimSid) - { - PathSimSid = pathSimSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSimSid { get; } + + /// + /// Construct a new ReadBillingPeriodOptions + /// + /// The SID of the Super SIM to list Billing Periods for. + public ReadBillingPeriodOptions(string pathSimSid) + { + PathSimSid = pathSimSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodResource.cs b/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodResource.cs index f54f95fa5..7c540b3a7 100644 --- a/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodResource.cs +++ b/src/Twilio/Rest/Supersim/V1/Sim/BillingPeriodResource.cs @@ -17,221 +17,221 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1.Sim -{ - - public class BillingPeriodResource : Resource - { - public sealed class BpTypeEnum : StringEnum - { - private BpTypeEnum(string value) : base(value) {} - public BpTypeEnum() {} - public static implicit operator BpTypeEnum(string value) - { - return new BpTypeEnum(value); - } - - public static readonly BpTypeEnum Ready = new BpTypeEnum("ready"); - public static readonly BpTypeEnum Active = new BpTypeEnum("active"); - } - - private static Request BuildReadRequest(ReadBillingPeriodOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Sims/" + options.PathSimSid + "/BillingPeriods", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Billing Periods for a Super SIM. - /// - /// Read BillingPeriod parameters - /// Client to make requests to Twilio - /// A single instance of BillingPeriod - public static ResourceSet Read(ReadBillingPeriodOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("billing_periods", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Billing Periods for a Super SIM. - /// - /// Read BillingPeriod parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BillingPeriod - public static async System.Threading.Tasks.Task> ReadAsync(ReadBillingPeriodOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("billing_periods", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Billing Periods for a Super SIM. - /// - /// The SID of the Super SIM to list Billing Periods for. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of BillingPeriod - public static ResourceSet Read(string pathSimSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBillingPeriodOptions(pathSimSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Billing Periods for a Super SIM. - /// - /// The SID of the Super SIM to list Billing Periods for. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BillingPeriod - public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBillingPeriodOptions(pathSimSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("billing_periods", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("billing_periods", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("billing_periods", response.Content); - } - - /// - /// Converts a JSON string into a BillingPeriodResource object - /// - /// Raw JSON string - /// BillingPeriodResource object represented by the provided JSON - public static BillingPeriodResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Billing Period - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account the Super SIM belongs to - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Super SIM the Billing Period belongs to - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The start time of the Billing Period - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end time of the Billing Period - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The type of the Billing Period - /// - [JsonProperty("period_type")] - [JsonConverter(typeof(StringEnumConverter))] - public BillingPeriodResource.BpTypeEnum PeriodType { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private BillingPeriodResource() - { - - } - } +{ + + public class BillingPeriodResource : Resource + { + public sealed class BpTypeEnum : StringEnum + { + private BpTypeEnum(string value) : base(value) { } + public BpTypeEnum() { } + public static implicit operator BpTypeEnum(string value) + { + return new BpTypeEnum(value); + } + + public static readonly BpTypeEnum Ready = new BpTypeEnum("ready"); + public static readonly BpTypeEnum Active = new BpTypeEnum("active"); + } + + private static Request BuildReadRequest(ReadBillingPeriodOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Sims/" + options.PathSimSid + "/BillingPeriods", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Billing Periods for a Super SIM. + /// + /// Read BillingPeriod parameters + /// Client to make requests to Twilio + /// A single instance of BillingPeriod + public static ResourceSet Read(ReadBillingPeriodOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("billing_periods", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Billing Periods for a Super SIM. + /// + /// Read BillingPeriod parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BillingPeriod + public static async System.Threading.Tasks.Task> ReadAsync(ReadBillingPeriodOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("billing_periods", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Billing Periods for a Super SIM. + /// + /// The SID of the Super SIM to list Billing Periods for. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of BillingPeriod + public static ResourceSet Read(string pathSimSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBillingPeriodOptions(pathSimSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Billing Periods for a Super SIM. + /// + /// The SID of the Super SIM to list Billing Periods for. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BillingPeriod + public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBillingPeriodOptions(pathSimSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("billing_periods", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("billing_periods", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("billing_periods", response.Content); + } + + /// + /// Converts a JSON string into a BillingPeriodResource object + /// + /// Raw JSON string + /// BillingPeriodResource object represented by the provided JSON + public static BillingPeriodResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Billing Period + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account the Super SIM belongs to + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Super SIM the Billing Period belongs to + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The start time of the Billing Period + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end time of the Billing Period + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The type of the Billing Period + /// + [JsonProperty("period_type")] + [JsonConverter(typeof(StringEnumConverter))] + public BillingPeriodResource.BpTypeEnum PeriodType { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private BillingPeriodResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/SimOptions.cs b/src/Twilio/Rest/Supersim/V1/SimOptions.cs index 4e94cc018..5e8e82fb8 100644 --- a/src/Twilio/Rest/Supersim/V1/SimOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/SimOptions.cs @@ -9,220 +9,220 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Register a Super SIM to your Account + /// + public class CreateSimOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Register a Super SIM to your Account - /// - public class CreateSimOptions : IOptions - { - /// - /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM to be added to your Account - /// - public string Iccid { get; } - /// - /// The 10-digit code required to claim the Super SIM for your Account - /// - public string RegistrationCode { get; } - - /// - /// Construct a new CreateSimOptions - /// - /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM - /// to be added to your Account - /// The 10-digit code required to claim the Super SIM for your Account - public CreateSimOptions(string iccid, string registrationCode) - { - Iccid = iccid; - RegistrationCode = registrationCode; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Iccid != null) - { - p.Add(new KeyValuePair("Iccid", Iccid)); - } - - if (RegistrationCode != null) - { - p.Add(new KeyValuePair("RegistrationCode", RegistrationCode)); - } - - return p; - } - } - + /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM to be added to your Account + /// + public string Iccid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a Super SIM instance from your account. + /// The 10-digit code required to claim the Super SIM for your Account /// - public class FetchSimOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSimOptions - /// - /// The SID that identifies the resource to fetch - public FetchSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string RegistrationCode { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Updates the given properties of a Super SIM instance from your account. - /// - public class UpdateSimOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The new status of the Super SIM - /// - public SimResource.StatusUpdateEnum Status { get; set; } - /// - /// The SID or unique name of the Fleet to which the SIM resource should be assigned - /// - public string Fleet { get; set; } - /// - /// The URL we should call after the update has finished - /// - public Uri CallbackUrl { get; set; } - /// - /// The HTTP method we should use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// The SID of the Account to which the Sim resource should belong - /// - public string AccountSid { get; set; } - - /// - /// Construct a new UpdateSimOptions - /// - /// The SID that identifies the resource to update - public UpdateSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Fleet != null) - { - p.Add(new KeyValuePair("Fleet", Fleet.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - return p; - } - } - + /// Construct a new CreateSimOptions + /// + /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM + /// to be added to your Account + /// The 10-digit code required to claim the Super SIM for your Account + public CreateSimOptions(string iccid, string registrationCode) + { + Iccid = iccid; + RegistrationCode = registrationCode; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of Super SIMs from your account. - /// - public class ReadSimOptions : ReadOptions - { - /// - /// The status of the Sim resources to read - /// - public SimResource.StatusEnum Status { get; set; } - /// - /// The SID or unique name of the Fleet to which a list of Sims are assigned - /// - public string Fleet { get; set; } - /// - /// The ICCID associated with a Super SIM to filter the list by - /// - public string Iccid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Fleet != null) - { - p.Add(new KeyValuePair("Fleet", Fleet.ToString())); - } - - if (Iccid != null) - { - p.Add(new KeyValuePair("Iccid", Iccid)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Iccid != null) + { + p.Add(new KeyValuePair("Iccid", Iccid)); + } + + if (RegistrationCode != null) + { + p.Add(new KeyValuePair("RegistrationCode", RegistrationCode)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a Super SIM instance from your account. + /// + public class FetchSimOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchSimOptions + /// + /// The SID that identifies the resource to fetch + public FetchSimOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Updates the given properties of a Super SIM instance from your account. + /// + public class UpdateSimOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The new status of the Super SIM + /// + public SimResource.StatusUpdateEnum Status { get; set; } + /// + /// The SID or unique name of the Fleet to which the SIM resource should be assigned + /// + public string Fleet { get; set; } + /// + /// The URL we should call after the update has finished + /// + public Uri CallbackUrl { get; set; } + /// + /// The HTTP method we should use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// The SID of the Account to which the Sim resource should belong + /// + public string AccountSid { get; set; } + + /// + /// Construct a new UpdateSimOptions + /// + /// The SID that identifies the resource to update + public UpdateSimOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Fleet != null) + { + p.Add(new KeyValuePair("Fleet", Fleet.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of Super SIMs from your account. + /// + public class ReadSimOptions : ReadOptions + { + /// + /// The status of the Sim resources to read + /// + public SimResource.StatusEnum Status { get; set; } + /// + /// The SID or unique name of the Fleet to which a list of Sims are assigned + /// + public string Fleet { get; set; } + /// + /// The ICCID associated with a Super SIM to filter the list by + /// + public string Iccid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Fleet != null) + { + p.Add(new KeyValuePair("Fleet", Fleet.ToString())); + } + + if (Iccid != null) + { + p.Add(new KeyValuePair("Iccid", Iccid)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/SimResource.cs b/src/Twilio/Rest/Supersim/V1/SimResource.cs index 5c87552d6..06eb5f603 100644 --- a/src/Twilio/Rest/Supersim/V1/SimResource.cs +++ b/src/Twilio/Rest/Supersim/V1/SimResource.cs @@ -19,486 +19,486 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class SimResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum New = new StatusEnum("new"); - public static readonly StatusEnum Ready = new StatusEnum("ready"); - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Inactive = new StatusEnum("inactive"); - public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); - } - - public sealed class StatusUpdateEnum : StringEnum - { - private StatusUpdateEnum(string value) : base(value) {} - public StatusUpdateEnum() {} - public static implicit operator StatusUpdateEnum(string value) - { - return new StatusUpdateEnum(value); - } - - public static readonly StatusUpdateEnum Ready = new StatusUpdateEnum("ready"); - public static readonly StatusUpdateEnum Active = new StatusUpdateEnum("active"); - public static readonly StatusUpdateEnum Inactive = new StatusUpdateEnum("inactive"); - } - - private static Request BuildCreateRequest(CreateSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/Sims", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Register a Super SIM to your Account - /// - /// Create Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Create(CreateSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Register a Super SIM to your Account - /// - /// Create Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task CreateAsync(CreateSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Register a Super SIM to your Account - /// - /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM - /// to be added to your Account - /// The 10-digit code required to claim the Super SIM for your Account - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Create(string iccid, string registrationCode, ITwilioRestClient client = null) - { - var options = new CreateSimOptions(iccid, registrationCode); - return Create(options, client); - } - - #if !NET35 - /// - /// Register a Super SIM to your Account - /// - /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM - /// to be added to your Account - /// The 10-digit code required to claim the Super SIM for your Account - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task CreateAsync(string iccid, - string registrationCode, - ITwilioRestClient client = null) - { - var options = new CreateSimOptions(iccid, registrationCode); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Sims/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Super SIM instance from your account. - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Super SIM instance from your account. - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Super SIM instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Super SIM instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/Sims/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the given properties of a Super SIM instance from your account. - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the given properties of a Super SIM instance from your account. - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the given properties of a Super SIM instance from your account. - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// The new status of the Super SIM - /// The SID or unique name of the Fleet to which the SIM resource should be assigned - /// The URL we should call after the update has finished - /// The HTTP method we should use to call callback_url - /// The SID of the Account to which the Sim resource should belong - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(string pathSid, - string uniqueName = null, - SimResource.StatusUpdateEnum status = null, - string fleet = null, - Uri callbackUrl = null, - Twilio.Http.HttpMethod callbackMethod = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, Status = status, Fleet = fleet, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod, AccountSid = accountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the given properties of a Super SIM instance from your account. - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// The new status of the Super SIM - /// The SID or unique name of the Fleet to which the SIM resource should be assigned - /// The URL we should call after the update has finished - /// The HTTP method we should use to call callback_url - /// The SID of the Account to which the Sim resource should belong - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - SimResource.StatusUpdateEnum status = null, - string fleet = null, - Uri callbackUrl = null, - Twilio.Http.HttpMethod callbackMethod = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, Status = status, Fleet = fleet, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod, AccountSid = accountSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/Sims", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Super SIMs from your account. - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Super SIMs from your account. - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Super SIMs from your account. - /// - /// The status of the Sim resources to read - /// The SID or unique name of the Fleet to which a list of Sims are assigned - /// The ICCID associated with a Super SIM to filter the list by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(SimResource.StatusEnum status = null, - string fleet = null, - string iccid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Fleet = fleet, Iccid = iccid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Super SIMs from your account. - /// - /// The status of the Sim resources to read - /// The SID or unique name of the Fleet to which a list of Sims are assigned - /// The ICCID associated with a Super SIM to filter the list by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(SimResource.StatusEnum status = null, - string fleet = null, - string iccid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Fleet = fleet, Iccid = iccid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Converts a JSON string into a SimResource object - /// - /// Raw JSON string - /// SimResource object represented by the provided JSON - public static SimResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that the Super SIM belongs to - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ICCID associated with the SIM - /// - [JsonProperty("iccid")] - public string Iccid { get; private set; } - /// - /// The status of the Super SIM - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SimResource.StatusEnum Status { get; private set; } - /// - /// The unique ID of the Fleet configured for this SIM - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Sim Resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private SimResource() - { - - } - } +{ + + public class SimResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum New = new StatusEnum("new"); + public static readonly StatusEnum Ready = new StatusEnum("ready"); + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Inactive = new StatusEnum("inactive"); + public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); + } + + public sealed class StatusUpdateEnum : StringEnum + { + private StatusUpdateEnum(string value) : base(value) { } + public StatusUpdateEnum() { } + public static implicit operator StatusUpdateEnum(string value) + { + return new StatusUpdateEnum(value); + } + + public static readonly StatusUpdateEnum Ready = new StatusUpdateEnum("ready"); + public static readonly StatusUpdateEnum Active = new StatusUpdateEnum("active"); + public static readonly StatusUpdateEnum Inactive = new StatusUpdateEnum("inactive"); + } + + private static Request BuildCreateRequest(CreateSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/Sims", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Register a Super SIM to your Account + /// + /// Create Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Create(CreateSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Register a Super SIM to your Account + /// + /// Create Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task CreateAsync(CreateSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Register a Super SIM to your Account + /// + /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM + /// to be added to your Account + /// The 10-digit code required to claim the Super SIM for your Account + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Create(string iccid, string registrationCode, ITwilioRestClient client = null) + { + var options = new CreateSimOptions(iccid, registrationCode); + return Create(options, client); + } + +#if !NET35 + /// + /// Register a Super SIM to your Account + /// + /// The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM + /// to be added to your Account + /// The 10-digit code required to claim the Super SIM for your Account + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task CreateAsync(string iccid, + string registrationCode, + ITwilioRestClient client = null) + { + var options = new CreateSimOptions(iccid, registrationCode); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Sims/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Super SIM instance from your account. + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Super SIM instance from your account. + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Super SIM instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Super SIM instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/Sims/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the given properties of a Super SIM instance from your account. + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the given properties of a Super SIM instance from your account. + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the given properties of a Super SIM instance from your account. + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// The new status of the Super SIM + /// The SID or unique name of the Fleet to which the SIM resource should be assigned + /// The URL we should call after the update has finished + /// The HTTP method we should use to call callback_url + /// The SID of the Account to which the Sim resource should belong + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(string pathSid, + string uniqueName = null, + SimResource.StatusUpdateEnum status = null, + string fleet = null, + Uri callbackUrl = null, + Twilio.Http.HttpMethod callbackMethod = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, Status = status, Fleet = fleet, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod, AccountSid = accountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the given properties of a Super SIM instance from your account. + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// The new status of the Super SIM + /// The SID or unique name of the Fleet to which the SIM resource should be assigned + /// The URL we should call after the update has finished + /// The HTTP method we should use to call callback_url + /// The SID of the Account to which the Sim resource should belong + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + SimResource.StatusUpdateEnum status = null, + string fleet = null, + Uri callbackUrl = null, + Twilio.Http.HttpMethod callbackMethod = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, Status = status, Fleet = fleet, CallbackUrl = callbackUrl, CallbackMethod = callbackMethod, AccountSid = accountSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/Sims", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Super SIMs from your account. + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Super SIMs from your account. + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Super SIMs from your account. + /// + /// The status of the Sim resources to read + /// The SID or unique name of the Fleet to which a list of Sims are assigned + /// The ICCID associated with a Super SIM to filter the list by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(SimResource.StatusEnum status = null, + string fleet = null, + string iccid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Fleet = fleet, Iccid = iccid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Super SIMs from your account. + /// + /// The status of the Sim resources to read + /// The SID or unique name of the Fleet to which a list of Sims are assigned + /// The ICCID associated with a Super SIM to filter the list by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(SimResource.StatusEnum status = null, + string fleet = null, + string iccid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Fleet = fleet, Iccid = iccid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Converts a JSON string into a SimResource object + /// + /// Raw JSON string + /// SimResource object represented by the provided JSON + public static SimResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that the Super SIM belongs to + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ICCID associated with the SIM + /// + [JsonProperty("iccid")] + public string Iccid { get; private set; } + /// + /// The status of the Super SIM + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SimResource.StatusEnum Status { get; private set; } + /// + /// The unique ID of the Fleet configured for this SIM + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Sim Resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private SimResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/SmsCommandOptions.cs b/src/Twilio/Rest/Supersim/V1/SmsCommandOptions.cs index a32aae2ed..c647ae7d0 100644 --- a/src/Twilio/Rest/Supersim/V1/SmsCommandOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/SmsCommandOptions.cs @@ -9,152 +9,152 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Send SMS Command to a Sim. + /// + public class CreateSmsCommandOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Send SMS Command to a Sim. + /// The sid or unique_name of the SIM to send the SMS Command to /// - public class CreateSmsCommandOptions : IOptions - { - /// - /// The sid or unique_name of the SIM to send the SMS Command to - /// - public string Sim { get; } - /// - /// The message body of the SMS Command - /// - public string Payload { get; } - /// - /// The HTTP method we should use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// The URL we should call after we have sent the command - /// - public Uri CallbackUrl { get; set; } - - /// - /// Construct a new CreateSmsCommandOptions - /// - /// The sid or unique_name of the SIM to send the SMS Command to - /// The message body of the SMS Command - public CreateSmsCommandOptions(string sim, string payload) - { - Sim = sim; - Payload = payload; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (Payload != null) - { - p.Add(new KeyValuePair("Payload", Payload)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - return p; - } - } - + public string Sim { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch SMS Command instance from your account. + /// The message body of the SMS Command /// - public class FetchSmsCommandOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSmsCommandOptions - /// - /// The SID that identifies the resource to fetch - public FetchSmsCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Payload { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of SMS Commands from your account. + /// The HTTP method we should use to call callback_url /// - public class ReadSmsCommandOptions : ReadOptions - { - /// - /// The SID or unique name of the Sim resource that SMS Command was sent to or from. - /// - public string Sim { get; set; } - /// - /// The status of the SMS Command - /// - public SmsCommandResource.StatusEnum Status { get; set; } - /// - /// The direction of the SMS Command - /// - public SmsCommandResource.DirectionEnum Direction { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// The URL we should call after we have sent the command + /// + public Uri CallbackUrl { get; set; } + + /// + /// Construct a new CreateSmsCommandOptions + /// + /// The sid or unique_name of the SIM to send the SMS Command to + /// The message body of the SMS Command + public CreateSmsCommandOptions(string sim, string payload) + { + Sim = sim; + Payload = payload; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (Payload != null) + { + p.Add(new KeyValuePair("Payload", Payload)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch SMS Command instance from your account. + /// + public class FetchSmsCommandOptions : IOptions + { + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchSmsCommandOptions + /// + /// The SID that identifies the resource to fetch + public FetchSmsCommandOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of SMS Commands from your account. + /// + public class ReadSmsCommandOptions : ReadOptions + { + /// + /// The SID or unique name of the Sim resource that SMS Command was sent to or from. + /// + public string Sim { get; set; } + /// + /// The status of the SMS Command + /// + public SmsCommandResource.StatusEnum Status { get; set; } + /// + /// The direction of the SMS Command + /// + public SmsCommandResource.DirectionEnum Direction { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/SmsCommandResource.cs b/src/Twilio/Rest/Supersim/V1/SmsCommandResource.cs index 499b109ed..be6fe8f28 100644 --- a/src/Twilio/Rest/Supersim/V1/SmsCommandResource.cs +++ b/src/Twilio/Rest/Supersim/V1/SmsCommandResource.cs @@ -19,397 +19,397 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class SmsCommandResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Sent = new StatusEnum("sent"); - public static readonly StatusEnum Delivered = new StatusEnum("delivered"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); - public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); - } - - private static Request BuildCreateRequest(CreateSmsCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Supersim, - "/v1/SmsCommands", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Send SMS Command to a Sim. - /// - /// Create SmsCommand parameters - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static SmsCommandResource Create(CreateSmsCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Send SMS Command to a Sim. - /// - /// Create SmsCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task CreateAsync(CreateSmsCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Send SMS Command to a Sim. - /// - /// The sid or unique_name of the SIM to send the SMS Command to - /// The message body of the SMS Command - /// The HTTP method we should use to call callback_url - /// The URL we should call after we have sent the command - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static SmsCommandResource Create(string sim, - string payload, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateSmsCommandOptions(sim, payload){CallbackMethod = callbackMethod, CallbackUrl = callbackUrl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Send SMS Command to a Sim. - /// - /// The sid or unique_name of the SIM to send the SMS Command to - /// The message body of the SMS Command - /// The HTTP method we should use to call callback_url - /// The URL we should call after we have sent the command - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task CreateAsync(string sim, - string payload, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - ITwilioRestClient client = null) - { - var options = new CreateSmsCommandOptions(sim, payload){CallbackMethod = callbackMethod, CallbackUrl = callbackUrl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchSmsCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/SmsCommands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch SMS Command instance from your account. - /// - /// Fetch SmsCommand parameters - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static SmsCommandResource Fetch(FetchSmsCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch SMS Command instance from your account. - /// - /// Fetch SmsCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task FetchAsync(FetchSmsCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch SMS Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static SmsCommandResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSmsCommandOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch SMS Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSmsCommandOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSmsCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/SmsCommands", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of SMS Commands from your account. - /// - /// Read SmsCommand parameters - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static ResourceSet Read(ReadSmsCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sms_commands", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of SMS Commands from your account. - /// - /// Read SmsCommand parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task> ReadAsync(ReadSmsCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sms_commands", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of SMS Commands from your account. - /// - /// The SID or unique name of the Sim resource that SMS Command was sent to or from. - /// The status of the SMS Command - /// The direction of the SMS Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SmsCommand - public static ResourceSet Read(string sim = null, - SmsCommandResource.StatusEnum status = null, - SmsCommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSmsCommandOptions(){Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of SMS Commands from your account. - /// - /// The SID or unique name of the Sim resource that SMS Command was sent to or from. - /// The status of the SMS Command - /// The direction of the SMS Command - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SmsCommand - public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, - SmsCommandResource.StatusEnum status = null, - SmsCommandResource.DirectionEnum direction = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSmsCommandOptions(){Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sms_commands", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("sms_commands", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("sms_commands", response.Content); - } - - /// - /// Converts a JSON string into a SmsCommandResource object - /// - /// Raw JSON string - /// SmsCommandResource object represented by the provided JSON - public static SmsCommandResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the SIM that this SMS Command was sent to or from - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The message body of the SMS Command sent to or from the SIM - /// - [JsonProperty("payload")] - public string Payload { get; private set; } - /// - /// The status of the SMS Command - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SmsCommandResource.StatusEnum Status { get; private set; } - /// - /// The direction of the SMS Command - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public SmsCommandResource.DirectionEnum Direction { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the SMS Command resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SmsCommandResource() - { - - } - } +{ + + public class SmsCommandResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Sent = new StatusEnum("sent"); + public static readonly StatusEnum Delivered = new StatusEnum("delivered"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); + public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); + } + + private static Request BuildCreateRequest(CreateSmsCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Supersim, + "/v1/SmsCommands", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Send SMS Command to a Sim. + /// + /// Create SmsCommand parameters + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static SmsCommandResource Create(CreateSmsCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Send SMS Command to a Sim. + /// + /// Create SmsCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task CreateAsync(CreateSmsCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Send SMS Command to a Sim. + /// + /// The sid or unique_name of the SIM to send the SMS Command to + /// The message body of the SMS Command + /// The HTTP method we should use to call callback_url + /// The URL we should call after we have sent the command + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static SmsCommandResource Create(string sim, + string payload, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateSmsCommandOptions(sim, payload) { CallbackMethod = callbackMethod, CallbackUrl = callbackUrl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Send SMS Command to a Sim. + /// + /// The sid or unique_name of the SIM to send the SMS Command to + /// The message body of the SMS Command + /// The HTTP method we should use to call callback_url + /// The URL we should call after we have sent the command + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task CreateAsync(string sim, + string payload, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + ITwilioRestClient client = null) + { + var options = new CreateSmsCommandOptions(sim, payload) { CallbackMethod = callbackMethod, CallbackUrl = callbackUrl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchSmsCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/SmsCommands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch SMS Command instance from your account. + /// + /// Fetch SmsCommand parameters + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static SmsCommandResource Fetch(FetchSmsCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch SMS Command instance from your account. + /// + /// Fetch SmsCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task FetchAsync(FetchSmsCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch SMS Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static SmsCommandResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSmsCommandOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch SMS Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSmsCommandOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSmsCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/SmsCommands", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of SMS Commands from your account. + /// + /// Read SmsCommand parameters + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static ResourceSet Read(ReadSmsCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sms_commands", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of SMS Commands from your account. + /// + /// Read SmsCommand parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task> ReadAsync(ReadSmsCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sms_commands", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of SMS Commands from your account. + /// + /// The SID or unique name of the Sim resource that SMS Command was sent to or from. + /// The status of the SMS Command + /// The direction of the SMS Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SmsCommand + public static ResourceSet Read(string sim = null, + SmsCommandResource.StatusEnum status = null, + SmsCommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSmsCommandOptions() { Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of SMS Commands from your account. + /// + /// The SID or unique name of the Sim resource that SMS Command was sent to or from. + /// The status of the SMS Command + /// The direction of the SMS Command + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SmsCommand + public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, + SmsCommandResource.StatusEnum status = null, + SmsCommandResource.DirectionEnum direction = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSmsCommandOptions() { Sim = sim, Status = status, Direction = direction, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sms_commands", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("sms_commands", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("sms_commands", response.Content); + } + + /// + /// Converts a JSON string into a SmsCommandResource object + /// + /// Raw JSON string + /// SmsCommandResource object represented by the provided JSON + public static SmsCommandResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the SIM that this SMS Command was sent to or from + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The message body of the SMS Command sent to or from the SIM + /// + [JsonProperty("payload")] + public string Payload { get; private set; } + /// + /// The status of the SMS Command + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SmsCommandResource.StatusEnum Status { get; private set; } + /// + /// The direction of the SMS Command + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public SmsCommandResource.DirectionEnum Direction { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the SMS Command resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SmsCommandResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/UsageRecordOptions.cs b/src/Twilio/Rest/Supersim/V1/UsageRecordOptions.cs index d10913171..5f2fe3120 100644 --- a/src/Twilio/Rest/Supersim/V1/UsageRecordOptions.cs +++ b/src/Twilio/Rest/Supersim/V1/UsageRecordOptions.cs @@ -9,101 +9,101 @@ using Twilio.Converters; namespace Twilio.Rest.Supersim.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// List UsageRecords + /// + public class ReadUsageRecordOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// List UsageRecords + /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM. /// - public class ReadUsageRecordOptions : ReadOptions - { - /// - /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM. - /// - public string Sim { get; set; } - /// - /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred. - /// - public string Fleet { get; set; } - /// - /// SID of a Network resource. Only show UsageRecords representing usage on this network. - /// - public string Network { get; set; } - /// - /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. - /// - public string IsoCountry { get; set; } - /// - /// Dimension over which to aggregate usage records. - /// - public UsageRecordResource.GroupEnum Group { get; set; } - /// - /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. - /// - public UsageRecordResource.GranularityEnum Granularity { get; set; } - /// - /// Only include usage that occurred at or after this time. - /// - public DateTime? StartTime { get; set; } - /// - /// Only include usage that occurred before this time. - /// - public DateTime? EndTime { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim.ToString())); - } - - if (Fleet != null) - { - p.Add(new KeyValuePair("Fleet", Fleet.ToString())); - } - - if (Network != null) - { - p.Add(new KeyValuePair("Network", Network.ToString())); - } - - if (IsoCountry != null) - { - p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); - } - - if (Group != null) - { - p.Add(new KeyValuePair("Group", Group.ToString())); - } - - if (Granularity != null) - { - p.Add(new KeyValuePair("Granularity", Granularity.ToString())); - } - - if (StartTime != null) - { - p.Add(new KeyValuePair("StartTime", Serializers.DateTimeIso8601(StartTime))); - } - - if (EndTime != null) - { - p.Add(new KeyValuePair("EndTime", Serializers.DateTimeIso8601(EndTime))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string Sim { get; set; } + /// + /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred. + /// + public string Fleet { get; set; } + /// + /// SID of a Network resource. Only show UsageRecords representing usage on this network. + /// + public string Network { get; set; } + /// + /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. + /// + public string IsoCountry { get; set; } + /// + /// Dimension over which to aggregate usage records. + /// + public UsageRecordResource.GroupEnum Group { get; set; } + /// + /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. + /// + public UsageRecordResource.GranularityEnum Granularity { get; set; } + /// + /// Only include usage that occurred at or after this time. + /// + public DateTime? StartTime { get; set; } + /// + /// Only include usage that occurred before this time. + /// + public DateTime? EndTime { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim.ToString())); + } + + if (Fleet != null) + { + p.Add(new KeyValuePair("Fleet", Fleet.ToString())); + } + + if (Network != null) + { + p.Add(new KeyValuePair("Network", Network.ToString())); + } + + if (IsoCountry != null) + { + p.Add(new KeyValuePair("IsoCountry", IsoCountry.ToString())); + } + + if (Group != null) + { + p.Add(new KeyValuePair("Group", Group.ToString())); + } + + if (Granularity != null) + { + p.Add(new KeyValuePair("Granularity", Granularity.ToString())); + } + + if (StartTime != null) + { + p.Add(new KeyValuePair("StartTime", Serializers.DateTimeIso8601(StartTime))); + } + + if (EndTime != null) + { + p.Add(new KeyValuePair("EndTime", Serializers.DateTimeIso8601(EndTime))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Supersim/V1/UsageRecordResource.cs b/src/Twilio/Rest/Supersim/V1/UsageRecordResource.cs index 97deaf9f3..7c3a75672 100644 --- a/src/Twilio/Rest/Supersim/V1/UsageRecordResource.cs +++ b/src/Twilio/Rest/Supersim/V1/UsageRecordResource.cs @@ -19,290 +19,290 @@ using Twilio.Types; namespace Twilio.Rest.Supersim.V1 -{ - - public class UsageRecordResource : Resource - { - public sealed class GranularityEnum : StringEnum - { - private GranularityEnum(string value) : base(value) {} - public GranularityEnum() {} - public static implicit operator GranularityEnum(string value) - { - return new GranularityEnum(value); - } - - public static readonly GranularityEnum Hour = new GranularityEnum("hour"); - public static readonly GranularityEnum Day = new GranularityEnum("day"); - public static readonly GranularityEnum All = new GranularityEnum("all"); - } - - public sealed class GroupEnum : StringEnum - { - private GroupEnum(string value) : base(value) {} - public GroupEnum() {} - public static implicit operator GroupEnum(string value) - { - return new GroupEnum(value); - } - - public static readonly GroupEnum Sim = new GroupEnum("sim"); - public static readonly GroupEnum Fleet = new GroupEnum("fleet"); - public static readonly GroupEnum Network = new GroupEnum("network"); - public static readonly GroupEnum Isocountry = new GroupEnum("isoCountry"); - } - - public sealed class SortByEnum : StringEnum - { - private SortByEnum(string value) : base(value) {} - public SortByEnum() {} - public static implicit operator SortByEnum(string value) - { - return new SortByEnum(value); - } - - public static readonly SortByEnum Time = new SortByEnum("time"); - } - - private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Supersim, - "/v1/UsageRecords", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List UsageRecords - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List UsageRecords - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List UsageRecords - /// - /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this - /// Super SIM. - /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super - /// SIMs belonging to this Fleet resource at the time the usage occurred. - /// SID of a Network resource. Only show UsageRecords representing usage on this network. - /// - /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. - /// - /// Dimension over which to aggregate usage records. - /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or - /// `all`. Default is `all`. - /// Only include usage that occurred at or after this time. - /// Only include usage that occurred before this time. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(string sim = null, - string fleet = null, - string network = null, - string isoCountry = null, - UsageRecordResource.GroupEnum group = null, - UsageRecordResource.GranularityEnum granularity = null, - DateTime? startTime = null, - DateTime? endTime = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(){Sim = sim, Fleet = fleet, Network = network, IsoCountry = isoCountry, Group = group, Granularity = granularity, StartTime = startTime, EndTime = endTime, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List UsageRecords - /// - /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this - /// Super SIM. - /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super - /// SIMs belonging to this Fleet resource at the time the usage occurred. - /// SID of a Network resource. Only show UsageRecords representing usage on this network. - /// - /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. - /// - /// Dimension over which to aggregate usage records. - /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or - /// `all`. Default is `all`. - /// Only include usage that occurred at or after this time. - /// Only include usage that occurred before this time. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, - string fleet = null, - string network = null, - string isoCountry = null, - UsageRecordResource.GroupEnum group = null, - UsageRecordResource.GranularityEnum granularity = null, - DateTime? startTime = null, - DateTime? endTime = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(){Sim = sim, Fleet = fleet, Network = network, IsoCountry = isoCountry, Group = group, Granularity = granularity, StartTime = startTime, EndTime = endTime, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Supersim) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a UsageRecordResource object - /// - /// Raw JSON string - /// UsageRecordResource object represented by the provided JSON - public static UsageRecordResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that incurred the usage. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// SID of a Sim resource to which the UsageRecord belongs. - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// SID of the Network resource on which the usage occurred. - /// - [JsonProperty("network_sid")] - public string NetworkSid { get; private set; } - /// - /// SID of the Fleet resource on which the usage occurred. - /// - [JsonProperty("fleet_sid")] - public string FleetSid { get; private set; } - /// - /// Alpha-2 ISO Country Code of the country the usage occurred in. - /// - [JsonProperty("iso_country")] - public string IsoCountry { get; private set; } - /// - /// The time period for which the usage is reported. - /// - [JsonProperty("period")] - public object Period { get; private set; } - /// - /// Total data uploaded in bytes, aggregated by the query parameters. - /// - [JsonProperty("data_upload")] - public long? DataUpload { get; private set; } - /// - /// Total data downloaded in bytes, aggregated by the query parameters. - /// - [JsonProperty("data_download")] - public long? DataDownload { get; private set; } - /// - /// Total of data_upload and data_download. - /// - [JsonProperty("data_total")] - public long? DataTotal { get; private set; } - - private UsageRecordResource() - { - - } - } +{ + + public class UsageRecordResource : Resource + { + public sealed class GranularityEnum : StringEnum + { + private GranularityEnum(string value) : base(value) { } + public GranularityEnum() { } + public static implicit operator GranularityEnum(string value) + { + return new GranularityEnum(value); + } + + public static readonly GranularityEnum Hour = new GranularityEnum("hour"); + public static readonly GranularityEnum Day = new GranularityEnum("day"); + public static readonly GranularityEnum All = new GranularityEnum("all"); + } + + public sealed class GroupEnum : StringEnum + { + private GroupEnum(string value) : base(value) { } + public GroupEnum() { } + public static implicit operator GroupEnum(string value) + { + return new GroupEnum(value); + } + + public static readonly GroupEnum Sim = new GroupEnum("sim"); + public static readonly GroupEnum Fleet = new GroupEnum("fleet"); + public static readonly GroupEnum Network = new GroupEnum("network"); + public static readonly GroupEnum Isocountry = new GroupEnum("isoCountry"); + } + + public sealed class SortByEnum : StringEnum + { + private SortByEnum(string value) : base(value) { } + public SortByEnum() { } + public static implicit operator SortByEnum(string value) + { + return new SortByEnum(value); + } + + public static readonly SortByEnum Time = new SortByEnum("time"); + } + + private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Supersim, + "/v1/UsageRecords", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List UsageRecords + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List UsageRecords + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List UsageRecords + /// + /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this + /// Super SIM. + /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super + /// SIMs belonging to this Fleet resource at the time the usage occurred. + /// SID of a Network resource. Only show UsageRecords representing usage on this network. + /// + /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. + /// + /// Dimension over which to aggregate usage records. + /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or + /// `all`. Default is `all`. + /// Only include usage that occurred at or after this time. + /// Only include usage that occurred before this time. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(string sim = null, + string fleet = null, + string network = null, + string isoCountry = null, + UsageRecordResource.GroupEnum group = null, + UsageRecordResource.GranularityEnum granularity = null, + DateTime? startTime = null, + DateTime? endTime = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions() { Sim = sim, Fleet = fleet, Network = network, IsoCountry = isoCountry, Group = group, Granularity = granularity, StartTime = startTime, EndTime = endTime, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List UsageRecords + /// + /// SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this + /// Super SIM. + /// SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super + /// SIMs belonging to this Fleet resource at the time the usage occurred. + /// SID of a Network resource. Only show UsageRecords representing usage on this network. + /// + /// Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country. + /// + /// Dimension over which to aggregate usage records. + /// Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or + /// `all`. Default is `all`. + /// Only include usage that occurred at or after this time. + /// Only include usage that occurred before this time. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, + string fleet = null, + string network = null, + string isoCountry = null, + UsageRecordResource.GroupEnum group = null, + UsageRecordResource.GranularityEnum granularity = null, + DateTime? startTime = null, + DateTime? endTime = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions() { Sim = sim, Fleet = fleet, Network = network, IsoCountry = isoCountry, Group = group, Granularity = granularity, StartTime = startTime, EndTime = endTime, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Supersim) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a UsageRecordResource object + /// + /// Raw JSON string + /// UsageRecordResource object represented by the provided JSON + public static UsageRecordResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that incurred the usage. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// SID of a Sim resource to which the UsageRecord belongs. + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// SID of the Network resource on which the usage occurred. + /// + [JsonProperty("network_sid")] + public string NetworkSid { get; private set; } + /// + /// SID of the Fleet resource on which the usage occurred. + /// + [JsonProperty("fleet_sid")] + public string FleetSid { get; private set; } + /// + /// Alpha-2 ISO Country Code of the country the usage occurred in. + /// + [JsonProperty("iso_country")] + public string IsoCountry { get; private set; } + /// + /// The time period for which the usage is reported. + /// + [JsonProperty("period")] + public object Period { get; private set; } + /// + /// Total data uploaded in bytes, aggregated by the query parameters. + /// + [JsonProperty("data_upload")] + public long? DataUpload { get; private set; } + /// + /// Total data downloaded in bytes, aggregated by the query parameters. + /// + [JsonProperty("data_download")] + public long? DataDownload { get; private set; } + /// + /// Total of data_upload and data_download. + /// + [JsonProperty("data_total")] + public long? DataTotal { get; private set; } + + private UsageRecordResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionOptions.cs b/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionOptions.cs index 3dbf5f766..82cb4ecbc 100644 --- a/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionOptions.cs @@ -9,210 +9,210 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.Document -{ - +{ + + /// + /// Fetch a specific Sync Document Permission. + /// + public class FetchDocumentPermissionOptions : IOptions + { /// - /// Fetch a specific Sync Document Permission. - /// - public class FetchDocumentPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document Permission resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Document with the Document Permission resource to fetch - /// - public string PathDocumentSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Document Permission resource to fetch - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchDocumentPermissionOptions - /// - /// The SID of the Sync Service with the Document Permission resource to fetch - /// The SID of the Sync Document with the Document Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to fetch - public FetchDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Document Permission resource to fetch + /// + public string PathServiceSid { get; } /// - /// Delete a specific Sync Document Permission. - /// - public class DeleteDocumentPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document Permission resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Document with the Document Permission resource to delete - /// - public string PathDocumentSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Document Permission resource to delete - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteDocumentPermissionOptions - /// - /// The SID of the Sync Service with the Document Permission resource to delete - /// The SID of the Sync Document with the Document Permission resource to delete - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to delete - public DeleteDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Document with the Document Permission resource to fetch + /// + public string PathDocumentSid { get; } /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - public class ReadDocumentPermissionOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Document Permission resources to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Document with the Document Permission resources to read - /// - public string PathDocumentSid { get; } - - /// - /// Construct a new ReadDocumentPermissionOptions - /// - /// The SID of the Sync Service with the Document Permission resources to read - /// The SID of the Sync Document with the Document Permission resources to read - public ReadDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The application-defined string that uniquely identifies the User's Document Permission resource to fetch + /// + public string PathIdentity { get; } + /// - /// Update an identity's access to a specific Sync Document. - /// - public class UpdateDocumentPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document Permission resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Document with the Document Permission resource to update - /// - public string PathDocumentSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Document Permission resource to update - /// - public string PathIdentity { get; } - /// - /// Read access - /// - public bool? Read { get; } - /// - /// Write access - /// - public bool? Write { get; } - /// - /// Manage access - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateDocumentPermissionOptions - /// - /// The SID of the Sync Service with the Document Permission resource to update - /// The SID of the Sync Document with the Document Permission resource to update - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - public UpdateDocumentPermissionOptions(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathDocumentSid = pathDocumentSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchDocumentPermissionOptions + /// + /// The SID of the Sync Service with the Document Permission resource to fetch + /// The SID of the Sync Document with the Document Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to fetch + public FetchDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Sync Document Permission. + /// + public class DeleteDocumentPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Document Permission resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Document with the Document Permission resource to delete + /// + public string PathDocumentSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Document Permission resource to delete + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteDocumentPermissionOptions + /// + /// The SID of the Sync Service with the Document Permission resource to delete + /// The SID of the Sync Document with the Document Permission resource to delete + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to delete + public DeleteDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + public class ReadDocumentPermissionOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Document Permission resources to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Document with the Document Permission resources to read + /// + public string PathDocumentSid { get; } + + /// + /// Construct a new ReadDocumentPermissionOptions + /// + /// The SID of the Sync Service with the Document Permission resources to read + /// The SID of the Sync Document with the Document Permission resources to read + public ReadDocumentPermissionOptions(string pathServiceSid, string pathDocumentSid) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Update an identity's access to a specific Sync Document. + /// + public class UpdateDocumentPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Document Permission resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Document with the Document Permission resource to update + /// + public string PathDocumentSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Document Permission resource to update + /// + public string PathIdentity { get; } + /// + /// Read access + /// + public bool? Read { get; } + /// + /// Write access + /// + public bool? Write { get; } + /// + /// Manage access + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateDocumentPermissionOptions + /// + /// The SID of the Sync Service with the Document Permission resource to update + /// The SID of the Sync Document with the Document Permission resource to update + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + public UpdateDocumentPermissionOptions(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathDocumentSid = pathDocumentSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionResource.cs b/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionResource.cs index ddcff7900..332c70378 100644 --- a/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/Document/DocumentPermissionResource.cs @@ -16,461 +16,461 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service.Document -{ - - public class DocumentPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync Document Permission. - /// - /// Fetch DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Fetch(FetchDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync Document Permission. - /// - /// Fetch DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync Document Permission. - /// - /// The SID of the Sync Service with the Document Permission resource to fetch - /// The SID of the Sync Document with the Document Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to fetch - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Fetch(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync Document Permission. - /// - /// The SID of the Sync Service with the Document Permission resource to fetch - /// The SID of the Sync Document with the Document Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync Document Permission. - /// - /// Delete DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static bool Delete(DeleteDocumentPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync Document Permission. - /// - /// Delete DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync Document Permission. - /// - /// The SID of the Sync Service with the Document Permission resource to delete - /// The SID of the Sync Document with the Document Permission resource to delete - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to delete - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static bool Delete(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync Document Permission. - /// - /// The SID of the Sync Service with the Document Permission resource to delete - /// The SID of the Sync Document with the Document Permission resource to delete - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// Read DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static ResourceSet Read(ReadDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// Read DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// The SID of the Sync Service with the Document Permission resources to read - /// The SID of the Sync Document with the Document Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static ResourceSet Read(string pathServiceSid, - string pathDocumentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Document. - /// - /// The SID of the Sync Service with the Document Permission resources to read - /// The SID of the Sync Document with the Document Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathDocumentSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDocumentPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Update DocumentPermission parameters - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Update(UpdateDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Document. - /// - /// Update DocumentPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync Document. - /// - /// The SID of the Sync Service with the Document Permission resource to update - /// The SID of the Sync Document with the Document Permission resource to update - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// A single instance of DocumentPermission - public static DocumentPermissionResource Update(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Document. - /// - /// The SID of the Sync Service with the Document Permission resource to update - /// The SID of the Sync Document with the Document Permission resource to update - /// The application-defined string that uniquely identifies the User's Document Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DocumentPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathDocumentSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DocumentPermissionResource object - /// - /// Raw JSON string - /// DocumentPermissionResource object represented by the provided JSON - public static DocumentPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The Sync Document SID - /// - [JsonProperty("document_sid")] - public string DocumentSid { get; private set; } - /// - /// The identity of the user to whom the Sync Document Permission applies - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// The absolute URL of the Sync Document Permission resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private DocumentPermissionResource() - { - - } - } +{ + + public class DocumentPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync Document Permission. + /// + /// Fetch DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Fetch(FetchDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync Document Permission. + /// + /// Fetch DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync Document Permission. + /// + /// The SID of the Sync Service with the Document Permission resource to fetch + /// The SID of the Sync Document with the Document Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to fetch + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Fetch(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync Document Permission. + /// + /// The SID of the Sync Service with the Document Permission resource to fetch + /// The SID of the Sync Document with the Document Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync Document Permission. + /// + /// Delete DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static bool Delete(DeleteDocumentPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync Document Permission. + /// + /// Delete DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync Document Permission. + /// + /// The SID of the Sync Service with the Document Permission resource to delete + /// The SID of the Sync Document with the Document Permission resource to delete + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to delete + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static bool Delete(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync Document Permission. + /// + /// The SID of the Sync Service with the Document Permission resource to delete + /// The SID of the Sync Document with the Document Permission resource to delete + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// Read DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static ResourceSet Read(ReadDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// Read DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// The SID of the Sync Service with the Document Permission resources to read + /// The SID of the Sync Document with the Document Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static ResourceSet Read(string pathServiceSid, + string pathDocumentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Document. + /// + /// The SID of the Sync Service with the Document Permission resources to read + /// The SID of the Sync Document with the Document Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathDocumentSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentPermissionOptions(pathServiceSid, pathDocumentSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDocumentPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathDocumentSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Update DocumentPermission parameters + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Update(UpdateDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Document. + /// + /// Update DocumentPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync Document. + /// + /// The SID of the Sync Service with the Document Permission resource to update + /// The SID of the Sync Document with the Document Permission resource to update + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// A single instance of DocumentPermission + public static DocumentPermissionResource Update(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Document. + /// + /// The SID of the Sync Service with the Document Permission resource to update + /// The SID of the Sync Document with the Document Permission resource to update + /// The application-defined string that uniquely identifies the User's Document Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DocumentPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathDocumentSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentPermissionOptions(pathServiceSid, pathDocumentSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DocumentPermissionResource object + /// + /// Raw JSON string + /// DocumentPermissionResource object represented by the provided JSON + public static DocumentPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The Sync Document SID + /// + [JsonProperty("document_sid")] + public string DocumentSid { get; private set; } + /// + /// The identity of the user to whom the Sync Document Permission applies + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// The absolute URL of the Sync Document Permission resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private DocumentPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/DocumentOptions.cs b/src/Twilio/Rest/Sync/V1/Service/DocumentOptions.cs index 5369dd0ae..410b5b2db 100644 --- a/src/Twilio/Rest/Sync/V1/Service/DocumentOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/DocumentOptions.cs @@ -9,237 +9,237 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service -{ - +{ + + /// + /// FetchDocumentOptions + /// + public class FetchDocumentOptions : IOptions + { /// - /// FetchDocumentOptions - /// - public class FetchDocumentOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Document resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchDocumentOptions - /// - /// The SID of the Sync Service with the Document resource to fetch - /// The SID of the Document resource to fetch - public FetchDocumentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Document resource to fetch + /// + public string PathServiceSid { get; } /// - /// DeleteDocumentOptions - /// - public class DeleteDocumentOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Document resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteDocumentOptions - /// - /// The SID of the Sync Service with the Document resource to delete - /// The SID of the Document resource to delete - public DeleteDocumentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Document resource to fetch + /// + public string PathSid { get; } + /// - /// CreateDocumentOptions - /// - public class CreateDocumentOptions : IOptions - { - /// - /// The SID of the Sync Service to associate the Document resource to create with - /// - public string PathServiceSid { get; } - /// - /// An application-defined string that uniquely identifies the Sync Document - /// - public string UniqueName { get; set; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - public object Data { get; set; } - /// - /// How long, in seconds, before the Sync Document expires and is deleted - /// - public int? Ttl { get; set; } - - /// - /// Construct a new CreateDocumentOptions - /// - /// The SID of the Sync Service to associate the Document resource to create with - public CreateDocumentOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } - + /// Construct a new FetchDocumentOptions + /// + /// The SID of the Sync Service with the Document resource to fetch + /// The SID of the Document resource to fetch + public FetchDocumentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// ReadDocumentOptions + /// Generate the necessary parameters /// - public class ReadDocumentOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Document resources to read - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadDocumentOptions - /// - /// The SID of the Sync Service with the Document resources to read - public ReadDocumentOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteDocumentOptions + /// + public class DeleteDocumentOptions : IOptions + { /// - /// UpdateDocumentOptions - /// - public class UpdateDocumentOptions : IOptions - { - /// - /// The SID of the Sync Service with the Document resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Document resource to update - /// - public string PathSid { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - public object Data { get; set; } - /// - /// How long, in seconds, before the Document resource expires and is deleted - /// - public int? Ttl { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateDocumentOptions - /// - /// The SID of the Sync Service with the Document resource to update - /// The SID of the Document resource to update - public UpdateDocumentOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// The SID of the Sync Service with the Document resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Document resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteDocumentOptions + /// + /// The SID of the Sync Service with the Document resource to delete + /// The SID of the Document resource to delete + public DeleteDocumentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateDocumentOptions + /// + public class CreateDocumentOptions : IOptions + { + /// + /// The SID of the Sync Service to associate the Document resource to create with + /// + public string PathServiceSid { get; } + /// + /// An application-defined string that uniquely identifies the Sync Document + /// + public string UniqueName { get; set; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + public object Data { get; set; } + /// + /// How long, in seconds, before the Sync Document expires and is deleted + /// + public int? Ttl { get; set; } + + /// + /// Construct a new CreateDocumentOptions + /// + /// The SID of the Sync Service to associate the Document resource to create with + public CreateDocumentOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } + + /// + /// ReadDocumentOptions + /// + public class ReadDocumentOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Document resources to read + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadDocumentOptions + /// + /// The SID of the Sync Service with the Document resources to read + public ReadDocumentOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateDocumentOptions + /// + public class UpdateDocumentOptions : IOptions + { + /// + /// The SID of the Sync Service with the Document resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Document resource to update + /// + public string PathSid { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + public object Data { get; set; } + /// + /// How long, in seconds, before the Document resource expires and is deleted + /// + public int? Ttl { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateDocumentOptions + /// + /// The SID of the Sync Service with the Document resource to update + /// The SID of the Document resource to update + public UpdateDocumentOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/DocumentResource.cs b/src/Twilio/Rest/Sync/V1/Service/DocumentResource.cs index 130b9bc88..261536f95 100644 --- a/src/Twilio/Rest/Sync/V1/Service/DocumentResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/DocumentResource.cs @@ -16,534 +16,534 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service -{ - - public class DocumentResource : Resource - { - private static Request BuildFetchRequest(FetchDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Fetch(FetchDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Sync Service with the Document resource to fetch - /// The SID of the Document resource to fetch - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchDocumentOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Sync Service with the Document resource to fetch - /// The SID of the Document resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchDocumentOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static bool Delete(DeleteDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Sync Service with the Document resource to delete - /// The SID of the Document resource to delete - /// Client to make requests to Twilio - /// A single instance of Document - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteDocumentOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Sync Service with the Document resource to delete - /// The SID of the Document resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteDocumentOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Create(CreateDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task CreateAsync(CreateDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Sync Service to associate the Document resource to create with - /// An application-defined string that uniquely identifies the Sync Document - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - /// How long, in seconds, before the Sync Document expires and is deleted - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Create(string pathServiceSid, - string uniqueName = null, - object data = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateDocumentOptions(pathServiceSid){UniqueName = uniqueName, Data = data, Ttl = ttl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Sync Service to associate the Document resource to create with - /// An application-defined string that uniquely identifies the Sync Document - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - /// How long, in seconds, before the Sync Document expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - object data = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateDocumentOptions(pathServiceSid){UniqueName = uniqueName, Data = data, Ttl = ttl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static ResourceSet Read(ReadDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("documents", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("documents", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sync Service with the Document resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Document - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sync Service with the Document resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDocumentOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("documents", response.Content); - } - - private static Request BuildUpdateRequest(UpdateDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Document parameters - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Update(UpdateDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Document parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Sync Service with the Document resource to update - /// The SID of the Document resource to update - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - /// How long, in seconds, before the Document resource expires and is deleted - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Document - public static DocumentResource Update(string pathServiceSid, - string pathSid, - object data = null, - int? ttl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentOptions(pathServiceSid, pathSid){Data = data, Ttl = ttl, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Sync Service with the Document resource to update - /// The SID of the Document resource to update - /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores - /// - /// How long, in seconds, before the Document resource expires and is deleted - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Document - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - object data = null, - int? ttl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateDocumentOptions(pathServiceSid, pathSid){Data = data, Ttl = ttl, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a DocumentResource object - /// - /// Raw JSON string - /// DocumentResource object represented by the provided JSON - public static DocumentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The absolute URL of the Document resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of resources related to the Sync Document - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The current revision of the Sync Document, represented by a string identifier - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// An arbitrary, schema-less object that the Sync Document stores - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Sync Document expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the Sync Document's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private DocumentResource() - { - - } - } +{ + + public class DocumentResource : Resource + { + private static Request BuildFetchRequest(FetchDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Fetch(FetchDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task FetchAsync(FetchDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Sync Service with the Document resource to fetch + /// The SID of the Document resource to fetch + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchDocumentOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Sync Service with the Document resource to fetch + /// The SID of the Document resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchDocumentOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static bool Delete(DeleteDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task DeleteAsync(DeleteDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Sync Service with the Document resource to delete + /// The SID of the Document resource to delete + /// Client to make requests to Twilio + /// A single instance of Document + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteDocumentOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Sync Service with the Document resource to delete + /// The SID of the Document resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteDocumentOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Create(CreateDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task CreateAsync(CreateDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Sync Service to associate the Document resource to create with + /// An application-defined string that uniquely identifies the Sync Document + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + /// How long, in seconds, before the Sync Document expires and is deleted + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Create(string pathServiceSid, + string uniqueName = null, + object data = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateDocumentOptions(pathServiceSid) { UniqueName = uniqueName, Data = data, Ttl = ttl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Sync Service to associate the Document resource to create with + /// An application-defined string that uniquely identifies the Sync Document + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + /// How long, in seconds, before the Sync Document expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + object data = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateDocumentOptions(pathServiceSid) { UniqueName = uniqueName, Data = data, Ttl = ttl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static ResourceSet Read(ReadDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("documents", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task> ReadAsync(ReadDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("documents", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sync Service with the Document resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Document + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sync Service with the Document resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDocumentOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("documents", response.Content); + } + + private static Request BuildUpdateRequest(UpdateDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Documents/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Document parameters + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Update(UpdateDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Document parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task UpdateAsync(UpdateDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Sync Service with the Document resource to update + /// The SID of the Document resource to update + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + /// How long, in seconds, before the Document resource expires and is deleted + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Document + public static DocumentResource Update(string pathServiceSid, + string pathSid, + object data = null, + int? ttl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentOptions(pathServiceSid, pathSid) { Data = data, Ttl = ttl, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Sync Service with the Document resource to update + /// The SID of the Document resource to update + /// A JSON string that represents an arbitrary, schema-less object that the Sync Document stores + /// + /// How long, in seconds, before the Document resource expires and is deleted + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Document + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + object data = null, + int? ttl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateDocumentOptions(pathServiceSid, pathSid) { Data = data, Ttl = ttl, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a DocumentResource object + /// + /// Raw JSON string + /// DocumentResource object represented by the provided JSON + public static DocumentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The absolute URL of the Document resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of resources related to the Sync Document + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The current revision of the Sync Document, represented by a string identifier + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// An arbitrary, schema-less object that the Sync Document stores + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Sync Document expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the Sync Document's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private DocumentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemOptions.cs index 70afcface..ecaf35aa8 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemOptions.cs @@ -9,342 +9,342 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.SyncList -{ - +{ + + /// + /// FetchSyncListItemOptions + /// + public class FetchSyncListItemOptions : IOptions + { /// - /// FetchSyncListItemOptions - /// - public class FetchSyncListItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Item resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Item resource to fetch - /// - public string PathListSid { get; } - /// - /// The index of the Sync List Item resource to fetch - /// - public int? PathIndex { get; } - - /// - /// Construct a new FetchSyncListItemOptions - /// - /// The SID of the Sync Service with the Sync List Item resource to fetch - /// The SID of the Sync List with the Sync List Item resource to fetch - /// The index of the Sync List Item resource to fetch - public FetchSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync List Item resource to fetch + /// + public string PathServiceSid { get; } /// - /// DeleteSyncListItemOptions - /// - public class DeleteSyncListItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Item resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Item resource to delete - /// - public string PathListSid { get; } - /// - /// The index of the Sync List Item resource to delete - /// - public int? PathIndex { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteSyncListItemOptions - /// - /// The SID of the Sync Service with the Sync List Item resource to delete - /// The SID of the Sync List with the Sync List Item resource to delete - /// The index of the Sync List Item resource to delete - public DeleteSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// The SID of the Sync List with the Sync List Item resource to fetch + /// + public string PathListSid { get; } /// - /// CreateSyncListItemOptions - /// - public class CreateSyncListItemOptions : IOptions - { - /// - /// The SID of the Sync Service to create the List Item in - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List to add the new List Item to - /// - public string PathListSid { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - public object Data { get; } - /// - /// An alias for item_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the List Item expires - /// - public int? ItemTtl { get; set; } - /// - /// How long, in seconds, before the List Item's parent Sync List expires - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new CreateSyncListItemOptions - /// - /// The SID of the Sync Service to create the List Item in - /// The SID of the Sync List to add the new List Item to - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - public CreateSyncListItemOptions(string pathServiceSid, string pathListSid, object data) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (ItemTtl != null) - { - p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// The index of the Sync List Item resource to fetch + /// + public int? PathIndex { get; } + /// - /// ReadSyncListItemOptions - /// - public class ReadSyncListItemOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the List Item resources to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the List Items to read - /// - public string PathListSid { get; } - /// - /// The order to return the List Items - /// - public SyncListItemResource.QueryResultOrderEnum Order { get; set; } - /// - /// The index of the first Sync List Item resource to read - /// - public string From { get; set; } - /// - /// Whether to include the List Item referenced by the from parameter - /// - public SyncListItemResource.QueryFromBoundTypeEnum Bounds { get; set; } - - /// - /// Construct a new ReadSyncListItemOptions - /// - /// The SID of the Sync Service with the List Item resources to read - /// The SID of the Sync List with the List Items to read - public ReadSyncListItemOptions(string pathServiceSid, string pathListSid) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Bounds != null) - { - p.Add(new KeyValuePair("Bounds", Bounds.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncListItemOptions + /// + /// The SID of the Sync Service with the Sync List Item resource to fetch + /// The SID of the Sync List with the Sync List Item resource to fetch + /// The index of the Sync List Item resource to fetch + public FetchSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + } + /// - /// UpdateSyncListItemOptions - /// - public class UpdateSyncListItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Item resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Item resource to update - /// - public string PathListSid { get; } - /// - /// The index of the Sync List Item resource to update - /// - public int? PathIndex { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - public object Data { get; set; } - /// - /// An alias for item_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the List Item expires - /// - public int? ItemTtl { get; set; } - /// - /// How long, in seconds, before the List Item's parent Sync List expires - /// - public int? CollectionTtl { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateSyncListItemOptions - /// - /// The SID of the Sync Service with the Sync List Item resource to update - /// The SID of the Sync List with the Sync List Item resource to update - /// The index of the Sync List Item resource to update - public UpdateSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIndex = pathIndex; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (ItemTtl != null) - { - p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteSyncListItemOptions + /// + public class DeleteSyncListItemOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync List Item resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the Sync List Item resource to delete + /// + public string PathListSid { get; } + /// + /// The index of the Sync List Item resource to delete + /// + public int? PathIndex { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteSyncListItemOptions + /// + /// The SID of the Sync Service with the Sync List Item resource to delete + /// The SID of the Sync List with the Sync List Item resource to delete + /// The index of the Sync List Item resource to delete + public DeleteSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// CreateSyncListItemOptions + /// + public class CreateSyncListItemOptions : IOptions + { + /// + /// The SID of the Sync Service to create the List Item in + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List to add the new List Item to + /// + public string PathListSid { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + public object Data { get; } + /// + /// An alias for item_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the List Item expires + /// + public int? ItemTtl { get; set; } + /// + /// How long, in seconds, before the List Item's parent Sync List expires + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new CreateSyncListItemOptions + /// + /// The SID of the Sync Service to create the List Item in + /// The SID of the Sync List to add the new List Item to + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + public CreateSyncListItemOptions(string pathServiceSid, string pathListSid, object data) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (ItemTtl != null) + { + p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// ReadSyncListItemOptions + /// + public class ReadSyncListItemOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the List Item resources to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the List Items to read + /// + public string PathListSid { get; } + /// + /// The order to return the List Items + /// + public SyncListItemResource.QueryResultOrderEnum Order { get; set; } + /// + /// The index of the first Sync List Item resource to read + /// + public string From { get; set; } + /// + /// Whether to include the List Item referenced by the from parameter + /// + public SyncListItemResource.QueryFromBoundTypeEnum Bounds { get; set; } + + /// + /// Construct a new ReadSyncListItemOptions + /// + /// The SID of the Sync Service with the List Item resources to read + /// The SID of the Sync List with the List Items to read + public ReadSyncListItemOptions(string pathServiceSid, string pathListSid) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Bounds != null) + { + p.Add(new KeyValuePair("Bounds", Bounds.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateSyncListItemOptions + /// + public class UpdateSyncListItemOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync List Item resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the Sync List Item resource to update + /// + public string PathListSid { get; } + /// + /// The index of the Sync List Item resource to update + /// + public int? PathIndex { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + public object Data { get; set; } + /// + /// An alias for item_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the List Item expires + /// + public int? ItemTtl { get; set; } + /// + /// How long, in seconds, before the List Item's parent Sync List expires + /// + public int? CollectionTtl { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateSyncListItemOptions + /// + /// The SID of the Sync Service with the Sync List Item resource to update + /// The SID of the Sync List with the Sync List Item resource to update + /// The index of the Sync List Item resource to update + public UpdateSyncListItemOptions(string pathServiceSid, string pathListSid, int? pathIndex) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIndex = pathIndex; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (ItemTtl != null) + { + p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemResource.cs index bf81857dd..87c2571be 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListItemResource.cs @@ -17,608 +17,608 @@ using Twilio.Types; namespace Twilio.Rest.Sync.V1.Service.SyncList -{ - - public class SyncListItemResource : Resource - { - public sealed class QueryResultOrderEnum : StringEnum - { - private QueryResultOrderEnum(string value) : base(value) {} - public QueryResultOrderEnum() {} - public static implicit operator QueryResultOrderEnum(string value) - { - return new QueryResultOrderEnum(value); - } - - public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); - public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); - } - - public sealed class QueryFromBoundTypeEnum : StringEnum - { - private QueryFromBoundTypeEnum(string value) : base(value) {} - public QueryFromBoundTypeEnum() {} - public static implicit operator QueryFromBoundTypeEnum(string value) - { - return new QueryFromBoundTypeEnum(value); - } - - public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); - public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); - } - - private static Request BuildFetchRequest(FetchSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Fetch(FetchSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync List Item resource to fetch - /// The SID of the Sync List with the Sync List Item resource to fetch - /// The index of the Sync List Item resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Fetch(string pathServiceSid, - string pathListSid, - int? pathIndex, - ITwilioRestClient client = null) - { - var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync List Item resource to fetch - /// The SID of the Sync List with the Sync List Item resource to fetch - /// The index of the Sync List Item resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - ITwilioRestClient client = null) - { - var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static bool Delete(DeleteSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Sync Service with the Sync List Item resource to delete - /// The SID of the Sync List with the Sync List Item resource to delete - /// The index of the Sync List Item resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static bool Delete(string pathServiceSid, - string pathListSid, - int? pathIndex, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Sync Service with the Sync List Item resource to delete - /// The SID of the Sync List with the Sync List Item resource to delete - /// The index of the Sync List Item resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Create(CreateSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Sync Service to create the List Item in - /// The SID of the Sync List to add the new List Item to - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - /// An alias for item_ttl - /// How long, in seconds, before the List Item expires - /// How long, in seconds, before the List Item's parent Sync List expires - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Create(string pathServiceSid, - string pathListSid, - object data, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data){Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Sync Service to create the List Item in - /// The SID of the Sync List to add the new List Item to - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - /// An alias for item_ttl - /// How long, in seconds, before the List Item expires - /// How long, in seconds, before the List Item's parent Sync List expires - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathListSid, - object data, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data){Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static ResourceSet Read(ReadSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sync Service with the List Item resources to read - /// The SID of the Sync List with the List Items to read - /// The order to return the List Items - /// The index of the first Sync List Item resource to read - /// Whether to include the List Item referenced by the from parameter - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static ResourceSet Read(string pathServiceSid, - string pathListSid, - SyncListItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncListItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sync Service with the List Item resources to read - /// The SID of the Sync List with the List Items to read - /// The order to return the List Items - /// The index of the first Sync List Item resource to read - /// Whether to include the List Item referenced by the from parameter - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathListSid, - SyncListItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncListItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncListItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update SyncListItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Update(UpdateSyncListItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncListItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Sync Service with the Sync List Item resource to update - /// The SID of the Sync List with the Sync List Item resource to update - /// The index of the Sync List Item resource to update - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - /// An alias for item_ttl - /// How long, in seconds, before the List Item expires - /// How long, in seconds, before the List Item's parent Sync List expires - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncListItem - public static SyncListItemResource Update(string pathServiceSid, - string pathListSid, - int? pathIndex, - object data = null, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Sync Service with the Sync List Item resource to update - /// The SID of the Sync List with the Sync List Item resource to update - /// The index of the Sync List Item resource to update - /// A JSON string that represents an arbitrary, schema-less object that the List Item stores - /// - /// An alias for item_ttl - /// How long, in seconds, before the List Item expires - /// How long, in seconds, before the List Item's parent Sync List expires - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListItem - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathListSid, - int? pathIndex, - object data = null, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex){Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncListItemResource object - /// - /// Raw JSON string - /// SyncListItemResource object represented by the provided JSON - public static SyncListItemResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The automatically generated index of the List Item - /// - [JsonProperty("index")] - public int? Index { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Sync List that contains the List Item - /// - [JsonProperty("list_sid")] - public string ListSid { get; private set; } - /// - /// The absolute URL of the List Item resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The current revision of the item, represented as a string - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// An arbitrary, schema-less object that the List Item stores - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the List Item expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the List Item's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncListItemResource() - { - - } - } +{ + + public class SyncListItemResource : Resource + { + public sealed class QueryResultOrderEnum : StringEnum + { + private QueryResultOrderEnum(string value) : base(value) { } + public QueryResultOrderEnum() { } + public static implicit operator QueryResultOrderEnum(string value) + { + return new QueryResultOrderEnum(value); + } + + public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); + public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); + } + + public sealed class QueryFromBoundTypeEnum : StringEnum + { + private QueryFromBoundTypeEnum(string value) : base(value) { } + public QueryFromBoundTypeEnum() { } + public static implicit operator QueryFromBoundTypeEnum(string value) + { + return new QueryFromBoundTypeEnum(value); + } + + public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); + public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); + } + + private static Request BuildFetchRequest(FetchSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Fetch(FetchSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync List Item resource to fetch + /// The SID of the Sync List with the Sync List Item resource to fetch + /// The index of the Sync List Item resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Fetch(string pathServiceSid, + string pathListSid, + int? pathIndex, + ITwilioRestClient client = null) + { + var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync List Item resource to fetch + /// The SID of the Sync List with the Sync List Item resource to fetch + /// The index of the Sync List Item resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + ITwilioRestClient client = null) + { + var options = new FetchSyncListItemOptions(pathServiceSid, pathListSid, pathIndex); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static bool Delete(DeleteSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Sync Service with the Sync List Item resource to delete + /// The SID of the Sync List with the Sync List Item resource to delete + /// The index of the Sync List Item resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static bool Delete(string pathServiceSid, + string pathListSid, + int? pathIndex, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Sync Service with the Sync List Item resource to delete + /// The SID of the Sync List with the Sync List Item resource to delete + /// The index of the Sync List Item resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Create(CreateSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Sync Service to create the List Item in + /// The SID of the Sync List to add the new List Item to + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + /// An alias for item_ttl + /// How long, in seconds, before the List Item expires + /// How long, in seconds, before the List Item's parent Sync List expires + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Create(string pathServiceSid, + string pathListSid, + object data, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data) { Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Sync Service to create the List Item in + /// The SID of the Sync List to add the new List Item to + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + /// An alias for item_ttl + /// How long, in seconds, before the List Item expires + /// How long, in seconds, before the List Item's parent Sync List expires + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathListSid, + object data, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListItemOptions(pathServiceSid, pathListSid, data) { Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static ResourceSet Read(ReadSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sync Service with the List Item resources to read + /// The SID of the Sync List with the List Items to read + /// The order to return the List Items + /// The index of the first Sync List Item resource to read + /// Whether to include the List Item referenced by the from parameter + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static ResourceSet Read(string pathServiceSid, + string pathListSid, + SyncListItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncListItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sync Service with the List Item resources to read + /// The SID of the Sync List with the List Items to read + /// The order to return the List Items + /// The index of the first Sync List Item resource to read + /// Whether to include the List Item referenced by the from parameter + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathListSid, + SyncListItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncListItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListItemOptions(pathServiceSid, pathListSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncListItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Items/" + options.PathIndex + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update SyncListItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Update(UpdateSyncListItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncListItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Sync Service with the Sync List Item resource to update + /// The SID of the Sync List with the Sync List Item resource to update + /// The index of the Sync List Item resource to update + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + /// An alias for item_ttl + /// How long, in seconds, before the List Item expires + /// How long, in seconds, before the List Item's parent Sync List expires + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncListItem + public static SyncListItemResource Update(string pathServiceSid, + string pathListSid, + int? pathIndex, + object data = null, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Sync Service with the Sync List Item resource to update + /// The SID of the Sync List with the Sync List Item resource to update + /// The index of the Sync List Item resource to update + /// A JSON string that represents an arbitrary, schema-less object that the List Item stores + /// + /// An alias for item_ttl + /// How long, in seconds, before the List Item expires + /// How long, in seconds, before the List Item's parent Sync List expires + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListItem + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathListSid, + int? pathIndex, + object data = null, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListItemOptions(pathServiceSid, pathListSid, pathIndex) { Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncListItemResource object + /// + /// Raw JSON string + /// SyncListItemResource object represented by the provided JSON + public static SyncListItemResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The automatically generated index of the List Item + /// + [JsonProperty("index")] + public int? Index { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Sync List that contains the List Item + /// + [JsonProperty("list_sid")] + public string ListSid { get; private set; } + /// + /// The absolute URL of the List Item resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The current revision of the item, represented as a string + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// An arbitrary, schema-less object that the List Item stores + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the List Item expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the List Item's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncListItemResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionOptions.cs index 31c4511fe..c7101bb0f 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionOptions.cs @@ -9,210 +9,210 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.SyncList -{ - +{ + + /// + /// Fetch a specific Sync List Permission. + /// + public class FetchSyncListPermissionOptions : IOptions + { /// - /// Fetch a specific Sync List Permission. - /// - public class FetchSyncListPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Permission resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Permission resource to fetch - /// - public string PathListSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync List Permission resource to fetch - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchSyncListPermissionOptions - /// - /// The SID of the Sync Service with the Sync List Permission resource to fetch - /// The SID of the Sync List with the Sync List Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to fetch - public FetchSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync List Permission resource to fetch + /// + public string PathServiceSid { get; } /// - /// Delete a specific Sync List Permission. - /// - public class DeleteSyncListPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Permission resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Permission resource to delete - /// - public string PathListSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync List Permission resource to delete - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteSyncListPermissionOptions - /// - /// The SID of the Sync Service with the Sync List Permission resource to delete - /// The SID of the Sync List with the Sync List Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to delete - public DeleteSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync List with the Sync List Permission resource to fetch + /// + public string PathListSid { get; } /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - public class ReadSyncListPermissionOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Sync List Permission resources to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Permission resources to read - /// - public string PathListSid { get; } - - /// - /// Construct a new ReadSyncListPermissionOptions - /// - /// The SID of the Sync Service with the Sync List Permission resources to read - /// The SID of the Sync List with the Sync List Permission resources to read - public ReadSyncListPermissionOptions(string pathServiceSid, string pathListSid) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The application-defined string that uniquely identifies the User's Sync List Permission resource to fetch + /// + public string PathIdentity { get; } + /// - /// Update an identity's access to a specific Sync List. - /// - public class UpdateSyncListPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List Permission resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List with the Sync List Permission resource to update - /// - public string PathListSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync List Permission resource to update - /// - public string PathIdentity { get; } - /// - /// Read access - /// - public bool? Read { get; } - /// - /// Write access - /// - public bool? Write { get; } - /// - /// Manage access - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateSyncListPermissionOptions - /// - /// The SID of the Sync Service with the Sync List Permission resource to update - /// The SID of the Sync List with the Sync List Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - public UpdateSyncListPermissionOptions(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathListSid = pathListSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchSyncListPermissionOptions + /// + /// The SID of the Sync Service with the Sync List Permission resource to fetch + /// The SID of the Sync List with the Sync List Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to fetch + public FetchSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Sync List Permission. + /// + public class DeleteSyncListPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync List Permission resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the Sync List Permission resource to delete + /// + public string PathListSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Sync List Permission resource to delete + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteSyncListPermissionOptions + /// + /// The SID of the Sync Service with the Sync List Permission resource to delete + /// The SID of the Sync List with the Sync List Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to delete + public DeleteSyncListPermissionOptions(string pathServiceSid, string pathListSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + public class ReadSyncListPermissionOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Sync List Permission resources to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the Sync List Permission resources to read + /// + public string PathListSid { get; } + + /// + /// Construct a new ReadSyncListPermissionOptions + /// + /// The SID of the Sync Service with the Sync List Permission resources to read + /// The SID of the Sync List with the Sync List Permission resources to read + public ReadSyncListPermissionOptions(string pathServiceSid, string pathListSid) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Update an identity's access to a specific Sync List. + /// + public class UpdateSyncListPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync List Permission resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List with the Sync List Permission resource to update + /// + public string PathListSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Sync List Permission resource to update + /// + public string PathIdentity { get; } + /// + /// Read access + /// + public bool? Read { get; } + /// + /// Write access + /// + public bool? Write { get; } + /// + /// Manage access + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateSyncListPermissionOptions + /// + /// The SID of the Sync Service with the Sync List Permission resource to update + /// The SID of the Sync List with the Sync List Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + public UpdateSyncListPermissionOptions(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathListSid = pathListSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionResource.cs index 312491fe6..40c240af2 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncList/SyncListPermissionResource.cs @@ -16,461 +16,461 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service.SyncList -{ - - public class SyncListPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync List Permission. - /// - /// Fetch SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Fetch(FetchSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync List Permission. - /// - /// Fetch SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync List Permission. - /// - /// The SID of the Sync Service with the Sync List Permission resource to fetch - /// The SID of the Sync List with the Sync List Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Fetch(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync List Permission. - /// - /// The SID of the Sync Service with the Sync List Permission resource to fetch - /// The SID of the Sync List with the Sync List Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync List Permission. - /// - /// Delete SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static bool Delete(DeleteSyncListPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync List Permission. - /// - /// Delete SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync List Permission. - /// - /// The SID of the Sync Service with the Sync List Permission resource to delete - /// The SID of the Sync List with the Sync List Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to delete - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static bool Delete(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync List Permission. - /// - /// The SID of the Sync Service with the Sync List Permission resource to delete - /// The SID of the Sync List with the Sync List Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// Read SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static ResourceSet Read(ReadSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// Read SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// The SID of the Sync Service with the Sync List Permission resources to read - /// The SID of the Sync List with the Sync List Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static ResourceSet Read(string pathServiceSid, - string pathListSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync List. - /// - /// The SID of the Sync Service with the Sync List Permission resources to read - /// The SID of the Sync List with the Sync List Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathListSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncListPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync List. - /// - /// Update SyncListPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Update(UpdateSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync List. - /// - /// Update SyncListPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync List. - /// - /// The SID of the Sync Service with the Sync List Permission resource to update - /// The SID of the Sync List with the Sync List Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// A single instance of SyncListPermission - public static SyncListPermissionResource Update(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync List. - /// - /// The SID of the Sync Service with the Sync List Permission resource to update - /// The SID of the Sync List with the Sync List Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync List Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncListPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathListSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncListPermissionResource object - /// - /// Raw JSON string - /// SyncListPermissionResource object represented by the provided JSON - public static SyncListPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Sync List to which the Permission applies - /// - [JsonProperty("list_sid")] - public string ListSid { get; private set; } - /// - /// The identity of the user to whom the Sync List Permission applies - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// The absolute URL of the Sync List Permission resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SyncListPermissionResource() - { - - } - } +{ + + public class SyncListPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync List Permission. + /// + /// Fetch SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Fetch(FetchSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync List Permission. + /// + /// Fetch SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync List Permission. + /// + /// The SID of the Sync Service with the Sync List Permission resource to fetch + /// The SID of the Sync List with the Sync List Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Fetch(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync List Permission. + /// + /// The SID of the Sync Service with the Sync List Permission resource to fetch + /// The SID of the Sync List with the Sync List Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync List Permission. + /// + /// Delete SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static bool Delete(DeleteSyncListPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync List Permission. + /// + /// Delete SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync List Permission. + /// + /// The SID of the Sync Service with the Sync List Permission resource to delete + /// The SID of the Sync List with the Sync List Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to delete + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static bool Delete(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync List Permission. + /// + /// The SID of the Sync Service with the Sync List Permission resource to delete + /// The SID of the Sync List with the Sync List Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// Read SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static ResourceSet Read(ReadSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// Read SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// The SID of the Sync Service with the Sync List Permission resources to read + /// The SID of the Sync List with the Sync List Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static ResourceSet Read(string pathServiceSid, + string pathListSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync List. + /// + /// The SID of the Sync Service with the Sync List Permission resources to read + /// The SID of the Sync List with the Sync List Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathListSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListPermissionOptions(pathServiceSid, pathListSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncListPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathListSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync List. + /// + /// Update SyncListPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Update(UpdateSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync List. + /// + /// Update SyncListPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync List. + /// + /// The SID of the Sync Service with the Sync List Permission resource to update + /// The SID of the Sync List with the Sync List Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// A single instance of SyncListPermission + public static SyncListPermissionResource Update(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync List. + /// + /// The SID of the Sync Service with the Sync List Permission resource to update + /// The SID of the Sync List with the Sync List Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync List Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncListPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathListSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListPermissionOptions(pathServiceSid, pathListSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncListPermissionResource object + /// + /// Raw JSON string + /// SyncListPermissionResource object represented by the provided JSON + public static SyncListPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Sync List to which the Permission applies + /// + [JsonProperty("list_sid")] + public string ListSid { get; private set; } + /// + /// The identity of the user to whom the Sync List Permission applies + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// The absolute URL of the Sync List Permission resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SyncListPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncListOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncListOptions.cs index 29ff4fe43..1dc371483 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncListOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncListOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service -{ - +{ + + /// + /// FetchSyncListOptions + /// + public class FetchSyncListOptions : IOptions + { /// - /// FetchSyncListOptions - /// - public class FetchSyncListOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSyncListOptions - /// - /// The SID of the Sync Service with the Sync List resource to fetch - /// The SID of the Sync List resource to fetch - public FetchSyncListOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync List resource to fetch + /// + public string PathServiceSid { get; } /// - /// DeleteSyncListOptions - /// - public class DeleteSyncListOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSyncListOptions - /// - /// The SID of the Sync Service with the Sync List resource to delete - /// The SID of the Sync List resource to delete - public DeleteSyncListOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync List resource to fetch + /// + public string PathSid { get; } + /// - /// CreateSyncListOptions - /// - public class CreateSyncListOptions : IOptions - { - /// - /// The SID of the Sync Service to create the new Sync List in - /// - public string PathServiceSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// Alias for collection_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Sync List expires and is deleted - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new CreateSyncListOptions - /// - /// The SID of the Sync Service to create the new Sync List in - public CreateSyncListOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncListOptions + /// + /// The SID of the Sync Service with the Sync List resource to fetch + /// The SID of the Sync List resource to fetch + public FetchSyncListOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// UpdateSyncListOptions - /// - public class UpdateSyncListOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync List resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync List resource to update - /// - public string PathSid { get; } - /// - /// An alias for collection_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Sync List expires and is deleted - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new UpdateSyncListOptions - /// - /// The SID of the Sync Service with the Sync List resource to update - /// The SID of the Sync List resource to update - public UpdateSyncListOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteSyncListOptions + /// + public class DeleteSyncListOptions : IOptions + { /// - /// ReadSyncListOptions + /// The SID of the Sync Service with the Sync List resource to delete /// - public class ReadSyncListOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Sync List resources to read - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSyncListOptions - /// - /// The SID of the Sync Service with the Sync List resources to read - public ReadSyncListOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Sync List resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSyncListOptions + /// + /// The SID of the Sync Service with the Sync List resource to delete + /// The SID of the Sync List resource to delete + public DeleteSyncListOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateSyncListOptions + /// + public class CreateSyncListOptions : IOptions + { + /// + /// The SID of the Sync Service to create the new Sync List in + /// + public string PathServiceSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// Alias for collection_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Sync List expires and is deleted + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new CreateSyncListOptions + /// + /// The SID of the Sync Service to create the new Sync List in + public CreateSyncListOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// UpdateSyncListOptions + /// + public class UpdateSyncListOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync List resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync List resource to update + /// + public string PathSid { get; } + /// + /// An alias for collection_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Sync List expires and is deleted + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new UpdateSyncListOptions + /// + /// The SID of the Sync Service with the Sync List resource to update + /// The SID of the Sync List resource to update + public UpdateSyncListOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// ReadSyncListOptions + /// + public class ReadSyncListOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Sync List resources to read + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSyncListOptions + /// + /// The SID of the Sync Service with the Sync List resources to read + public ReadSyncListOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncListResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncListResource.cs index 2ab8d3a5f..83571c14d 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncListResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncListResource.cs @@ -16,521 +16,521 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service -{ - - public class SyncListResource : Resource - { - private static Request BuildFetchRequest(FetchSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Fetch(FetchSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync List resource to fetch - /// The SID of the Sync List resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSyncListOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync List resource to fetch - /// The SID of the Sync List resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSyncListOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static bool Delete(DeleteSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Sync Service with the Sync List resource to delete - /// The SID of the Sync List resource to delete - /// Client to make requests to Twilio - /// A single instance of SyncList - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSyncListOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Sync Service with the Sync List resource to delete - /// The SID of the Sync List resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSyncListOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Create(CreateSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Sync Service to create the new Sync List in - /// An application-defined string that uniquely identifies the resource - /// Alias for collection_ttl - /// How long, in seconds, before the Sync List expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Create(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Sync Service to create the new Sync List in - /// An application-defined string that uniquely identifies the resource - /// Alias for collection_ttl - /// How long, in seconds, before the Sync List expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncListOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Update(UpdateSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Sync Service with the Sync List resource to update - /// The SID of the Sync List resource to update - /// An alias for collection_ttl - /// How long, in seconds, before the Sync List expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncList - public static SyncListResource Update(string pathServiceSid, - string pathSid, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListOptions(pathServiceSid, pathSid){Ttl = ttl, CollectionTtl = collectionTtl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Sync Service with the Sync List resource to update - /// The SID of the Sync List resource to update - /// An alias for collection_ttl - /// How long, in seconds, before the Sync List expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncListOptions(pathServiceSid, pathSid){Ttl = ttl, CollectionTtl = collectionTtl}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Lists", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncList parameters - /// Client to make requests to Twilio - /// A single instance of SyncList - public static ResourceSet Read(ReadSyncListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sync Service with the Sync List resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncList - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sync Service with the Sync List resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncList - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncListOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("lists", response.Content); - } - - /// - /// Converts a JSON string into a SyncListResource object - /// - /// Raw JSON string - /// SyncListResource object represented by the provided JSON - public static SyncListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The absolute URL of the Sync List resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Sync List's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The current revision of the Sync List, represented as a string - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Sync List expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the Sync List's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncListResource() - { - - } - } +{ + + public class SyncListResource : Resource + { + private static Request BuildFetchRequest(FetchSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Fetch(FetchSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync List resource to fetch + /// The SID of the Sync List resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSyncListOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync List resource to fetch + /// The SID of the Sync List resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSyncListOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static bool Delete(DeleteSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Sync Service with the Sync List resource to delete + /// The SID of the Sync List resource to delete + /// Client to make requests to Twilio + /// A single instance of SyncList + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSyncListOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Sync Service with the Sync List resource to delete + /// The SID of the Sync List resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSyncListOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Create(CreateSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Sync Service to create the new Sync List in + /// An application-defined string that uniquely identifies the resource + /// Alias for collection_ttl + /// How long, in seconds, before the Sync List expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Create(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Sync Service to create the new Sync List in + /// An application-defined string that uniquely identifies the resource + /// Alias for collection_ttl + /// How long, in seconds, before the Sync List expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncListOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Update(UpdateSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Sync Service with the Sync List resource to update + /// The SID of the Sync List resource to update + /// An alias for collection_ttl + /// How long, in seconds, before the Sync List expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncList + public static SyncListResource Update(string pathServiceSid, + string pathSid, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListOptions(pathServiceSid, pathSid) { Ttl = ttl, CollectionTtl = collectionTtl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Sync Service with the Sync List resource to update + /// The SID of the Sync List resource to update + /// An alias for collection_ttl + /// How long, in seconds, before the Sync List expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncListOptions(pathServiceSid, pathSid) { Ttl = ttl, CollectionTtl = collectionTtl }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Lists", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncList parameters + /// Client to make requests to Twilio + /// A single instance of SyncList + public static ResourceSet Read(ReadSyncListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sync Service with the Sync List resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncList + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sync Service with the Sync List resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncList + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncListOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("lists", response.Content); + } + + /// + /// Converts a JSON string into a SyncListResource object + /// + /// Raw JSON string + /// SyncListResource object represented by the provided JSON + public static SyncListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The absolute URL of the Sync List resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Sync List's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The current revision of the Sync List, represented as a string + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Sync List expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the Sync List's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemOptions.cs index b029fb5e3..d17dd9905 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemOptions.cs @@ -9,352 +9,352 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.SyncMap -{ - +{ + + /// + /// FetchSyncMapItemOptions + /// + public class FetchSyncMapItemOptions : IOptions + { /// - /// FetchSyncMapItemOptions - /// - public class FetchSyncMapItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Item resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// - public string PathMapSid { get; } - /// - /// The key value of the Sync Map Item resource to fetch - /// - public string PathKey { get; } - - /// - /// Construct a new FetchSyncMapItemOptions - /// - /// The SID of the Sync Service with the Sync Map Item resource to fetch - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// The key value of the Sync Map Item resource to fetch - public FetchSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync Map Item resource to fetch + /// + public string PathServiceSid { get; } /// - /// DeleteSyncMapItemOptions - /// - public class DeleteSyncMapItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Item resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Item resource to delete - /// - public string PathMapSid { get; } - /// - /// The key value of the Sync Map Item resource to delete - /// - public string PathKey { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteSyncMapItemOptions - /// - /// The SID of the Sync Service with the Sync Map Item resource to delete - /// The SID of the Sync Map with the Sync Map Item resource to delete - /// The key value of the Sync Map Item resource to delete - public DeleteSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// + public string PathMapSid { get; } /// - /// CreateSyncMapItemOptions - /// - public class CreateSyncMapItemOptions : IOptions - { - /// - /// The SID of the Sync Service to create the Map Item in - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map to add the new Map Item to - /// - public string PathMapSid { get; } - /// - /// The unique, user-defined key for the Map Item - /// - public string Key { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// - public object Data { get; } - /// - /// An alias for item_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Map Item expires - /// - public int? ItemTtl { get; set; } - /// - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new CreateSyncMapItemOptions - /// - /// The SID of the Sync Service to create the Map Item in - /// The SID of the Sync Map to add the new Map Item to - /// The unique, user-defined key for the Map Item - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - public CreateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string key, object data) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - Key = key; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Key != null) - { - p.Add(new KeyValuePair("Key", Key)); - } - - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (ItemTtl != null) - { - p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// The key value of the Sync Map Item resource to fetch + /// + public string PathKey { get; } + /// - /// ReadSyncMapItemOptions - /// - public class ReadSyncMapItemOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Map Item resources to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// - public string PathMapSid { get; } - /// - /// How to order the Map Items returned by their key value - /// - public SyncMapItemResource.QueryResultOrderEnum Order { get; set; } - /// - /// The index of the first Sync Map Item resource to read - /// - public string From { get; set; } - /// - /// Whether to include the Map Item referenced by the from parameter - /// - public SyncMapItemResource.QueryFromBoundTypeEnum Bounds { get; set; } - - /// - /// Construct a new ReadSyncMapItemOptions - /// - /// The SID of the Sync Service with the Map Item resources to read - /// The SID of the Sync Map with the Sync Map Item resource to fetch - public ReadSyncMapItemOptions(string pathServiceSid, string pathMapSid) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (Bounds != null) - { - p.Add(new KeyValuePair("Bounds", Bounds.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncMapItemOptions + /// + /// The SID of the Sync Service with the Sync Map Item resource to fetch + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// The key value of the Sync Map Item resource to fetch + public FetchSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + } + /// - /// UpdateSyncMapItemOptions - /// - public class UpdateSyncMapItemOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Item resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Item resource to update - /// - public string PathMapSid { get; } - /// - /// The key value of the Sync Map Item resource to update - /// - public string PathKey { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// - public object Data { get; set; } - /// - /// An alias for item_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Map Item expires - /// - public int? ItemTtl { get; set; } - /// - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - public int? CollectionTtl { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateSyncMapItemOptions - /// - /// The SID of the Sync Service with the Sync Map Item resource to update - /// The SID of the Sync Map with the Sync Map Item resource to update - /// The key value of the Sync Map Item resource to update - public UpdateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathKey = pathKey; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (ItemTtl != null) - { - p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteSyncMapItemOptions + /// + public class DeleteSyncMapItemOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Map Item resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Sync Map Item resource to delete + /// + public string PathMapSid { get; } + /// + /// The key value of the Sync Map Item resource to delete + /// + public string PathKey { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteSyncMapItemOptions + /// + /// The SID of the Sync Service with the Sync Map Item resource to delete + /// The SID of the Sync Map with the Sync Map Item resource to delete + /// The key value of the Sync Map Item resource to delete + public DeleteSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// CreateSyncMapItemOptions + /// + public class CreateSyncMapItemOptions : IOptions + { + /// + /// The SID of the Sync Service to create the Map Item in + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map to add the new Map Item to + /// + public string PathMapSid { get; } + /// + /// The unique, user-defined key for the Map Item + /// + public string Key { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// + public object Data { get; } + /// + /// An alias for item_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Map Item expires + /// + public int? ItemTtl { get; set; } + /// + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new CreateSyncMapItemOptions + /// + /// The SID of the Sync Service to create the Map Item in + /// The SID of the Sync Map to add the new Map Item to + /// The unique, user-defined key for the Map Item + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + public CreateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string key, object data) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + Key = key; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Key != null) + { + p.Add(new KeyValuePair("Key", Key)); + } + + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (ItemTtl != null) + { + p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// ReadSyncMapItemOptions + /// + public class ReadSyncMapItemOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Map Item resources to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// + public string PathMapSid { get; } + /// + /// How to order the Map Items returned by their key value + /// + public SyncMapItemResource.QueryResultOrderEnum Order { get; set; } + /// + /// The index of the first Sync Map Item resource to read + /// + public string From { get; set; } + /// + /// Whether to include the Map Item referenced by the from parameter + /// + public SyncMapItemResource.QueryFromBoundTypeEnum Bounds { get; set; } + + /// + /// Construct a new ReadSyncMapItemOptions + /// + /// The SID of the Sync Service with the Map Item resources to read + /// The SID of the Sync Map with the Sync Map Item resource to fetch + public ReadSyncMapItemOptions(string pathServiceSid, string pathMapSid) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (Bounds != null) + { + p.Add(new KeyValuePair("Bounds", Bounds.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateSyncMapItemOptions + /// + public class UpdateSyncMapItemOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Map Item resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Sync Map Item resource to update + /// + public string PathMapSid { get; } + /// + /// The key value of the Sync Map Item resource to update + /// + public string PathKey { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// + public object Data { get; set; } + /// + /// An alias for item_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Map Item expires + /// + public int? ItemTtl { get; set; } + /// + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + public int? CollectionTtl { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateSyncMapItemOptions + /// + /// The SID of the Sync Service with the Sync Map Item resource to update + /// The SID of the Sync Map with the Sync Map Item resource to update + /// The key value of the Sync Map Item resource to update + public UpdateSyncMapItemOptions(string pathServiceSid, string pathMapSid, string pathKey) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathKey = pathKey; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (ItemTtl != null) + { + p.Add(new KeyValuePair("ItemTtl", ItemTtl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemResource.cs index 8560834a9..2dea0dc4e 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItemResource.cs @@ -17,611 +17,611 @@ using Twilio.Types; namespace Twilio.Rest.Sync.V1.Service.SyncMap -{ - - public class SyncMapItemResource : Resource - { - public sealed class QueryResultOrderEnum : StringEnum - { - private QueryResultOrderEnum(string value) : base(value) {} - public QueryResultOrderEnum() {} - public static implicit operator QueryResultOrderEnum(string value) - { - return new QueryResultOrderEnum(value); - } - - public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); - public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); - } - - public sealed class QueryFromBoundTypeEnum : StringEnum - { - private QueryFromBoundTypeEnum(string value) : base(value) {} - public QueryFromBoundTypeEnum() {} - public static implicit operator QueryFromBoundTypeEnum(string value) - { - return new QueryFromBoundTypeEnum(value); - } - - public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); - public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); - } - - private static Request BuildFetchRequest(FetchSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Fetch(FetchSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync Map Item resource to fetch - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// The key value of the Sync Map Item resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Fetch(string pathServiceSid, - string pathMapSid, - string pathKey, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync Map Item resource to fetch - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// The key value of the Sync Map Item resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static bool Delete(DeleteSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Sync Service with the Sync Map Item resource to delete - /// The SID of the Sync Map with the Sync Map Item resource to delete - /// The key value of the Sync Map Item resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static bool Delete(string pathServiceSid, - string pathMapSid, - string pathKey, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Sync Service with the Sync Map Item resource to delete - /// The SID of the Sync Map with the Sync Map Item resource to delete - /// The key value of the Sync Map Item resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Create(CreateSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Sync Service to create the Map Item in - /// The SID of the Sync Map to add the new Map Item to - /// The unique, user-defined key for the Map Item - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// An alias for item_ttl - /// How long, in seconds, before the Map Item expires - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Create(string pathServiceSid, - string pathMapSid, - string key, - object data, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data){Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Sync Service to create the Map Item in - /// The SID of the Sync Map to add the new Map Item to - /// The unique, user-defined key for the Map Item - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// An alias for item_ttl - /// How long, in seconds, before the Map Item expires - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathMapSid, - string key, - object data, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data){Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static ResourceSet Read(ReadSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("items", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sync Service with the Map Item resources to read - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// How to order the Map Items returned by their key value - /// The index of the first Sync Map Item resource to read - /// Whether to include the Map Item referenced by the from parameter - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static ResourceSet Read(string pathServiceSid, - string pathMapSid, - SyncMapItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sync Service with the Map Item resources to read - /// The SID of the Sync Map with the Sync Map Item resource to fetch - /// How to order the Map Items returned by their key value - /// The index of the first Sync Map Item resource to read - /// Whether to include the Map Item referenced by the from parameter - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathMapSid, - SyncMapItemResource.QueryResultOrderEnum order = null, - string from = null, - SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid){Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("items", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncMapItemOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update SyncMapItem parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Update(UpdateSyncMapItemOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncMapItem parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapItemOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Sync Service with the Sync Map Item resource to update - /// The SID of the Sync Map with the Sync Map Item resource to update - /// The key value of the Sync Map Item resource to update - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// An alias for item_ttl - /// How long, in seconds, before the Map Item expires - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of SyncMapItem - public static SyncMapItemResource Update(string pathServiceSid, - string pathMapSid, - string pathKey, - object data = null, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Sync Service with the Sync Map Item resource to update - /// The SID of the Sync Map with the Sync Map Item resource to update - /// The key value of the Sync Map Item resource to update - /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores - /// An alias for item_ttl - /// How long, in seconds, before the Map Item expires - /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted - /// - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapItem - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathMapSid, - string pathKey, - object data = null, - int? ttl = null, - int? itemTtl = null, - int? collectionTtl = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey){Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncMapItemResource object - /// - /// Raw JSON string - /// SyncMapItemResource object represented by the provided JSON - public static SyncMapItemResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique, user-defined key for the Map Item - /// - [JsonProperty("key")] - public string Key { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Sync Map that contains the Map Item - /// - [JsonProperty("map_sid")] - public string MapSid { get; private set; } - /// - /// The absolute URL of the Map Item resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The current revision of the Map Item, represented as a string - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// An arbitrary, schema-less object that the Map Item stores - /// - [JsonProperty("data")] - public object Data { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Map Item expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the Map Item's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncMapItemResource() - { - - } - } +{ + + public class SyncMapItemResource : Resource + { + public sealed class QueryResultOrderEnum : StringEnum + { + private QueryResultOrderEnum(string value) : base(value) { } + public QueryResultOrderEnum() { } + public static implicit operator QueryResultOrderEnum(string value) + { + return new QueryResultOrderEnum(value); + } + + public static readonly QueryResultOrderEnum Asc = new QueryResultOrderEnum("asc"); + public static readonly QueryResultOrderEnum Desc = new QueryResultOrderEnum("desc"); + } + + public sealed class QueryFromBoundTypeEnum : StringEnum + { + private QueryFromBoundTypeEnum(string value) : base(value) { } + public QueryFromBoundTypeEnum() { } + public static implicit operator QueryFromBoundTypeEnum(string value) + { + return new QueryFromBoundTypeEnum(value); + } + + public static readonly QueryFromBoundTypeEnum Inclusive = new QueryFromBoundTypeEnum("inclusive"); + public static readonly QueryFromBoundTypeEnum Exclusive = new QueryFromBoundTypeEnum("exclusive"); + } + + private static Request BuildFetchRequest(FetchSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Fetch(FetchSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync Map Item resource to fetch + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// The key value of the Sync Map Item resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Fetch(string pathServiceSid, + string pathMapSid, + string pathKey, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync Map Item resource to fetch + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// The key value of the Sync Map Item resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static bool Delete(DeleteSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Sync Service with the Sync Map Item resource to delete + /// The SID of the Sync Map with the Sync Map Item resource to delete + /// The key value of the Sync Map Item resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static bool Delete(string pathServiceSid, + string pathMapSid, + string pathKey, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Sync Service with the Sync Map Item resource to delete + /// The SID of the Sync Map with the Sync Map Item resource to delete + /// The key value of the Sync Map Item resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Create(CreateSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Sync Service to create the Map Item in + /// The SID of the Sync Map to add the new Map Item to + /// The unique, user-defined key for the Map Item + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// An alias for item_ttl + /// How long, in seconds, before the Map Item expires + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Create(string pathServiceSid, + string pathMapSid, + string key, + object data, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data) { Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Sync Service to create the Map Item in + /// The SID of the Sync Map to add the new Map Item to + /// The unique, user-defined key for the Map Item + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// An alias for item_ttl + /// How long, in seconds, before the Map Item expires + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathMapSid, + string key, + object data, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapItemOptions(pathServiceSid, pathMapSid, key, data) { Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static ResourceSet Read(ReadSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("items", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sync Service with the Map Item resources to read + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// How to order the Map Items returned by their key value + /// The index of the first Sync Map Item resource to read + /// Whether to include the Map Item referenced by the from parameter + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static ResourceSet Read(string pathServiceSid, + string pathMapSid, + SyncMapItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sync Service with the Map Item resources to read + /// The SID of the Sync Map with the Sync Map Item resource to fetch + /// How to order the Map Items returned by their key value + /// The index of the first Sync Map Item resource to read + /// Whether to include the Map Item referenced by the from parameter + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathMapSid, + SyncMapItemResource.QueryResultOrderEnum order = null, + string from = null, + SyncMapItemResource.QueryFromBoundTypeEnum bounds = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapItemOptions(pathServiceSid, pathMapSid) { Order = order, From = from, Bounds = bounds, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("items", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncMapItemOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Items/" + options.PathKey + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update SyncMapItem parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Update(UpdateSyncMapItemOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncMapItem parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapItemOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Sync Service with the Sync Map Item resource to update + /// The SID of the Sync Map with the Sync Map Item resource to update + /// The key value of the Sync Map Item resource to update + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// An alias for item_ttl + /// How long, in seconds, before the Map Item expires + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of SyncMapItem + public static SyncMapItemResource Update(string pathServiceSid, + string pathMapSid, + string pathKey, + object data = null, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Sync Service with the Sync Map Item resource to update + /// The SID of the Sync Map with the Sync Map Item resource to update + /// The key value of the Sync Map Item resource to update + /// A JSON string that represents an arbitrary, schema-less object that the Map Item stores + /// An alias for item_ttl + /// How long, in seconds, before the Map Item expires + /// How long, in seconds, before the Map Item's parent Sync Map expires and is deleted + /// + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapItem + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathMapSid, + string pathKey, + object data = null, + int? ttl = null, + int? itemTtl = null, + int? collectionTtl = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapItemOptions(pathServiceSid, pathMapSid, pathKey) { Data = data, Ttl = ttl, ItemTtl = itemTtl, CollectionTtl = collectionTtl, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncMapItemResource object + /// + /// Raw JSON string + /// SyncMapItemResource object represented by the provided JSON + public static SyncMapItemResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique, user-defined key for the Map Item + /// + [JsonProperty("key")] + public string Key { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Sync Map that contains the Map Item + /// + [JsonProperty("map_sid")] + public string MapSid { get; private set; } + /// + /// The absolute URL of the Map Item resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The current revision of the Map Item, represented as a string + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// An arbitrary, schema-less object that the Map Item stores + /// + [JsonProperty("data")] + public object Data { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Map Item expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the Map Item's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncMapItemResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionOptions.cs index 8385d63ac..3c64ef58c 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionOptions.cs @@ -9,210 +9,210 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.SyncMap -{ - +{ + + /// + /// Fetch a specific Sync Map Permission. + /// + public class FetchSyncMapPermissionOptions : IOptions + { /// - /// Fetch a specific Sync Map Permission. - /// - public class FetchSyncMapPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Permission resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Permission resource to fetch - /// - public string PathMapSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to fetch - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchSyncMapPermissionOptions - /// - /// The SID of the Sync Service with the Sync Map Permission resource to fetch - /// The SID of the Sync Map with the Sync Map Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to fetch - public FetchSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync Map Permission resource to fetch + /// + public string PathServiceSid { get; } /// - /// Delete a specific Sync Map Permission. - /// - public class DeleteSyncMapPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Permission resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Permission resource to delete - /// - public string PathMapSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to delete - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteSyncMapPermissionOptions - /// - /// The SID of the Sync Service with the Sync Map Permission resource to delete - /// The SID of the Sync Map with the Sync Map Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to delete - public DeleteSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Map with the Sync Map Permission resource to fetch + /// + public string PathMapSid { get; } /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - public class ReadSyncMapPermissionOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Sync Map Permission resources to read - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Permission resources to read - /// - public string PathMapSid { get; } - - /// - /// Construct a new ReadSyncMapPermissionOptions - /// - /// The SID of the Sync Service with the Sync Map Permission resources to read - /// The SID of the Sync Map with the Permission resources to read - public ReadSyncMapPermissionOptions(string pathServiceSid, string pathMapSid) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to fetch + /// + public string PathIdentity { get; } + /// - /// Update an identity's access to a specific Sync Map. - /// - public class UpdateSyncMapPermissionOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map Permission resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map with the Sync Map Permission resource to update - /// - public string PathMapSid { get; } - /// - /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to update - /// - public string PathIdentity { get; } - /// - /// Read access - /// - public bool? Read { get; } - /// - /// Write access - /// - public bool? Write { get; } - /// - /// Manage access - /// - public bool? Manage { get; } - - /// - /// Construct a new UpdateSyncMapPermissionOptions - /// - /// The SID of the Sync Service with the Sync Map Permission resource to update - /// The SID of the Sync Map with the Sync Map Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - public UpdateSyncMapPermissionOptions(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage) - { - PathServiceSid = pathServiceSid; - PathMapSid = pathMapSid; - PathIdentity = pathIdentity; - Read = read; - Write = write; - Manage = manage; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Read != null) - { - p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); - } - - if (Write != null) - { - p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); - } - - if (Manage != null) - { - p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new FetchSyncMapPermissionOptions + /// + /// The SID of the Sync Service with the Sync Map Permission resource to fetch + /// The SID of the Sync Map with the Sync Map Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to fetch + public FetchSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Sync Map Permission. + /// + public class DeleteSyncMapPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Map Permission resource to delete + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Sync Map Permission resource to delete + /// + public string PathMapSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to delete + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteSyncMapPermissionOptions + /// + /// The SID of the Sync Service with the Sync Map Permission resource to delete + /// The SID of the Sync Map with the Sync Map Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to delete + public DeleteSyncMapPermissionOptions(string pathServiceSid, string pathMapSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + public class ReadSyncMapPermissionOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Sync Map Permission resources to read + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Permission resources to read + /// + public string PathMapSid { get; } + + /// + /// Construct a new ReadSyncMapPermissionOptions + /// + /// The SID of the Sync Service with the Sync Map Permission resources to read + /// The SID of the Sync Map with the Permission resources to read + public ReadSyncMapPermissionOptions(string pathServiceSid, string pathMapSid) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Update an identity's access to a specific Sync Map. + /// + public class UpdateSyncMapPermissionOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Map Permission resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map with the Sync Map Permission resource to update + /// + public string PathMapSid { get; } + /// + /// The application-defined string that uniquely identifies the User's Sync Map Permission resource to update + /// + public string PathIdentity { get; } + /// + /// Read access + /// + public bool? Read { get; } + /// + /// Write access + /// + public bool? Write { get; } + /// + /// Manage access + /// + public bool? Manage { get; } + + /// + /// Construct a new UpdateSyncMapPermissionOptions + /// + /// The SID of the Sync Service with the Sync Map Permission resource to update + /// The SID of the Sync Map with the Sync Map Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + public UpdateSyncMapPermissionOptions(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage) + { + PathServiceSid = pathServiceSid; + PathMapSid = pathMapSid; + PathIdentity = pathIdentity; + Read = read; + Write = write; + Manage = manage; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Read != null) + { + p.Add(new KeyValuePair("Read", Read.Value.ToString().ToLower())); + } + + if (Write != null) + { + p.Add(new KeyValuePair("Write", Write.Value.ToString().ToLower())); + } + + if (Manage != null) + { + p.Add(new KeyValuePair("Manage", Manage.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionResource.cs index 9d76ec14e..3f258643c 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapPermissionResource.cs @@ -16,460 +16,460 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service.SyncMap -{ - - public class SyncMapPermissionResource : Resource - { - private static Request BuildFetchRequest(FetchSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Sync Map Permission. - /// - /// Fetch SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Fetch(FetchSyncMapPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Sync Map Permission. - /// - /// Fetch SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Sync Map Permission. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to fetch - /// The SID of the Sync Map with the Sync Map Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Fetch(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Sync Map Permission. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to fetch - /// The SID of the Sync Map with the Sync Map Permission resource to fetch - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Sync Map Permission. - /// - /// Delete SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static bool Delete(DeleteSyncMapPermissionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Sync Map Permission. - /// - /// Delete SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Sync Map Permission. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to delete - /// The SID of the Sync Map with the Sync Map Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to delete - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static bool Delete(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Sync Map Permission. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to delete - /// The SID of the Sync Map with the Sync Map Permission resource to delete - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// Read SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static ResourceSet Read(ReadSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// Read SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("permissions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// The SID of the Sync Service with the Sync Map Permission resources to read - /// The SID of the Sync Map with the Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static ResourceSet Read(string pathServiceSid, - string pathMapSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Permissions applying to a Sync Map. - /// - /// The SID of the Sync Service with the Sync Map Permission resources to read - /// The SID of the Sync Map with the Permission resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathMapSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("permissions", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSyncMapPermissionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Update SyncMapPermission parameters - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Update(UpdateSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Map. - /// - /// Update SyncMapPermission parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapPermissionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an identity's access to a specific Sync Map. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to update - /// The SID of the Sync Map with the Sync Map Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// A single instance of SyncMapPermission - public static SyncMapPermissionResource Update(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); - return Update(options, client); - } - - #if !NET35 - /// - /// Update an identity's access to a specific Sync Map. - /// - /// The SID of the Sync Service with the Sync Map Permission resource to update - /// The SID of the Sync Map with the Sync Map Permission resource to update - /// The application-defined string that uniquely identifies the User's Sync Map Permission - /// resource to update - /// Read access - /// Write access - /// Manage access - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMapPermission - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathMapSid, - string pathIdentity, - bool? read, - bool? write, - bool? manage, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SyncMapPermissionResource object - /// - /// Raw JSON string - /// SyncMapPermissionResource object represented by the provided JSON - public static SyncMapPermissionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Sync Map SID - /// - [JsonProperty("map_sid")] - public string MapSid { get; private set; } - /// - /// The identity of the user to whom the Sync Document Permission applies - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Read access - /// - [JsonProperty("read")] - public bool? _Read { get; private set; } - /// - /// Write access - /// - [JsonProperty("write")] - public bool? Write { get; private set; } - /// - /// Manage access - /// - [JsonProperty("manage")] - public bool? Manage { get; private set; } - /// - /// The absolute URL of the Sync Map Permission resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SyncMapPermissionResource() - { - - } - } +{ + + public class SyncMapPermissionResource : Resource + { + private static Request BuildFetchRequest(FetchSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Sync Map Permission. + /// + /// Fetch SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Fetch(FetchSyncMapPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Sync Map Permission. + /// + /// Fetch SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Sync Map Permission. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to fetch + /// The SID of the Sync Map with the Sync Map Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Fetch(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Sync Map Permission. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to fetch + /// The SID of the Sync Map with the Sync Map Permission resource to fetch + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Sync Map Permission. + /// + /// Delete SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static bool Delete(DeleteSyncMapPermissionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Sync Map Permission. + /// + /// Delete SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Sync Map Permission. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to delete + /// The SID of the Sync Map with the Sync Map Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to delete + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static bool Delete(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Sync Map Permission. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to delete + /// The SID of the Sync Map with the Sync Map Permission resource to delete + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// Read SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static ResourceSet Read(ReadSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// Read SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("permissions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// The SID of the Sync Service with the Sync Map Permission resources to read + /// The SID of the Sync Map with the Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static ResourceSet Read(string pathServiceSid, + string pathMapSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Permissions applying to a Sync Map. + /// + /// The SID of the Sync Service with the Sync Map Permission resources to read + /// The SID of the Sync Map with the Permission resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathMapSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapPermissionOptions(pathServiceSid, pathMapSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("permissions", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSyncMapPermissionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathMapSid + "/Permissions/" + options.PathIdentity + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Update SyncMapPermission parameters + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Update(UpdateSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Map. + /// + /// Update SyncMapPermission parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapPermissionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an identity's access to a specific Sync Map. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to update + /// The SID of the Sync Map with the Sync Map Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// A single instance of SyncMapPermission + public static SyncMapPermissionResource Update(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); + return Update(options, client); + } + +#if !NET35 + /// + /// Update an identity's access to a specific Sync Map. + /// + /// The SID of the Sync Service with the Sync Map Permission resource to update + /// The SID of the Sync Map with the Sync Map Permission resource to update + /// The application-defined string that uniquely identifies the User's Sync Map Permission + /// resource to update + /// Read access + /// Write access + /// Manage access + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMapPermission + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathMapSid, + string pathIdentity, + bool? read, + bool? write, + bool? manage, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapPermissionOptions(pathServiceSid, pathMapSid, pathIdentity, read, write, manage); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SyncMapPermissionResource object + /// + /// Raw JSON string + /// SyncMapPermissionResource object represented by the provided JSON + public static SyncMapPermissionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Sync Map SID + /// + [JsonProperty("map_sid")] + public string MapSid { get; private set; } + /// + /// The identity of the user to whom the Sync Document Permission applies + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Read access + /// + [JsonProperty("read")] + public bool? _Read { get; private set; } + /// + /// Write access + /// + [JsonProperty("write")] + public bool? Write { get; private set; } + /// + /// Manage access + /// + [JsonProperty("manage")] + public bool? Manage { get; private set; } + /// + /// The absolute URL of the Sync Map Permission resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SyncMapPermissionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMapOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMapOptions.cs index 49c98c669..c6856af17 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMapOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMapOptions.cs @@ -9,219 +9,219 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service -{ - +{ + + /// + /// FetchSyncMapOptions + /// + public class FetchSyncMapOptions : IOptions + { /// - /// FetchSyncMapOptions - /// - public class FetchSyncMapOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSyncMapOptions - /// - /// The SID of the Sync Service with the Sync Map resource to fetch - /// The SID of the Sync Map resource to fetch - public FetchSyncMapOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync Map resource to fetch + /// + public string PathServiceSid { get; } /// - /// DeleteSyncMapOptions - /// - public class DeleteSyncMapOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSyncMapOptions - /// - /// The SID of the Sync Service with the Sync Map resource to delete - /// The SID of the Sync Map resource to delete - public DeleteSyncMapOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Map resource to fetch + /// + public string PathSid { get; } + /// - /// CreateSyncMapOptions - /// - public class CreateSyncMapOptions : IOptions - { - /// - /// The SID of the Sync Service to create the Sync Map in - /// - public string PathServiceSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// An alias for collection_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Sync Map expires and is deleted - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new CreateSyncMapOptions - /// - /// The SID of the Sync Service to create the Sync Map in - public CreateSyncMapOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncMapOptions + /// + /// The SID of the Sync Service with the Sync Map resource to fetch + /// The SID of the Sync Map resource to fetch + public FetchSyncMapOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// UpdateSyncMapOptions - /// - public class UpdateSyncMapOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Map resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Map resource to update - /// - public string PathSid { get; } - /// - /// An alias for collection_ttl - /// - public int? Ttl { get; set; } - /// - /// How long, in seconds, before the Sync Map expires and is deleted - /// - public int? CollectionTtl { get; set; } - - /// - /// Construct a new UpdateSyncMapOptions - /// - /// The SID of the Sync Service with the Sync Map resource to update - /// The SID of the Sync Map resource to update - public UpdateSyncMapOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - if (CollectionTtl != null) - { - p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteSyncMapOptions + /// + public class DeleteSyncMapOptions : IOptions + { /// - /// ReadSyncMapOptions + /// The SID of the Sync Service with the Sync Map resource to delete /// - public class ReadSyncMapOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Sync Map resources to read - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSyncMapOptions - /// - /// The SID of the Sync Service with the Sync Map resources to read - public ReadSyncMapOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSyncMapOptions + /// + /// The SID of the Sync Service with the Sync Map resource to delete + /// The SID of the Sync Map resource to delete + public DeleteSyncMapOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateSyncMapOptions + /// + public class CreateSyncMapOptions : IOptions + { + /// + /// The SID of the Sync Service to create the Sync Map in + /// + public string PathServiceSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// An alias for collection_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Sync Map expires and is deleted + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new CreateSyncMapOptions + /// + /// The SID of the Sync Service to create the Sync Map in + public CreateSyncMapOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// UpdateSyncMapOptions + /// + public class UpdateSyncMapOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Map resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Sync Map resource to update + /// + public string PathSid { get; } + /// + /// An alias for collection_ttl + /// + public int? Ttl { get; set; } + /// + /// How long, in seconds, before the Sync Map expires and is deleted + /// + public int? CollectionTtl { get; set; } + + /// + /// Construct a new UpdateSyncMapOptions + /// + /// The SID of the Sync Service with the Sync Map resource to update + /// The SID of the Sync Map resource to update + public UpdateSyncMapOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + if (CollectionTtl != null) + { + p.Add(new KeyValuePair("CollectionTtl", CollectionTtl.ToString())); + } + + return p; + } + } + + /// + /// ReadSyncMapOptions + /// + public class ReadSyncMapOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Sync Map resources to read + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSyncMapOptions + /// + /// The SID of the Sync Service with the Sync Map resources to read + public ReadSyncMapOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncMapResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncMapResource.cs index c3601b892..60ed77ce4 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncMapResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncMapResource.cs @@ -16,521 +16,521 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service -{ - - public class SyncMapResource : Resource - { - private static Request BuildFetchRequest(FetchSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Fetch(FetchSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync Map resource to fetch - /// The SID of the Sync Map resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSyncMapOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Sync Service with the Sync Map resource to fetch - /// The SID of the Sync Map resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSyncMapOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static bool Delete(DeleteSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Sync Service with the Sync Map resource to delete - /// The SID of the Sync Map resource to delete - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Sync Service with the Sync Map resource to delete - /// The SID of the Sync Map resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Create(CreateSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Sync Service to create the Sync Map in - /// An application-defined string that uniquely identifies the resource - /// An alias for collection_ttl - /// How long, in seconds, before the Sync Map expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Create(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Sync Service to create the Sync Map in - /// An application-defined string that uniquely identifies the resource - /// An alias for collection_ttl - /// How long, in seconds, before the Sync Map expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncMapOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Update(UpdateSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Sync Service with the Sync Map resource to update - /// The SID of the Sync Map resource to update - /// An alias for collection_ttl - /// How long, in seconds, before the Sync Map expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static SyncMapResource Update(string pathServiceSid, - string pathSid, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapOptions(pathServiceSid, pathSid){Ttl = ttl, CollectionTtl = collectionTtl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Sync Service with the Sync Map resource to update - /// The SID of the Sync Map resource to update - /// An alias for collection_ttl - /// How long, in seconds, before the Sync Map expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - int? ttl = null, - int? collectionTtl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncMapOptions(pathServiceSid, pathSid){Ttl = ttl, CollectionTtl = collectionTtl}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncMapOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Maps", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SyncMap parameters - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static ResourceSet Read(ReadSyncMapOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("maps", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SyncMap parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("maps", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sync Service with the Sync Map resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncMap - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sync Service with the Sync Map resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncMap - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncMapOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("maps", response.Content); - } - - /// - /// Converts a JSON string into a SyncMapResource object - /// - /// Raw JSON string - /// SyncMapResource object represented by the provided JSON - public static SyncMapResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The absolute URL of the Sync Map resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Sync Map's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The current revision of the Sync Map, represented as a string - /// - [JsonProperty("revision")] - public string Revision { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Sync Map expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The identity of the Sync Map's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncMapResource() - { - - } - } +{ + + public class SyncMapResource : Resource + { + private static Request BuildFetchRequest(FetchSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Fetch(FetchSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync Map resource to fetch + /// The SID of the Sync Map resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSyncMapOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Sync Service with the Sync Map resource to fetch + /// The SID of the Sync Map resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSyncMapOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static bool Delete(DeleteSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Sync Service with the Sync Map resource to delete + /// The SID of the Sync Map resource to delete + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Sync Service with the Sync Map resource to delete + /// The SID of the Sync Map resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSyncMapOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Create(CreateSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Sync Service to create the Sync Map in + /// An application-defined string that uniquely identifies the resource + /// An alias for collection_ttl + /// How long, in seconds, before the Sync Map expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Create(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Sync Service to create the Sync Map in + /// An application-defined string that uniquely identifies the resource + /// An alias for collection_ttl + /// How long, in seconds, before the Sync Map expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncMapOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl, CollectionTtl = collectionTtl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Update(UpdateSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Sync Service with the Sync Map resource to update + /// The SID of the Sync Map resource to update + /// An alias for collection_ttl + /// How long, in seconds, before the Sync Map expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static SyncMapResource Update(string pathServiceSid, + string pathSid, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapOptions(pathServiceSid, pathSid) { Ttl = ttl, CollectionTtl = collectionTtl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Sync Service with the Sync Map resource to update + /// The SID of the Sync Map resource to update + /// An alias for collection_ttl + /// How long, in seconds, before the Sync Map expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + int? ttl = null, + int? collectionTtl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncMapOptions(pathServiceSid, pathSid) { Ttl = ttl, CollectionTtl = collectionTtl }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncMapOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Maps", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SyncMap parameters + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static ResourceSet Read(ReadSyncMapOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("maps", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SyncMap parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncMapOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("maps", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sync Service with the Sync Map resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncMap + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sync Service with the Sync Map resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncMap + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncMapOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("maps", response.Content); + } + + /// + /// Converts a JSON string into a SyncMapResource object + /// + /// Raw JSON string + /// SyncMapResource object represented by the provided JSON + public static SyncMapResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The absolute URL of the Sync Map resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Sync Map's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The current revision of the Sync Map, represented as a string + /// + [JsonProperty("revision")] + public string Revision { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Sync Map expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The identity of the Sync Map's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncMapResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageOptions.cs index cfc5f497e..9e550e37c 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageOptions.cs @@ -9,53 +9,53 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service.SyncStream -{ - +{ + + /// + /// Create a new Stream Message. + /// + public class CreateStreamMessageOptions : IOptions + { /// - /// Create a new Stream Message. + /// The SID of the Sync Service to create the new Stream Message in /// - public class CreateStreamMessageOptions : IOptions - { - /// - /// The SID of the Sync Service to create the new Stream Message in - /// - public string PathServiceSid { get; } - /// - /// The SID of the Sync Stream to create the new Stream Message resource for - /// - public string PathStreamSid { get; } - /// - /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message body - /// - public object Data { get; } - - /// - /// Construct a new CreateStreamMessageOptions - /// - /// The SID of the Sync Service to create the new Stream Message in - /// The SID of the Sync Stream to create the new Stream Message resource for - /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message - /// body - public CreateStreamMessageOptions(string pathServiceSid, string pathStreamSid, object data) - { - PathServiceSid = pathServiceSid; - PathStreamSid = pathStreamSid; - Data = data; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Data != null) - { - p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Sync Stream to create the new Stream Message resource for + /// + public string PathStreamSid { get; } + /// + /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message body + /// + public object Data { get; } + + /// + /// Construct a new CreateStreamMessageOptions + /// + /// The SID of the Sync Service to create the new Stream Message in + /// The SID of the Sync Stream to create the new Stream Message resource for + /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message + /// body + public CreateStreamMessageOptions(string pathServiceSid, string pathStreamSid, object data) + { + PathServiceSid = pathServiceSid; + PathStreamSid = pathStreamSid; + Data = data; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Data != null) + { + p.Add(new KeyValuePair("Data", Serializers.JsonObject(Data))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageResource.cs index 92b48471c..798bfb318 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncStream/StreamMessageResource.cs @@ -16,121 +16,121 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service.SyncStream -{ - - public class StreamMessageResource : Resource - { - private static Request BuildCreateRequest(CreateStreamMessageOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathStreamSid + "/Messages", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Stream Message. - /// - /// Create StreamMessage parameters - /// Client to make requests to Twilio - /// A single instance of StreamMessage - public static StreamMessageResource Create(CreateStreamMessageOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Stream Message. - /// - /// Create StreamMessage parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StreamMessage - public static async System.Threading.Tasks.Task CreateAsync(CreateStreamMessageOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Stream Message. - /// - /// The SID of the Sync Service to create the new Stream Message in - /// The SID of the Sync Stream to create the new Stream Message resource for - /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message - /// body - /// Client to make requests to Twilio - /// A single instance of StreamMessage - public static StreamMessageResource Create(string pathServiceSid, - string pathStreamSid, - object data, - ITwilioRestClient client = null) - { - var options = new CreateStreamMessageOptions(pathServiceSid, pathStreamSid, data); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Stream Message. - /// - /// The SID of the Sync Service to create the new Stream Message in - /// The SID of the Sync Stream to create the new Stream Message resource for - /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message - /// body - /// Client to make requests to Twilio - /// Task that resolves to A single instance of StreamMessage - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathStreamSid, - object data, - ITwilioRestClient client = null) - { - var options = new CreateStreamMessageOptions(pathServiceSid, pathStreamSid, data); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a StreamMessageResource object - /// - /// Raw JSON string - /// StreamMessageResource object represented by the provided JSON - public static StreamMessageResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Stream Message body - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private StreamMessageResource() - { - - } - } +{ + + public class StreamMessageResource : Resource + { + private static Request BuildCreateRequest(CreateStreamMessageOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathStreamSid + "/Messages", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Stream Message. + /// + /// Create StreamMessage parameters + /// Client to make requests to Twilio + /// A single instance of StreamMessage + public static StreamMessageResource Create(CreateStreamMessageOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Stream Message. + /// + /// Create StreamMessage parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StreamMessage + public static async System.Threading.Tasks.Task CreateAsync(CreateStreamMessageOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Stream Message. + /// + /// The SID of the Sync Service to create the new Stream Message in + /// The SID of the Sync Stream to create the new Stream Message resource for + /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message + /// body + /// Client to make requests to Twilio + /// A single instance of StreamMessage + public static StreamMessageResource Create(string pathServiceSid, + string pathStreamSid, + object data, + ITwilioRestClient client = null) + { + var options = new CreateStreamMessageOptions(pathServiceSid, pathStreamSid, data); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Stream Message. + /// + /// The SID of the Sync Service to create the new Stream Message in + /// The SID of the Sync Stream to create the new Stream Message resource for + /// A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message + /// body + /// Client to make requests to Twilio + /// Task that resolves to A single instance of StreamMessage + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathStreamSid, + object data, + ITwilioRestClient client = null) + { + var options = new CreateStreamMessageOptions(pathServiceSid, pathStreamSid, data); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a StreamMessageResource object + /// + /// Raw JSON string + /// StreamMessageResource object represented by the provided JSON + public static StreamMessageResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Stream Message body + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private StreamMessageResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncStreamOptions.cs b/src/Twilio/Rest/Sync/V1/Service/SyncStreamOptions.cs index 74174fd74..1688ed47e 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncStreamOptions.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncStreamOptions.cs @@ -9,201 +9,201 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1.Service -{ - +{ + + /// + /// Fetch a specific Stream. + /// + public class FetchSyncStreamOptions : IOptions + { /// - /// Fetch a specific Stream. - /// - public class FetchSyncStreamOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Stream resource to fetch - /// - public string PathServiceSid { get; } - /// - /// The SID of the Stream resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSyncStreamOptions - /// - /// The SID of the Sync Service with the Sync Stream resource to fetch - /// The SID of the Stream resource to fetch - public FetchSyncStreamOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Sync Service with the Sync Stream resource to fetch + /// + public string PathServiceSid { get; } /// - /// Delete a specific Stream. - /// - public class DeleteSyncStreamOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Stream resource to delete - /// - public string PathServiceSid { get; } - /// - /// The SID of the Stream resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSyncStreamOptions - /// - /// The SID of the Sync Service with the Sync Stream resource to delete - /// The SID of the Stream resource to delete - public DeleteSyncStreamOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Stream resource to fetch + /// + public string PathSid { get; } + /// - /// Create a new Stream. - /// - public class CreateSyncStreamOptions : IOptions - { - /// - /// The SID of the Sync Service to create the new Stream in - /// - public string PathServiceSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// How long, in seconds, before the Stream expires and is deleted - /// - public int? Ttl { get; set; } - - /// - /// Construct a new CreateSyncStreamOptions - /// - /// The SID of the Sync Service to create the new Stream in - public CreateSyncStreamOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSyncStreamOptions + /// + /// The SID of the Sync Service with the Sync Stream resource to fetch + /// The SID of the Stream resource to fetch + public FetchSyncStreamOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + /// - /// Update a specific Stream. - /// - public class UpdateSyncStreamOptions : IOptions - { - /// - /// The SID of the Sync Service with the Sync Stream resource to update - /// - public string PathServiceSid { get; } - /// - /// The SID of the Stream resource to update - /// - public string PathSid { get; } - /// - /// How long, in seconds, before the Stream expires and is deleted - /// - public int? Ttl { get; set; } - - /// - /// Construct a new UpdateSyncStreamOptions - /// - /// The SID of the Sync Service with the Sync Stream resource to update - /// The SID of the Stream resource to update - public UpdateSyncStreamOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Stream. + /// + public class DeleteSyncStreamOptions : IOptions + { /// - /// Retrieve a list of all Streams in a Service Instance. + /// The SID of the Sync Service with the Sync Stream resource to delete /// - public class ReadSyncStreamOptions : ReadOptions - { - /// - /// The SID of the Sync Service with the Stream resources to read - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadSyncStreamOptions - /// - /// The SID of the Sync Service with the Stream resources to read - public ReadSyncStreamOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The SID of the Stream resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSyncStreamOptions + /// + /// The SID of the Sync Service with the Sync Stream resource to delete + /// The SID of the Stream resource to delete + public DeleteSyncStreamOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Create a new Stream. + /// + public class CreateSyncStreamOptions : IOptions + { + /// + /// The SID of the Sync Service to create the new Stream in + /// + public string PathServiceSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// How long, in seconds, before the Stream expires and is deleted + /// + public int? Ttl { get; set; } + + /// + /// Construct a new CreateSyncStreamOptions + /// + /// The SID of the Sync Service to create the new Stream in + public CreateSyncStreamOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } + + /// + /// Update a specific Stream. + /// + public class UpdateSyncStreamOptions : IOptions + { + /// + /// The SID of the Sync Service with the Sync Stream resource to update + /// + public string PathServiceSid { get; } + /// + /// The SID of the Stream resource to update + /// + public string PathSid { get; } + /// + /// How long, in seconds, before the Stream expires and is deleted + /// + public int? Ttl { get; set; } + + /// + /// Construct a new UpdateSyncStreamOptions + /// + /// The SID of the Sync Service with the Sync Stream resource to update + /// The SID of the Stream resource to update + public UpdateSyncStreamOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Streams in a Service Instance. + /// + public class ReadSyncStreamOptions : ReadOptions + { + /// + /// The SID of the Sync Service with the Stream resources to read + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadSyncStreamOptions + /// + /// The SID of the Sync Service with the Stream resources to read + public ReadSyncStreamOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/Service/SyncStreamResource.cs b/src/Twilio/Rest/Sync/V1/Service/SyncStreamResource.cs index 6a7f5c656..74d9b8ac6 100644 --- a/src/Twilio/Rest/Sync/V1/Service/SyncStreamResource.cs +++ b/src/Twilio/Rest/Sync/V1/Service/SyncStreamResource.cs @@ -16,508 +16,508 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1.Service -{ - - public class SyncStreamResource : Resource - { - private static Request BuildFetchRequest(FetchSyncStreamOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Stream. - /// - /// Fetch SyncStream parameters - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Fetch(FetchSyncStreamOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Stream. - /// - /// Fetch SyncStream parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task FetchAsync(FetchSyncStreamOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to fetch - /// The SID of the Stream resource to fetch - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSyncStreamOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to fetch - /// The SID of the Stream resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSyncStreamOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSyncStreamOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Stream. - /// - /// Delete SyncStream parameters - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static bool Delete(DeleteSyncStreamOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Stream. - /// - /// Delete SyncStream parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncStreamOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to delete - /// The SID of the Stream resource to delete - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSyncStreamOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to delete - /// The SID of the Stream resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteSyncStreamOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateSyncStreamOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Stream. - /// - /// Create SyncStream parameters - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Create(CreateSyncStreamOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Stream. - /// - /// Create SyncStream parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task CreateAsync(CreateSyncStreamOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Stream. - /// - /// The SID of the Sync Service to create the new Stream in - /// An application-defined string that uniquely identifies the resource - /// How long, in seconds, before the Stream expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Create(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncStreamOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Stream. - /// - /// The SID of the Sync Service to create the new Stream in - /// An application-defined string that uniquely identifies the resource - /// How long, in seconds, before the Stream expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName = null, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateSyncStreamOptions(pathServiceSid){UniqueName = uniqueName, Ttl = ttl}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSyncStreamOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Stream. - /// - /// Update SyncStream parameters - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Update(UpdateSyncStreamOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Stream. - /// - /// Update SyncStream parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncStreamOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to update - /// The SID of the Stream resource to update - /// How long, in seconds, before the Stream expires and is deleted - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static SyncStreamResource Update(string pathServiceSid, - string pathSid, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncStreamOptions(pathServiceSid, pathSid){Ttl = ttl}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Stream. - /// - /// The SID of the Sync Service with the Sync Stream resource to update - /// The SID of the Stream resource to update - /// How long, in seconds, before the Stream expires and is deleted - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new UpdateSyncStreamOptions(pathServiceSid, pathSid){Ttl = ttl}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSyncStreamOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathServiceSid + "/Streams", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Streams in a Service Instance. - /// - /// Read SyncStream parameters - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static ResourceSet Read(ReadSyncStreamOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("streams", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Streams in a Service Instance. - /// - /// Read SyncStream parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncStreamOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("streams", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Streams in a Service Instance. - /// - /// The SID of the Sync Service with the Stream resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SyncStream - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncStreamOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Streams in a Service Instance. - /// - /// The SID of the Sync Service with the Stream resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SyncStream - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSyncStreamOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("streams", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("streams", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("streams", response.Content); - } - - /// - /// Converts a JSON string into a SyncStreamResource object - /// - /// Raw JSON string - /// SyncStreamResource object represented by the provided JSON - public static SyncStreamResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sync Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The absolute URL of the Message Stream resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Stream's nested resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Message Stream expires - /// - [JsonProperty("date_expires")] - public DateTime? DateExpires { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The Identity of the Stream's creator - /// - [JsonProperty("created_by")] - public string CreatedBy { get; private set; } - - private SyncStreamResource() - { - - } - } +{ + + public class SyncStreamResource : Resource + { + private static Request BuildFetchRequest(FetchSyncStreamOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Stream. + /// + /// Fetch SyncStream parameters + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Fetch(FetchSyncStreamOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Stream. + /// + /// Fetch SyncStream parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task FetchAsync(FetchSyncStreamOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to fetch + /// The SID of the Stream resource to fetch + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSyncStreamOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to fetch + /// The SID of the Stream resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSyncStreamOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSyncStreamOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Stream. + /// + /// Delete SyncStream parameters + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static bool Delete(DeleteSyncStreamOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Stream. + /// + /// Delete SyncStream parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSyncStreamOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to delete + /// The SID of the Stream resource to delete + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSyncStreamOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to delete + /// The SID of the Stream resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteSyncStreamOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateSyncStreamOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Stream. + /// + /// Create SyncStream parameters + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Create(CreateSyncStreamOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Stream. + /// + /// Create SyncStream parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task CreateAsync(CreateSyncStreamOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Stream. + /// + /// The SID of the Sync Service to create the new Stream in + /// An application-defined string that uniquely identifies the resource + /// How long, in seconds, before the Stream expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Create(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncStreamOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Stream. + /// + /// The SID of the Sync Service to create the new Stream in + /// An application-defined string that uniquely identifies the resource + /// How long, in seconds, before the Stream expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName = null, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateSyncStreamOptions(pathServiceSid) { UniqueName = uniqueName, Ttl = ttl }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSyncStreamOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Stream. + /// + /// Update SyncStream parameters + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Update(UpdateSyncStreamOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Stream. + /// + /// Update SyncStream parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSyncStreamOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to update + /// The SID of the Stream resource to update + /// How long, in seconds, before the Stream expires and is deleted + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static SyncStreamResource Update(string pathServiceSid, + string pathSid, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncStreamOptions(pathServiceSid, pathSid) { Ttl = ttl }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Stream. + /// + /// The SID of the Sync Service with the Sync Stream resource to update + /// The SID of the Stream resource to update + /// How long, in seconds, before the Stream expires and is deleted + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new UpdateSyncStreamOptions(pathServiceSid, pathSid) { Ttl = ttl }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSyncStreamOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathServiceSid + "/Streams", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Streams in a Service Instance. + /// + /// Read SyncStream parameters + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static ResourceSet Read(ReadSyncStreamOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("streams", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Streams in a Service Instance. + /// + /// Read SyncStream parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task> ReadAsync(ReadSyncStreamOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("streams", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Streams in a Service Instance. + /// + /// The SID of the Sync Service with the Stream resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SyncStream + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncStreamOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Streams in a Service Instance. + /// + /// The SID of the Sync Service with the Stream resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SyncStream + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSyncStreamOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("streams", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("streams", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("streams", response.Content); + } + + /// + /// Converts a JSON string into a SyncStreamResource object + /// + /// Raw JSON string + /// SyncStreamResource object represented by the provided JSON + public static SyncStreamResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sync Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The absolute URL of the Message Stream resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Stream's nested resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Message Stream expires + /// + [JsonProperty("date_expires")] + public DateTime? DateExpires { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The Identity of the Stream's creator + /// + [JsonProperty("created_by")] + public string CreatedBy { get; private set; } + + private SyncStreamResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/ServiceOptions.cs b/src/Twilio/Rest/Sync/V1/ServiceOptions.cs index 0903118ed..419a8d280 100644 --- a/src/Twilio/Rest/Sync/V1/ServiceOptions.cs +++ b/src/Twilio/Rest/Sync/V1/ServiceOptions.cs @@ -9,255 +9,255 @@ using Twilio.Converters; namespace Twilio.Rest.Sync.V1 -{ - +{ + + /// + /// FetchServiceOptions + /// + public class FetchServiceOptions : IOptions + { /// - /// FetchServiceOptions + /// The SID of the Service resource to fetch /// - public class FetchServiceOptions : IOptions - { - /// - /// The SID of the Service resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The SID of the Service resource to fetch - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteServiceOptions + /// Construct a new FetchServiceOptions /// - public class DeleteServiceOptions : IOptions - { - /// - /// The SID of the Service resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The SID of the Service resource to delete - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Service resource to fetch + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateServiceOptions + /// Generate the necessary parameters /// - public class CreateServiceOptions : IOptions - { - /// - /// A string that you assign to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The URL we should call when Sync objects are manipulated - /// - public Uri WebhookUrl { get; set; } - /// - /// Whether the service instance should call webhook_url when client endpoints connect to Sync - /// - public bool? ReachabilityWebhooksEnabled { get; set; } - /// - /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource - /// - public bool? AclEnabled { get; set; } - /// - /// Whether every endpoint_disconnected event occurs after a configurable delay - /// - public bool? ReachabilityDebouncingEnabled { get; set; } - /// - /// The reachability event delay in milliseconds - /// - public int? ReachabilityDebouncingWindow { get; set; } - /// - /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects - /// - public bool? WebhooksFromRestEnabled { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (ReachabilityWebhooksEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); - } - - if (AclEnabled != null) - { - p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityDebouncingEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityDebouncingEnabled", ReachabilityDebouncingEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityDebouncingWindow != null) - { - p.Add(new KeyValuePair("ReachabilityDebouncingWindow", ReachabilityDebouncingWindow.ToString())); - } - - if (WebhooksFromRestEnabled != null) - { - p.Add(new KeyValuePair("WebhooksFromRestEnabled", WebhooksFromRestEnabled.Value.ToString().ToLower())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteServiceOptions + /// + public class DeleteServiceOptions : IOptions + { /// - /// ReadServiceOptions + /// The SID of the Service resource to delete /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// UpdateServiceOptions + /// Construct a new DeleteServiceOptions /// - public class UpdateServiceOptions : IOptions - { - /// - /// The SID of the Service resource to update - /// - public string PathSid { get; } - /// - /// The URL we should call when Sync objects are manipulated - /// - public Uri WebhookUrl { get; set; } - /// - /// A string that you assign to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// Whether the service instance should call webhook_url when client endpoints connect to Sync - /// - public bool? ReachabilityWebhooksEnabled { get; set; } - /// - /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource - /// - public bool? AclEnabled { get; set; } - /// - /// Whether every endpoint_disconnected event occurs after a configurable delay - /// - public bool? ReachabilityDebouncingEnabled { get; set; } - /// - /// The reachability event delay in milliseconds - /// - public int? ReachabilityDebouncingWindow { get; set; } - /// - /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects - /// - public bool? WebhooksFromRestEnabled { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The SID of the Service resource to update - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ReachabilityWebhooksEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); - } - - if (AclEnabled != null) - { - p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityDebouncingEnabled != null) - { - p.Add(new KeyValuePair("ReachabilityDebouncingEnabled", ReachabilityDebouncingEnabled.Value.ToString().ToLower())); - } - - if (ReachabilityDebouncingWindow != null) - { - p.Add(new KeyValuePair("ReachabilityDebouncingWindow", ReachabilityDebouncingWindow.ToString())); - } - - if (WebhooksFromRestEnabled != null) - { - p.Add(new KeyValuePair("WebhooksFromRestEnabled", WebhooksFromRestEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the Service resource to delete + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateServiceOptions + /// + public class CreateServiceOptions : IOptions + { + /// + /// A string that you assign to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The URL we should call when Sync objects are manipulated + /// + public Uri WebhookUrl { get; set; } + /// + /// Whether the service instance should call webhook_url when client endpoints connect to Sync + /// + public bool? ReachabilityWebhooksEnabled { get; set; } + /// + /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource + /// + public bool? AclEnabled { get; set; } + /// + /// Whether every endpoint_disconnected event occurs after a configurable delay + /// + public bool? ReachabilityDebouncingEnabled { get; set; } + /// + /// The reachability event delay in milliseconds + /// + public int? ReachabilityDebouncingWindow { get; set; } + /// + /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects + /// + public bool? WebhooksFromRestEnabled { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (ReachabilityWebhooksEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); + } + + if (AclEnabled != null) + { + p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityDebouncingEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityDebouncingEnabled", ReachabilityDebouncingEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityDebouncingWindow != null) + { + p.Add(new KeyValuePair("ReachabilityDebouncingWindow", ReachabilityDebouncingWindow.ToString())); + } + + if (WebhooksFromRestEnabled != null) + { + p.Add(new KeyValuePair("WebhooksFromRestEnabled", WebhooksFromRestEnabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// ReadServiceOptions + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateServiceOptions + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The SID of the Service resource to update + /// + public string PathSid { get; } + /// + /// The URL we should call when Sync objects are manipulated + /// + public Uri WebhookUrl { get; set; } + /// + /// A string that you assign to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// Whether the service instance should call webhook_url when client endpoints connect to Sync + /// + public bool? ReachabilityWebhooksEnabled { get; set; } + /// + /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource + /// + public bool? AclEnabled { get; set; } + /// + /// Whether every endpoint_disconnected event occurs after a configurable delay + /// + public bool? ReachabilityDebouncingEnabled { get; set; } + /// + /// The reachability event delay in milliseconds + /// + public int? ReachabilityDebouncingWindow { get; set; } + /// + /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects + /// + public bool? WebhooksFromRestEnabled { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The SID of the Service resource to update + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", Serializers.Url(WebhookUrl))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ReachabilityWebhooksEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityWebhooksEnabled", ReachabilityWebhooksEnabled.Value.ToString().ToLower())); + } + + if (AclEnabled != null) + { + p.Add(new KeyValuePair("AclEnabled", AclEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityDebouncingEnabled != null) + { + p.Add(new KeyValuePair("ReachabilityDebouncingEnabled", ReachabilityDebouncingEnabled.Value.ToString().ToLower())); + } + + if (ReachabilityDebouncingWindow != null) + { + p.Add(new KeyValuePair("ReachabilityDebouncingWindow", ReachabilityDebouncingWindow.ToString())); + } + + if (WebhooksFromRestEnabled != null) + { + p.Add(new KeyValuePair("WebhooksFromRestEnabled", WebhooksFromRestEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Sync/V1/ServiceResource.cs b/src/Twilio/Rest/Sync/V1/ServiceResource.cs index 84435cdb4..10b1ff04b 100644 --- a/src/Twilio/Rest/Sync/V1/ServiceResource.cs +++ b/src/Twilio/Rest/Sync/V1/ServiceResource.cs @@ -16,569 +16,569 @@ using Twilio.Http; namespace Twilio.Rest.Sync.V1 -{ - - public class ServiceResource : Resource - { - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Service resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Sync, - "/v1/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Service resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string that you assign to describe the resource - /// The URL we should call when Sync objects are manipulated - /// Whether the service instance should call webhook_url when client - /// endpoints connect to Sync - /// Whether token identities in the Service must be granted access to Sync objects by using - /// the Permissions resource - /// Whether every endpoint_disconnected event occurs after a configurable - /// delay - /// The reachability event delay in milliseconds - /// Whether the Service instance should call webhook_url when the REST API is - /// used to update Sync objects - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName = null, - Uri webhookUrl = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - bool? reachabilityDebouncingEnabled = null, - int? reachabilityDebouncingWindow = null, - bool? webhooksFromRestEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string that you assign to describe the resource - /// The URL we should call when Sync objects are manipulated - /// Whether the service instance should call webhook_url when client - /// endpoints connect to Sync - /// Whether token identities in the Service must be granted access to Sync objects by using - /// the Permissions resource - /// Whether every endpoint_disconnected event occurs after a configurable - /// delay - /// The reachability event delay in milliseconds - /// Whether the Service instance should call webhook_url when the REST API is - /// used to update Sync objects - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - Uri webhookUrl = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - bool? reachabilityDebouncingEnabled = null, - int? reachabilityDebouncingWindow = null, - bool? webhooksFromRestEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(){FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Sync, - "/v1/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Sync) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Sync, - "/v1/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Service resource to update - /// The URL we should call when Sync objects are manipulated - /// A string that you assign to describe the resource - /// Whether the service instance should call webhook_url when client - /// endpoints connect to Sync - /// Whether token identities in the Service must be granted access to Sync objects by using - /// the Permissions resource - /// Whether every endpoint_disconnected event occurs after a configurable - /// delay - /// The reachability event delay in milliseconds - /// Whether the Service instance should call webhook_url when the REST API is - /// used to update Sync objects - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - Uri webhookUrl = null, - string friendlyName = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - bool? reachabilityDebouncingEnabled = null, - int? reachabilityDebouncingWindow = null, - bool? webhooksFromRestEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Service resource to update - /// The URL we should call when Sync objects are manipulated - /// A string that you assign to describe the resource - /// Whether the service instance should call webhook_url when client - /// endpoints connect to Sync - /// Whether token identities in the Service must be granted access to Sync objects by using - /// the Permissions resource - /// Whether every endpoint_disconnected event occurs after a configurable - /// delay - /// The reachability event delay in milliseconds - /// Whether the Service instance should call webhook_url when the REST API is - /// used to update Sync objects - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - Uri webhookUrl = null, - string friendlyName = null, - bool? reachabilityWebhooksEnabled = null, - bool? aclEnabled = null, - bool? reachabilityDebouncingEnabled = null, - int? reachabilityDebouncingWindow = null, - bool? webhooksFromRestEnabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Service resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URL we call when Sync objects are manipulated - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects - /// - [JsonProperty("webhooks_from_rest_enabled")] - public bool? WebhooksFromRestEnabled { get; private set; } - /// - /// Whether the service instance calls webhook_url when client endpoints connect to Sync - /// - [JsonProperty("reachability_webhooks_enabled")] - public bool? ReachabilityWebhooksEnabled { get; private set; } - /// - /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource - /// - [JsonProperty("acl_enabled")] - public bool? AclEnabled { get; private set; } - /// - /// Whether every endpoint_disconnected event occurs after a configurable delay - /// - [JsonProperty("reachability_debouncing_enabled")] - public bool? ReachabilityDebouncingEnabled { get; private set; } - /// - /// The reachability event delay in milliseconds - /// - [JsonProperty("reachability_debouncing_window")] - public int? ReachabilityDebouncingWindow { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Service resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Sync, + "/v1/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Service resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string that you assign to describe the resource + /// The URL we should call when Sync objects are manipulated + /// Whether the service instance should call webhook_url when client + /// endpoints connect to Sync + /// Whether token identities in the Service must be granted access to Sync objects by using + /// the Permissions resource + /// Whether every endpoint_disconnected event occurs after a configurable + /// delay + /// The reachability event delay in milliseconds + /// Whether the Service instance should call webhook_url when the REST API is + /// used to update Sync objects + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName = null, + Uri webhookUrl = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + bool? reachabilityDebouncingEnabled = null, + int? reachabilityDebouncingWindow = null, + bool? webhooksFromRestEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string that you assign to describe the resource + /// The URL we should call when Sync objects are manipulated + /// Whether the service instance should call webhook_url when client + /// endpoints connect to Sync + /// Whether token identities in the Service must be granted access to Sync objects by using + /// the Permissions resource + /// Whether every endpoint_disconnected event occurs after a configurable + /// delay + /// The reachability event delay in milliseconds + /// Whether the Service instance should call webhook_url when the REST API is + /// used to update Sync objects + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + Uri webhookUrl = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + bool? reachabilityDebouncingEnabled = null, + int? reachabilityDebouncingWindow = null, + bool? webhooksFromRestEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions() { FriendlyName = friendlyName, WebhookUrl = webhookUrl, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Sync, + "/v1/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Sync) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Sync, + "/v1/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Service resource to update + /// The URL we should call when Sync objects are manipulated + /// A string that you assign to describe the resource + /// Whether the service instance should call webhook_url when client + /// endpoints connect to Sync + /// Whether token identities in the Service must be granted access to Sync objects by using + /// the Permissions resource + /// Whether every endpoint_disconnected event occurs after a configurable + /// delay + /// The reachability event delay in milliseconds + /// Whether the Service instance should call webhook_url when the REST API is + /// used to update Sync objects + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + Uri webhookUrl = null, + string friendlyName = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + bool? reachabilityDebouncingEnabled = null, + int? reachabilityDebouncingWindow = null, + bool? webhooksFromRestEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Service resource to update + /// The URL we should call when Sync objects are manipulated + /// A string that you assign to describe the resource + /// Whether the service instance should call webhook_url when client + /// endpoints connect to Sync + /// Whether token identities in the Service must be granted access to Sync objects by using + /// the Permissions resource + /// Whether every endpoint_disconnected event occurs after a configurable + /// delay + /// The reachability event delay in milliseconds + /// Whether the Service instance should call webhook_url when the REST API is + /// used to update Sync objects + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + Uri webhookUrl = null, + string friendlyName = null, + bool? reachabilityWebhooksEnabled = null, + bool? aclEnabled = null, + bool? reachabilityDebouncingEnabled = null, + int? reachabilityDebouncingWindow = null, + bool? webhooksFromRestEnabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { WebhookUrl = webhookUrl, FriendlyName = friendlyName, ReachabilityWebhooksEnabled = reachabilityWebhooksEnabled, AclEnabled = aclEnabled, ReachabilityDebouncingEnabled = reachabilityDebouncingEnabled, ReachabilityDebouncingWindow = reachabilityDebouncingWindow, WebhooksFromRestEnabled = webhooksFromRestEnabled }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Service resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URL we call when Sync objects are manipulated + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// Whether the Service instance should call webhook_url when the REST API is used to update Sync objects + /// + [JsonProperty("webhooks_from_rest_enabled")] + public bool? WebhooksFromRestEnabled { get; private set; } + /// + /// Whether the service instance calls webhook_url when client endpoints connect to Sync + /// + [JsonProperty("reachability_webhooks_enabled")] + public bool? ReachabilityWebhooksEnabled { get; private set; } + /// + /// Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource + /// + [JsonProperty("acl_enabled")] + public bool? AclEnabled { get; private set; } + /// + /// Whether every endpoint_disconnected event occurs after a configurable delay + /// + [JsonProperty("reachability_debouncing_enabled")] + public bool? ReachabilityDebouncingEnabled { get; private set; } + /// + /// The reachability event delay in milliseconds + /// + [JsonProperty("reachability_debouncing_window")] + public int? ReachabilityDebouncingWindow { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityOptions.cs index 025d96f17..e1be97d16 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityOptions.cs @@ -9,221 +9,221 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchActivityOptions + /// + public class FetchActivityOptions : IOptions + { /// - /// FetchActivityOptions - /// - public class FetchActivityOptions : IOptions - { - /// - /// The SID of the Workspace with the Activity resources to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchActivityOptions - /// - /// The SID of the Workspace with the Activity resources to fetch - /// The SID of the resource to fetch - public FetchActivityOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the Activity resources to fetch + /// + public string PathWorkspaceSid { get; } /// - /// UpdateActivityOptions - /// - public class UpdateActivityOptions : IOptions - { - /// - /// The SID of the Workspace with the Activity resources to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Activity resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the Activity resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateActivityOptions - /// - /// The SID of the Workspace with the Activity resources to update - /// The SID of the Activity resource to update - public UpdateActivityOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The SID of the resource to fetch + /// + public string PathSid { get; } + /// - /// DeleteActivityOptions - /// - public class DeleteActivityOptions : IOptions - { - /// - /// The SID of the Workspace with the Activity resources to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Activity resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteActivityOptions - /// - /// The SID of the Workspace with the Activity resources to delete - /// The SID of the Activity resource to delete - public DeleteActivityOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Construct a new FetchActivityOptions + /// + /// The SID of the Workspace with the Activity resources to fetch + /// The SID of the resource to fetch + public FetchActivityOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + /// - /// ReadActivityOptions - /// - public class ReadActivityOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Activity resources to read - /// - public string PathWorkspaceSid { get; } - /// - /// The friendly_name of the Activity resources to read - /// - public string FriendlyName { get; set; } - /// - /// Whether to return activities that are available or unavailable - /// - public string Available { get; set; } - - /// - /// Construct a new ReadActivityOptions - /// - /// The SID of the Workspace with the Activity resources to read - public ReadActivityOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Available != null) - { - p.Add(new KeyValuePair("Available", Available)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateActivityOptions + /// + public class UpdateActivityOptions : IOptions + { /// - /// CreateActivityOptions - /// - public class CreateActivityOptions : IOptions - { - /// - /// The SID of the Workspace that the new Activity belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// A string to describe the Activity resource - /// - public string FriendlyName { get; } - /// - /// Whether the Worker should be eligible to receive a Task when it occupies the Activity - /// - public bool? Available { get; set; } - - /// - /// Construct a new CreateActivityOptions - /// - /// The SID of the Workspace that the new Activity belongs to - /// A string to describe the Activity resource - public CreateActivityOptions(string pathWorkspaceSid, string friendlyName) - { - PathWorkspaceSid = pathWorkspaceSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Available != null) - { - p.Add(new KeyValuePair("Available", Available.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the Workspace with the Activity resources to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Activity resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the Activity resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateActivityOptions + /// + /// The SID of the Workspace with the Activity resources to update + /// The SID of the Activity resource to update + public UpdateActivityOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteActivityOptions + /// + public class DeleteActivityOptions : IOptions + { + /// + /// The SID of the Workspace with the Activity resources to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Activity resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteActivityOptions + /// + /// The SID of the Workspace with the Activity resources to delete + /// The SID of the Activity resource to delete + public DeleteActivityOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadActivityOptions + /// + public class ReadActivityOptions : ReadOptions + { + /// + /// The SID of the Workspace with the Activity resources to read + /// + public string PathWorkspaceSid { get; } + /// + /// The friendly_name of the Activity resources to read + /// + public string FriendlyName { get; set; } + /// + /// Whether to return activities that are available or unavailable + /// + public string Available { get; set; } + + /// + /// Construct a new ReadActivityOptions + /// + /// The SID of the Workspace with the Activity resources to read + public ReadActivityOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Available != null) + { + p.Add(new KeyValuePair("Available", Available)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateActivityOptions + /// + public class CreateActivityOptions : IOptions + { + /// + /// The SID of the Workspace that the new Activity belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// A string to describe the Activity resource + /// + public string FriendlyName { get; } + /// + /// Whether the Worker should be eligible to receive a Task when it occupies the Activity + /// + public bool? Available { get; set; } + + /// + /// Construct a new CreateActivityOptions + /// + /// The SID of the Workspace that the new Activity belongs to + /// A string to describe the Activity resource + public CreateActivityOptions(string pathWorkspaceSid, string friendlyName) + { + PathWorkspaceSid = pathWorkspaceSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Available != null) + { + p.Add(new KeyValuePair("Available", Available.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityResource.cs index b47304a6f..342f00c04 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/ActivityResource.cs @@ -16,513 +16,513 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class ActivityResource : Resource - { - private static Request BuildFetchRequest(FetchActivityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Activity parameters - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Fetch(FetchActivityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Activity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task FetchAsync(FetchActivityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Activity resources to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchActivityOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Activity resources to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchActivityOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateActivityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Activity parameters - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Update(UpdateActivityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Activity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task UpdateAsync(UpdateActivityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the Activity resources to update - /// The SID of the Activity resource to update - /// A string to describe the Activity resource - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Update(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateActivityOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the Activity resources to update - /// The SID of the Activity resource to update - /// A string to describe the Activity resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateActivityOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteActivityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Activity parameters - /// Client to make requests to Twilio - /// A single instance of Activity - public static bool Delete(DeleteActivityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Activity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task DeleteAsync(DeleteActivityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the Activity resources to delete - /// The SID of the Activity resource to delete - /// Client to make requests to Twilio - /// A single instance of Activity - public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteActivityOptions(pathWorkspaceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the Activity resources to delete - /// The SID of the Activity resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteActivityOptions(pathWorkspaceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadActivityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Activity parameters - /// Client to make requests to Twilio - /// A single instance of Activity - public static ResourceSet Read(ReadActivityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("activities", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Activity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task> ReadAsync(ReadActivityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("activities", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Activity resources to read - /// The friendly_name of the Activity resources to read - /// Whether to return activities that are available or unavailable - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Activity - public static ResourceSet Read(string pathWorkspaceSid, - string friendlyName = null, - string available = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadActivityOptions(pathWorkspaceSid){FriendlyName = friendlyName, Available = available, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Activity resources to read - /// The friendly_name of the Activity resources to read - /// Whether to return activities that are available or unavailable - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string friendlyName = null, - string available = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadActivityOptions(pathWorkspaceSid){FriendlyName = friendlyName, Available = available, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("activities", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("activities", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("activities", response.Content); - } - - private static Request BuildCreateRequest(CreateActivityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Activity parameters - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Create(CreateActivityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Activity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task CreateAsync(CreateActivityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new Activity belongs to - /// A string to describe the Activity resource - /// Whether the Worker should be eligible to receive a Task when it occupies the Activity - /// - /// Client to make requests to Twilio - /// A single instance of Activity - public static ActivityResource Create(string pathWorkspaceSid, - string friendlyName, - bool? available = null, - ITwilioRestClient client = null) - { - var options = new CreateActivityOptions(pathWorkspaceSid, friendlyName){Available = available}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new Activity belongs to - /// A string to describe the Activity resource - /// Whether the Worker should be eligible to receive a Task when it occupies the Activity - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Activity - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - string friendlyName, - bool? available = null, - ITwilioRestClient client = null) - { - var options = new CreateActivityOptions(pathWorkspaceSid, friendlyName){Available = available}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ActivityResource object - /// - /// Raw JSON string - /// ActivityResource object represented by the provided JSON - public static ActivityResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Whether the Worker should be eligible to receive a Task when it occupies the Activity - /// - [JsonProperty("available")] - public bool? Available { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the Activity resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Workspace that contains the Activity - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Activity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The links - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ActivityResource() - { - - } - } +{ + + public class ActivityResource : Resource + { + private static Request BuildFetchRequest(FetchActivityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Activity parameters + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Fetch(FetchActivityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Activity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task FetchAsync(FetchActivityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Activity resources to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchActivityOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Activity resources to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchActivityOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateActivityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Activity parameters + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Update(UpdateActivityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Activity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task UpdateAsync(UpdateActivityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the Activity resources to update + /// The SID of the Activity resource to update + /// A string to describe the Activity resource + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Update(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateActivityOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the Activity resources to update + /// The SID of the Activity resource to update + /// A string to describe the Activity resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateActivityOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteActivityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Activity parameters + /// Client to make requests to Twilio + /// A single instance of Activity + public static bool Delete(DeleteActivityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Activity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task DeleteAsync(DeleteActivityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the Activity resources to delete + /// The SID of the Activity resource to delete + /// Client to make requests to Twilio + /// A single instance of Activity + public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteActivityOptions(pathWorkspaceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the Activity resources to delete + /// The SID of the Activity resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteActivityOptions(pathWorkspaceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadActivityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Activity parameters + /// Client to make requests to Twilio + /// A single instance of Activity + public static ResourceSet Read(ReadActivityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("activities", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Activity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task> ReadAsync(ReadActivityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("activities", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Activity resources to read + /// The friendly_name of the Activity resources to read + /// Whether to return activities that are available or unavailable + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Activity + public static ResourceSet Read(string pathWorkspaceSid, + string friendlyName = null, + string available = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadActivityOptions(pathWorkspaceSid) { FriendlyName = friendlyName, Available = available, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Activity resources to read + /// The friendly_name of the Activity resources to read + /// Whether to return activities that are available or unavailable + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string friendlyName = null, + string available = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadActivityOptions(pathWorkspaceSid) { FriendlyName = friendlyName, Available = available, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("activities", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("activities", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("activities", response.Content); + } + + private static Request BuildCreateRequest(CreateActivityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Activities", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Activity parameters + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Create(CreateActivityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Activity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task CreateAsync(CreateActivityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new Activity belongs to + /// A string to describe the Activity resource + /// Whether the Worker should be eligible to receive a Task when it occupies the Activity + /// + /// Client to make requests to Twilio + /// A single instance of Activity + public static ActivityResource Create(string pathWorkspaceSid, + string friendlyName, + bool? available = null, + ITwilioRestClient client = null) + { + var options = new CreateActivityOptions(pathWorkspaceSid, friendlyName) { Available = available }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new Activity belongs to + /// A string to describe the Activity resource + /// Whether the Worker should be eligible to receive a Task when it occupies the Activity + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Activity + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + string friendlyName, + bool? available = null, + ITwilioRestClient client = null) + { + var options = new CreateActivityOptions(pathWorkspaceSid, friendlyName) { Available = available }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ActivityResource object + /// + /// Raw JSON string + /// ActivityResource object represented by the provided JSON + public static ActivityResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Whether the Worker should be eligible to receive a Task when it occupies the Activity + /// + [JsonProperty("available")] + public bool? Available { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the Activity resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Workspace that contains the Activity + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Activity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The links + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ActivityResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/EventOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/EventOptions.cs index 5504e75a6..2a799cd9d 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/EventOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/EventOptions.cs @@ -9,174 +9,174 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchEventOptions + /// + public class FetchEventOptions : IOptions + { /// - /// FetchEventOptions - /// - public class FetchEventOptions : IOptions - { - /// - /// The SID of the Workspace with the Event to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEventOptions - /// - /// The SID of the Workspace with the Event to fetch - /// The SID of the resource to fetch - public FetchEventOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the Event to fetch + /// + public string PathWorkspaceSid { get; } /// - /// ReadEventOptions - /// - public class ReadEventOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Events to read - /// - public string PathWorkspaceSid { get; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// The type of Events to read - /// - public string EventType { get; set; } - /// - /// The period of events to read in minutes - /// - public int? Minutes { get; set; } - /// - /// The SID of the Reservation with the Events to read - /// - public string ReservationSid { get; set; } - /// - /// Only include Events from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// The SID of the TaskQueue with the Events to read - /// - public string TaskQueueSid { get; set; } - /// - /// The SID of the Task with the Events to read - /// - public string TaskSid { get; set; } - /// - /// The SID of the Worker with the Events to read - /// - public string WorkerSid { get; set; } - /// - /// The SID of the Worker with the Events to read - /// - public string WorkflowSid { get; set; } - /// - /// The TaskChannel with the Events to read - /// - public string TaskChannel { get; set; } - /// - /// The unique string that identifies the resource - /// - public string Sid { get; set; } - - /// - /// Construct a new ReadEventOptions - /// - /// The SID of the Workspace with the Events to read - public ReadEventOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (EventType != null) - { - p.Add(new KeyValuePair("EventType", EventType)); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (ReservationSid != null) - { - p.Add(new KeyValuePair("ReservationSid", ReservationSid.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskQueueSid != null) - { - p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); - } - - if (TaskSid != null) - { - p.Add(new KeyValuePair("TaskSid", TaskSid.ToString())); - } - - if (WorkerSid != null) - { - p.Add(new KeyValuePair("WorkerSid", WorkerSid.ToString())); - } - - if (WorkflowSid != null) - { - p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (Sid != null) - { - p.Add(new KeyValuePair("Sid", Sid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The SID of the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEventOptions + /// + /// The SID of the Workspace with the Event to fetch + /// The SID of the resource to fetch + public FetchEventOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadEventOptions + /// + public class ReadEventOptions : ReadOptions + { + /// + /// The SID of the Workspace with the Events to read + /// + public string PathWorkspaceSid { get; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// The type of Events to read + /// + public string EventType { get; set; } + /// + /// The period of events to read in minutes + /// + public int? Minutes { get; set; } + /// + /// The SID of the Reservation with the Events to read + /// + public string ReservationSid { get; set; } + /// + /// Only include Events from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// The SID of the TaskQueue with the Events to read + /// + public string TaskQueueSid { get; set; } + /// + /// The SID of the Task with the Events to read + /// + public string TaskSid { get; set; } + /// + /// The SID of the Worker with the Events to read + /// + public string WorkerSid { get; set; } + /// + /// The SID of the Worker with the Events to read + /// + public string WorkflowSid { get; set; } + /// + /// The TaskChannel with the Events to read + /// + public string TaskChannel { get; set; } + /// + /// The unique string that identifies the resource + /// + public string Sid { get; set; } + + /// + /// Construct a new ReadEventOptions + /// + /// The SID of the Workspace with the Events to read + public ReadEventOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (EventType != null) + { + p.Add(new KeyValuePair("EventType", EventType)); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (ReservationSid != null) + { + p.Add(new KeyValuePair("ReservationSid", ReservationSid.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskQueueSid != null) + { + p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); + } + + if (TaskSid != null) + { + p.Add(new KeyValuePair("TaskSid", TaskSid.ToString())); + } + + if (WorkerSid != null) + { + p.Add(new KeyValuePair("WorkerSid", WorkerSid.ToString())); + } + + if (WorkflowSid != null) + { + p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (Sid != null) + { + p.Add(new KeyValuePair("Sid", Sid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/EventResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/EventResource.cs index 8ef5ff780..612de8690 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/EventResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/EventResource.cs @@ -16,365 +16,365 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class EventResource : Resource - { - private static Request BuildFetchRequest(FetchEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Events/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static EventResource Fetch(FetchEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task FetchAsync(FetchEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Event to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Event - public static EventResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEventOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Event to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEventOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Events", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Event parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("events", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Events to read - /// Only include usage that occurred on or before this date - /// The type of Events to read - /// The period of events to read in minutes - /// The SID of the Reservation with the Events to read - /// Only include Events from on or after this date - /// The SID of the TaskQueue with the Events to read - /// The SID of the Task with the Events to read - /// The SID of the Worker with the Events to read - /// The SID of the Worker with the Events to read - /// The TaskChannel with the Events to read - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Event - public static ResourceSet Read(string pathWorkspaceSid, - DateTime? endDate = null, - string eventType = null, - int? minutes = null, - string reservationSid = null, - DateTime? startDate = null, - string taskQueueSid = null, - string taskSid = null, - string workerSid = null, - string workflowSid = null, - string taskChannel = null, - string sid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathWorkspaceSid){EndDate = endDate, EventType = eventType, Minutes = minutes, ReservationSid = reservationSid, StartDate = startDate, TaskQueueSid = taskQueueSid, TaskSid = taskSid, WorkerSid = workerSid, WorkflowSid = workflowSid, TaskChannel = taskChannel, Sid = sid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Events to read - /// Only include usage that occurred on or before this date - /// The type of Events to read - /// The period of events to read in minutes - /// The SID of the Reservation with the Events to read - /// Only include Events from on or after this date - /// The SID of the TaskQueue with the Events to read - /// The SID of the Task with the Events to read - /// The SID of the Worker with the Events to read - /// The SID of the Worker with the Events to read - /// The TaskChannel with the Events to read - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Event - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - DateTime? endDate = null, - string eventType = null, - int? minutes = null, - string reservationSid = null, - DateTime? startDate = null, - string taskQueueSid = null, - string taskSid = null, - string workerSid = null, - string workflowSid = null, - string taskChannel = null, - string sid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEventOptions(pathWorkspaceSid){EndDate = endDate, EventType = eventType, Minutes = minutes, ReservationSid = reservationSid, StartDate = startDate, TaskQueueSid = taskQueueSid, TaskSid = taskSid, WorkerSid = workerSid, WorkflowSid = workflowSid, TaskChannel = taskChannel, Sid = sid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("events", response.Content); - } - - /// - /// Converts a JSON string into a EventResource object - /// - /// Raw JSON string - /// EventResource object represented by the provided JSON - public static EventResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the resource that triggered the event - /// - [JsonProperty("actor_sid")] - public string ActorSid { get; private set; } - /// - /// The type of resource that triggered the event - /// - [JsonProperty("actor_type")] - public string ActorType { get; private set; } - /// - /// The absolute URL of the resource that triggered the event - /// - [JsonProperty("actor_url")] - public Uri ActorUrl { get; private set; } - /// - /// A description of the event - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// Data about the event - /// - [JsonProperty("event_data")] - public object EventData { get; private set; } - /// - /// The time the event was sent - /// - [JsonProperty("event_date")] - public DateTime? EventDate { get; private set; } - /// - /// The time the event was sent in milliseconds - /// - [JsonProperty("event_date_ms")] - public long? EventDateMs { get; private set; } - /// - /// The identifier for the event - /// - [JsonProperty("event_type")] - public string EventType { get; private set; } - /// - /// The SID of the object the event is most relevant to - /// - [JsonProperty("resource_sid")] - public string ResourceSid { get; private set; } - /// - /// The type of object the event is most relevant to - /// - [JsonProperty("resource_type")] - public string ResourceType { get; private set; } - /// - /// The URL of the resource the event is most relevant to - /// - [JsonProperty("resource_url")] - public Uri ResourceUrl { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Where the Event originated - /// - [JsonProperty("source")] - public string Source { get; private set; } - /// - /// The IP from which the Event originated - /// - [JsonProperty("source_ip_address")] - public string SourceIpAddress { get; private set; } - /// - /// The absolute URL of the Event resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The SID of the Workspace that contains the Event - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - - private EventResource() - { - - } - } +{ + + public class EventResource : Resource + { + private static Request BuildFetchRequest(FetchEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Events/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static EventResource Fetch(FetchEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task FetchAsync(FetchEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Event to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Event + public static EventResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEventOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Event to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEventOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEventOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Events", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(ReadEventOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Event parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(ReadEventOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("events", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Events to read + /// Only include usage that occurred on or before this date + /// The type of Events to read + /// The period of events to read in minutes + /// The SID of the Reservation with the Events to read + /// Only include Events from on or after this date + /// The SID of the TaskQueue with the Events to read + /// The SID of the Task with the Events to read + /// The SID of the Worker with the Events to read + /// The SID of the Worker with the Events to read + /// The TaskChannel with the Events to read + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Event + public static ResourceSet Read(string pathWorkspaceSid, + DateTime? endDate = null, + string eventType = null, + int? minutes = null, + string reservationSid = null, + DateTime? startDate = null, + string taskQueueSid = null, + string taskSid = null, + string workerSid = null, + string workflowSid = null, + string taskChannel = null, + string sid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathWorkspaceSid) { EndDate = endDate, EventType = eventType, Minutes = minutes, ReservationSid = reservationSid, StartDate = startDate, TaskQueueSid = taskQueueSid, TaskSid = taskSid, WorkerSid = workerSid, WorkflowSid = workflowSid, TaskChannel = taskChannel, Sid = sid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Events to read + /// Only include usage that occurred on or before this date + /// The type of Events to read + /// The period of events to read in minutes + /// The SID of the Reservation with the Events to read + /// Only include Events from on or after this date + /// The SID of the TaskQueue with the Events to read + /// The SID of the Task with the Events to read + /// The SID of the Worker with the Events to read + /// The SID of the Worker with the Events to read + /// The TaskChannel with the Events to read + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Event + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + DateTime? endDate = null, + string eventType = null, + int? minutes = null, + string reservationSid = null, + DateTime? startDate = null, + string taskQueueSid = null, + string taskSid = null, + string workerSid = null, + string workflowSid = null, + string taskChannel = null, + string sid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEventOptions(pathWorkspaceSid) { EndDate = endDate, EventType = eventType, Minutes = minutes, ReservationSid = reservationSid, StartDate = startDate, TaskQueueSid = taskQueueSid, TaskSid = taskSid, WorkerSid = workerSid, WorkflowSid = workflowSid, TaskChannel = taskChannel, Sid = sid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("events", response.Content); + } + + /// + /// Converts a JSON string into a EventResource object + /// + /// Raw JSON string + /// EventResource object represented by the provided JSON + public static EventResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the resource that triggered the event + /// + [JsonProperty("actor_sid")] + public string ActorSid { get; private set; } + /// + /// The type of resource that triggered the event + /// + [JsonProperty("actor_type")] + public string ActorType { get; private set; } + /// + /// The absolute URL of the resource that triggered the event + /// + [JsonProperty("actor_url")] + public Uri ActorUrl { get; private set; } + /// + /// A description of the event + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// Data about the event + /// + [JsonProperty("event_data")] + public object EventData { get; private set; } + /// + /// The time the event was sent + /// + [JsonProperty("event_date")] + public DateTime? EventDate { get; private set; } + /// + /// The time the event was sent in milliseconds + /// + [JsonProperty("event_date_ms")] + public long? EventDateMs { get; private set; } + /// + /// The identifier for the event + /// + [JsonProperty("event_type")] + public string EventType { get; private set; } + /// + /// The SID of the object the event is most relevant to + /// + [JsonProperty("resource_sid")] + public string ResourceSid { get; private set; } + /// + /// The type of object the event is most relevant to + /// + [JsonProperty("resource_type")] + public string ResourceType { get; private set; } + /// + /// The URL of the resource the event is most relevant to + /// + [JsonProperty("resource_url")] + public Uri ResourceUrl { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Where the Event originated + /// + [JsonProperty("source")] + public string Source { get; private set; } + /// + /// The IP from which the Event originated + /// + [JsonProperty("source_ip_address")] + public string SourceIpAddress { get; private set; } + /// + /// The absolute URL of the Event resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The SID of the Workspace that contains the Event + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + + private EventResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationOptions.cs index b0b56406e..4f7bcb970 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationOptions.cs @@ -10,636 +10,636 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Task -{ - +{ + + /// + /// ReadReservationOptions + /// + public class ReadReservationOptions : ReadOptions + { /// - /// ReadReservationOptions - /// - public class ReadReservationOptions : ReadOptions - { - /// - /// The SID of the Workspace with the TaskReservation resources to read - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Task resource with the TaskReservation resources to read - /// - public string PathTaskSid { get; } - /// - /// Returns the list of reservations for a task with a specified ReservationStatus - /// - public ReservationResource.StatusEnum ReservationStatus { get; set; } - - /// - /// Construct a new ReadReservationOptions - /// - /// The SID of the Workspace with the TaskReservation resources to read - /// The SID of the reserved Task resource with the TaskReservation resources to read - public ReadReservationOptions(string pathWorkspaceSid, string pathTaskSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskSid = pathTaskSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ReservationStatus != null) - { - p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Workspace with the TaskReservation resources to read + /// + public string PathWorkspaceSid { get; } /// - /// FetchReservationOptions - /// - public class FetchReservationOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskReservation resource to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Task resource with the TaskReservation resource to fetch - /// - public string PathTaskSid { get; } - /// - /// The SID of the TaskReservation resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchReservationOptions - /// - /// The SID of the Workspace with the TaskReservation resource to fetch - /// The SID of the reserved Task resource with the TaskReservation resource to fetch - /// The SID of the TaskReservation resource to fetch - public FetchReservationOptions(string pathWorkspaceSid, string pathTaskSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the reserved Task resource with the TaskReservation resources to read + /// + public string PathTaskSid { get; } /// - /// UpdateReservationOptions - /// - public class UpdateReservationOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskReservation resources to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Task resource with the TaskReservation resources to update - /// - public string PathTaskSid { get; } - /// - /// The SID of the TaskReservation resource to update - /// - public string PathSid { get; } - /// - /// The new status of the reservation - /// - public ReservationResource.StatusEnum ReservationStatus { get; set; } - /// - /// The new worker activity SID if rejecting a reservation - /// - public string WorkerActivitySid { get; set; } - /// - /// The assignment instruction for reservation - /// - public string Instruction { get; set; } - /// - /// The SID of the Activity resource to start after executing a Dequeue instruction - /// - public string DequeuePostWorkActivitySid { get; set; } - /// - /// The Caller ID of the call to the worker when executing a Dequeue instruction - /// - public string DequeueFrom { get; set; } - /// - /// Whether to record both legs of a call when executing a Dequeue instruction - /// - public string DequeueRecord { get; set; } - /// - /// Timeout for call when executing a Dequeue instruction - /// - public int? DequeueTimeout { get; set; } - /// - /// The Contact URI of the worker when executing a Dequeue instruction - /// - public string DequeueTo { get; set; } - /// - /// The Callback URL for completed call event when executing a Dequeue instruction - /// - public Uri DequeueStatusCallbackUrl { get; set; } - /// - /// The Caller ID of the outbound call when executing a Call instruction - /// - public string CallFrom { get; set; } - /// - /// Whether to record both legs of a call when executing a Call instruction - /// - public string CallRecord { get; set; } - /// - /// Timeout for call when executing a Call instruction - /// - public int? CallTimeout { get; set; } - /// - /// The Contact URI of the worker when executing a Call instruction - /// - public string CallTo { get; set; } - /// - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// - public Uri CallUrl { get; set; } - /// - /// The URL to call for the completed call event when executing a Call instruction - /// - public Uri CallStatusCallbackUrl { get; set; } - /// - /// Whether to accept a reservation when executing a Call instruction - /// - public bool? CallAccept { get; set; } - /// - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - public string RedirectCallSid { get; set; } - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - public bool? RedirectAccept { get; set; } - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// - public Uri RedirectUrl { get; set; } - /// - /// The Contact URI of the worker when executing a Conference instruction - /// - public string To { get; set; } - /// - /// The Caller ID of the call to the worker when executing a Conference instruction - /// - public string From { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The call progress events that we will send to status_callback - /// - public List StatusCallbackEvent { get; set; } - /// - /// Timeout for call when executing a Conference instruction - /// - public int? Timeout { get; set; } - /// - /// Whether to record the participant and their conferences - /// - public bool? Record { get; set; } - /// - /// Whether to mute the agent - /// - public bool? Muted { get; set; } - /// - /// Whether to play a notification beep when the participant joins - /// - public string Beep { get; set; } - /// - /// Whether the conference starts when the participant joins the conference - /// - public bool? StartConferenceOnEnter { get; set; } - /// - /// Whether to end the conference when the agent leaves - /// - public bool? EndConferenceOnExit { get; set; } - /// - /// URL that hosts pre-conference hold music - /// - public Uri WaitUrl { get; set; } - /// - /// The HTTP method we should use to call `wait_url` - /// - public Twilio.Http.HttpMethod WaitMethod { get; set; } - /// - /// Whether agents can hear the state of the outbound call - /// - public bool? EarlyMedia { get; set; } - /// - /// The maximum number of agent conference participants - /// - public int? MaxParticipants { get; set; } - /// - /// The callback URL for conference events - /// - public Uri ConferenceStatusCallback { get; set; } - /// - /// HTTP method for requesting `conference_status_callback` URL - /// - public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } - /// - /// The conference status events that we will send to conference_status_callback - /// - public List ConferenceStatusCallbackEvent { get; set; } - /// - /// Whether to record the conference the participant is joining - /// - public string ConferenceRecord { get; set; } - /// - /// How to trim leading and trailing silence from your recorded conference audio files - /// - public string ConferenceTrim { get; set; } - /// - /// Specify `mono` or `dual` recording channels - /// - public string RecordingChannels { get; set; } - /// - /// The URL that we should call using the `recording_status_callback_method` when the recording status changes - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use when we call `recording_status_callback` - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available - /// - public Uri ConferenceRecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use to call `conference_recording_status_callback` - /// - public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } - /// - /// The region where we should mix the conference audio - /// - public string Region { get; set; } - /// - /// The SIP username used for authentication - /// - public string SipAuthUsername { get; set; } - /// - /// The SIP password for authentication - /// - public string SipAuthPassword { get; set; } - /// - /// The Call progress events sent via webhooks as a result of a Dequeue instruction - /// - public List DequeueStatusCallbackEvent { get; set; } - /// - /// The new worker activity SID after executing a Conference instruction - /// - public string PostWorkActivitySid { get; set; } - /// - /// The Supervisor mode when executing the Supervise instruction - /// - public ReservationResource.SupervisorModeEnum SupervisorMode { get; set; } - /// - /// The Supervisor SID/URI when executing the Supervise instruction - /// - public string Supervisor { get; set; } - /// - /// Whether to end the conference when the customer leaves - /// - public bool? EndConferenceOnCustomerExit { get; set; } - /// - /// Whether to play a notification beep when the customer joins - /// - public bool? BeepOnCustomerEntrance { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateReservationOptions - /// - /// The SID of the Workspace with the TaskReservation resources to update - /// The SID of the reserved Task resource with the TaskReservation resources to update - /// - /// The SID of the TaskReservation resource to update - public UpdateReservationOptions(string pathWorkspaceSid, string pathTaskSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskSid = pathTaskSid; - PathSid = pathSid; - StatusCallbackEvent = new List(); - ConferenceStatusCallbackEvent = new List(); - DequeueStatusCallbackEvent = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ReservationStatus != null) - { - p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); - } - - if (WorkerActivitySid != null) - { - p.Add(new KeyValuePair("WorkerActivitySid", WorkerActivitySid.ToString())); - } - - if (Instruction != null) - { - p.Add(new KeyValuePair("Instruction", Instruction)); - } - - if (DequeuePostWorkActivitySid != null) - { - p.Add(new KeyValuePair("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); - } - - if (DequeueFrom != null) - { - p.Add(new KeyValuePair("DequeueFrom", DequeueFrom)); - } - - if (DequeueRecord != null) - { - p.Add(new KeyValuePair("DequeueRecord", DequeueRecord)); - } - - if (DequeueTimeout != null) - { - p.Add(new KeyValuePair("DequeueTimeout", DequeueTimeout.ToString())); - } - - if (DequeueTo != null) - { - p.Add(new KeyValuePair("DequeueTo", DequeueTo)); - } - - if (DequeueStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("DequeueStatusCallbackUrl", Serializers.Url(DequeueStatusCallbackUrl))); - } - - if (CallFrom != null) - { - p.Add(new KeyValuePair("CallFrom", CallFrom)); - } - - if (CallRecord != null) - { - p.Add(new KeyValuePair("CallRecord", CallRecord)); - } - - if (CallTimeout != null) - { - p.Add(new KeyValuePair("CallTimeout", CallTimeout.ToString())); - } - - if (CallTo != null) - { - p.Add(new KeyValuePair("CallTo", CallTo)); - } - - if (CallUrl != null) - { - p.Add(new KeyValuePair("CallUrl", Serializers.Url(CallUrl))); - } - - if (CallStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("CallStatusCallbackUrl", Serializers.Url(CallStatusCallbackUrl))); - } - - if (CallAccept != null) - { - p.Add(new KeyValuePair("CallAccept", CallAccept.Value.ToString().ToLower())); - } - - if (RedirectCallSid != null) - { - p.Add(new KeyValuePair("RedirectCallSid", RedirectCallSid.ToString())); - } - - if (RedirectAccept != null) - { - p.Add(new KeyValuePair("RedirectAccept", RedirectAccept.Value.ToString().ToLower())); - } - - if (RedirectUrl != null) - { - p.Add(new KeyValuePair("RedirectUrl", Serializers.Url(RedirectUrl))); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (StatusCallbackEvent != null) - { - p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop.ToString()))); - } - - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (Record != null) - { - p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); - } - - if (Muted != null) - { - p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); - } - - if (Beep != null) - { - p.Add(new KeyValuePair("Beep", Beep)); - } - - if (StartConferenceOnEnter != null) - { - p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); - } - - if (EndConferenceOnExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); - } - - if (WaitUrl != null) - { - p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); - } - - if (WaitMethod != null) - { - p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); - } - - if (EarlyMedia != null) - { - p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); - } - - if (MaxParticipants != null) - { - p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); - } - - if (ConferenceStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); - } - - if (ConferenceStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); - } - - if (ConferenceStatusCallbackEvent != null) - { - p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop.ToString()))); - } - - if (ConferenceRecord != null) - { - p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); - } - - if (ConferenceTrim != null) - { - p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); - } - - if (RecordingChannels != null) - { - p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); - } - - if (RecordingStatusCallback != null) - { - p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); - } - - if (RecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); - } - - if (ConferenceRecordingStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); - } - - if (ConferenceRecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); - } - - if (Region != null) - { - p.Add(new KeyValuePair("Region", Region)); - } - - if (SipAuthUsername != null) - { - p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); - } - - if (SipAuthPassword != null) - { - p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); - } - - if (DequeueStatusCallbackEvent != null) - { - p.AddRange(DequeueStatusCallbackEvent.Select(prop => new KeyValuePair("DequeueStatusCallbackEvent", prop))); - } - - if (PostWorkActivitySid != null) - { - p.Add(new KeyValuePair("PostWorkActivitySid", PostWorkActivitySid.ToString())); - } - - if (SupervisorMode != null) - { - p.Add(new KeyValuePair("SupervisorMode", SupervisorMode.ToString())); - } - - if (Supervisor != null) - { - p.Add(new KeyValuePair("Supervisor", Supervisor)); - } - - if (EndConferenceOnCustomerExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnCustomerExit", EndConferenceOnCustomerExit.Value.ToString().ToLower())); - } - - if (BeepOnCustomerEntrance != null) - { - p.Add(new KeyValuePair("BeepOnCustomerEntrance", BeepOnCustomerEntrance.Value.ToString().ToLower())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Returns the list of reservations for a task with a specified ReservationStatus + /// + public ReservationResource.StatusEnum ReservationStatus { get; set; } + + /// + /// Construct a new ReadReservationOptions + /// + /// The SID of the Workspace with the TaskReservation resources to read + /// The SID of the reserved Task resource with the TaskReservation resources to read + public ReadReservationOptions(string pathWorkspaceSid, string pathTaskSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskSid = pathTaskSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ReservationStatus != null) + { + p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchReservationOptions + /// + public class FetchReservationOptions : IOptions + { + /// + /// The SID of the Workspace with the TaskReservation resource to fetch + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the reserved Task resource with the TaskReservation resource to fetch + /// + public string PathTaskSid { get; } + /// + /// The SID of the TaskReservation resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchReservationOptions + /// + /// The SID of the Workspace with the TaskReservation resource to fetch + /// The SID of the reserved Task resource with the TaskReservation resource to fetch + /// The SID of the TaskReservation resource to fetch + public FetchReservationOptions(string pathWorkspaceSid, string pathTaskSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateReservationOptions + /// + public class UpdateReservationOptions : IOptions + { + /// + /// The SID of the Workspace with the TaskReservation resources to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the reserved Task resource with the TaskReservation resources to update + /// + public string PathTaskSid { get; } + /// + /// The SID of the TaskReservation resource to update + /// + public string PathSid { get; } + /// + /// The new status of the reservation + /// + public ReservationResource.StatusEnum ReservationStatus { get; set; } + /// + /// The new worker activity SID if rejecting a reservation + /// + public string WorkerActivitySid { get; set; } + /// + /// The assignment instruction for reservation + /// + public string Instruction { get; set; } + /// + /// The SID of the Activity resource to start after executing a Dequeue instruction + /// + public string DequeuePostWorkActivitySid { get; set; } + /// + /// The Caller ID of the call to the worker when executing a Dequeue instruction + /// + public string DequeueFrom { get; set; } + /// + /// Whether to record both legs of a call when executing a Dequeue instruction + /// + public string DequeueRecord { get; set; } + /// + /// Timeout for call when executing a Dequeue instruction + /// + public int? DequeueTimeout { get; set; } + /// + /// The Contact URI of the worker when executing a Dequeue instruction + /// + public string DequeueTo { get; set; } + /// + /// The Callback URL for completed call event when executing a Dequeue instruction + /// + public Uri DequeueStatusCallbackUrl { get; set; } + /// + /// The Caller ID of the outbound call when executing a Call instruction + /// + public string CallFrom { get; set; } + /// + /// Whether to record both legs of a call when executing a Call instruction + /// + public string CallRecord { get; set; } + /// + /// Timeout for call when executing a Call instruction + /// + public int? CallTimeout { get; set; } + /// + /// The Contact URI of the worker when executing a Call instruction + /// + public string CallTo { get; set; } + /// + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// + public Uri CallUrl { get; set; } + /// + /// The URL to call for the completed call event when executing a Call instruction + /// + public Uri CallStatusCallbackUrl { get; set; } + /// + /// Whether to accept a reservation when executing a Call instruction + /// + public bool? CallAccept { get; set; } + /// + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + public string RedirectCallSid { get; set; } + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + public bool? RedirectAccept { get; set; } + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// + public Uri RedirectUrl { get; set; } + /// + /// The Contact URI of the worker when executing a Conference instruction + /// + public string To { get; set; } + /// + /// The Caller ID of the call to the worker when executing a Conference instruction + /// + public string From { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The call progress events that we will send to status_callback + /// + public List StatusCallbackEvent { get; set; } + /// + /// Timeout for call when executing a Conference instruction + /// + public int? Timeout { get; set; } + /// + /// Whether to record the participant and their conferences + /// + public bool? Record { get; set; } + /// + /// Whether to mute the agent + /// + public bool? Muted { get; set; } + /// + /// Whether to play a notification beep when the participant joins + /// + public string Beep { get; set; } + /// + /// Whether the conference starts when the participant joins the conference + /// + public bool? StartConferenceOnEnter { get; set; } + /// + /// Whether to end the conference when the agent leaves + /// + public bool? EndConferenceOnExit { get; set; } + /// + /// URL that hosts pre-conference hold music + /// + public Uri WaitUrl { get; set; } + /// + /// The HTTP method we should use to call `wait_url` + /// + public Twilio.Http.HttpMethod WaitMethod { get; set; } + /// + /// Whether agents can hear the state of the outbound call + /// + public bool? EarlyMedia { get; set; } + /// + /// The maximum number of agent conference participants + /// + public int? MaxParticipants { get; set; } + /// + /// The callback URL for conference events + /// + public Uri ConferenceStatusCallback { get; set; } + /// + /// HTTP method for requesting `conference_status_callback` URL + /// + public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } + /// + /// The conference status events that we will send to conference_status_callback + /// + public List ConferenceStatusCallbackEvent { get; set; } + /// + /// Whether to record the conference the participant is joining + /// + public string ConferenceRecord { get; set; } + /// + /// How to trim leading and trailing silence from your recorded conference audio files + /// + public string ConferenceTrim { get; set; } + /// + /// Specify `mono` or `dual` recording channels + /// + public string RecordingChannels { get; set; } + /// + /// The URL that we should call using the `recording_status_callback_method` when the recording status changes + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use when we call `recording_status_callback` + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available + /// + public Uri ConferenceRecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use to call `conference_recording_status_callback` + /// + public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } + /// + /// The region where we should mix the conference audio + /// + public string Region { get; set; } + /// + /// The SIP username used for authentication + /// + public string SipAuthUsername { get; set; } + /// + /// The SIP password for authentication + /// + public string SipAuthPassword { get; set; } + /// + /// The Call progress events sent via webhooks as a result of a Dequeue instruction + /// + public List DequeueStatusCallbackEvent { get; set; } + /// + /// The new worker activity SID after executing a Conference instruction + /// + public string PostWorkActivitySid { get; set; } + /// + /// The Supervisor mode when executing the Supervise instruction + /// + public ReservationResource.SupervisorModeEnum SupervisorMode { get; set; } + /// + /// The Supervisor SID/URI when executing the Supervise instruction + /// + public string Supervisor { get; set; } + /// + /// Whether to end the conference when the customer leaves + /// + public bool? EndConferenceOnCustomerExit { get; set; } + /// + /// Whether to play a notification beep when the customer joins + /// + public bool? BeepOnCustomerEntrance { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateReservationOptions + /// + /// The SID of the Workspace with the TaskReservation resources to update + /// The SID of the reserved Task resource with the TaskReservation resources to update + /// + /// The SID of the TaskReservation resource to update + public UpdateReservationOptions(string pathWorkspaceSid, string pathTaskSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskSid = pathTaskSid; + PathSid = pathSid; + StatusCallbackEvent = new List(); + ConferenceStatusCallbackEvent = new List(); + DequeueStatusCallbackEvent = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ReservationStatus != null) + { + p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); + } + + if (WorkerActivitySid != null) + { + p.Add(new KeyValuePair("WorkerActivitySid", WorkerActivitySid.ToString())); + } + + if (Instruction != null) + { + p.Add(new KeyValuePair("Instruction", Instruction)); + } + + if (DequeuePostWorkActivitySid != null) + { + p.Add(new KeyValuePair("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); + } + + if (DequeueFrom != null) + { + p.Add(new KeyValuePair("DequeueFrom", DequeueFrom)); + } + + if (DequeueRecord != null) + { + p.Add(new KeyValuePair("DequeueRecord", DequeueRecord)); + } + + if (DequeueTimeout != null) + { + p.Add(new KeyValuePair("DequeueTimeout", DequeueTimeout.ToString())); + } + + if (DequeueTo != null) + { + p.Add(new KeyValuePair("DequeueTo", DequeueTo)); + } + + if (DequeueStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("DequeueStatusCallbackUrl", Serializers.Url(DequeueStatusCallbackUrl))); + } + + if (CallFrom != null) + { + p.Add(new KeyValuePair("CallFrom", CallFrom)); + } + + if (CallRecord != null) + { + p.Add(new KeyValuePair("CallRecord", CallRecord)); + } + + if (CallTimeout != null) + { + p.Add(new KeyValuePair("CallTimeout", CallTimeout.ToString())); + } + + if (CallTo != null) + { + p.Add(new KeyValuePair("CallTo", CallTo)); + } + + if (CallUrl != null) + { + p.Add(new KeyValuePair("CallUrl", Serializers.Url(CallUrl))); + } + + if (CallStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("CallStatusCallbackUrl", Serializers.Url(CallStatusCallbackUrl))); + } + + if (CallAccept != null) + { + p.Add(new KeyValuePair("CallAccept", CallAccept.Value.ToString().ToLower())); + } + + if (RedirectCallSid != null) + { + p.Add(new KeyValuePair("RedirectCallSid", RedirectCallSid.ToString())); + } + + if (RedirectAccept != null) + { + p.Add(new KeyValuePair("RedirectAccept", RedirectAccept.Value.ToString().ToLower())); + } + + if (RedirectUrl != null) + { + p.Add(new KeyValuePair("RedirectUrl", Serializers.Url(RedirectUrl))); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (StatusCallbackEvent != null) + { + p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop.ToString()))); + } + + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (Record != null) + { + p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); + } + + if (Muted != null) + { + p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); + } + + if (Beep != null) + { + p.Add(new KeyValuePair("Beep", Beep)); + } + + if (StartConferenceOnEnter != null) + { + p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); + } + + if (EndConferenceOnExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); + } + + if (WaitUrl != null) + { + p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); + } + + if (WaitMethod != null) + { + p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); + } + + if (EarlyMedia != null) + { + p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); + } + + if (MaxParticipants != null) + { + p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); + } + + if (ConferenceStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); + } + + if (ConferenceStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); + } + + if (ConferenceStatusCallbackEvent != null) + { + p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop.ToString()))); + } + + if (ConferenceRecord != null) + { + p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); + } + + if (ConferenceTrim != null) + { + p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); + } + + if (RecordingChannels != null) + { + p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); + } + + if (RecordingStatusCallback != null) + { + p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); + } + + if (RecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); + } + + if (ConferenceRecordingStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); + } + + if (ConferenceRecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); + } + + if (Region != null) + { + p.Add(new KeyValuePair("Region", Region)); + } + + if (SipAuthUsername != null) + { + p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); + } + + if (SipAuthPassword != null) + { + p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); + } + + if (DequeueStatusCallbackEvent != null) + { + p.AddRange(DequeueStatusCallbackEvent.Select(prop => new KeyValuePair("DequeueStatusCallbackEvent", prop))); + } + + if (PostWorkActivitySid != null) + { + p.Add(new KeyValuePair("PostWorkActivitySid", PostWorkActivitySid.ToString())); + } + + if (SupervisorMode != null) + { + p.Add(new KeyValuePair("SupervisorMode", SupervisorMode.ToString())); + } + + if (Supervisor != null) + { + p.Add(new KeyValuePair("Supervisor", Supervisor)); + } + + if (EndConferenceOnCustomerExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnCustomerExit", EndConferenceOnCustomerExit.Value.ToString().ToLower())); + } + + if (BeepOnCustomerEntrance != null) + { + p.Add(new KeyValuePair("BeepOnCustomerEntrance", BeepOnCustomerEntrance.Value.ToString().ToLower())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationResource.cs index fe8dc7a0e..117f2af92 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationResource.cs @@ -17,696 +17,696 @@ using Twilio.Types; namespace Twilio.Rest.Taskrouter.V1.Workspace.Task -{ - - public class ReservationResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Pending = new StatusEnum("pending"); - public static readonly StatusEnum Accepted = new StatusEnum("accepted"); - public static readonly StatusEnum Rejected = new StatusEnum("rejected"); - public static readonly StatusEnum Timeout = new StatusEnum("timeout"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Rescinded = new StatusEnum("rescinded"); - public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - } - - public sealed class CallStatusEnum : StringEnum - { - private CallStatusEnum(string value) : base(value) {} - public CallStatusEnum() {} - public static implicit operator CallStatusEnum(string value) - { - return new CallStatusEnum(value); - } - - public static readonly CallStatusEnum Initiated = new CallStatusEnum("initiated"); - public static readonly CallStatusEnum Ringing = new CallStatusEnum("ringing"); - public static readonly CallStatusEnum Answered = new CallStatusEnum("answered"); - public static readonly CallStatusEnum Completed = new CallStatusEnum("completed"); - } - - public sealed class ConferenceEventEnum : StringEnum - { - private ConferenceEventEnum(string value) : base(value) {} - public ConferenceEventEnum() {} - public static implicit operator ConferenceEventEnum(string value) - { - return new ConferenceEventEnum(value); - } - - public static readonly ConferenceEventEnum Start = new ConferenceEventEnum("start"); - public static readonly ConferenceEventEnum End = new ConferenceEventEnum("end"); - public static readonly ConferenceEventEnum Join = new ConferenceEventEnum("join"); - public static readonly ConferenceEventEnum Leave = new ConferenceEventEnum("leave"); - public static readonly ConferenceEventEnum Mute = new ConferenceEventEnum("mute"); - public static readonly ConferenceEventEnum Hold = new ConferenceEventEnum("hold"); - public static readonly ConferenceEventEnum Speaker = new ConferenceEventEnum("speaker"); - } - - public sealed class SupervisorModeEnum : StringEnum - { - private SupervisorModeEnum(string value) : base(value) {} - public SupervisorModeEnum() {} - public static implicit operator SupervisorModeEnum(string value) - { - return new SupervisorModeEnum(value); - } - - public static readonly SupervisorModeEnum Monitor = new SupervisorModeEnum("monitor"); - public static readonly SupervisorModeEnum Whisper = new SupervisorModeEnum("whisper"); - public static readonly SupervisorModeEnum Barge = new SupervisorModeEnum("barge"); - } - - private static Request BuildReadRequest(ReadReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ResourceSet Read(ReadReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("reservations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task> ReadAsync(ReadReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("reservations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the TaskReservation resources to read - /// The SID of the reserved Task resource with the TaskReservation resources to read - /// Returns the list of reservations for a task with a specified ReservationStatus - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ResourceSet Read(string pathWorkspaceSid, - string pathTaskSid, - ReservationResource.StatusEnum reservationStatus = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadReservationOptions(pathWorkspaceSid, pathTaskSid){ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the TaskReservation resources to read - /// The SID of the reserved Task resource with the TaskReservation resources to read - /// Returns the list of reservations for a task with a specified ReservationStatus - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string pathTaskSid, - ReservationResource.StatusEnum reservationStatus = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadReservationOptions(pathWorkspaceSid, pathTaskSid){ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - private static Request BuildFetchRequest(FetchReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Fetch(FetchReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task FetchAsync(FetchReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the TaskReservation resource to fetch - /// The SID of the reserved Task resource with the TaskReservation resource to fetch - /// The SID of the TaskReservation resource to fetch - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Fetch(string pathWorkspaceSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the TaskReservation resource to fetch - /// The SID of the reserved Task resource with the TaskReservation resource to fetch - /// The SID of the TaskReservation resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathTaskSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Update(UpdateReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the TaskReservation resources to update - /// The SID of the reserved Task resource with the TaskReservation resources to update - /// - /// The SID of the TaskReservation resource to update - /// The new status of the reservation - /// The new worker activity SID if rejecting a reservation - /// The assignment instruction for reservation - /// The SID of the Activity resource to start after executing a Dequeue - /// instruction - /// The Caller ID of the call to the worker when executing a Dequeue instruction - /// Whether to record both legs of a call when executing a Dequeue instruction - /// Timeout for call when executing a Dequeue instruction - /// The Contact URI of the worker when executing a Dequeue instruction - /// The Callback URL for completed call event when executing a Dequeue - /// instruction - /// The Caller ID of the outbound call when executing a Call instruction - /// Whether to record both legs of a call when executing a Call instruction - /// Timeout for call when executing a Call instruction - /// The Contact URI of the worker when executing a Call instruction - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// The URL to call for the completed call event when executing a Call - /// instruction - /// Whether to accept a reservation when executing a Call instruction - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// The Contact URI of the worker when executing a Conference instruction - /// The Caller ID of the call to the worker when executing a Conference instruction - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The call progress events that we will send to status_callback - /// Timeout for call when executing a Conference instruction - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the agent leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference status events that we will send to - /// conference_status_callback - /// Whether to record the conference the participant is joining - /// How to trim leading and trailing silence from your recorded conference audio files - /// - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The region where we should mix the conference audio - /// The SIP username used for authentication - /// The SIP password for authentication - /// The Call progress events sent via webhooks as a result of a Dequeue - /// instruction - /// The new worker activity SID after executing a Conference instruction - /// The Supervisor mode when executing the Supervise instruction - /// The Supervisor SID/URI when executing the Supervise instruction - /// Whether to end the conference when the customer leaves - /// Whether to play a notification beep when the customer joins - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Update(string pathWorkspaceSid, - string pathTaskSid, - string pathSid, - ReservationResource.StatusEnum reservationStatus = null, - string workerActivitySid = null, - string instruction = null, - string dequeuePostWorkActivitySid = null, - string dequeueFrom = null, - string dequeueRecord = null, - int? dequeueTimeout = null, - string dequeueTo = null, - Uri dequeueStatusCallbackUrl = null, - string callFrom = null, - string callRecord = null, - int? callTimeout = null, - string callTo = null, - Uri callUrl = null, - Uri callStatusCallbackUrl = null, - bool? callAccept = null, - string redirectCallSid = null, - bool? redirectAccept = null, - Uri redirectUrl = null, - string to = null, - string from = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string conferenceRecord = null, - string conferenceTrim = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - string region = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - List dequeueStatusCallbackEvent = null, - string postWorkActivitySid = null, - ReservationResource.SupervisorModeEnum supervisorMode = null, - string supervisor = null, - bool? endConferenceOnCustomerExit = null, - bool? beepOnCustomerEntrance = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid){ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, SupervisorMode = supervisorMode, Supervisor = supervisor, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the TaskReservation resources to update - /// The SID of the reserved Task resource with the TaskReservation resources to update - /// - /// The SID of the TaskReservation resource to update - /// The new status of the reservation - /// The new worker activity SID if rejecting a reservation - /// The assignment instruction for reservation - /// The SID of the Activity resource to start after executing a Dequeue - /// instruction - /// The Caller ID of the call to the worker when executing a Dequeue instruction - /// Whether to record both legs of a call when executing a Dequeue instruction - /// Timeout for call when executing a Dequeue instruction - /// The Contact URI of the worker when executing a Dequeue instruction - /// The Callback URL for completed call event when executing a Dequeue - /// instruction - /// The Caller ID of the outbound call when executing a Call instruction - /// Whether to record both legs of a call when executing a Call instruction - /// Timeout for call when executing a Call instruction - /// The Contact URI of the worker when executing a Call instruction - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// The URL to call for the completed call event when executing a Call - /// instruction - /// Whether to accept a reservation when executing a Call instruction - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// The Contact URI of the worker when executing a Conference instruction - /// The Caller ID of the call to the worker when executing a Conference instruction - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The call progress events that we will send to status_callback - /// Timeout for call when executing a Conference instruction - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the agent leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference status events that we will send to - /// conference_status_callback - /// Whether to record the conference the participant is joining - /// How to trim leading and trailing silence from your recorded conference audio files - /// - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The region where we should mix the conference audio - /// The SIP username used for authentication - /// The SIP password for authentication - /// The Call progress events sent via webhooks as a result of a Dequeue - /// instruction - /// The new worker activity SID after executing a Conference instruction - /// The Supervisor mode when executing the Supervise instruction - /// The Supervisor SID/URI when executing the Supervise instruction - /// Whether to end the conference when the customer leaves - /// Whether to play a notification beep when the customer joins - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathTaskSid, - string pathSid, - ReservationResource.StatusEnum reservationStatus = null, - string workerActivitySid = null, - string instruction = null, - string dequeuePostWorkActivitySid = null, - string dequeueFrom = null, - string dequeueRecord = null, - int? dequeueTimeout = null, - string dequeueTo = null, - Uri dequeueStatusCallbackUrl = null, - string callFrom = null, - string callRecord = null, - int? callTimeout = null, - string callTo = null, - Uri callUrl = null, - Uri callStatusCallbackUrl = null, - bool? callAccept = null, - string redirectCallSid = null, - bool? redirectAccept = null, - Uri redirectUrl = null, - string to = null, - string from = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string conferenceRecord = null, - string conferenceTrim = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - string region = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - List dequeueStatusCallbackEvent = null, - string postWorkActivitySid = null, - ReservationResource.SupervisorModeEnum supervisorMode = null, - string supervisor = null, - bool? endConferenceOnCustomerExit = null, - bool? beepOnCustomerEntrance = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid){ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, SupervisorMode = supervisorMode, Supervisor = supervisor, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ReservationResource object - /// - /// Raw JSON string - /// ReservationResource object represented by the provided JSON - public static ReservationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The current status of the reservation - /// - [JsonProperty("reservation_status")] - [JsonConverter(typeof(StringEnumConverter))] - public ReservationResource.StatusEnum ReservationStatus { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the reserved Task resource - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The friendly_name of the Worker that is reserved - /// - [JsonProperty("worker_name")] - public string WorkerName { get; private set; } - /// - /// The SID of the reserved Worker resource - /// - [JsonProperty("worker_sid")] - public string WorkerSid { get; private set; } - /// - /// The SID of the Workspace that this task is contained within. - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the TaskReservation reservation - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ReservationResource() - { - - } - } +{ + + public class ReservationResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Pending = new StatusEnum("pending"); + public static readonly StatusEnum Accepted = new StatusEnum("accepted"); + public static readonly StatusEnum Rejected = new StatusEnum("rejected"); + public static readonly StatusEnum Timeout = new StatusEnum("timeout"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Rescinded = new StatusEnum("rescinded"); + public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + } + + public sealed class CallStatusEnum : StringEnum + { + private CallStatusEnum(string value) : base(value) { } + public CallStatusEnum() { } + public static implicit operator CallStatusEnum(string value) + { + return new CallStatusEnum(value); + } + + public static readonly CallStatusEnum Initiated = new CallStatusEnum("initiated"); + public static readonly CallStatusEnum Ringing = new CallStatusEnum("ringing"); + public static readonly CallStatusEnum Answered = new CallStatusEnum("answered"); + public static readonly CallStatusEnum Completed = new CallStatusEnum("completed"); + } + + public sealed class ConferenceEventEnum : StringEnum + { + private ConferenceEventEnum(string value) : base(value) { } + public ConferenceEventEnum() { } + public static implicit operator ConferenceEventEnum(string value) + { + return new ConferenceEventEnum(value); + } + + public static readonly ConferenceEventEnum Start = new ConferenceEventEnum("start"); + public static readonly ConferenceEventEnum End = new ConferenceEventEnum("end"); + public static readonly ConferenceEventEnum Join = new ConferenceEventEnum("join"); + public static readonly ConferenceEventEnum Leave = new ConferenceEventEnum("leave"); + public static readonly ConferenceEventEnum Mute = new ConferenceEventEnum("mute"); + public static readonly ConferenceEventEnum Hold = new ConferenceEventEnum("hold"); + public static readonly ConferenceEventEnum Speaker = new ConferenceEventEnum("speaker"); + } + + public sealed class SupervisorModeEnum : StringEnum + { + private SupervisorModeEnum(string value) : base(value) { } + public SupervisorModeEnum() { } + public static implicit operator SupervisorModeEnum(string value) + { + return new SupervisorModeEnum(value); + } + + public static readonly SupervisorModeEnum Monitor = new SupervisorModeEnum("monitor"); + public static readonly SupervisorModeEnum Whisper = new SupervisorModeEnum("whisper"); + public static readonly SupervisorModeEnum Barge = new SupervisorModeEnum("barge"); + } + + private static Request BuildReadRequest(ReadReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ResourceSet Read(ReadReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("reservations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task> ReadAsync(ReadReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("reservations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the TaskReservation resources to read + /// The SID of the reserved Task resource with the TaskReservation resources to read + /// Returns the list of reservations for a task with a specified ReservationStatus + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ResourceSet Read(string pathWorkspaceSid, + string pathTaskSid, + ReservationResource.StatusEnum reservationStatus = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadReservationOptions(pathWorkspaceSid, pathTaskSid) { ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the TaskReservation resources to read + /// The SID of the reserved Task resource with the TaskReservation resources to read + /// Returns the list of reservations for a task with a specified ReservationStatus + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string pathTaskSid, + ReservationResource.StatusEnum reservationStatus = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadReservationOptions(pathWorkspaceSid, pathTaskSid) { ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + private static Request BuildFetchRequest(FetchReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Fetch(FetchReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task FetchAsync(FetchReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the TaskReservation resource to fetch + /// The SID of the reserved Task resource with the TaskReservation resource to fetch + /// The SID of the TaskReservation resource to fetch + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Fetch(string pathWorkspaceSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the TaskReservation resource to fetch + /// The SID of the reserved Task resource with the TaskReservation resource to fetch + /// The SID of the TaskReservation resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathTaskSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathTaskSid + "/Reservations/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Update(UpdateReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the TaskReservation resources to update + /// The SID of the reserved Task resource with the TaskReservation resources to update + /// + /// The SID of the TaskReservation resource to update + /// The new status of the reservation + /// The new worker activity SID if rejecting a reservation + /// The assignment instruction for reservation + /// The SID of the Activity resource to start after executing a Dequeue + /// instruction + /// The Caller ID of the call to the worker when executing a Dequeue instruction + /// Whether to record both legs of a call when executing a Dequeue instruction + /// Timeout for call when executing a Dequeue instruction + /// The Contact URI of the worker when executing a Dequeue instruction + /// The Callback URL for completed call event when executing a Dequeue + /// instruction + /// The Caller ID of the outbound call when executing a Call instruction + /// Whether to record both legs of a call when executing a Call instruction + /// Timeout for call when executing a Call instruction + /// The Contact URI of the worker when executing a Call instruction + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// The URL to call for the completed call event when executing a Call + /// instruction + /// Whether to accept a reservation when executing a Call instruction + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// The Contact URI of the worker when executing a Conference instruction + /// The Caller ID of the call to the worker when executing a Conference instruction + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The call progress events that we will send to status_callback + /// Timeout for call when executing a Conference instruction + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the agent leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference status events that we will send to + /// conference_status_callback + /// Whether to record the conference the participant is joining + /// How to trim leading and trailing silence from your recorded conference audio files + /// + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The region where we should mix the conference audio + /// The SIP username used for authentication + /// The SIP password for authentication + /// The Call progress events sent via webhooks as a result of a Dequeue + /// instruction + /// The new worker activity SID after executing a Conference instruction + /// The Supervisor mode when executing the Supervise instruction + /// The Supervisor SID/URI when executing the Supervise instruction + /// Whether to end the conference when the customer leaves + /// Whether to play a notification beep when the customer joins + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Update(string pathWorkspaceSid, + string pathTaskSid, + string pathSid, + ReservationResource.StatusEnum reservationStatus = null, + string workerActivitySid = null, + string instruction = null, + string dequeuePostWorkActivitySid = null, + string dequeueFrom = null, + string dequeueRecord = null, + int? dequeueTimeout = null, + string dequeueTo = null, + Uri dequeueStatusCallbackUrl = null, + string callFrom = null, + string callRecord = null, + int? callTimeout = null, + string callTo = null, + Uri callUrl = null, + Uri callStatusCallbackUrl = null, + bool? callAccept = null, + string redirectCallSid = null, + bool? redirectAccept = null, + Uri redirectUrl = null, + string to = null, + string from = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string conferenceRecord = null, + string conferenceTrim = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + string region = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + List dequeueStatusCallbackEvent = null, + string postWorkActivitySid = null, + ReservationResource.SupervisorModeEnum supervisorMode = null, + string supervisor = null, + bool? endConferenceOnCustomerExit = null, + bool? beepOnCustomerEntrance = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid) { ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, SupervisorMode = supervisorMode, Supervisor = supervisor, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the TaskReservation resources to update + /// The SID of the reserved Task resource with the TaskReservation resources to update + /// + /// The SID of the TaskReservation resource to update + /// The new status of the reservation + /// The new worker activity SID if rejecting a reservation + /// The assignment instruction for reservation + /// The SID of the Activity resource to start after executing a Dequeue + /// instruction + /// The Caller ID of the call to the worker when executing a Dequeue instruction + /// Whether to record both legs of a call when executing a Dequeue instruction + /// Timeout for call when executing a Dequeue instruction + /// The Contact URI of the worker when executing a Dequeue instruction + /// The Callback URL for completed call event when executing a Dequeue + /// instruction + /// The Caller ID of the outbound call when executing a Call instruction + /// Whether to record both legs of a call when executing a Call instruction + /// Timeout for call when executing a Call instruction + /// The Contact URI of the worker when executing a Call instruction + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// The URL to call for the completed call event when executing a Call + /// instruction + /// Whether to accept a reservation when executing a Call instruction + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// The Contact URI of the worker when executing a Conference instruction + /// The Caller ID of the call to the worker when executing a Conference instruction + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The call progress events that we will send to status_callback + /// Timeout for call when executing a Conference instruction + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the agent leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference status events that we will send to + /// conference_status_callback + /// Whether to record the conference the participant is joining + /// How to trim leading and trailing silence from your recorded conference audio files + /// + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The region where we should mix the conference audio + /// The SIP username used for authentication + /// The SIP password for authentication + /// The Call progress events sent via webhooks as a result of a Dequeue + /// instruction + /// The new worker activity SID after executing a Conference instruction + /// The Supervisor mode when executing the Supervise instruction + /// The Supervisor SID/URI when executing the Supervise instruction + /// Whether to end the conference when the customer leaves + /// Whether to play a notification beep when the customer joins + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathTaskSid, + string pathSid, + ReservationResource.StatusEnum reservationStatus = null, + string workerActivitySid = null, + string instruction = null, + string dequeuePostWorkActivitySid = null, + string dequeueFrom = null, + string dequeueRecord = null, + int? dequeueTimeout = null, + string dequeueTo = null, + Uri dequeueStatusCallbackUrl = null, + string callFrom = null, + string callRecord = null, + int? callTimeout = null, + string callTo = null, + Uri callUrl = null, + Uri callStatusCallbackUrl = null, + bool? callAccept = null, + string redirectCallSid = null, + bool? redirectAccept = null, + Uri redirectUrl = null, + string to = null, + string from = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string conferenceRecord = null, + string conferenceTrim = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + string region = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + List dequeueStatusCallbackEvent = null, + string postWorkActivitySid = null, + ReservationResource.SupervisorModeEnum supervisorMode = null, + string supervisor = null, + bool? endConferenceOnCustomerExit = null, + bool? beepOnCustomerEntrance = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateReservationOptions(pathWorkspaceSid, pathTaskSid, pathSid) { ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, SupervisorMode = supervisorMode, Supervisor = supervisor, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ReservationResource object + /// + /// Raw JSON string + /// ReservationResource object represented by the provided JSON + public static ReservationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The current status of the reservation + /// + [JsonProperty("reservation_status")] + [JsonConverter(typeof(StringEnumConverter))] + public ReservationResource.StatusEnum ReservationStatus { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the reserved Task resource + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The friendly_name of the Worker that is reserved + /// + [JsonProperty("worker_name")] + public string WorkerName { get; private set; } + /// + /// The SID of the reserved Worker resource + /// + [JsonProperty("worker_sid")] + public string WorkerSid { get; private set; } + /// + /// The SID of the Workspace that this task is contained within. + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the TaskReservation reservation + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ReservationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelOptions.cs index bd4d00678..0981bce2c 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelOptions.cs @@ -9,223 +9,223 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchTaskChannelOptions + /// + public class FetchTaskChannelOptions : IOptions + { /// - /// FetchTaskChannelOptions - /// - public class FetchTaskChannelOptions : IOptions - { - /// - /// The SID of the Workspace with the Task Channel to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Task Channel resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTaskChannelOptions - /// - /// The SID of the Workspace with the Task Channel to fetch - /// The SID of the Task Channel resource to fetch - public FetchTaskChannelOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the Task Channel to fetch + /// + public string PathWorkspaceSid { get; } /// - /// ReadTaskChannelOptions + /// The SID of the Task Channel resource to fetch /// - public class ReadTaskChannelOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Task Channel to read - /// - public string PathWorkspaceSid { get; } - - /// - /// Construct a new ReadTaskChannelOptions - /// - /// The SID of the Workspace with the Task Channel to read - public ReadTaskChannelOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// UpdateTaskChannelOptions - /// - public class UpdateTaskChannelOptions : IOptions - { - /// - /// The SID of the Workspace with the Task Channel to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Task Channel resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the Task Channel resource - /// - public string FriendlyName { get; set; } - /// - /// Whether the TaskChannel should prioritize Workers that have been idle - /// - public bool? ChannelOptimizedRouting { get; set; } - - /// - /// Construct a new UpdateTaskChannelOptions - /// - /// The SID of the Workspace with the Task Channel to update - /// The SID of the Task Channel resource to update - public UpdateTaskChannelOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ChannelOptimizedRouting != null) - { - p.Add(new KeyValuePair("ChannelOptimizedRouting", ChannelOptimizedRouting.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Construct a new FetchTaskChannelOptions + /// + /// The SID of the Workspace with the Task Channel to fetch + /// The SID of the Task Channel resource to fetch + public FetchTaskChannelOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + /// - /// DeleteTaskChannelOptions - /// - public class DeleteTaskChannelOptions : IOptions - { - /// - /// The SID of the Workspace with the Task Channel to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Task Channel resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTaskChannelOptions - /// - /// The SID of the Workspace with the Task Channel to delete - /// The SID of the Task Channel resource to delete - public DeleteTaskChannelOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadTaskChannelOptions + /// + public class ReadTaskChannelOptions : ReadOptions + { /// - /// CreateTaskChannelOptions - /// - public class CreateTaskChannelOptions : IOptions - { - /// - /// The SID of the Workspace that the new Task Channel belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// A string to describe the Task Channel resource - /// - public string FriendlyName { get; } - /// - /// An application-defined string that uniquely identifies the Task Channel - /// - public string UniqueName { get; } - /// - /// Whether the Task Channel should prioritize Workers that have been idle - /// - public bool? ChannelOptimizedRouting { get; set; } - - /// - /// Construct a new CreateTaskChannelOptions - /// - /// The SID of the Workspace that the new Task Channel belongs to - /// A string to describe the Task Channel resource - /// An application-defined string that uniquely identifies the Task Channel - public CreateTaskChannelOptions(string pathWorkspaceSid, string friendlyName, string uniqueName) - { - PathWorkspaceSid = pathWorkspaceSid; - FriendlyName = friendlyName; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (ChannelOptimizedRouting != null) - { - p.Add(new KeyValuePair("ChannelOptimizedRouting", ChannelOptimizedRouting.Value.ToString().ToLower())); - } - - return p; - } - } + /// The SID of the Workspace with the Task Channel to read + /// + public string PathWorkspaceSid { get; } + + /// + /// Construct a new ReadTaskChannelOptions + /// + /// The SID of the Workspace with the Task Channel to read + public ReadTaskChannelOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateTaskChannelOptions + /// + public class UpdateTaskChannelOptions : IOptions + { + /// + /// The SID of the Workspace with the Task Channel to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Task Channel resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the Task Channel resource + /// + public string FriendlyName { get; set; } + /// + /// Whether the TaskChannel should prioritize Workers that have been idle + /// + public bool? ChannelOptimizedRouting { get; set; } + + /// + /// Construct a new UpdateTaskChannelOptions + /// + /// The SID of the Workspace with the Task Channel to update + /// The SID of the Task Channel resource to update + public UpdateTaskChannelOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ChannelOptimizedRouting != null) + { + p.Add(new KeyValuePair("ChannelOptimizedRouting", ChannelOptimizedRouting.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// DeleteTaskChannelOptions + /// + public class DeleteTaskChannelOptions : IOptions + { + /// + /// The SID of the Workspace with the Task Channel to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Task Channel resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTaskChannelOptions + /// + /// The SID of the Workspace with the Task Channel to delete + /// The SID of the Task Channel resource to delete + public DeleteTaskChannelOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateTaskChannelOptions + /// + public class CreateTaskChannelOptions : IOptions + { + /// + /// The SID of the Workspace that the new Task Channel belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// A string to describe the Task Channel resource + /// + public string FriendlyName { get; } + /// + /// An application-defined string that uniquely identifies the Task Channel + /// + public string UniqueName { get; } + /// + /// Whether the Task Channel should prioritize Workers that have been idle + /// + public bool? ChannelOptimizedRouting { get; set; } + + /// + /// Construct a new CreateTaskChannelOptions + /// + /// The SID of the Workspace that the new Task Channel belongs to + /// A string to describe the Task Channel resource + /// An application-defined string that uniquely identifies the Task Channel + public CreateTaskChannelOptions(string pathWorkspaceSid, string friendlyName, string uniqueName) + { + PathWorkspaceSid = pathWorkspaceSid; + FriendlyName = friendlyName; + UniqueName = uniqueName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (ChannelOptimizedRouting != null) + { + p.Add(new KeyValuePair("ChannelOptimizedRouting", ChannelOptimizedRouting.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelResource.cs index 729aa0a92..65a6f432d 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskChannelResource.cs @@ -16,520 +16,520 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class TaskChannelResource : Resource - { - private static Request BuildFetchRequest(FetchTaskChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskChannel parameters - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Fetch(FetchTaskChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Task Channel to fetch - /// The SID of the Task Channel resource to fetch - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTaskChannelOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Task Channel to fetch - /// The SID of the Task Channel resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskChannelOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTaskChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read TaskChannel parameters - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static ResourceSet Read(ReadTaskChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read TaskChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Task Channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static ResourceSet Read(string pathWorkspaceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskChannelOptions(pathWorkspaceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Task Channel to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskChannelOptions(pathWorkspaceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildUpdateRequest(UpdateTaskChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update TaskChannel parameters - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Update(UpdateTaskChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update TaskChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the Task Channel to update - /// The SID of the Task Channel resource to update - /// A string to describe the Task Channel resource - /// Whether the TaskChannel should prioritize Workers that have been idle - /// - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Update(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - bool? channelOptimizedRouting = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskChannelOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, ChannelOptimizedRouting = channelOptimizedRouting}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the Task Channel to update - /// The SID of the Task Channel resource to update - /// A string to describe the Task Channel resource - /// Whether the TaskChannel should prioritize Workers that have been idle - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - bool? channelOptimizedRouting = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskChannelOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, ChannelOptimizedRouting = channelOptimizedRouting}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTaskChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete TaskChannel parameters - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static bool Delete(DeleteTaskChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete TaskChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the Task Channel to delete - /// The SID of the Task Channel resource to delete - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTaskChannelOptions(pathWorkspaceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the Task Channel to delete - /// The SID of the Task Channel resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTaskChannelOptions(pathWorkspaceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateTaskChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create TaskChannel parameters - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Create(CreateTaskChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create TaskChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task CreateAsync(CreateTaskChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new Task Channel belongs to - /// A string to describe the Task Channel resource - /// An application-defined string that uniquely identifies the Task Channel - /// Whether the Task Channel should prioritize Workers that have been idle - /// - /// Client to make requests to Twilio - /// A single instance of TaskChannel - public static TaskChannelResource Create(string pathWorkspaceSid, - string friendlyName, - string uniqueName, - bool? channelOptimizedRouting = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskChannelOptions(pathWorkspaceSid, friendlyName, uniqueName){ChannelOptimizedRouting = channelOptimizedRouting}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new Task Channel belongs to - /// A string to describe the Task Channel resource - /// An application-defined string that uniquely identifies the Task Channel - /// Whether the Task Channel should prioritize Workers that have been idle - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskChannel - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - string friendlyName, - string uniqueName, - bool? channelOptimizedRouting = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskChannelOptions(pathWorkspaceSid, friendlyName, uniqueName){ChannelOptimizedRouting = channelOptimizedRouting}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskChannelResource object - /// - /// Raw JSON string - /// TaskChannelResource object represented by the provided JSON - public static TaskChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the Task Channel - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Workspace that contains the Task Channel - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// Whether the Task Channel will prioritize Workers that have been idle - /// - [JsonProperty("channel_optimized_routing")] - public bool? ChannelOptimizedRouting { get; private set; } - /// - /// The absolute URL of the Task Channel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private TaskChannelResource() - { - - } - } +{ + + public class TaskChannelResource : Resource + { + private static Request BuildFetchRequest(FetchTaskChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskChannel parameters + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Fetch(FetchTaskChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Task Channel to fetch + /// The SID of the Task Channel resource to fetch + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTaskChannelOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Task Channel to fetch + /// The SID of the Task Channel resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskChannelOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTaskChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read TaskChannel parameters + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static ResourceSet Read(ReadTaskChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read TaskChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Task Channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static ResourceSet Read(string pathWorkspaceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskChannelOptions(pathWorkspaceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Task Channel to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskChannelOptions(pathWorkspaceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildUpdateRequest(UpdateTaskChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update TaskChannel parameters + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Update(UpdateTaskChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update TaskChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the Task Channel to update + /// The SID of the Task Channel resource to update + /// A string to describe the Task Channel resource + /// Whether the TaskChannel should prioritize Workers that have been idle + /// + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Update(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + bool? channelOptimizedRouting = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskChannelOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, ChannelOptimizedRouting = channelOptimizedRouting }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the Task Channel to update + /// The SID of the Task Channel resource to update + /// A string to describe the Task Channel resource + /// Whether the TaskChannel should prioritize Workers that have been idle + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + bool? channelOptimizedRouting = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskChannelOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, ChannelOptimizedRouting = channelOptimizedRouting }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTaskChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete TaskChannel parameters + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static bool Delete(DeleteTaskChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete TaskChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the Task Channel to delete + /// The SID of the Task Channel resource to delete + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTaskChannelOptions(pathWorkspaceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the Task Channel to delete + /// The SID of the Task Channel resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTaskChannelOptions(pathWorkspaceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateTaskChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskChannels", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create TaskChannel parameters + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Create(CreateTaskChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create TaskChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task CreateAsync(CreateTaskChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new Task Channel belongs to + /// A string to describe the Task Channel resource + /// An application-defined string that uniquely identifies the Task Channel + /// Whether the Task Channel should prioritize Workers that have been idle + /// + /// Client to make requests to Twilio + /// A single instance of TaskChannel + public static TaskChannelResource Create(string pathWorkspaceSid, + string friendlyName, + string uniqueName, + bool? channelOptimizedRouting = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskChannelOptions(pathWorkspaceSid, friendlyName, uniqueName) { ChannelOptimizedRouting = channelOptimizedRouting }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new Task Channel belongs to + /// A string to describe the Task Channel resource + /// An application-defined string that uniquely identifies the Task Channel + /// Whether the Task Channel should prioritize Workers that have been idle + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskChannel + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + string friendlyName, + string uniqueName, + bool? channelOptimizedRouting = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskChannelOptions(pathWorkspaceSid, friendlyName, uniqueName) { ChannelOptimizedRouting = channelOptimizedRouting }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskChannelResource object + /// + /// Raw JSON string + /// TaskChannelResource object represented by the provided JSON + public static TaskChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the Task Channel + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Workspace that contains the Task Channel + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// Whether the Task Channel will prioritize Workers that have been idle + /// + [JsonProperty("channel_optimized_routing")] + public bool? ChannelOptimizedRouting { get; private set; } + /// + /// The absolute URL of the Task Channel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private TaskChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskOptions.cs index db8cbebe8..a8c561f64 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskOptions.cs @@ -10,382 +10,382 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchTaskOptions + /// + public class FetchTaskOptions : IOptions + { /// - /// FetchTaskOptions - /// - public class FetchTaskOptions : IOptions - { - /// - /// The SID of the Workspace with the Task to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTaskOptions - /// - /// The SID of the Workspace with the Task to fetch - /// The SID of the resource to fetch - public FetchTaskOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the Task to fetch + /// + public string PathWorkspaceSid { get; } /// - /// UpdateTaskOptions - /// - public class UpdateTaskOptions : IOptions - { - /// - /// The SID of the Workspace with the Task to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to update - /// - public string PathSid { get; } - /// - /// The JSON string that describes the custom attributes of the task - /// - public string Attributes { get; set; } - /// - /// The new status of the task - /// - public TaskResource.StatusEnum AssignmentStatus { get; set; } - /// - /// The reason that the Task was canceled or complete - /// - public string Reason { get; set; } - /// - /// The Task's new priority value - /// - public int? Priority { get; set; } - /// - /// When MultiTasking is enabled, specify the TaskChannel with the task to update - /// - public string TaskChannel { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateTaskOptions - /// - /// The SID of the Workspace with the Task to update - /// The SID of the resource to update - public UpdateTaskOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (AssignmentStatus != null) - { - p.Add(new KeyValuePair("AssignmentStatus", AssignmentStatus.ToString())); - } - - if (Reason != null) - { - p.Add(new KeyValuePair("Reason", Reason)); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// The SID of the resource to fetch + /// + public string PathSid { get; } + /// - /// DeleteTaskOptions - /// - public class DeleteTaskOptions : IOptions - { - /// - /// The SID of the Workspace with the Task to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteTaskOptions - /// - /// The SID of the Workspace with the Task to delete - /// The SID of the resource to delete - public DeleteTaskOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// Construct a new FetchTaskOptions + /// + /// The SID of the Workspace with the Task to fetch + /// The SID of the resource to fetch + public FetchTaskOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + /// - /// ReadTaskOptions - /// - public class ReadTaskOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Tasks to read - /// - public string PathWorkspaceSid { get; } - /// - /// The priority value of the Tasks to read - /// - public int? Priority { get; set; } - /// - /// Returns the list of all Tasks in the Workspace with the specified assignment_status - /// - public List AssignmentStatus { get; set; } - /// - /// The SID of the Workflow with the Tasks to read - /// - public string WorkflowSid { get; set; } - /// - /// The friendly name of the Workflow with the Tasks to read - /// - public string WorkflowName { get; set; } - /// - /// The SID of the TaskQueue with the Tasks to read - /// - public string TaskQueueSid { get; set; } - /// - /// The friendly_name of the TaskQueue with the Tasks to read - /// - public string TaskQueueName { get; set; } - /// - /// The task attributes of the Tasks to read - /// - public string EvaluateTaskAttributes { get; set; } - /// - /// Controls the order of the Tasks returned - /// - public string Ordering { get; set; } - /// - /// Whether to read Tasks with addons - /// - public bool? HasAddons { get; set; } - - /// - /// Construct a new ReadTaskOptions - /// - /// The SID of the Workspace with the Tasks to read - public ReadTaskOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - AssignmentStatus = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (AssignmentStatus != null) - { - p.AddRange(AssignmentStatus.Select(prop => new KeyValuePair("AssignmentStatus", prop))); - } - - if (WorkflowSid != null) - { - p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); - } - - if (WorkflowName != null) - { - p.Add(new KeyValuePair("WorkflowName", WorkflowName)); - } - - if (TaskQueueSid != null) - { - p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); - } - - if (TaskQueueName != null) - { - p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); - } - - if (EvaluateTaskAttributes != null) - { - p.Add(new KeyValuePair("EvaluateTaskAttributes", EvaluateTaskAttributes)); - } - - if (Ordering != null) - { - p.Add(new KeyValuePair("Ordering", Ordering)); - } - - if (HasAddons != null) - { - p.Add(new KeyValuePair("HasAddons", HasAddons.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateTaskOptions + /// + public class UpdateTaskOptions : IOptions + { /// - /// CreateTaskOptions - /// - public class CreateTaskOptions : IOptions - { - /// - /// The SID of the Workspace that the new Task belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// The amount of time in seconds the task can live before being assigned - /// - public int? Timeout { get; set; } - /// - /// The priority to assign the new task and override the default - /// - public int? Priority { get; set; } - /// - /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name or SID - /// - public string TaskChannel { get; set; } - /// - /// The SID of the Workflow that you would like to handle routing for the new Task - /// - public string WorkflowSid { get; set; } - /// - /// A URL-encoded JSON string describing the attributes of the task - /// - public string Attributes { get; set; } - - /// - /// Construct a new CreateTaskOptions - /// - /// The SID of the Workspace that the new Task belongs to - public CreateTaskOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (WorkflowSid != null) - { - p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } + /// The SID of the Workspace with the Task to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to update + /// + public string PathSid { get; } + /// + /// The JSON string that describes the custom attributes of the task + /// + public string Attributes { get; set; } + /// + /// The new status of the task + /// + public TaskResource.StatusEnum AssignmentStatus { get; set; } + /// + /// The reason that the Task was canceled or complete + /// + public string Reason { get; set; } + /// + /// The Task's new priority value + /// + public int? Priority { get; set; } + /// + /// When MultiTasking is enabled, specify the TaskChannel with the task to update + /// + public string TaskChannel { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateTaskOptions + /// + /// The SID of the Workspace with the Task to update + /// The SID of the resource to update + public UpdateTaskOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (AssignmentStatus != null) + { + p.Add(new KeyValuePair("AssignmentStatus", AssignmentStatus.ToString())); + } + + if (Reason != null) + { + p.Add(new KeyValuePair("Reason", Reason)); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// DeleteTaskOptions + /// + public class DeleteTaskOptions : IOptions + { + /// + /// The SID of the Workspace with the Task to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to delete + /// + public string PathSid { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteTaskOptions + /// + /// The SID of the Workspace with the Task to delete + /// The SID of the resource to delete + public DeleteTaskOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// ReadTaskOptions + /// + public class ReadTaskOptions : ReadOptions + { + /// + /// The SID of the Workspace with the Tasks to read + /// + public string PathWorkspaceSid { get; } + /// + /// The priority value of the Tasks to read + /// + public int? Priority { get; set; } + /// + /// Returns the list of all Tasks in the Workspace with the specified assignment_status + /// + public List AssignmentStatus { get; set; } + /// + /// The SID of the Workflow with the Tasks to read + /// + public string WorkflowSid { get; set; } + /// + /// The friendly name of the Workflow with the Tasks to read + /// + public string WorkflowName { get; set; } + /// + /// The SID of the TaskQueue with the Tasks to read + /// + public string TaskQueueSid { get; set; } + /// + /// The friendly_name of the TaskQueue with the Tasks to read + /// + public string TaskQueueName { get; set; } + /// + /// The task attributes of the Tasks to read + /// + public string EvaluateTaskAttributes { get; set; } + /// + /// Controls the order of the Tasks returned + /// + public string Ordering { get; set; } + /// + /// Whether to read Tasks with addons + /// + public bool? HasAddons { get; set; } + + /// + /// Construct a new ReadTaskOptions + /// + /// The SID of the Workspace with the Tasks to read + public ReadTaskOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + AssignmentStatus = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (AssignmentStatus != null) + { + p.AddRange(AssignmentStatus.Select(prop => new KeyValuePair("AssignmentStatus", prop))); + } + + if (WorkflowSid != null) + { + p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); + } + + if (WorkflowName != null) + { + p.Add(new KeyValuePair("WorkflowName", WorkflowName)); + } + + if (TaskQueueSid != null) + { + p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); + } + + if (TaskQueueName != null) + { + p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); + } + + if (EvaluateTaskAttributes != null) + { + p.Add(new KeyValuePair("EvaluateTaskAttributes", EvaluateTaskAttributes)); + } + + if (Ordering != null) + { + p.Add(new KeyValuePair("Ordering", Ordering)); + } + + if (HasAddons != null) + { + p.Add(new KeyValuePair("HasAddons", HasAddons.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateTaskOptions + /// + public class CreateTaskOptions : IOptions + { + /// + /// The SID of the Workspace that the new Task belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// The amount of time in seconds the task can live before being assigned + /// + public int? Timeout { get; set; } + /// + /// The priority to assign the new task and override the default + /// + public int? Priority { get; set; } + /// + /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name or SID + /// + public string TaskChannel { get; set; } + /// + /// The SID of the Workflow that you would like to handle routing for the new Task + /// + public string WorkflowSid { get; set; } + /// + /// A URL-encoded JSON string describing the attributes of the task + /// + public string Attributes { get; set; } + + /// + /// Construct a new CreateTaskOptions + /// + /// The SID of the Workspace that the new Task belongs to + public CreateTaskOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (WorkflowSid != null) + { + p.Add(new KeyValuePair("WorkflowSid", WorkflowSid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsOptions.cs index 928408a15..db359a4ac 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsOptions.cs @@ -9,86 +9,86 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - +{ + + /// + /// FetchTaskQueueCumulativeStatisticsOptions + /// + public class FetchTaskQueueCumulativeStatisticsOptions : IOptions + { /// - /// FetchTaskQueueCumulativeStatisticsOptions + /// The SID of the Workspace with the TaskQueue to fetch /// - public class FetchTaskQueueCumulativeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the TaskQueue for which to fetch statistics - /// - public string PathTaskQueueSid { get; } - /// - /// Only calculate statistics from on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate cumulative statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchTaskQueueCumulativeStatisticsOptions - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - public FetchTaskQueueCumulativeStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskQueueSid = pathTaskQueueSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// The SID of the TaskQueue for which to fetch statistics + /// + public string PathTaskQueueSid { get; } + /// + /// Only calculate statistics from on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate cumulative statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchTaskQueueCumulativeStatisticsOptions + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + public FetchTaskQueueCumulativeStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskQueueSid = pathTaskQueueSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsResource.cs index 0c1f671cb..69e6749b3 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueCumulativeStatisticsResource.cs @@ -16,238 +16,238 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - - public class TaskQueueCumulativeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskQueueCumulativeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/CumulativeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskQueueCumulativeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueueCumulativeStatistics - public static TaskQueueCumulativeStatisticsResource Fetch(FetchTaskQueueCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskQueueCumulativeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of TaskQueueCumulativeStatistics - public static TaskQueueCumulativeStatisticsResource Fetch(string pathWorkspaceSid, - string pathTaskQueueSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueCumulativeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathTaskQueueSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueCumulativeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskQueueCumulativeStatisticsResource object - /// - /// Raw JSON string - /// TaskQueueCumulativeStatisticsResource object represented by the provided JSON - public static TaskQueueCumulativeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The average time in seconds between Task creation and acceptance - /// - [JsonProperty("avg_task_acceptance_time")] - public int? AvgTaskAcceptanceTime { get; private set; } - /// - /// The beginning of the interval during which these statistics were calculated - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end of the interval during which these statistics were calculated - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The total number of Reservations created for Tasks in the TaskQueue - /// - [JsonProperty("reservations_created")] - public int? ReservationsCreated { get; private set; } - /// - /// The total number of Reservations accepted for Tasks in the TaskQueue - /// - [JsonProperty("reservations_accepted")] - public int? ReservationsAccepted { get; private set; } - /// - /// The total number of Reservations rejected for Tasks in the TaskQueue - /// - [JsonProperty("reservations_rejected")] - public int? ReservationsRejected { get; private set; } - /// - /// The total number of Reservations that timed out for Tasks in the TaskQueue - /// - [JsonProperty("reservations_timed_out")] - public int? ReservationsTimedOut { get; private set; } - /// - /// The total number of Reservations canceled for Tasks in the TaskQueue - /// - [JsonProperty("reservations_canceled")] - public int? ReservationsCanceled { get; private set; } - /// - /// The total number of Reservations rescinded - /// - [JsonProperty("reservations_rescinded")] - public int? ReservationsRescinded { get; private set; } - /// - /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds - /// - [JsonProperty("split_by_wait_time")] - public object SplitByWaitTime { get; private set; } - /// - /// The SID of the TaskQueue from which these statistics were calculated - /// - [JsonProperty("task_queue_sid")] - public string TaskQueueSid { get; private set; } - /// - /// The wait duration statistics for Tasks accepted while in the TaskQueue - /// - [JsonProperty("wait_duration_until_accepted")] - public object WaitDurationUntilAccepted { get; private set; } - /// - /// The wait duration statistics for Tasks canceled while in the TaskQueue - /// - [JsonProperty("wait_duration_until_canceled")] - public object WaitDurationUntilCanceled { get; private set; } - /// - /// The relative wait duration statistics for Tasks accepted while in the TaskQueue - /// - [JsonProperty("wait_duration_in_queue_until_accepted")] - public object WaitDurationInQueueUntilAccepted { get; private set; } - /// - /// The total number of Tasks canceled in the TaskQueue - /// - [JsonProperty("tasks_canceled")] - public int? TasksCanceled { get; private set; } - /// - /// The total number of Tasks completed in the TaskQueue - /// - [JsonProperty("tasks_completed")] - public int? TasksCompleted { get; private set; } - /// - /// The total number of Tasks deleted in the TaskQueue - /// - [JsonProperty("tasks_deleted")] - public int? TasksDeleted { get; private set; } - /// - /// The total number of Tasks entered into the TaskQueue - /// - [JsonProperty("tasks_entered")] - public int? TasksEntered { get; private set; } - /// - /// The total number of Tasks that were moved from one queue to another - /// - [JsonProperty("tasks_moved")] - public int? TasksMoved { get; private set; } - /// - /// The SID of the Workspace that contains the TaskQueue - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the TaskQueue statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskQueueCumulativeStatisticsResource() - { - - } - } +{ + + public class TaskQueueCumulativeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskQueueCumulativeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/CumulativeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskQueueCumulativeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueueCumulativeStatistics + public static TaskQueueCumulativeStatisticsResource Fetch(FetchTaskQueueCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskQueueCumulativeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of TaskQueueCumulativeStatistics + public static TaskQueueCumulativeStatisticsResource Fetch(string pathWorkspaceSid, + string pathTaskQueueSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueCumulativeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathTaskQueueSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueCumulativeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskQueueCumulativeStatisticsResource object + /// + /// Raw JSON string + /// TaskQueueCumulativeStatisticsResource object represented by the provided JSON + public static TaskQueueCumulativeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The average time in seconds between Task creation and acceptance + /// + [JsonProperty("avg_task_acceptance_time")] + public int? AvgTaskAcceptanceTime { get; private set; } + /// + /// The beginning of the interval during which these statistics were calculated + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end of the interval during which these statistics were calculated + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The total number of Reservations created for Tasks in the TaskQueue + /// + [JsonProperty("reservations_created")] + public int? ReservationsCreated { get; private set; } + /// + /// The total number of Reservations accepted for Tasks in the TaskQueue + /// + [JsonProperty("reservations_accepted")] + public int? ReservationsAccepted { get; private set; } + /// + /// The total number of Reservations rejected for Tasks in the TaskQueue + /// + [JsonProperty("reservations_rejected")] + public int? ReservationsRejected { get; private set; } + /// + /// The total number of Reservations that timed out for Tasks in the TaskQueue + /// + [JsonProperty("reservations_timed_out")] + public int? ReservationsTimedOut { get; private set; } + /// + /// The total number of Reservations canceled for Tasks in the TaskQueue + /// + [JsonProperty("reservations_canceled")] + public int? ReservationsCanceled { get; private set; } + /// + /// The total number of Reservations rescinded + /// + [JsonProperty("reservations_rescinded")] + public int? ReservationsRescinded { get; private set; } + /// + /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds + /// + [JsonProperty("split_by_wait_time")] + public object SplitByWaitTime { get; private set; } + /// + /// The SID of the TaskQueue from which these statistics were calculated + /// + [JsonProperty("task_queue_sid")] + public string TaskQueueSid { get; private set; } + /// + /// The wait duration statistics for Tasks accepted while in the TaskQueue + /// + [JsonProperty("wait_duration_until_accepted")] + public object WaitDurationUntilAccepted { get; private set; } + /// + /// The wait duration statistics for Tasks canceled while in the TaskQueue + /// + [JsonProperty("wait_duration_until_canceled")] + public object WaitDurationUntilCanceled { get; private set; } + /// + /// The relative wait duration statistics for Tasks accepted while in the TaskQueue + /// + [JsonProperty("wait_duration_in_queue_until_accepted")] + public object WaitDurationInQueueUntilAccepted { get; private set; } + /// + /// The total number of Tasks canceled in the TaskQueue + /// + [JsonProperty("tasks_canceled")] + public int? TasksCanceled { get; private set; } + /// + /// The total number of Tasks completed in the TaskQueue + /// + [JsonProperty("tasks_completed")] + public int? TasksCompleted { get; private set; } + /// + /// The total number of Tasks deleted in the TaskQueue + /// + [JsonProperty("tasks_deleted")] + public int? TasksDeleted { get; private set; } + /// + /// The total number of Tasks entered into the TaskQueue + /// + [JsonProperty("tasks_entered")] + public int? TasksEntered { get; private set; } + /// + /// The total number of Tasks that were moved from one queue to another + /// + [JsonProperty("tasks_moved")] + public int? TasksMoved { get; private set; } + /// + /// The SID of the Workspace that contains the TaskQueue + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the TaskQueue statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskQueueCumulativeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsOptions.cs index 8f20462dd..e37bacc59 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsOptions.cs @@ -9,50 +9,50 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - +{ + + /// + /// FetchTaskQueueRealTimeStatisticsOptions + /// + public class FetchTaskQueueRealTimeStatisticsOptions : IOptions + { /// - /// FetchTaskQueueRealTimeStatisticsOptions + /// The SID of the Workspace with the TaskQueue to fetch /// - public class FetchTaskQueueRealTimeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the TaskQueue for which to fetch statistics - /// - public string PathTaskQueueSid { get; } - /// - /// The TaskChannel for which to fetch statistics - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchTaskQueueRealTimeStatisticsOptions - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - public FetchTaskQueueRealTimeStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskQueueSid = pathTaskQueueSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// The SID of the TaskQueue for which to fetch statistics + /// + public string PathTaskQueueSid { get; } + /// + /// The TaskChannel for which to fetch statistics + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchTaskQueueRealTimeStatisticsOptions + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + public FetchTaskQueueRealTimeStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskQueueSid = pathTaskQueueSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsResource.cs index 72a108f12..68b7088fe 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueRealTimeStatisticsResource.cs @@ -16,180 +16,180 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - - public class TaskQueueRealTimeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskQueueRealTimeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/RealTimeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskQueueRealTimeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueueRealTimeStatistics - public static TaskQueueRealTimeStatisticsResource Fetch(FetchTaskQueueRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskQueueRealTimeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// The TaskChannel for which to fetch statistics - /// Client to make requests to Twilio - /// A single instance of TaskQueueRealTimeStatistics - public static TaskQueueRealTimeStatisticsResource Fetch(string pathWorkspaceSid, - string pathTaskQueueSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueRealTimeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// The TaskChannel for which to fetch statistics - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathTaskQueueSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueRealTimeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskQueueRealTimeStatisticsResource object - /// - /// Raw JSON string - /// TaskQueueRealTimeStatisticsResource object represented by the provided JSON - public static TaskQueueRealTimeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number of current Workers by Activity - /// - [JsonProperty("activity_statistics")] - public List ActivityStatistics { get; private set; } - /// - /// The age of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_age")] - public int? LongestTaskWaitingAge { get; private set; } - /// - /// The SID of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_sid")] - public string LongestTaskWaitingSid { get; private set; } - /// - /// The relative age in the TaskQueue for the longest waiting Task. - /// - [JsonProperty("longest_relative_task_age_in_queue")] - public int? LongestRelativeTaskAgeInQueue { get; private set; } - /// - /// The SID of the Task waiting in the TaskQueue the longest. - /// - [JsonProperty("longest_relative_task_sid_in_queue")] - public string LongestRelativeTaskSidInQueue { get; private set; } - /// - /// The SID of the TaskQueue from which these statistics were calculated - /// - [JsonProperty("task_queue_sid")] - public string TaskQueueSid { get; private set; } - /// - /// The number of Tasks by priority - /// - [JsonProperty("tasks_by_priority")] - public object TasksByPriority { get; private set; } - /// - /// The number of Tasks by their current status - /// - [JsonProperty("tasks_by_status")] - public object TasksByStatus { get; private set; } - /// - /// The total number of Workers available for Tasks in the TaskQueue - /// - [JsonProperty("total_available_workers")] - public int? TotalAvailableWorkers { get; private set; } - /// - /// The total number of Workers eligible for Tasks in the TaskQueue, independent of their Activity state - /// - [JsonProperty("total_eligible_workers")] - public int? TotalEligibleWorkers { get; private set; } - /// - /// The total number of Tasks - /// - [JsonProperty("total_tasks")] - public int? TotalTasks { get; private set; } - /// - /// The SID of the Workspace that contains the TaskQueue - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the TaskQueue statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskQueueRealTimeStatisticsResource() - { - - } - } +{ + + public class TaskQueueRealTimeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskQueueRealTimeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/RealTimeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskQueueRealTimeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueueRealTimeStatistics + public static TaskQueueRealTimeStatisticsResource Fetch(FetchTaskQueueRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskQueueRealTimeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// The TaskChannel for which to fetch statistics + /// Client to make requests to Twilio + /// A single instance of TaskQueueRealTimeStatistics + public static TaskQueueRealTimeStatisticsResource Fetch(string pathWorkspaceSid, + string pathTaskQueueSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueRealTimeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// The TaskChannel for which to fetch statistics + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathTaskQueueSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueRealTimeStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskQueueRealTimeStatisticsResource object + /// + /// Raw JSON string + /// TaskQueueRealTimeStatisticsResource object represented by the provided JSON + public static TaskQueueRealTimeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number of current Workers by Activity + /// + [JsonProperty("activity_statistics")] + public List ActivityStatistics { get; private set; } + /// + /// The age of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_age")] + public int? LongestTaskWaitingAge { get; private set; } + /// + /// The SID of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_sid")] + public string LongestTaskWaitingSid { get; private set; } + /// + /// The relative age in the TaskQueue for the longest waiting Task. + /// + [JsonProperty("longest_relative_task_age_in_queue")] + public int? LongestRelativeTaskAgeInQueue { get; private set; } + /// + /// The SID of the Task waiting in the TaskQueue the longest. + /// + [JsonProperty("longest_relative_task_sid_in_queue")] + public string LongestRelativeTaskSidInQueue { get; private set; } + /// + /// The SID of the TaskQueue from which these statistics were calculated + /// + [JsonProperty("task_queue_sid")] + public string TaskQueueSid { get; private set; } + /// + /// The number of Tasks by priority + /// + [JsonProperty("tasks_by_priority")] + public object TasksByPriority { get; private set; } + /// + /// The number of Tasks by their current status + /// + [JsonProperty("tasks_by_status")] + public object TasksByStatus { get; private set; } + /// + /// The total number of Workers available for Tasks in the TaskQueue + /// + [JsonProperty("total_available_workers")] + public int? TotalAvailableWorkers { get; private set; } + /// + /// The total number of Workers eligible for Tasks in the TaskQueue, independent of their Activity state + /// + [JsonProperty("total_eligible_workers")] + public int? TotalEligibleWorkers { get; private set; } + /// + /// The total number of Tasks + /// + [JsonProperty("total_tasks")] + public int? TotalTasks { get; private set; } + /// + /// The SID of the Workspace that contains the TaskQueue + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the TaskQueue statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskQueueRealTimeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsOptions.cs index aeb3222f6..c3b085cbd 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsOptions.cs @@ -9,86 +9,86 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - +{ + + /// + /// FetchTaskQueueStatisticsOptions + /// + public class FetchTaskQueueStatisticsOptions : IOptions + { /// - /// FetchTaskQueueStatisticsOptions + /// The SID of the Workspace with the TaskQueue to fetch /// - public class FetchTaskQueueStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the TaskQueue for which to fetch statistics - /// - public string PathTaskQueueSid { get; } - /// - /// Only calculate statistics from on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate real-time and cumulative statistics for the specified TaskChannel - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchTaskQueueStatisticsOptions - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - public FetchTaskQueueStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathTaskQueueSid = pathTaskQueueSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// The SID of the TaskQueue for which to fetch statistics + /// + public string PathTaskQueueSid { get; } + /// + /// Only calculate statistics from on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate real-time and cumulative statistics for the specified TaskChannel + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchTaskQueueStatisticsOptions + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + public FetchTaskQueueStatisticsOptions(string pathWorkspaceSid, string pathTaskQueueSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathTaskQueueSid = pathTaskQueueSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsResource.cs index 0fd37978d..ddd034c2d 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueStatisticsResource.cs @@ -16,158 +16,158 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - - public class TaskQueueStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchTaskQueueStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskQueueStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueueStatistics - public static TaskQueueStatisticsResource Fetch(FetchTaskQueueStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskQueueStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate real-time and cumulative statistics for the specified TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of TaskQueueStatistics - public static TaskQueueStatisticsResource Fetch(string pathWorkspaceSid, - string pathTaskQueueSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the TaskQueue for which to fetch statistics - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate real-time and cumulative statistics for the specified TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueueStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathTaskQueueSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskQueueStatisticsResource object - /// - /// Raw JSON string - /// TaskQueueStatisticsResource object represented by the provided JSON - public static TaskQueueStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// An object that contains the cumulative statistics for the TaskQueue - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// An object that contains the real-time statistics for the TaskQueue - /// - [JsonProperty("realtime")] - public object Realtime { get; private set; } - /// - /// The SID of the TaskQueue from which these statistics were calculated - /// - [JsonProperty("task_queue_sid")] - public string TaskQueueSid { get; private set; } - /// - /// The SID of the Workspace that contains the TaskQueue - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the TaskQueue statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TaskQueueStatisticsResource() - { - - } - } +{ + + public class TaskQueueStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchTaskQueueStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathTaskQueueSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskQueueStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueueStatistics + public static TaskQueueStatisticsResource Fetch(FetchTaskQueueStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskQueueStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate real-time and cumulative statistics for the specified TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of TaskQueueStatistics + public static TaskQueueStatisticsResource Fetch(string pathWorkspaceSid, + string pathTaskQueueSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the TaskQueue for which to fetch statistics + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate real-time and cumulative statistics for the specified TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueueStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathTaskQueueSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueStatisticsOptions(pathWorkspaceSid, pathTaskQueueSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskQueueStatisticsResource object + /// + /// Raw JSON string + /// TaskQueueStatisticsResource object represented by the provided JSON + public static TaskQueueStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// An object that contains the cumulative statistics for the TaskQueue + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// An object that contains the real-time statistics for the TaskQueue + /// + [JsonProperty("realtime")] + public object Realtime { get; private set; } + /// + /// The SID of the TaskQueue from which these statistics were calculated + /// + [JsonProperty("task_queue_sid")] + public string TaskQueueSid { get; private set; } + /// + /// The SID of the Workspace that contains the TaskQueue + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the TaskQueue statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TaskQueueStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsOptions.cs index c2fbd0ac1..740bd4c28 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsOptions.cs @@ -9,94 +9,94 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - +{ + + /// + /// ReadTaskQueuesStatisticsOptions + /// + public class ReadTaskQueuesStatisticsOptions : ReadOptions + { /// - /// ReadTaskQueuesStatisticsOptions + /// The SID of the Workspace with the TaskQueues to read /// - public class ReadTaskQueuesStatisticsOptions : ReadOptions - { - /// - /// The SID of the Workspace with the TaskQueues to read - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate statistics from on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// The friendly_name of the TaskQueue statistics to read - /// - public string FriendlyName { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate statistics on this TaskChannel. - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new ReadTaskQueuesStatisticsOptions - /// - /// The SID of the Workspace with the TaskQueues to read - public ReadTaskQueuesStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate statistics from on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// The friendly_name of the TaskQueue statistics to read + /// + public string FriendlyName { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate statistics on this TaskChannel. + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new ReadTaskQueuesStatisticsOptions + /// + /// The SID of the Workspace with the TaskQueues to read + public ReadTaskQueuesStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsResource.cs index 2b03e1a13..f048649da 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueuesStatisticsResource.cs @@ -16,220 +16,220 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.TaskQueue -{ - - public class TaskQueuesStatisticsResource : Resource - { - private static Request BuildReadRequest(ReadTaskQueuesStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read TaskQueuesStatistics parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueuesStatistics - public static ResourceSet Read(ReadTaskQueuesStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("task_queues_statistics", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read TaskQueuesStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueuesStatistics - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskQueuesStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("task_queues_statistics", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the TaskQueues to read - /// Only calculate statistics from on or before this date - /// The friendly_name of the TaskQueue statistics to read - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TaskQueuesStatistics - public static ResourceSet Read(string pathWorkspaceSid, - DateTime? endDate = null, - string friendlyName = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskQueuesStatisticsOptions(pathWorkspaceSid){EndDate = endDate, FriendlyName = friendlyName, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the TaskQueues to read - /// Only calculate statistics from on or before this date - /// The friendly_name of the TaskQueue statistics to read - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueuesStatistics - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - DateTime? endDate = null, - string friendlyName = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskQueuesStatisticsOptions(pathWorkspaceSid){EndDate = endDate, FriendlyName = friendlyName, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("task_queues_statistics", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("task_queues_statistics", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("task_queues_statistics", response.Content); - } - - /// - /// Converts a JSON string into a TaskQueuesStatisticsResource object - /// - /// Raw JSON string - /// TaskQueuesStatisticsResource object represented by the provided JSON - public static TaskQueuesStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// An object that contains the cumulative statistics for the TaskQueues - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// An object that contains the real-time statistics for the TaskQueues - /// - [JsonProperty("realtime")] - public object Realtime { get; private set; } - /// - /// The SID of the TaskQueue from which these statistics were calculated - /// - [JsonProperty("task_queue_sid")] - public string TaskQueueSid { get; private set; } - /// - /// The SID of the Workspace that contains the TaskQueues - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - - private TaskQueuesStatisticsResource() - { - - } - } +{ + + public class TaskQueuesStatisticsResource : Resource + { + private static Request BuildReadRequest(ReadTaskQueuesStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read TaskQueuesStatistics parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueuesStatistics + public static ResourceSet Read(ReadTaskQueuesStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("task_queues_statistics", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read TaskQueuesStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueuesStatistics + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskQueuesStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("task_queues_statistics", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the TaskQueues to read + /// Only calculate statistics from on or before this date + /// The friendly_name of the TaskQueue statistics to read + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TaskQueuesStatistics + public static ResourceSet Read(string pathWorkspaceSid, + DateTime? endDate = null, + string friendlyName = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskQueuesStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, FriendlyName = friendlyName, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the TaskQueues to read + /// Only calculate statistics from on or before this date + /// The friendly_name of the TaskQueue statistics to read + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueuesStatistics + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + DateTime? endDate = null, + string friendlyName = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskQueuesStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, FriendlyName = friendlyName, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("task_queues_statistics", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("task_queues_statistics", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("task_queues_statistics", response.Content); + } + + /// + /// Converts a JSON string into a TaskQueuesStatisticsResource object + /// + /// Raw JSON string + /// TaskQueuesStatisticsResource object represented by the provided JSON + public static TaskQueuesStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// An object that contains the cumulative statistics for the TaskQueues + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// An object that contains the real-time statistics for the TaskQueues + /// + [JsonProperty("realtime")] + public object Realtime { get; private set; } + /// + /// The SID of the TaskQueue from which these statistics were calculated + /// + [JsonProperty("task_queue_sid")] + public string TaskQueueSid { get; private set; } + /// + /// The SID of the Workspace that contains the TaskQueues + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + + private TaskQueuesStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueOptions.cs index faab7c317..fc794244a 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueOptions.cs @@ -9,311 +9,311 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchTaskQueueOptions + /// + public class FetchTaskQueueOptions : IOptions + { /// - /// FetchTaskQueueOptions - /// - public class FetchTaskQueueOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTaskQueueOptions - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the resource to - public FetchTaskQueueOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the TaskQueue to fetch + /// + public string PathWorkspaceSid { get; } /// - /// UpdateTaskQueueOptions - /// - public class UpdateTaskQueueOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to update - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue - /// - public string TargetWorkers { get; set; } - /// - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - public string ReservationActivitySid { get; set; } - /// - /// The SID of the Activity to assign Workers when a task is assigned for them - /// - public string AssignmentActivitySid { get; set; } - /// - /// The maximum number of Workers to create reservations for the assignment of a task while in the queue - /// - public int? MaxReservedWorkers { get; set; } - /// - /// How Tasks will be assigned to Workers - /// - public TaskQueueResource.TaskOrderEnum TaskOrder { get; set; } - - /// - /// Construct a new UpdateTaskQueueOptions - /// - /// The SID of the Workspace with the TaskQueue to update - /// The SID of the resource to update - public UpdateTaskQueueOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (TargetWorkers != null) - { - p.Add(new KeyValuePair("TargetWorkers", TargetWorkers)); - } - - if (ReservationActivitySid != null) - { - p.Add(new KeyValuePair("ReservationActivitySid", ReservationActivitySid.ToString())); - } - - if (AssignmentActivitySid != null) - { - p.Add(new KeyValuePair("AssignmentActivitySid", AssignmentActivitySid.ToString())); - } - - if (MaxReservedWorkers != null) - { - p.Add(new KeyValuePair("MaxReservedWorkers", MaxReservedWorkers.ToString())); - } - - if (TaskOrder != null) - { - p.Add(new KeyValuePair("TaskOrder", TaskOrder.ToString())); - } - - return p; - } - } - + /// The SID of the resource to + /// + public string PathSid { get; } + /// - /// ReadTaskQueueOptions - /// - public class ReadTaskQueueOptions : ReadOptions - { - /// - /// The SID of the Workspace with the TaskQueue to read - /// - public string PathWorkspaceSid { get; } - /// - /// The friendly_name of the TaskQueue resources to read - /// - public string FriendlyName { get; set; } - /// - /// The attributes of the Workers to read - /// - public string EvaluateWorkerAttributes { get; set; } - /// - /// The SID of the Worker with the TaskQueue resources to read - /// - public string WorkerSid { get; set; } - - /// - /// Construct a new ReadTaskQueueOptions - /// - /// The SID of the Workspace with the TaskQueue to read - public ReadTaskQueueOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (EvaluateWorkerAttributes != null) - { - p.Add(new KeyValuePair("EvaluateWorkerAttributes", EvaluateWorkerAttributes)); - } - - if (WorkerSid != null) - { - p.Add(new KeyValuePair("WorkerSid", WorkerSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchTaskQueueOptions + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the resource to + public FetchTaskQueueOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + /// - /// CreateTaskQueueOptions - /// - public class CreateTaskQueueOptions : IOptions - { - /// - /// The SID of the Workspace that the new TaskQueue belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue - /// - public string TargetWorkers { get; set; } - /// - /// The maximum number of Workers to reserve - /// - public int? MaxReservedWorkers { get; set; } - /// - /// How Tasks will be assigned to Workers - /// - public TaskQueueResource.TaskOrderEnum TaskOrder { get; set; } - /// - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - public string ReservationActivitySid { get; set; } - /// - /// The SID of the Activity to assign Workers once a task is assigned to them - /// - public string AssignmentActivitySid { get; set; } - - /// - /// Construct a new CreateTaskQueueOptions - /// - /// The SID of the Workspace that the new TaskQueue belongs to - /// A string to describe the resource - public CreateTaskQueueOptions(string pathWorkspaceSid, string friendlyName) - { - PathWorkspaceSid = pathWorkspaceSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (TargetWorkers != null) - { - p.Add(new KeyValuePair("TargetWorkers", TargetWorkers)); - } - - if (MaxReservedWorkers != null) - { - p.Add(new KeyValuePair("MaxReservedWorkers", MaxReservedWorkers.ToString())); - } - - if (TaskOrder != null) - { - p.Add(new KeyValuePair("TaskOrder", TaskOrder.ToString())); - } - - if (ReservationActivitySid != null) - { - p.Add(new KeyValuePair("ReservationActivitySid", ReservationActivitySid.ToString())); - } - - if (AssignmentActivitySid != null) - { - p.Add(new KeyValuePair("AssignmentActivitySid", AssignmentActivitySid.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateTaskQueueOptions + /// + public class UpdateTaskQueueOptions : IOptions + { /// - /// DeleteTaskQueueOptions - /// - public class DeleteTaskQueueOptions : IOptions - { - /// - /// The SID of the Workspace with the TaskQueue to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTaskQueueOptions - /// - /// The SID of the Workspace with the TaskQueue to delete - /// The SID of the resource to delete - public DeleteTaskQueueOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Workspace with the TaskQueue to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to update + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue + /// + public string TargetWorkers { get; set; } + /// + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + public string ReservationActivitySid { get; set; } + /// + /// The SID of the Activity to assign Workers when a task is assigned for them + /// + public string AssignmentActivitySid { get; set; } + /// + /// The maximum number of Workers to create reservations for the assignment of a task while in the queue + /// + public int? MaxReservedWorkers { get; set; } + /// + /// How Tasks will be assigned to Workers + /// + public TaskQueueResource.TaskOrderEnum TaskOrder { get; set; } + + /// + /// Construct a new UpdateTaskQueueOptions + /// + /// The SID of the Workspace with the TaskQueue to update + /// The SID of the resource to update + public UpdateTaskQueueOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (TargetWorkers != null) + { + p.Add(new KeyValuePair("TargetWorkers", TargetWorkers)); + } + + if (ReservationActivitySid != null) + { + p.Add(new KeyValuePair("ReservationActivitySid", ReservationActivitySid.ToString())); + } + + if (AssignmentActivitySid != null) + { + p.Add(new KeyValuePair("AssignmentActivitySid", AssignmentActivitySid.ToString())); + } + + if (MaxReservedWorkers != null) + { + p.Add(new KeyValuePair("MaxReservedWorkers", MaxReservedWorkers.ToString())); + } + + if (TaskOrder != null) + { + p.Add(new KeyValuePair("TaskOrder", TaskOrder.ToString())); + } + + return p; + } + } + + /// + /// ReadTaskQueueOptions + /// + public class ReadTaskQueueOptions : ReadOptions + { + /// + /// The SID of the Workspace with the TaskQueue to read + /// + public string PathWorkspaceSid { get; } + /// + /// The friendly_name of the TaskQueue resources to read + /// + public string FriendlyName { get; set; } + /// + /// The attributes of the Workers to read + /// + public string EvaluateWorkerAttributes { get; set; } + /// + /// The SID of the Worker with the TaskQueue resources to read + /// + public string WorkerSid { get; set; } + + /// + /// Construct a new ReadTaskQueueOptions + /// + /// The SID of the Workspace with the TaskQueue to read + public ReadTaskQueueOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (EvaluateWorkerAttributes != null) + { + p.Add(new KeyValuePair("EvaluateWorkerAttributes", EvaluateWorkerAttributes)); + } + + if (WorkerSid != null) + { + p.Add(new KeyValuePair("WorkerSid", WorkerSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateTaskQueueOptions + /// + public class CreateTaskQueueOptions : IOptions + { + /// + /// The SID of the Workspace that the new TaskQueue belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + /// + /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue + /// + public string TargetWorkers { get; set; } + /// + /// The maximum number of Workers to reserve + /// + public int? MaxReservedWorkers { get; set; } + /// + /// How Tasks will be assigned to Workers + /// + public TaskQueueResource.TaskOrderEnum TaskOrder { get; set; } + /// + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + public string ReservationActivitySid { get; set; } + /// + /// The SID of the Activity to assign Workers once a task is assigned to them + /// + public string AssignmentActivitySid { get; set; } + + /// + /// Construct a new CreateTaskQueueOptions + /// + /// The SID of the Workspace that the new TaskQueue belongs to + /// A string to describe the resource + public CreateTaskQueueOptions(string pathWorkspaceSid, string friendlyName) + { + PathWorkspaceSid = pathWorkspaceSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (TargetWorkers != null) + { + p.Add(new KeyValuePair("TargetWorkers", TargetWorkers)); + } + + if (MaxReservedWorkers != null) + { + p.Add(new KeyValuePair("MaxReservedWorkers", MaxReservedWorkers.ToString())); + } + + if (TaskOrder != null) + { + p.Add(new KeyValuePair("TaskOrder", TaskOrder.ToString())); + } + + if (ReservationActivitySid != null) + { + p.Add(new KeyValuePair("ReservationActivitySid", ReservationActivitySid.ToString())); + } + + if (AssignmentActivitySid != null) + { + p.Add(new KeyValuePair("AssignmentActivitySid", AssignmentActivitySid.ToString())); + } + + return p; + } + } + + /// + /// DeleteTaskQueueOptions + /// + public class DeleteTaskQueueOptions : IOptions + { + /// + /// The SID of the Workspace with the TaskQueue to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTaskQueueOptions + /// + /// The SID of the Workspace with the TaskQueue to delete + /// The SID of the resource to delete + public DeleteTaskQueueOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueResource.cs index 68f7797ee..912caee40 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueResource.cs @@ -17,609 +17,609 @@ using Twilio.Types; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class TaskQueueResource : Resource - { - public sealed class TaskOrderEnum : StringEnum - { - private TaskOrderEnum(string value) : base(value) {} - public TaskOrderEnum() {} - public static implicit operator TaskOrderEnum(string value) - { - return new TaskOrderEnum(value); - } - - public static readonly TaskOrderEnum Fifo = new TaskOrderEnum("FIFO"); - public static readonly TaskOrderEnum Lifo = new TaskOrderEnum("LIFO"); - } - - private static Request BuildFetchRequest(FetchTaskQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch TaskQueue parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Fetch(FetchTaskQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch TaskQueue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the resource to - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTaskQueueOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the TaskQueue to fetch - /// The SID of the resource to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskQueueOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update TaskQueue parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Update(UpdateTaskQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update TaskQueue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the TaskQueue to update - /// The SID of the resource to update - /// A string to describe the resource - /// A string describing the Worker selection criteria for any Tasks that enter the - /// TaskQueue - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - /// The SID of the Activity to assign Workers when a task is assigned for them - /// - /// The maximum number of Workers to create reservations for the assignment of a task - /// while in the queue - /// How Tasks will be assigned to Workers - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Update(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - string targetWorkers = null, - string reservationActivitySid = null, - string assignmentActivitySid = null, - int? maxReservedWorkers = null, - TaskQueueResource.TaskOrderEnum taskOrder = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskQueueOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, TargetWorkers = targetWorkers, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the TaskQueue to update - /// The SID of the resource to update - /// A string to describe the resource - /// A string describing the Worker selection criteria for any Tasks that enter the - /// TaskQueue - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - /// The SID of the Activity to assign Workers when a task is assigned for them - /// - /// The maximum number of Workers to create reservations for the assignment of a task - /// while in the queue - /// How Tasks will be assigned to Workers - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - string targetWorkers = null, - string reservationActivitySid = null, - string assignmentActivitySid = null, - int? maxReservedWorkers = null, - TaskQueueResource.TaskOrderEnum taskOrder = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskQueueOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, TargetWorkers = targetWorkers, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTaskQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read TaskQueue parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static ResourceSet Read(ReadTaskQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("task_queues", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read TaskQueue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("task_queues", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the TaskQueue to read - /// The friendly_name of the TaskQueue resources to read - /// The attributes of the Workers to read - /// The SID of the Worker with the TaskQueue resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static ResourceSet Read(string pathWorkspaceSid, - string friendlyName = null, - string evaluateWorkerAttributes = null, - string workerSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskQueueOptions(pathWorkspaceSid){FriendlyName = friendlyName, EvaluateWorkerAttributes = evaluateWorkerAttributes, WorkerSid = workerSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the TaskQueue to read - /// The friendly_name of the TaskQueue resources to read - /// The attributes of the Workers to read - /// The SID of the Worker with the TaskQueue resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string friendlyName = null, - string evaluateWorkerAttributes = null, - string workerSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskQueueOptions(pathWorkspaceSid){FriendlyName = friendlyName, EvaluateWorkerAttributes = evaluateWorkerAttributes, WorkerSid = workerSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("task_queues", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("task_queues", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("task_queues", response.Content); - } - - private static Request BuildCreateRequest(CreateTaskQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create TaskQueue parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Create(CreateTaskQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create TaskQueue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task CreateAsync(CreateTaskQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new TaskQueue belongs to - /// A string to describe the resource - /// A string describing the Worker selection criteria for any Tasks that enter the - /// TaskQueue - /// The maximum number of Workers to reserve - /// How Tasks will be assigned to Workers - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - /// The SID of the Activity to assign Workers once a task is assigned to them - /// - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static TaskQueueResource Create(string pathWorkspaceSid, - string friendlyName, - string targetWorkers = null, - int? maxReservedWorkers = null, - TaskQueueResource.TaskOrderEnum taskOrder = null, - string reservationActivitySid = null, - string assignmentActivitySid = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskQueueOptions(pathWorkspaceSid, friendlyName){TargetWorkers = targetWorkers, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new TaskQueue belongs to - /// A string to describe the resource - /// A string describing the Worker selection criteria for any Tasks that enter the - /// TaskQueue - /// The maximum number of Workers to reserve - /// How Tasks will be assigned to Workers - /// The SID of the Activity to assign Workers when a task is reserved for them - /// - /// The SID of the Activity to assign Workers once a task is assigned to them - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - string friendlyName, - string targetWorkers = null, - int? maxReservedWorkers = null, - TaskQueueResource.TaskOrderEnum taskOrder = null, - string reservationActivitySid = null, - string assignmentActivitySid = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskQueueOptions(pathWorkspaceSid, friendlyName){TargetWorkers = targetWorkers, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTaskQueueOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete TaskQueue parameters - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static bool Delete(DeleteTaskQueueOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete TaskQueue parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskQueueOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the TaskQueue to delete - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// A single instance of TaskQueue - public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTaskQueueOptions(pathWorkspaceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the TaskQueue to delete - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TaskQueue - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTaskQueueOptions(pathWorkspaceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskQueueResource object - /// - /// Raw JSON string - /// TaskQueueResource object represented by the provided JSON - public static TaskQueueResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Activity to assign Workers when a task is assigned for them - /// - [JsonProperty("assignment_activity_sid")] - public string AssignmentActivitySid { get; private set; } - /// - /// The name of the Activity to assign Workers when a task is assigned for them - /// - [JsonProperty("assignment_activity_name")] - public string AssignmentActivityName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The maximum number of Workers to reserve - /// - [JsonProperty("max_reserved_workers")] - public int? MaxReservedWorkers { get; private set; } - /// - /// The SID of the Activity to assign Workers once a task is reserved for them - /// - [JsonProperty("reservation_activity_sid")] - public string ReservationActivitySid { get; private set; } - /// - /// The name of the Activity to assign Workers once a task is reserved for them - /// - [JsonProperty("reservation_activity_name")] - public string ReservationActivityName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue - /// - [JsonProperty("target_workers")] - public string TargetWorkers { get; private set; } - /// - /// How Tasks will be assigned to Workers - /// - [JsonProperty("task_order")] - [JsonConverter(typeof(StringEnumConverter))] - public TaskQueueResource.TaskOrderEnum TaskOrder { get; private set; } - /// - /// The absolute URL of the TaskQueue resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The SID of the Workspace that contains the TaskQueue - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private TaskQueueResource() - { - - } - } +{ + + public class TaskQueueResource : Resource + { + public sealed class TaskOrderEnum : StringEnum + { + private TaskOrderEnum(string value) : base(value) { } + public TaskOrderEnum() { } + public static implicit operator TaskOrderEnum(string value) + { + return new TaskOrderEnum(value); + } + + public static readonly TaskOrderEnum Fifo = new TaskOrderEnum("FIFO"); + public static readonly TaskOrderEnum Lifo = new TaskOrderEnum("LIFO"); + } + + private static Request BuildFetchRequest(FetchTaskQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch TaskQueue parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Fetch(FetchTaskQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch TaskQueue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the resource to + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTaskQueueOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the TaskQueue to fetch + /// The SID of the resource to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskQueueOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update TaskQueue parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Update(UpdateTaskQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update TaskQueue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the TaskQueue to update + /// The SID of the resource to update + /// A string to describe the resource + /// A string describing the Worker selection criteria for any Tasks that enter the + /// TaskQueue + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + /// The SID of the Activity to assign Workers when a task is assigned for them + /// + /// The maximum number of Workers to create reservations for the assignment of a task + /// while in the queue + /// How Tasks will be assigned to Workers + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Update(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + string targetWorkers = null, + string reservationActivitySid = null, + string assignmentActivitySid = null, + int? maxReservedWorkers = null, + TaskQueueResource.TaskOrderEnum taskOrder = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskQueueOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, TargetWorkers = targetWorkers, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the TaskQueue to update + /// The SID of the resource to update + /// A string to describe the resource + /// A string describing the Worker selection criteria for any Tasks that enter the + /// TaskQueue + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + /// The SID of the Activity to assign Workers when a task is assigned for them + /// + /// The maximum number of Workers to create reservations for the assignment of a task + /// while in the queue + /// How Tasks will be assigned to Workers + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + string targetWorkers = null, + string reservationActivitySid = null, + string assignmentActivitySid = null, + int? maxReservedWorkers = null, + TaskQueueResource.TaskOrderEnum taskOrder = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskQueueOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, TargetWorkers = targetWorkers, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTaskQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read TaskQueue parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static ResourceSet Read(ReadTaskQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("task_queues", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read TaskQueue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("task_queues", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the TaskQueue to read + /// The friendly_name of the TaskQueue resources to read + /// The attributes of the Workers to read + /// The SID of the Worker with the TaskQueue resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static ResourceSet Read(string pathWorkspaceSid, + string friendlyName = null, + string evaluateWorkerAttributes = null, + string workerSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskQueueOptions(pathWorkspaceSid) { FriendlyName = friendlyName, EvaluateWorkerAttributes = evaluateWorkerAttributes, WorkerSid = workerSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the TaskQueue to read + /// The friendly_name of the TaskQueue resources to read + /// The attributes of the Workers to read + /// The SID of the Worker with the TaskQueue resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string friendlyName = null, + string evaluateWorkerAttributes = null, + string workerSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskQueueOptions(pathWorkspaceSid) { FriendlyName = friendlyName, EvaluateWorkerAttributes = evaluateWorkerAttributes, WorkerSid = workerSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("task_queues", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("task_queues", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("task_queues", response.Content); + } + + private static Request BuildCreateRequest(CreateTaskQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create TaskQueue parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Create(CreateTaskQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create TaskQueue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task CreateAsync(CreateTaskQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new TaskQueue belongs to + /// A string to describe the resource + /// A string describing the Worker selection criteria for any Tasks that enter the + /// TaskQueue + /// The maximum number of Workers to reserve + /// How Tasks will be assigned to Workers + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + /// The SID of the Activity to assign Workers once a task is assigned to them + /// + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static TaskQueueResource Create(string pathWorkspaceSid, + string friendlyName, + string targetWorkers = null, + int? maxReservedWorkers = null, + TaskQueueResource.TaskOrderEnum taskOrder = null, + string reservationActivitySid = null, + string assignmentActivitySid = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskQueueOptions(pathWorkspaceSid, friendlyName) { TargetWorkers = targetWorkers, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new TaskQueue belongs to + /// A string to describe the resource + /// A string describing the Worker selection criteria for any Tasks that enter the + /// TaskQueue + /// The maximum number of Workers to reserve + /// How Tasks will be assigned to Workers + /// The SID of the Activity to assign Workers when a task is reserved for them + /// + /// The SID of the Activity to assign Workers once a task is assigned to them + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + string friendlyName, + string targetWorkers = null, + int? maxReservedWorkers = null, + TaskQueueResource.TaskOrderEnum taskOrder = null, + string reservationActivitySid = null, + string assignmentActivitySid = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskQueueOptions(pathWorkspaceSid, friendlyName) { TargetWorkers = targetWorkers, MaxReservedWorkers = maxReservedWorkers, TaskOrder = taskOrder, ReservationActivitySid = reservationActivitySid, AssignmentActivitySid = assignmentActivitySid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTaskQueueOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/TaskQueues/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete TaskQueue parameters + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static bool Delete(DeleteTaskQueueOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete TaskQueue parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskQueueOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the TaskQueue to delete + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// A single instance of TaskQueue + public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTaskQueueOptions(pathWorkspaceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the TaskQueue to delete + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TaskQueue + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTaskQueueOptions(pathWorkspaceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskQueueResource object + /// + /// Raw JSON string + /// TaskQueueResource object represented by the provided JSON + public static TaskQueueResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Activity to assign Workers when a task is assigned for them + /// + [JsonProperty("assignment_activity_sid")] + public string AssignmentActivitySid { get; private set; } + /// + /// The name of the Activity to assign Workers when a task is assigned for them + /// + [JsonProperty("assignment_activity_name")] + public string AssignmentActivityName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The maximum number of Workers to reserve + /// + [JsonProperty("max_reserved_workers")] + public int? MaxReservedWorkers { get; private set; } + /// + /// The SID of the Activity to assign Workers once a task is reserved for them + /// + [JsonProperty("reservation_activity_sid")] + public string ReservationActivitySid { get; private set; } + /// + /// The name of the Activity to assign Workers once a task is reserved for them + /// + [JsonProperty("reservation_activity_name")] + public string ReservationActivityName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A string describing the Worker selection criteria for any Tasks that enter the TaskQueue + /// + [JsonProperty("target_workers")] + public string TargetWorkers { get; private set; } + /// + /// How Tasks will be assigned to Workers + /// + [JsonProperty("task_order")] + [JsonConverter(typeof(StringEnumConverter))] + public TaskQueueResource.TaskOrderEnum TaskOrder { get; private set; } + /// + /// The absolute URL of the TaskQueue resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The SID of the Workspace that contains the TaskQueue + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private TaskQueueResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskResource.cs index dcdb2a514..5ee92c52b 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskResource.cs @@ -17,659 +17,659 @@ using Twilio.Types; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class TaskResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Pending = new StatusEnum("pending"); - public static readonly StatusEnum Reserved = new StatusEnum("reserved"); - public static readonly StatusEnum Assigned = new StatusEnum("assigned"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); - } - - private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Task to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Task to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTaskOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the Task to update - /// The SID of the resource to update - /// The JSON string that describes the custom attributes of the task - /// The new status of the task - /// The reason that the Task was canceled or complete - /// The Task's new priority value - /// When MultiTasking is enabled, specify the TaskChannel with the task to update - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Update(string pathWorkspaceSid, - string pathSid, - string attributes = null, - TaskResource.StatusEnum assignmentStatus = null, - string reason = null, - int? priority = null, - string taskChannel = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathWorkspaceSid, pathSid){Attributes = attributes, AssignmentStatus = assignmentStatus, Reason = reason, Priority = priority, TaskChannel = taskChannel, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the Task to update - /// The SID of the resource to update - /// The JSON string that describes the custom attributes of the task - /// The new status of the task - /// The reason that the Task was canceled or complete - /// The Task's new priority value - /// When MultiTasking is enabled, specify the TaskChannel with the task to update - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string attributes = null, - TaskResource.StatusEnum assignmentStatus = null, - string reason = null, - int? priority = null, - string taskChannel = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateTaskOptions(pathWorkspaceSid, pathSid){Attributes = attributes, AssignmentStatus = assignmentStatus, Reason = reason, Priority = priority, TaskChannel = taskChannel, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the Task to delete - /// The SID of the resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Task - public static bool Delete(string pathWorkspaceSid, - string pathSid, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathWorkspaceSid, pathSid){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the Task to delete - /// The SID of the resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteTaskOptions(pathWorkspaceSid, pathSid){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("tasks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Tasks to read - /// The priority value of the Tasks to read - /// Returns the list of all Tasks in the Workspace with the specified assignment_status - /// - /// The SID of the Workflow with the Tasks to read - /// The friendly name of the Workflow with the Tasks to read - /// The SID of the TaskQueue with the Tasks to read - /// The friendly_name of the TaskQueue with the Tasks to read - /// The task attributes of the Tasks to read - /// Controls the order of the Tasks returned - /// Whether to read Tasks with addons - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Task - public static ResourceSet Read(string pathWorkspaceSid, - int? priority = null, - List assignmentStatus = null, - string workflowSid = null, - string workflowName = null, - string taskQueueSid = null, - string taskQueueName = null, - string evaluateTaskAttributes = null, - string ordering = null, - bool? hasAddons = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathWorkspaceSid){Priority = priority, AssignmentStatus = assignmentStatus, WorkflowSid = workflowSid, WorkflowName = workflowName, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, EvaluateTaskAttributes = evaluateTaskAttributes, Ordering = ordering, HasAddons = hasAddons, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Tasks to read - /// The priority value of the Tasks to read - /// Returns the list of all Tasks in the Workspace with the specified assignment_status - /// - /// The SID of the Workflow with the Tasks to read - /// The friendly name of the Workflow with the Tasks to read - /// The SID of the TaskQueue with the Tasks to read - /// The friendly_name of the TaskQueue with the Tasks to read - /// The task attributes of the Tasks to read - /// Controls the order of the Tasks returned - /// Whether to read Tasks with addons - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - int? priority = null, - List assignmentStatus = null, - string workflowSid = null, - string workflowName = null, - string taskQueueSid = null, - string taskQueueName = null, - string evaluateTaskAttributes = null, - string ordering = null, - bool? hasAddons = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTaskOptions(pathWorkspaceSid){Priority = priority, AssignmentStatus = assignmentStatus, WorkflowSid = workflowSid, WorkflowName = workflowName, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, EvaluateTaskAttributes = evaluateTaskAttributes, Ordering = ordering, HasAddons = hasAddons, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("tasks", response.Content); - } - - private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Task parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new Task belongs to - /// The amount of time in seconds the task can live before being assigned - /// The priority to assign the new task and override the default - /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name - /// or SID - /// The SID of the Workflow that you would like to handle routing for the new Task - /// A URL-encoded JSON string describing the attributes of the task - /// Client to make requests to Twilio - /// A single instance of Task - public static TaskResource Create(string pathWorkspaceSid, - int? timeout = null, - int? priority = null, - string taskChannel = null, - string workflowSid = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathWorkspaceSid){Timeout = timeout, Priority = priority, TaskChannel = taskChannel, WorkflowSid = workflowSid, Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new Task belongs to - /// The amount of time in seconds the task can live before being assigned - /// The priority to assign the new task and override the default - /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name - /// or SID - /// The SID of the Workflow that you would like to handle routing for the new Task - /// A URL-encoded JSON string describing the attributes of the task - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Task - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - int? timeout = null, - int? priority = null, - string taskChannel = null, - string workflowSid = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateTaskOptions(pathWorkspaceSid){Timeout = timeout, Priority = priority, TaskChannel = taskChannel, WorkflowSid = workflowSid, Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TaskResource object - /// - /// Raw JSON string - /// TaskResource object represented by the provided JSON - public static TaskResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number of seconds since the Task was created - /// - [JsonProperty("age")] - public int? Age { get; private set; } - /// - /// The current status of the Task's assignment - /// - [JsonProperty("assignment_status")] - [JsonConverter(typeof(StringEnumConverter))] - public TaskResource.StatusEnum AssignmentStatus { get; private set; } - /// - /// The JSON string with custom attributes of the work - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// An object that contains the addon data for all installed addons - /// - [JsonProperty("addons")] - public string Addons { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Task entered the TaskQueue. - /// - [JsonProperty("task_queue_entered_date")] - public DateTime? TaskQueueEnteredDate { get; private set; } - /// - /// Retrieve the list of all Tasks in the Workspace with the specified priority - /// - [JsonProperty("priority")] - public int? Priority { get; private set; } - /// - /// The reason the Task was canceled or completed - /// - [JsonProperty("reason")] - public string Reason { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the TaskQueue - /// - [JsonProperty("task_queue_sid")] - public string TaskQueueSid { get; private set; } - /// - /// The friendly name of the TaskQueue - /// - [JsonProperty("task_queue_friendly_name")] - public string TaskQueueFriendlyName { get; private set; } - /// - /// The SID of the TaskChannel - /// - [JsonProperty("task_channel_sid")] - public string TaskChannelSid { get; private set; } - /// - /// The unique name of the TaskChannel - /// - [JsonProperty("task_channel_unique_name")] - public string TaskChannelUniqueName { get; private set; } - /// - /// The amount of time in seconds that the Task can live before being assigned - /// - [JsonProperty("timeout")] - public int? Timeout { get; private set; } - /// - /// The SID of the Workflow that is controlling the Task - /// - [JsonProperty("workflow_sid")] - public string WorkflowSid { get; private set; } - /// - /// The friendly name of the Workflow that is controlling the Task - /// - [JsonProperty("workflow_friendly_name")] - public string WorkflowFriendlyName { get; private set; } - /// - /// The SID of the Workspace that contains the Task - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Task resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private TaskResource() - { - - } - } +{ + + public class TaskResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Pending = new StatusEnum("pending"); + public static readonly StatusEnum Reserved = new StatusEnum("reserved"); + public static readonly StatusEnum Assigned = new StatusEnum("assigned"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); + } + + private static Request BuildFetchRequest(FetchTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(FetchTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(FetchTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Task to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Task to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTaskOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(UpdateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the Task to update + /// The SID of the resource to update + /// The JSON string that describes the custom attributes of the task + /// The new status of the task + /// The reason that the Task was canceled or complete + /// The Task's new priority value + /// When MultiTasking is enabled, specify the TaskChannel with the task to update + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Update(string pathWorkspaceSid, + string pathSid, + string attributes = null, + TaskResource.StatusEnum assignmentStatus = null, + string reason = null, + int? priority = null, + string taskChannel = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathWorkspaceSid, pathSid) { Attributes = attributes, AssignmentStatus = assignmentStatus, Reason = reason, Priority = priority, TaskChannel = taskChannel, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the Task to update + /// The SID of the resource to update + /// The JSON string that describes the custom attributes of the task + /// The new status of the task + /// The reason that the Task was canceled or complete + /// The Task's new priority value + /// When MultiTasking is enabled, specify the TaskChannel with the task to update + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string attributes = null, + TaskResource.StatusEnum assignmentStatus = null, + string reason = null, + int? priority = null, + string taskChannel = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateTaskOptions(pathWorkspaceSid, pathSid) { Attributes = attributes, AssignmentStatus = assignmentStatus, Reason = reason, Priority = priority, TaskChannel = taskChannel, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(DeleteTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the Task to delete + /// The SID of the resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Task + public static bool Delete(string pathWorkspaceSid, + string pathSid, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathWorkspaceSid, pathSid) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the Task to delete + /// The SID of the resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteTaskOptions(pathWorkspaceSid, pathSid) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(ReadTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(ReadTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("tasks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Tasks to read + /// The priority value of the Tasks to read + /// Returns the list of all Tasks in the Workspace with the specified assignment_status + /// + /// The SID of the Workflow with the Tasks to read + /// The friendly name of the Workflow with the Tasks to read + /// The SID of the TaskQueue with the Tasks to read + /// The friendly_name of the TaskQueue with the Tasks to read + /// The task attributes of the Tasks to read + /// Controls the order of the Tasks returned + /// Whether to read Tasks with addons + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Task + public static ResourceSet Read(string pathWorkspaceSid, + int? priority = null, + List assignmentStatus = null, + string workflowSid = null, + string workflowName = null, + string taskQueueSid = null, + string taskQueueName = null, + string evaluateTaskAttributes = null, + string ordering = null, + bool? hasAddons = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathWorkspaceSid) { Priority = priority, AssignmentStatus = assignmentStatus, WorkflowSid = workflowSid, WorkflowName = workflowName, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, EvaluateTaskAttributes = evaluateTaskAttributes, Ordering = ordering, HasAddons = hasAddons, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Tasks to read + /// The priority value of the Tasks to read + /// Returns the list of all Tasks in the Workspace with the specified assignment_status + /// + /// The SID of the Workflow with the Tasks to read + /// The friendly name of the Workflow with the Tasks to read + /// The SID of the TaskQueue with the Tasks to read + /// The friendly_name of the TaskQueue with the Tasks to read + /// The task attributes of the Tasks to read + /// Controls the order of the Tasks returned + /// Whether to read Tasks with addons + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + int? priority = null, + List assignmentStatus = null, + string workflowSid = null, + string workflowName = null, + string taskQueueSid = null, + string taskQueueName = null, + string evaluateTaskAttributes = null, + string ordering = null, + bool? hasAddons = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTaskOptions(pathWorkspaceSid) { Priority = priority, AssignmentStatus = assignmentStatus, WorkflowSid = workflowSid, WorkflowName = workflowName, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, EvaluateTaskAttributes = evaluateTaskAttributes, Ordering = ordering, HasAddons = hasAddons, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("tasks", response.Content); + } + + private static Request BuildCreateRequest(CreateTaskOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Tasks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(CreateTaskOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Task parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(CreateTaskOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new Task belongs to + /// The amount of time in seconds the task can live before being assigned + /// The priority to assign the new task and override the default + /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name + /// or SID + /// The SID of the Workflow that you would like to handle routing for the new Task + /// A URL-encoded JSON string describing the attributes of the task + /// Client to make requests to Twilio + /// A single instance of Task + public static TaskResource Create(string pathWorkspaceSid, + int? timeout = null, + int? priority = null, + string taskChannel = null, + string workflowSid = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathWorkspaceSid) { Timeout = timeout, Priority = priority, TaskChannel = taskChannel, WorkflowSid = workflowSid, Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new Task belongs to + /// The amount of time in seconds the task can live before being assigned + /// The priority to assign the new task and override the default + /// When MultiTasking is enabled specify the TaskChannel by passing either its unique_name + /// or SID + /// The SID of the Workflow that you would like to handle routing for the new Task + /// A URL-encoded JSON string describing the attributes of the task + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Task + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + int? timeout = null, + int? priority = null, + string taskChannel = null, + string workflowSid = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateTaskOptions(pathWorkspaceSid) { Timeout = timeout, Priority = priority, TaskChannel = taskChannel, WorkflowSid = workflowSid, Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TaskResource object + /// + /// Raw JSON string + /// TaskResource object represented by the provided JSON + public static TaskResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number of seconds since the Task was created + /// + [JsonProperty("age")] + public int? Age { get; private set; } + /// + /// The current status of the Task's assignment + /// + [JsonProperty("assignment_status")] + [JsonConverter(typeof(StringEnumConverter))] + public TaskResource.StatusEnum AssignmentStatus { get; private set; } + /// + /// The JSON string with custom attributes of the work + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// An object that contains the addon data for all installed addons + /// + [JsonProperty("addons")] + public string Addons { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Task entered the TaskQueue. + /// + [JsonProperty("task_queue_entered_date")] + public DateTime? TaskQueueEnteredDate { get; private set; } + /// + /// Retrieve the list of all Tasks in the Workspace with the specified priority + /// + [JsonProperty("priority")] + public int? Priority { get; private set; } + /// + /// The reason the Task was canceled or completed + /// + [JsonProperty("reason")] + public string Reason { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the TaskQueue + /// + [JsonProperty("task_queue_sid")] + public string TaskQueueSid { get; private set; } + /// + /// The friendly name of the TaskQueue + /// + [JsonProperty("task_queue_friendly_name")] + public string TaskQueueFriendlyName { get; private set; } + /// + /// The SID of the TaskChannel + /// + [JsonProperty("task_channel_sid")] + public string TaskChannelSid { get; private set; } + /// + /// The unique name of the TaskChannel + /// + [JsonProperty("task_channel_unique_name")] + public string TaskChannelUniqueName { get; private set; } + /// + /// The amount of time in seconds that the Task can live before being assigned + /// + [JsonProperty("timeout")] + public int? Timeout { get; private set; } + /// + /// The SID of the Workflow that is controlling the Task + /// + [JsonProperty("workflow_sid")] + public string WorkflowSid { get; private set; } + /// + /// The friendly name of the Workflow that is controlling the Task + /// + [JsonProperty("workflow_friendly_name")] + public string WorkflowFriendlyName { get; private set; } + /// + /// The SID of the Workspace that contains the Task + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Task resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private TaskResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationOptions.cs index 727957683..24d8f598f 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationOptions.cs @@ -10,620 +10,620 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// ReadReservationOptions + /// + public class ReadReservationOptions : ReadOptions + { /// - /// ReadReservationOptions - /// - public class ReadReservationOptions : ReadOptions - { - /// - /// The SID of the Workspace with the WorkerReservation resources to read - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Worker resource with the WorkerReservation resources to read - /// - public string PathWorkerSid { get; } - /// - /// Returns the list of reservations for a worker with a specified ReservationStatus - /// - public ReservationResource.StatusEnum ReservationStatus { get; set; } - - /// - /// Construct a new ReadReservationOptions - /// - /// The SID of the Workspace with the WorkerReservation resources to read - /// The SID of the reserved Worker resource with the WorkerReservation resources to read - /// - public ReadReservationOptions(string pathWorkspaceSid, string pathWorkerSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ReservationStatus != null) - { - p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Workspace with the WorkerReservation resources to read + /// + public string PathWorkspaceSid { get; } /// - /// FetchReservationOptions - /// - public class FetchReservationOptions : IOptions - { - /// - /// The SID of the Workspace with the WorkerReservation resource to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch - /// - public string PathWorkerSid { get; } - /// - /// The SID of the WorkerReservation resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchReservationOptions - /// - /// The SID of the Workspace with the WorkerReservation resource to fetch - /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch - /// - /// The SID of the WorkerReservation resource to fetch - public FetchReservationOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the reserved Worker resource with the WorkerReservation resources to read + /// + public string PathWorkerSid { get; } /// - /// UpdateReservationOptions - /// - public class UpdateReservationOptions : IOptions - { - /// - /// The SID of the Workspace with the WorkerReservation resources to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the reserved Worker resource with the WorkerReservation resources to update - /// - public string PathWorkerSid { get; } - /// - /// The SID of the WorkerReservation resource to update - /// - public string PathSid { get; } - /// - /// The new status of the reservation - /// - public ReservationResource.StatusEnum ReservationStatus { get; set; } - /// - /// The new worker activity SID if rejecting a reservation - /// - public string WorkerActivitySid { get; set; } - /// - /// The assignment instruction for the reservation - /// - public string Instruction { get; set; } - /// - /// The SID of the Activity resource to start after executing a Dequeue instruction - /// - public string DequeuePostWorkActivitySid { get; set; } - /// - /// The caller ID of the call to the worker when executing a Dequeue instruction - /// - public string DequeueFrom { get; set; } - /// - /// Whether to record both legs of a call when executing a Dequeue instruction - /// - public string DequeueRecord { get; set; } - /// - /// The timeout for call when executing a Dequeue instruction - /// - public int? DequeueTimeout { get; set; } - /// - /// The contact URI of the worker when executing a Dequeue instruction - /// - public string DequeueTo { get; set; } - /// - /// The callback URL for completed call event when executing a Dequeue instruction - /// - public Uri DequeueStatusCallbackUrl { get; set; } - /// - /// The Caller ID of the outbound call when executing a Call instruction - /// - public string CallFrom { get; set; } - /// - /// Whether to record both legs of a call when executing a Call instruction - /// - public string CallRecord { get; set; } - /// - /// The timeout for a call when executing a Call instruction - /// - public int? CallTimeout { get; set; } - /// - /// The contact URI of the worker when executing a Call instruction - /// - public string CallTo { get; set; } - /// - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// - public Uri CallUrl { get; set; } - /// - /// The URL to call for the completed call event when executing a Call instruction - /// - public Uri CallStatusCallbackUrl { get; set; } - /// - /// Whether to accept a reservation when executing a Call instruction - /// - public bool? CallAccept { get; set; } - /// - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - public string RedirectCallSid { get; set; } - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - public bool? RedirectAccept { get; set; } - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// - public Uri RedirectUrl { get; set; } - /// - /// The Contact URI of the worker when executing a Conference instruction - /// - public string To { get; set; } - /// - /// The caller ID of the call to the worker when executing a Conference instruction - /// - public string From { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The call progress events that we will send to status_callback - /// - public List StatusCallbackEvent { get; set; } - /// - /// The timeout for a call when executing a Conference instruction - /// - public int? Timeout { get; set; } - /// - /// Whether to record the participant and their conferences - /// - public bool? Record { get; set; } - /// - /// Whether to mute the agent - /// - public bool? Muted { get; set; } - /// - /// Whether to play a notification beep when the participant joins - /// - public string Beep { get; set; } - /// - /// Whether the conference starts when the participant joins the conference - /// - public bool? StartConferenceOnEnter { get; set; } - /// - /// Whether to end the conference when the agent leaves - /// - public bool? EndConferenceOnExit { get; set; } - /// - /// URL that hosts pre-conference hold music - /// - public Uri WaitUrl { get; set; } - /// - /// The HTTP method we should use to call `wait_url` - /// - public Twilio.Http.HttpMethod WaitMethod { get; set; } - /// - /// Whether agents can hear the state of the outbound call - /// - public bool? EarlyMedia { get; set; } - /// - /// The maximum number of agent conference participants - /// - public int? MaxParticipants { get; set; } - /// - /// The callback URL for conference events - /// - public Uri ConferenceStatusCallback { get; set; } - /// - /// HTTP method for requesting `conference_status_callback` URL - /// - public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } - /// - /// The conference status events that we will send to conference_status_callback - /// - public List ConferenceStatusCallbackEvent { get; set; } - /// - /// Whether to record the conference the participant is joining - /// - public string ConferenceRecord { get; set; } - /// - /// Whether to trim leading and trailing silence from your recorded conference audio files - /// - public string ConferenceTrim { get; set; } - /// - /// Specify `mono` or `dual` recording channels - /// - public string RecordingChannels { get; set; } - /// - /// The URL that we should call using the `recording_status_callback_method` when the recording status changes - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use when we call `recording_status_callback` - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available - /// - public Uri ConferenceRecordingStatusCallback { get; set; } - /// - /// The HTTP method we should use to call `conference_recording_status_callback` - /// - public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } - /// - /// The region where we should mix the conference audio - /// - public string Region { get; set; } - /// - /// The SIP username used for authentication - /// - public string SipAuthUsername { get; set; } - /// - /// The SIP password for authentication - /// - public string SipAuthPassword { get; set; } - /// - /// The call progress events sent via webhooks as a result of a Dequeue instruction - /// - public List DequeueStatusCallbackEvent { get; set; } - /// - /// The new worker activity SID after executing a Conference instruction - /// - public string PostWorkActivitySid { get; set; } - /// - /// Whether to end the conference when the customer leaves - /// - public bool? EndConferenceOnCustomerExit { get; set; } - /// - /// Whether to play a notification beep when the customer joins - /// - public bool? BeepOnCustomerEntrance { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateReservationOptions - /// - /// The SID of the Workspace with the WorkerReservation resources to update - /// The SID of the reserved Worker resource with the WorkerReservation resources to update - /// - /// The SID of the WorkerReservation resource to update - public UpdateReservationOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - PathSid = pathSid; - StatusCallbackEvent = new List(); - ConferenceStatusCallbackEvent = new List(); - DequeueStatusCallbackEvent = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ReservationStatus != null) - { - p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); - } - - if (WorkerActivitySid != null) - { - p.Add(new KeyValuePair("WorkerActivitySid", WorkerActivitySid.ToString())); - } - - if (Instruction != null) - { - p.Add(new KeyValuePair("Instruction", Instruction)); - } - - if (DequeuePostWorkActivitySid != null) - { - p.Add(new KeyValuePair("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); - } - - if (DequeueFrom != null) - { - p.Add(new KeyValuePair("DequeueFrom", DequeueFrom)); - } - - if (DequeueRecord != null) - { - p.Add(new KeyValuePair("DequeueRecord", DequeueRecord)); - } - - if (DequeueTimeout != null) - { - p.Add(new KeyValuePair("DequeueTimeout", DequeueTimeout.ToString())); - } - - if (DequeueTo != null) - { - p.Add(new KeyValuePair("DequeueTo", DequeueTo)); - } - - if (DequeueStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("DequeueStatusCallbackUrl", Serializers.Url(DequeueStatusCallbackUrl))); - } - - if (CallFrom != null) - { - p.Add(new KeyValuePair("CallFrom", CallFrom)); - } - - if (CallRecord != null) - { - p.Add(new KeyValuePair("CallRecord", CallRecord)); - } - - if (CallTimeout != null) - { - p.Add(new KeyValuePair("CallTimeout", CallTimeout.ToString())); - } - - if (CallTo != null) - { - p.Add(new KeyValuePair("CallTo", CallTo)); - } - - if (CallUrl != null) - { - p.Add(new KeyValuePair("CallUrl", Serializers.Url(CallUrl))); - } - - if (CallStatusCallbackUrl != null) - { - p.Add(new KeyValuePair("CallStatusCallbackUrl", Serializers.Url(CallStatusCallbackUrl))); - } - - if (CallAccept != null) - { - p.Add(new KeyValuePair("CallAccept", CallAccept.Value.ToString().ToLower())); - } - - if (RedirectCallSid != null) - { - p.Add(new KeyValuePair("RedirectCallSid", RedirectCallSid.ToString())); - } - - if (RedirectAccept != null) - { - p.Add(new KeyValuePair("RedirectAccept", RedirectAccept.Value.ToString().ToLower())); - } - - if (RedirectUrl != null) - { - p.Add(new KeyValuePair("RedirectUrl", Serializers.Url(RedirectUrl))); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (From != null) - { - p.Add(new KeyValuePair("From", From)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (StatusCallbackEvent != null) - { - p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop.ToString()))); - } - - if (Timeout != null) - { - p.Add(new KeyValuePair("Timeout", Timeout.ToString())); - } - - if (Record != null) - { - p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); - } - - if (Muted != null) - { - p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); - } - - if (Beep != null) - { - p.Add(new KeyValuePair("Beep", Beep)); - } - - if (StartConferenceOnEnter != null) - { - p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); - } - - if (EndConferenceOnExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); - } - - if (WaitUrl != null) - { - p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); - } - - if (WaitMethod != null) - { - p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); - } - - if (EarlyMedia != null) - { - p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); - } - - if (MaxParticipants != null) - { - p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); - } - - if (ConferenceStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); - } - - if (ConferenceStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); - } - - if (ConferenceStatusCallbackEvent != null) - { - p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop.ToString()))); - } - - if (ConferenceRecord != null) - { - p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); - } - - if (ConferenceTrim != null) - { - p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); - } - - if (RecordingChannels != null) - { - p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); - } - - if (RecordingStatusCallback != null) - { - p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); - } - - if (RecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); - } - - if (ConferenceRecordingStatusCallback != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); - } - - if (ConferenceRecordingStatusCallbackMethod != null) - { - p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); - } - - if (Region != null) - { - p.Add(new KeyValuePair("Region", Region)); - } - - if (SipAuthUsername != null) - { - p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); - } - - if (SipAuthPassword != null) - { - p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); - } - - if (DequeueStatusCallbackEvent != null) - { - p.AddRange(DequeueStatusCallbackEvent.Select(prop => new KeyValuePair("DequeueStatusCallbackEvent", prop))); - } - - if (PostWorkActivitySid != null) - { - p.Add(new KeyValuePair("PostWorkActivitySid", PostWorkActivitySid.ToString())); - } - - if (EndConferenceOnCustomerExit != null) - { - p.Add(new KeyValuePair("EndConferenceOnCustomerExit", EndConferenceOnCustomerExit.Value.ToString().ToLower())); - } - - if (BeepOnCustomerEntrance != null) - { - p.Add(new KeyValuePair("BeepOnCustomerEntrance", BeepOnCustomerEntrance.Value.ToString().ToLower())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// Returns the list of reservations for a worker with a specified ReservationStatus + /// + public ReservationResource.StatusEnum ReservationStatus { get; set; } + + /// + /// Construct a new ReadReservationOptions + /// + /// The SID of the Workspace with the WorkerReservation resources to read + /// The SID of the reserved Worker resource with the WorkerReservation resources to read + /// + public ReadReservationOptions(string pathWorkspaceSid, string pathWorkerSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ReservationStatus != null) + { + p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchReservationOptions + /// + public class FetchReservationOptions : IOptions + { + /// + /// The SID of the Workspace with the WorkerReservation resource to fetch + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch + /// + public string PathWorkerSid { get; } + /// + /// The SID of the WorkerReservation resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchReservationOptions + /// + /// The SID of the Workspace with the WorkerReservation resource to fetch + /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch + /// + /// The SID of the WorkerReservation resource to fetch + public FetchReservationOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateReservationOptions + /// + public class UpdateReservationOptions : IOptions + { + /// + /// The SID of the Workspace with the WorkerReservation resources to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the reserved Worker resource with the WorkerReservation resources to update + /// + public string PathWorkerSid { get; } + /// + /// The SID of the WorkerReservation resource to update + /// + public string PathSid { get; } + /// + /// The new status of the reservation + /// + public ReservationResource.StatusEnum ReservationStatus { get; set; } + /// + /// The new worker activity SID if rejecting a reservation + /// + public string WorkerActivitySid { get; set; } + /// + /// The assignment instruction for the reservation + /// + public string Instruction { get; set; } + /// + /// The SID of the Activity resource to start after executing a Dequeue instruction + /// + public string DequeuePostWorkActivitySid { get; set; } + /// + /// The caller ID of the call to the worker when executing a Dequeue instruction + /// + public string DequeueFrom { get; set; } + /// + /// Whether to record both legs of a call when executing a Dequeue instruction + /// + public string DequeueRecord { get; set; } + /// + /// The timeout for call when executing a Dequeue instruction + /// + public int? DequeueTimeout { get; set; } + /// + /// The contact URI of the worker when executing a Dequeue instruction + /// + public string DequeueTo { get; set; } + /// + /// The callback URL for completed call event when executing a Dequeue instruction + /// + public Uri DequeueStatusCallbackUrl { get; set; } + /// + /// The Caller ID of the outbound call when executing a Call instruction + /// + public string CallFrom { get; set; } + /// + /// Whether to record both legs of a call when executing a Call instruction + /// + public string CallRecord { get; set; } + /// + /// The timeout for a call when executing a Call instruction + /// + public int? CallTimeout { get; set; } + /// + /// The contact URI of the worker when executing a Call instruction + /// + public string CallTo { get; set; } + /// + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// + public Uri CallUrl { get; set; } + /// + /// The URL to call for the completed call event when executing a Call instruction + /// + public Uri CallStatusCallbackUrl { get; set; } + /// + /// Whether to accept a reservation when executing a Call instruction + /// + public bool? CallAccept { get; set; } + /// + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + public string RedirectCallSid { get; set; } + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + public bool? RedirectAccept { get; set; } + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// + public Uri RedirectUrl { get; set; } + /// + /// The Contact URI of the worker when executing a Conference instruction + /// + public string To { get; set; } + /// + /// The caller ID of the call to the worker when executing a Conference instruction + /// + public string From { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The call progress events that we will send to status_callback + /// + public List StatusCallbackEvent { get; set; } + /// + /// The timeout for a call when executing a Conference instruction + /// + public int? Timeout { get; set; } + /// + /// Whether to record the participant and their conferences + /// + public bool? Record { get; set; } + /// + /// Whether to mute the agent + /// + public bool? Muted { get; set; } + /// + /// Whether to play a notification beep when the participant joins + /// + public string Beep { get; set; } + /// + /// Whether the conference starts when the participant joins the conference + /// + public bool? StartConferenceOnEnter { get; set; } + /// + /// Whether to end the conference when the agent leaves + /// + public bool? EndConferenceOnExit { get; set; } + /// + /// URL that hosts pre-conference hold music + /// + public Uri WaitUrl { get; set; } + /// + /// The HTTP method we should use to call `wait_url` + /// + public Twilio.Http.HttpMethod WaitMethod { get; set; } + /// + /// Whether agents can hear the state of the outbound call + /// + public bool? EarlyMedia { get; set; } + /// + /// The maximum number of agent conference participants + /// + public int? MaxParticipants { get; set; } + /// + /// The callback URL for conference events + /// + public Uri ConferenceStatusCallback { get; set; } + /// + /// HTTP method for requesting `conference_status_callback` URL + /// + public Twilio.Http.HttpMethod ConferenceStatusCallbackMethod { get; set; } + /// + /// The conference status events that we will send to conference_status_callback + /// + public List ConferenceStatusCallbackEvent { get; set; } + /// + /// Whether to record the conference the participant is joining + /// + public string ConferenceRecord { get; set; } + /// + /// Whether to trim leading and trailing silence from your recorded conference audio files + /// + public string ConferenceTrim { get; set; } + /// + /// Specify `mono` or `dual` recording channels + /// + public string RecordingChannels { get; set; } + /// + /// The URL that we should call using the `recording_status_callback_method` when the recording status changes + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use when we call `recording_status_callback` + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available + /// + public Uri ConferenceRecordingStatusCallback { get; set; } + /// + /// The HTTP method we should use to call `conference_recording_status_callback` + /// + public Twilio.Http.HttpMethod ConferenceRecordingStatusCallbackMethod { get; set; } + /// + /// The region where we should mix the conference audio + /// + public string Region { get; set; } + /// + /// The SIP username used for authentication + /// + public string SipAuthUsername { get; set; } + /// + /// The SIP password for authentication + /// + public string SipAuthPassword { get; set; } + /// + /// The call progress events sent via webhooks as a result of a Dequeue instruction + /// + public List DequeueStatusCallbackEvent { get; set; } + /// + /// The new worker activity SID after executing a Conference instruction + /// + public string PostWorkActivitySid { get; set; } + /// + /// Whether to end the conference when the customer leaves + /// + public bool? EndConferenceOnCustomerExit { get; set; } + /// + /// Whether to play a notification beep when the customer joins + /// + public bool? BeepOnCustomerEntrance { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateReservationOptions + /// + /// The SID of the Workspace with the WorkerReservation resources to update + /// The SID of the reserved Worker resource with the WorkerReservation resources to update + /// + /// The SID of the WorkerReservation resource to update + public UpdateReservationOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + PathSid = pathSid; + StatusCallbackEvent = new List(); + ConferenceStatusCallbackEvent = new List(); + DequeueStatusCallbackEvent = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ReservationStatus != null) + { + p.Add(new KeyValuePair("ReservationStatus", ReservationStatus.ToString())); + } + + if (WorkerActivitySid != null) + { + p.Add(new KeyValuePair("WorkerActivitySid", WorkerActivitySid.ToString())); + } + + if (Instruction != null) + { + p.Add(new KeyValuePair("Instruction", Instruction)); + } + + if (DequeuePostWorkActivitySid != null) + { + p.Add(new KeyValuePair("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); + } + + if (DequeueFrom != null) + { + p.Add(new KeyValuePair("DequeueFrom", DequeueFrom)); + } + + if (DequeueRecord != null) + { + p.Add(new KeyValuePair("DequeueRecord", DequeueRecord)); + } + + if (DequeueTimeout != null) + { + p.Add(new KeyValuePair("DequeueTimeout", DequeueTimeout.ToString())); + } + + if (DequeueTo != null) + { + p.Add(new KeyValuePair("DequeueTo", DequeueTo)); + } + + if (DequeueStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("DequeueStatusCallbackUrl", Serializers.Url(DequeueStatusCallbackUrl))); + } + + if (CallFrom != null) + { + p.Add(new KeyValuePair("CallFrom", CallFrom)); + } + + if (CallRecord != null) + { + p.Add(new KeyValuePair("CallRecord", CallRecord)); + } + + if (CallTimeout != null) + { + p.Add(new KeyValuePair("CallTimeout", CallTimeout.ToString())); + } + + if (CallTo != null) + { + p.Add(new KeyValuePair("CallTo", CallTo)); + } + + if (CallUrl != null) + { + p.Add(new KeyValuePair("CallUrl", Serializers.Url(CallUrl))); + } + + if (CallStatusCallbackUrl != null) + { + p.Add(new KeyValuePair("CallStatusCallbackUrl", Serializers.Url(CallStatusCallbackUrl))); + } + + if (CallAccept != null) + { + p.Add(new KeyValuePair("CallAccept", CallAccept.Value.ToString().ToLower())); + } + + if (RedirectCallSid != null) + { + p.Add(new KeyValuePair("RedirectCallSid", RedirectCallSid.ToString())); + } + + if (RedirectAccept != null) + { + p.Add(new KeyValuePair("RedirectAccept", RedirectAccept.Value.ToString().ToLower())); + } + + if (RedirectUrl != null) + { + p.Add(new KeyValuePair("RedirectUrl", Serializers.Url(RedirectUrl))); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (From != null) + { + p.Add(new KeyValuePair("From", From)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (StatusCallbackEvent != null) + { + p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair("StatusCallbackEvent", prop.ToString()))); + } + + if (Timeout != null) + { + p.Add(new KeyValuePair("Timeout", Timeout.ToString())); + } + + if (Record != null) + { + p.Add(new KeyValuePair("Record", Record.Value.ToString().ToLower())); + } + + if (Muted != null) + { + p.Add(new KeyValuePair("Muted", Muted.Value.ToString().ToLower())); + } + + if (Beep != null) + { + p.Add(new KeyValuePair("Beep", Beep)); + } + + if (StartConferenceOnEnter != null) + { + p.Add(new KeyValuePair("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); + } + + if (EndConferenceOnExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); + } + + if (WaitUrl != null) + { + p.Add(new KeyValuePair("WaitUrl", Serializers.Url(WaitUrl))); + } + + if (WaitMethod != null) + { + p.Add(new KeyValuePair("WaitMethod", WaitMethod.ToString())); + } + + if (EarlyMedia != null) + { + p.Add(new KeyValuePair("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); + } + + if (MaxParticipants != null) + { + p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); + } + + if (ConferenceStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallback", Serializers.Url(ConferenceStatusCallback))); + } + + if (ConferenceStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); + } + + if (ConferenceStatusCallbackEvent != null) + { + p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair("ConferenceStatusCallbackEvent", prop.ToString()))); + } + + if (ConferenceRecord != null) + { + p.Add(new KeyValuePair("ConferenceRecord", ConferenceRecord)); + } + + if (ConferenceTrim != null) + { + p.Add(new KeyValuePair("ConferenceTrim", ConferenceTrim)); + } + + if (RecordingChannels != null) + { + p.Add(new KeyValuePair("RecordingChannels", RecordingChannels)); + } + + if (RecordingStatusCallback != null) + { + p.Add(new KeyValuePair("RecordingStatusCallback", Serializers.Url(RecordingStatusCallback))); + } + + if (RecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); + } + + if (ConferenceRecordingStatusCallback != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallback", Serializers.Url(ConferenceRecordingStatusCallback))); + } + + if (ConferenceRecordingStatusCallbackMethod != null) + { + p.Add(new KeyValuePair("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); + } + + if (Region != null) + { + p.Add(new KeyValuePair("Region", Region)); + } + + if (SipAuthUsername != null) + { + p.Add(new KeyValuePair("SipAuthUsername", SipAuthUsername)); + } + + if (SipAuthPassword != null) + { + p.Add(new KeyValuePair("SipAuthPassword", SipAuthPassword)); + } + + if (DequeueStatusCallbackEvent != null) + { + p.AddRange(DequeueStatusCallbackEvent.Select(prop => new KeyValuePair("DequeueStatusCallbackEvent", prop))); + } + + if (PostWorkActivitySid != null) + { + p.Add(new KeyValuePair("PostWorkActivitySid", PostWorkActivitySid.ToString())); + } + + if (EndConferenceOnCustomerExit != null) + { + p.Add(new KeyValuePair("EndConferenceOnCustomerExit", EndConferenceOnCustomerExit.Value.ToString().ToLower())); + } + + if (BeepOnCustomerEntrance != null) + { + p.Add(new KeyValuePair("BeepOnCustomerEntrance", BeepOnCustomerEntrance.Value.ToString().ToLower())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationResource.cs index f024b89a3..5541e8a93 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/ReservationResource.cs @@ -17,678 +17,678 @@ using Twilio.Types; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class ReservationResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Pending = new StatusEnum("pending"); - public static readonly StatusEnum Accepted = new StatusEnum("accepted"); - public static readonly StatusEnum Rejected = new StatusEnum("rejected"); - public static readonly StatusEnum Timeout = new StatusEnum("timeout"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Rescinded = new StatusEnum("rescinded"); - public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - } - - public sealed class CallStatusEnum : StringEnum - { - private CallStatusEnum(string value) : base(value) {} - public CallStatusEnum() {} - public static implicit operator CallStatusEnum(string value) - { - return new CallStatusEnum(value); - } - - public static readonly CallStatusEnum Initiated = new CallStatusEnum("initiated"); - public static readonly CallStatusEnum Ringing = new CallStatusEnum("ringing"); - public static readonly CallStatusEnum Answered = new CallStatusEnum("answered"); - public static readonly CallStatusEnum Completed = new CallStatusEnum("completed"); - } - - public sealed class ConferenceEventEnum : StringEnum - { - private ConferenceEventEnum(string value) : base(value) {} - public ConferenceEventEnum() {} - public static implicit operator ConferenceEventEnum(string value) - { - return new ConferenceEventEnum(value); - } - - public static readonly ConferenceEventEnum Start = new ConferenceEventEnum("start"); - public static readonly ConferenceEventEnum End = new ConferenceEventEnum("end"); - public static readonly ConferenceEventEnum Join = new ConferenceEventEnum("join"); - public static readonly ConferenceEventEnum Leave = new ConferenceEventEnum("leave"); - public static readonly ConferenceEventEnum Mute = new ConferenceEventEnum("mute"); - public static readonly ConferenceEventEnum Hold = new ConferenceEventEnum("hold"); - public static readonly ConferenceEventEnum Speaker = new ConferenceEventEnum("speaker"); - } - - private static Request BuildReadRequest(ReadReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ResourceSet Read(ReadReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("reservations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task> ReadAsync(ReadReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("reservations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the WorkerReservation resources to read - /// The SID of the reserved Worker resource with the WorkerReservation resources to read - /// - /// Returns the list of reservations for a worker with a specified ReservationStatus - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ResourceSet Read(string pathWorkspaceSid, - string pathWorkerSid, - ReservationResource.StatusEnum reservationStatus = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadReservationOptions(pathWorkspaceSid, pathWorkerSid){ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the WorkerReservation resources to read - /// The SID of the reserved Worker resource with the WorkerReservation resources to read - /// - /// Returns the list of reservations for a worker with a specified ReservationStatus - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string pathWorkerSid, - ReservationResource.StatusEnum reservationStatus = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadReservationOptions(pathWorkspaceSid, pathWorkerSid){ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("reservations", response.Content); - } - - private static Request BuildFetchRequest(FetchReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Fetch(FetchReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task FetchAsync(FetchReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerReservation resource to fetch - /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch - /// - /// The SID of the WorkerReservation resource to fetch - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Fetch(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerReservation resource to fetch - /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch - /// - /// The SID of the WorkerReservation resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateReservationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Reservation parameters - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Update(UpdateReservationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Reservation parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task UpdateAsync(UpdateReservationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the WorkerReservation resources to update - /// The SID of the reserved Worker resource with the WorkerReservation resources to update - /// - /// The SID of the WorkerReservation resource to update - /// The new status of the reservation - /// The new worker activity SID if rejecting a reservation - /// The assignment instruction for the reservation - /// The SID of the Activity resource to start after executing a Dequeue - /// instruction - /// The caller ID of the call to the worker when executing a Dequeue instruction - /// Whether to record both legs of a call when executing a Dequeue instruction - /// The timeout for call when executing a Dequeue instruction - /// The contact URI of the worker when executing a Dequeue instruction - /// The callback URL for completed call event when executing a Dequeue - /// instruction - /// The Caller ID of the outbound call when executing a Call instruction - /// Whether to record both legs of a call when executing a Call instruction - /// The timeout for a call when executing a Call instruction - /// The contact URI of the worker when executing a Call instruction - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// The URL to call for the completed call event when executing a Call instruction - /// - /// Whether to accept a reservation when executing a Call instruction - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// The Contact URI of the worker when executing a Conference instruction - /// The caller ID of the call to the worker when executing a Conference instruction - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The call progress events that we will send to status_callback - /// The timeout for a call when executing a Conference instruction - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the agent leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference status events that we will send to - /// conference_status_callback - /// Whether to record the conference the participant is joining - /// Whether to trim leading and trailing silence from your recorded conference audio - /// files - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The region where we should mix the conference audio - /// The SIP username used for authentication - /// The SIP password for authentication - /// The call progress events sent via webhooks as a result of a Dequeue - /// instruction - /// The new worker activity SID after executing a Conference instruction - /// Whether to end the conference when the customer leaves - /// Whether to play a notification beep when the customer joins - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Reservation - public static ReservationResource Update(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ReservationResource.StatusEnum reservationStatus = null, - string workerActivitySid = null, - string instruction = null, - string dequeuePostWorkActivitySid = null, - string dequeueFrom = null, - string dequeueRecord = null, - int? dequeueTimeout = null, - string dequeueTo = null, - Uri dequeueStatusCallbackUrl = null, - string callFrom = null, - string callRecord = null, - int? callTimeout = null, - string callTo = null, - Uri callUrl = null, - Uri callStatusCallbackUrl = null, - bool? callAccept = null, - string redirectCallSid = null, - bool? redirectAccept = null, - Uri redirectUrl = null, - string to = null, - string from = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string conferenceRecord = null, - string conferenceTrim = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - string region = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - List dequeueStatusCallbackEvent = null, - string postWorkActivitySid = null, - bool? endConferenceOnCustomerExit = null, - bool? beepOnCustomerEntrance = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid){ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the WorkerReservation resources to update - /// The SID of the reserved Worker resource with the WorkerReservation resources to update - /// - /// The SID of the WorkerReservation resource to update - /// The new status of the reservation - /// The new worker activity SID if rejecting a reservation - /// The assignment instruction for the reservation - /// The SID of the Activity resource to start after executing a Dequeue - /// instruction - /// The caller ID of the call to the worker when executing a Dequeue instruction - /// Whether to record both legs of a call when executing a Dequeue instruction - /// The timeout for call when executing a Dequeue instruction - /// The contact URI of the worker when executing a Dequeue instruction - /// The callback URL for completed call event when executing a Dequeue - /// instruction - /// The Caller ID of the outbound call when executing a Call instruction - /// Whether to record both legs of a call when executing a Call instruction - /// The timeout for a call when executing a Call instruction - /// The contact URI of the worker when executing a Call instruction - /// TwiML URI executed on answering the worker's leg as a result of the Call instruction - /// The URL to call for the completed call event when executing a Call instruction - /// - /// Whether to accept a reservation when executing a Call instruction - /// The Call SID of the call parked in the queue when executing a Redirect instruction - /// - /// Whether the reservation should be accepted when executing a Redirect instruction - /// - /// TwiML URI to redirect the call to when executing the Redirect instruction - /// The Contact URI of the worker when executing a Conference instruction - /// The caller ID of the call to the worker when executing a Conference instruction - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// The call progress events that we will send to status_callback - /// The timeout for a call when executing a Conference instruction - /// Whether to record the participant and their conferences - /// Whether to mute the agent - /// Whether to play a notification beep when the participant joins - /// Whether the conference starts when the participant joins the conference - /// - /// Whether to end the conference when the agent leaves - /// URL that hosts pre-conference hold music - /// The HTTP method we should use to call `wait_url` - /// Whether agents can hear the state of the outbound call - /// The maximum number of agent conference participants - /// The callback URL for conference events - /// HTTP method for requesting `conference_status_callback` URL - /// The conference status events that we will send to - /// conference_status_callback - /// Whether to record the conference the participant is joining - /// Whether to trim leading and trailing silence from your recorded conference audio - /// files - /// Specify `mono` or `dual` recording channels - /// The URL that we should call using the `recording_status_callback_method` - /// when the recording status changes - /// The HTTP method we should use when we call `recording_status_callback` - /// - /// The URL we should call using the - /// `conference_recording_status_callback_method` when the conference recording - /// is available - /// The HTTP method we should use to call - /// `conference_recording_status_callback` - /// The region where we should mix the conference audio - /// The SIP username used for authentication - /// The SIP password for authentication - /// The call progress events sent via webhooks as a result of a Dequeue - /// instruction - /// The new worker activity SID after executing a Conference instruction - /// Whether to end the conference when the customer leaves - /// Whether to play a notification beep when the customer joins - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Reservation - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ReservationResource.StatusEnum reservationStatus = null, - string workerActivitySid = null, - string instruction = null, - string dequeuePostWorkActivitySid = null, - string dequeueFrom = null, - string dequeueRecord = null, - int? dequeueTimeout = null, - string dequeueTo = null, - Uri dequeueStatusCallbackUrl = null, - string callFrom = null, - string callRecord = null, - int? callTimeout = null, - string callTo = null, - Uri callUrl = null, - Uri callStatusCallbackUrl = null, - bool? callAccept = null, - string redirectCallSid = null, - bool? redirectAccept = null, - Uri redirectUrl = null, - string to = null, - string from = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - List statusCallbackEvent = null, - int? timeout = null, - bool? record = null, - bool? muted = null, - string beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - bool? earlyMedia = null, - int? maxParticipants = null, - Uri conferenceStatusCallback = null, - Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, - List conferenceStatusCallbackEvent = null, - string conferenceRecord = null, - string conferenceTrim = null, - string recordingChannels = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - Uri conferenceRecordingStatusCallback = null, - Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, - string region = null, - string sipAuthUsername = null, - string sipAuthPassword = null, - List dequeueStatusCallbackEvent = null, - string postWorkActivitySid = null, - bool? endConferenceOnCustomerExit = null, - bool? beepOnCustomerEntrance = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid){ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ReservationResource object - /// - /// Raw JSON string - /// ReservationResource object represented by the provided JSON - public static ReservationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The current status of the reservation - /// - [JsonProperty("reservation_status")] - [JsonConverter(typeof(StringEnumConverter))] - public ReservationResource.StatusEnum ReservationStatus { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the reserved Task resource - /// - [JsonProperty("task_sid")] - public string TaskSid { get; private set; } - /// - /// The friendly_name of the Worker that is reserved - /// - [JsonProperty("worker_name")] - public string WorkerName { get; private set; } - /// - /// The SID of the reserved Worker resource - /// - [JsonProperty("worker_sid")] - public string WorkerSid { get; private set; } - /// - /// The SID of the Workspace that this worker is contained within. - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the WorkerReservation resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ReservationResource() - { - - } - } +{ + + public class ReservationResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Pending = new StatusEnum("pending"); + public static readonly StatusEnum Accepted = new StatusEnum("accepted"); + public static readonly StatusEnum Rejected = new StatusEnum("rejected"); + public static readonly StatusEnum Timeout = new StatusEnum("timeout"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Rescinded = new StatusEnum("rescinded"); + public static readonly StatusEnum Wrapping = new StatusEnum("wrapping"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + } + + public sealed class CallStatusEnum : StringEnum + { + private CallStatusEnum(string value) : base(value) { } + public CallStatusEnum() { } + public static implicit operator CallStatusEnum(string value) + { + return new CallStatusEnum(value); + } + + public static readonly CallStatusEnum Initiated = new CallStatusEnum("initiated"); + public static readonly CallStatusEnum Ringing = new CallStatusEnum("ringing"); + public static readonly CallStatusEnum Answered = new CallStatusEnum("answered"); + public static readonly CallStatusEnum Completed = new CallStatusEnum("completed"); + } + + public sealed class ConferenceEventEnum : StringEnum + { + private ConferenceEventEnum(string value) : base(value) { } + public ConferenceEventEnum() { } + public static implicit operator ConferenceEventEnum(string value) + { + return new ConferenceEventEnum(value); + } + + public static readonly ConferenceEventEnum Start = new ConferenceEventEnum("start"); + public static readonly ConferenceEventEnum End = new ConferenceEventEnum("end"); + public static readonly ConferenceEventEnum Join = new ConferenceEventEnum("join"); + public static readonly ConferenceEventEnum Leave = new ConferenceEventEnum("leave"); + public static readonly ConferenceEventEnum Mute = new ConferenceEventEnum("mute"); + public static readonly ConferenceEventEnum Hold = new ConferenceEventEnum("hold"); + public static readonly ConferenceEventEnum Speaker = new ConferenceEventEnum("speaker"); + } + + private static Request BuildReadRequest(ReadReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ResourceSet Read(ReadReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("reservations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task> ReadAsync(ReadReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("reservations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the WorkerReservation resources to read + /// The SID of the reserved Worker resource with the WorkerReservation resources to read + /// + /// Returns the list of reservations for a worker with a specified ReservationStatus + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ResourceSet Read(string pathWorkspaceSid, + string pathWorkerSid, + ReservationResource.StatusEnum reservationStatus = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadReservationOptions(pathWorkspaceSid, pathWorkerSid) { ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the WorkerReservation resources to read + /// The SID of the reserved Worker resource with the WorkerReservation resources to read + /// + /// Returns the list of reservations for a worker with a specified ReservationStatus + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string pathWorkerSid, + ReservationResource.StatusEnum reservationStatus = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadReservationOptions(pathWorkspaceSid, pathWorkerSid) { ReservationStatus = reservationStatus, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("reservations", response.Content); + } + + private static Request BuildFetchRequest(FetchReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Fetch(FetchReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task FetchAsync(FetchReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerReservation resource to fetch + /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch + /// + /// The SID of the WorkerReservation resource to fetch + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Fetch(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerReservation resource to fetch + /// The SID of the reserved Worker resource with the WorkerReservation resource to fetch + /// + /// The SID of the WorkerReservation resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateReservationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Reservations/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Reservation parameters + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Update(UpdateReservationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Reservation parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task UpdateAsync(UpdateReservationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the WorkerReservation resources to update + /// The SID of the reserved Worker resource with the WorkerReservation resources to update + /// + /// The SID of the WorkerReservation resource to update + /// The new status of the reservation + /// The new worker activity SID if rejecting a reservation + /// The assignment instruction for the reservation + /// The SID of the Activity resource to start after executing a Dequeue + /// instruction + /// The caller ID of the call to the worker when executing a Dequeue instruction + /// Whether to record both legs of a call when executing a Dequeue instruction + /// The timeout for call when executing a Dequeue instruction + /// The contact URI of the worker when executing a Dequeue instruction + /// The callback URL for completed call event when executing a Dequeue + /// instruction + /// The Caller ID of the outbound call when executing a Call instruction + /// Whether to record both legs of a call when executing a Call instruction + /// The timeout for a call when executing a Call instruction + /// The contact URI of the worker when executing a Call instruction + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// The URL to call for the completed call event when executing a Call instruction + /// + /// Whether to accept a reservation when executing a Call instruction + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// The Contact URI of the worker when executing a Conference instruction + /// The caller ID of the call to the worker when executing a Conference instruction + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The call progress events that we will send to status_callback + /// The timeout for a call when executing a Conference instruction + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the agent leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference status events that we will send to + /// conference_status_callback + /// Whether to record the conference the participant is joining + /// Whether to trim leading and trailing silence from your recorded conference audio + /// files + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The region where we should mix the conference audio + /// The SIP username used for authentication + /// The SIP password for authentication + /// The call progress events sent via webhooks as a result of a Dequeue + /// instruction + /// The new worker activity SID after executing a Conference instruction + /// Whether to end the conference when the customer leaves + /// Whether to play a notification beep when the customer joins + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Reservation + public static ReservationResource Update(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ReservationResource.StatusEnum reservationStatus = null, + string workerActivitySid = null, + string instruction = null, + string dequeuePostWorkActivitySid = null, + string dequeueFrom = null, + string dequeueRecord = null, + int? dequeueTimeout = null, + string dequeueTo = null, + Uri dequeueStatusCallbackUrl = null, + string callFrom = null, + string callRecord = null, + int? callTimeout = null, + string callTo = null, + Uri callUrl = null, + Uri callStatusCallbackUrl = null, + bool? callAccept = null, + string redirectCallSid = null, + bool? redirectAccept = null, + Uri redirectUrl = null, + string to = null, + string from = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string conferenceRecord = null, + string conferenceTrim = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + string region = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + List dequeueStatusCallbackEvent = null, + string postWorkActivitySid = null, + bool? endConferenceOnCustomerExit = null, + bool? beepOnCustomerEntrance = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid) { ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the WorkerReservation resources to update + /// The SID of the reserved Worker resource with the WorkerReservation resources to update + /// + /// The SID of the WorkerReservation resource to update + /// The new status of the reservation + /// The new worker activity SID if rejecting a reservation + /// The assignment instruction for the reservation + /// The SID of the Activity resource to start after executing a Dequeue + /// instruction + /// The caller ID of the call to the worker when executing a Dequeue instruction + /// Whether to record both legs of a call when executing a Dequeue instruction + /// The timeout for call when executing a Dequeue instruction + /// The contact URI of the worker when executing a Dequeue instruction + /// The callback URL for completed call event when executing a Dequeue + /// instruction + /// The Caller ID of the outbound call when executing a Call instruction + /// Whether to record both legs of a call when executing a Call instruction + /// The timeout for a call when executing a Call instruction + /// The contact URI of the worker when executing a Call instruction + /// TwiML URI executed on answering the worker's leg as a result of the Call instruction + /// The URL to call for the completed call event when executing a Call instruction + /// + /// Whether to accept a reservation when executing a Call instruction + /// The Call SID of the call parked in the queue when executing a Redirect instruction + /// + /// Whether the reservation should be accepted when executing a Redirect instruction + /// + /// TwiML URI to redirect the call to when executing the Redirect instruction + /// The Contact URI of the worker when executing a Conference instruction + /// The caller ID of the call to the worker when executing a Conference instruction + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// The call progress events that we will send to status_callback + /// The timeout for a call when executing a Conference instruction + /// Whether to record the participant and their conferences + /// Whether to mute the agent + /// Whether to play a notification beep when the participant joins + /// Whether the conference starts when the participant joins the conference + /// + /// Whether to end the conference when the agent leaves + /// URL that hosts pre-conference hold music + /// The HTTP method we should use to call `wait_url` + /// Whether agents can hear the state of the outbound call + /// The maximum number of agent conference participants + /// The callback URL for conference events + /// HTTP method for requesting `conference_status_callback` URL + /// The conference status events that we will send to + /// conference_status_callback + /// Whether to record the conference the participant is joining + /// Whether to trim leading and trailing silence from your recorded conference audio + /// files + /// Specify `mono` or `dual` recording channels + /// The URL that we should call using the `recording_status_callback_method` + /// when the recording status changes + /// The HTTP method we should use when we call `recording_status_callback` + /// + /// The URL we should call using the + /// `conference_recording_status_callback_method` when the conference recording + /// is available + /// The HTTP method we should use to call + /// `conference_recording_status_callback` + /// The region where we should mix the conference audio + /// The SIP username used for authentication + /// The SIP password for authentication + /// The call progress events sent via webhooks as a result of a Dequeue + /// instruction + /// The new worker activity SID after executing a Conference instruction + /// Whether to end the conference when the customer leaves + /// Whether to play a notification beep when the customer joins + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Reservation + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ReservationResource.StatusEnum reservationStatus = null, + string workerActivitySid = null, + string instruction = null, + string dequeuePostWorkActivitySid = null, + string dequeueFrom = null, + string dequeueRecord = null, + int? dequeueTimeout = null, + string dequeueTo = null, + Uri dequeueStatusCallbackUrl = null, + string callFrom = null, + string callRecord = null, + int? callTimeout = null, + string callTo = null, + Uri callUrl = null, + Uri callStatusCallbackUrl = null, + bool? callAccept = null, + string redirectCallSid = null, + bool? redirectAccept = null, + Uri redirectUrl = null, + string to = null, + string from = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + List statusCallbackEvent = null, + int? timeout = null, + bool? record = null, + bool? muted = null, + string beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + bool? earlyMedia = null, + int? maxParticipants = null, + Uri conferenceStatusCallback = null, + Twilio.Http.HttpMethod conferenceStatusCallbackMethod = null, + List conferenceStatusCallbackEvent = null, + string conferenceRecord = null, + string conferenceTrim = null, + string recordingChannels = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + Uri conferenceRecordingStatusCallback = null, + Twilio.Http.HttpMethod conferenceRecordingStatusCallbackMethod = null, + string region = null, + string sipAuthUsername = null, + string sipAuthPassword = null, + List dequeueStatusCallbackEvent = null, + string postWorkActivitySid = null, + bool? endConferenceOnCustomerExit = null, + bool? beepOnCustomerEntrance = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateReservationOptions(pathWorkspaceSid, pathWorkerSid, pathSid) { ReservationStatus = reservationStatus, WorkerActivitySid = workerActivitySid, Instruction = instruction, DequeuePostWorkActivitySid = dequeuePostWorkActivitySid, DequeueFrom = dequeueFrom, DequeueRecord = dequeueRecord, DequeueTimeout = dequeueTimeout, DequeueTo = dequeueTo, DequeueStatusCallbackUrl = dequeueStatusCallbackUrl, CallFrom = callFrom, CallRecord = callRecord, CallTimeout = callTimeout, CallTo = callTo, CallUrl = callUrl, CallStatusCallbackUrl = callStatusCallbackUrl, CallAccept = callAccept, RedirectCallSid = redirectCallSid, RedirectAccept = redirectAccept, RedirectUrl = redirectUrl, To = to, From = from, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, StatusCallbackEvent = statusCallbackEvent, Timeout = timeout, Record = record, Muted = muted, Beep = beep, StartConferenceOnEnter = startConferenceOnEnter, EndConferenceOnExit = endConferenceOnExit, WaitUrl = waitUrl, WaitMethod = waitMethod, EarlyMedia = earlyMedia, MaxParticipants = maxParticipants, ConferenceStatusCallback = conferenceStatusCallback, ConferenceStatusCallbackMethod = conferenceStatusCallbackMethod, ConferenceStatusCallbackEvent = conferenceStatusCallbackEvent, ConferenceRecord = conferenceRecord, ConferenceTrim = conferenceTrim, RecordingChannels = recordingChannels, RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackMethod = recordingStatusCallbackMethod, ConferenceRecordingStatusCallback = conferenceRecordingStatusCallback, ConferenceRecordingStatusCallbackMethod = conferenceRecordingStatusCallbackMethod, Region = region, SipAuthUsername = sipAuthUsername, SipAuthPassword = sipAuthPassword, DequeueStatusCallbackEvent = dequeueStatusCallbackEvent, PostWorkActivitySid = postWorkActivitySid, EndConferenceOnCustomerExit = endConferenceOnCustomerExit, BeepOnCustomerEntrance = beepOnCustomerEntrance, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ReservationResource object + /// + /// Raw JSON string + /// ReservationResource object represented by the provided JSON + public static ReservationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The current status of the reservation + /// + [JsonProperty("reservation_status")] + [JsonConverter(typeof(StringEnumConverter))] + public ReservationResource.StatusEnum ReservationStatus { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the reserved Task resource + /// + [JsonProperty("task_sid")] + public string TaskSid { get; private set; } + /// + /// The friendly_name of the Worker that is reserved + /// + [JsonProperty("worker_name")] + public string WorkerName { get; private set; } + /// + /// The SID of the reserved Worker resource + /// + [JsonProperty("worker_sid")] + public string WorkerSid { get; private set; } + /// + /// The SID of the Workspace that this worker is contained within. + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the WorkerReservation resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ReservationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelOptions.cs index 306790325..26e4212c9 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelOptions.cs @@ -9,146 +9,146 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// ReadWorkerChannelOptions + /// + public class ReadWorkerChannelOptions : ReadOptions + { /// - /// ReadWorkerChannelOptions - /// - public class ReadWorkerChannelOptions : ReadOptions - { - /// - /// The SID of the Workspace with the WorkerChannels to read - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Worker with the WorkerChannels to read - /// - public string PathWorkerSid { get; } - - /// - /// Construct a new ReadWorkerChannelOptions - /// - /// The SID of the Workspace with the WorkerChannels to read - /// The SID of the Worker with the WorkerChannels to read - public ReadWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Workspace with the WorkerChannels to read + /// + public string PathWorkspaceSid { get; } /// - /// FetchWorkerChannelOptions - /// - public class FetchWorkerChannelOptions : IOptions - { - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Worker with the WorkerChannel to fetch - /// - public string PathWorkerSid { get; } - /// - /// The SID of the to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWorkerChannelOptions - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - /// The SID of the to fetch - public FetchWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Worker with the WorkerChannels to read + /// + public string PathWorkerSid { get; } + /// - /// UpdateWorkerChannelOptions - /// - public class UpdateWorkerChannelOptions : IOptions - { - /// - /// The SID of the Workspace with the WorkerChannel to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Worker with the WorkerChannel to update - /// - public string PathWorkerSid { get; } - /// - /// The SID of the WorkerChannel to update - /// - public string PathSid { get; } - /// - /// The total number of Tasks that the Worker should handle for the TaskChannel type - /// - public int? Capacity { get; set; } - /// - /// Whether the WorkerChannel is available - /// - public bool? Available { get; set; } - - /// - /// Construct a new UpdateWorkerChannelOptions - /// - /// The SID of the Workspace with the WorkerChannel to update - /// The SID of the Worker with the WorkerChannel to update - /// The SID of the WorkerChannel to update - public UpdateWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Capacity != null) - { - p.Add(new KeyValuePair("Capacity", Capacity.ToString())); - } - - if (Available != null) - { - p.Add(new KeyValuePair("Available", Available.Value.ToString().ToLower())); - } - - return p; - } - } + /// Construct a new ReadWorkerChannelOptions + /// + /// The SID of the Workspace with the WorkerChannels to read + /// The SID of the Worker with the WorkerChannels to read + public ReadWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchWorkerChannelOptions + /// + public class FetchWorkerChannelOptions : IOptions + { + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Worker with the WorkerChannel to fetch + /// + public string PathWorkerSid { get; } + /// + /// The SID of the to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWorkerChannelOptions + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + /// The SID of the to fetch + public FetchWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateWorkerChannelOptions + /// + public class UpdateWorkerChannelOptions : IOptions + { + /// + /// The SID of the Workspace with the WorkerChannel to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Worker with the WorkerChannel to update + /// + public string PathWorkerSid { get; } + /// + /// The SID of the WorkerChannel to update + /// + public string PathSid { get; } + /// + /// The total number of Tasks that the Worker should handle for the TaskChannel type + /// + public int? Capacity { get; set; } + /// + /// Whether the WorkerChannel is available + /// + public bool? Available { get; set; } + + /// + /// Construct a new UpdateWorkerChannelOptions + /// + /// The SID of the Workspace with the WorkerChannel to update + /// The SID of the Worker with the WorkerChannel to update + /// The SID of the WorkerChannel to update + public UpdateWorkerChannelOptions(string pathWorkspaceSid, string pathWorkerSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Capacity != null) + { + p.Add(new KeyValuePair("Capacity", Capacity.ToString())); + } + + if (Available != null) + { + p.Add(new KeyValuePair("Available", Available.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelResource.cs index f673d097b..089954498 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerChannelResource.cs @@ -16,396 +16,396 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class WorkerChannelResource : Resource - { - private static Request BuildReadRequest(ReadWorkerChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read WorkerChannel parameters - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static ResourceSet Read(ReadWorkerChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read WorkerChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkerChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("channels", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the WorkerChannels to read - /// The SID of the Worker with the WorkerChannels to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static ResourceSet Read(string pathWorkspaceSid, - string pathWorkerSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the WorkerChannels to read - /// The SID of the Worker with the WorkerChannels to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string pathWorkerSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("channels", response.Content); - } - - private static Request BuildFetchRequest(FetchWorkerChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkerChannel parameters - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static WorkerChannelResource Fetch(FetchWorkerChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkerChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - /// The SID of the to fetch - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static WorkerChannelResource Fetch(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - /// The SID of the to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWorkerChannelOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update WorkerChannel parameters - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static WorkerChannelResource Update(UpdateWorkerChannelOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update WorkerChannel parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkerChannelOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the WorkerChannel to update - /// The SID of the Worker with the WorkerChannel to update - /// The SID of the WorkerChannel to update - /// The total number of Tasks that the Worker should handle for the TaskChannel type - /// Whether the WorkerChannel is available - /// Client to make requests to Twilio - /// A single instance of WorkerChannel - public static WorkerChannelResource Update(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - int? capacity = null, - bool? available = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid){Capacity = capacity, Available = available}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the WorkerChannel to update - /// The SID of the Worker with the WorkerChannel to update - /// The SID of the WorkerChannel to update - /// The total number of Tasks that the Worker should handle for the TaskChannel type - /// Whether the WorkerChannel is available - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerChannel - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathWorkerSid, - string pathSid, - int? capacity = null, - bool? available = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid){Capacity = capacity, Available = available}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkerChannelResource object - /// - /// Raw JSON string - /// WorkerChannelResource object represented by the provided JSON - public static WorkerChannelResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The total number of Tasks assigned to Worker for the TaskChannel type - /// - [JsonProperty("assigned_tasks")] - public int? AssignedTasks { get; private set; } - /// - /// Whether the Worker should receive Tasks of the TaskChannel type - /// - [JsonProperty("available")] - public bool? Available { get; private set; } - /// - /// The current available capacity between 0 to 100 for the TaskChannel - /// - [JsonProperty("available_capacity_percentage")] - public int? AvailableCapacityPercentage { get; private set; } - /// - /// The current configured capacity for the WorkerChannel - /// - [JsonProperty("configured_capacity")] - public int? ConfiguredCapacity { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the TaskChannel - /// - [JsonProperty("task_channel_sid")] - public string TaskChannelSid { get; private set; } - /// - /// The unique name of the TaskChannel, such as 'voice' or 'sms' - /// - [JsonProperty("task_channel_unique_name")] - public string TaskChannelUniqueName { get; private set; } - /// - /// The SID of the Worker that contains the WorkerChannel - /// - [JsonProperty("worker_sid")] - public string WorkerSid { get; private set; } - /// - /// The SID of the Workspace that contains the WorkerChannel - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the WorkerChannel resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkerChannelResource() - { - - } - } +{ + + public class WorkerChannelResource : Resource + { + private static Request BuildReadRequest(ReadWorkerChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read WorkerChannel parameters + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static ResourceSet Read(ReadWorkerChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read WorkerChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkerChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("channels", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the WorkerChannels to read + /// The SID of the Worker with the WorkerChannels to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static ResourceSet Read(string pathWorkspaceSid, + string pathWorkerSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the WorkerChannels to read + /// The SID of the Worker with the WorkerChannels to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string pathWorkerSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("channels", response.Content); + } + + private static Request BuildFetchRequest(FetchWorkerChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkerChannel parameters + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static WorkerChannelResource Fetch(FetchWorkerChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkerChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + /// The SID of the to fetch + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static WorkerChannelResource Fetch(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + /// The SID of the to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWorkerChannelOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Channels/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update WorkerChannel parameters + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static WorkerChannelResource Update(UpdateWorkerChannelOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update WorkerChannel parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkerChannelOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the WorkerChannel to update + /// The SID of the Worker with the WorkerChannel to update + /// The SID of the WorkerChannel to update + /// The total number of Tasks that the Worker should handle for the TaskChannel type + /// Whether the WorkerChannel is available + /// Client to make requests to Twilio + /// A single instance of WorkerChannel + public static WorkerChannelResource Update(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + int? capacity = null, + bool? available = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid) { Capacity = capacity, Available = available }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the WorkerChannel to update + /// The SID of the Worker with the WorkerChannel to update + /// The SID of the WorkerChannel to update + /// The total number of Tasks that the Worker should handle for the TaskChannel type + /// Whether the WorkerChannel is available + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerChannel + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathWorkerSid, + string pathSid, + int? capacity = null, + bool? available = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkerChannelOptions(pathWorkspaceSid, pathWorkerSid, pathSid) { Capacity = capacity, Available = available }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkerChannelResource object + /// + /// Raw JSON string + /// WorkerChannelResource object represented by the provided JSON + public static WorkerChannelResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The total number of Tasks assigned to Worker for the TaskChannel type + /// + [JsonProperty("assigned_tasks")] + public int? AssignedTasks { get; private set; } + /// + /// Whether the Worker should receive Tasks of the TaskChannel type + /// + [JsonProperty("available")] + public bool? Available { get; private set; } + /// + /// The current available capacity between 0 to 100 for the TaskChannel + /// + [JsonProperty("available_capacity_percentage")] + public int? AvailableCapacityPercentage { get; private set; } + /// + /// The current configured capacity for the WorkerChannel + /// + [JsonProperty("configured_capacity")] + public int? ConfiguredCapacity { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the TaskChannel + /// + [JsonProperty("task_channel_sid")] + public string TaskChannelSid { get; private set; } + /// + /// The unique name of the TaskChannel, such as 'voice' or 'sms' + /// + [JsonProperty("task_channel_unique_name")] + public string TaskChannelUniqueName { get; private set; } + /// + /// The SID of the Worker that contains the WorkerChannel + /// + [JsonProperty("worker_sid")] + public string WorkerSid { get; private set; } + /// + /// The SID of the Workspace that contains the WorkerChannel + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the WorkerChannel resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkerChannelResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsOptions.cs index ab5f5c35d..ab8c3cb29 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsOptions.cs @@ -9,77 +9,77 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// FetchWorkerStatisticsOptions + /// + public class FetchWorkerStatisticsOptions : IOptions + { /// - /// FetchWorkerStatisticsOptions + /// The SID of the Workspace with the WorkerChannel to fetch /// - public class FetchWorkerStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Worker with the WorkerChannel to fetch - /// - public string PathWorkerSid { get; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkerStatisticsOptions - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - public FetchWorkerStatisticsOptions(string pathWorkspaceSid, string pathWorkerSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkerSid = pathWorkerSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// The SID of the Worker with the WorkerChannel to fetch + /// + public string PathWorkerSid { get; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkerStatisticsOptions + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + public FetchWorkerStatisticsOptions(string pathWorkspaceSid, string pathWorkerSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkerSid = pathWorkerSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsResource.cs index f95d84c2b..444265ef5 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkerStatisticsResource.cs @@ -16,146 +16,146 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class WorkerStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkerStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkerStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkerStatistics - public static WorkerStatisticsResource Fetch(FetchWorkerStatisticsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkerStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only include usage that occurred on or before this date - /// Only calculate statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkerStatistics - public static WorkerStatisticsResource Fetch(string pathWorkspaceSid, - string pathWorkerSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkerStatisticsOptions(pathWorkspaceSid, pathWorkerSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the WorkerChannel to fetch - /// The SID of the Worker with the WorkerChannel to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only include usage that occurred on or before this date - /// Only calculate statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkerStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkerSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkerStatisticsOptions(pathWorkspaceSid, pathWorkerSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkerStatisticsResource object - /// - /// Raw JSON string - /// WorkerStatisticsResource object represented by the provided JSON - public static WorkerStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// An object that contains the cumulative statistics for the Worker - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// The SID of the Worker that contains the WorkerChannel - /// - [JsonProperty("worker_sid")] - public string WorkerSid { get; private set; } - /// - /// The SID of the Workspace that contains the WorkerChannel - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the WorkerChannel statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkerStatisticsResource() - { - - } - } +{ + + public class WorkerStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkerStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathWorkerSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkerStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkerStatistics + public static WorkerStatisticsResource Fetch(FetchWorkerStatisticsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkerStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only include usage that occurred on or before this date + /// Only calculate statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkerStatistics + public static WorkerStatisticsResource Fetch(string pathWorkspaceSid, + string pathWorkerSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkerStatisticsOptions(pathWorkspaceSid, pathWorkerSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the WorkerChannel to fetch + /// The SID of the Worker with the WorkerChannel to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only include usage that occurred on or before this date + /// Only calculate statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkerStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkerSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkerStatisticsOptions(pathWorkspaceSid, pathWorkerSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkerStatisticsResource object + /// + /// Raw JSON string + /// WorkerStatisticsResource object represented by the provided JSON + public static WorkerStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// An object that contains the cumulative statistics for the Worker + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// The SID of the Worker that contains the WorkerChannel + /// + [JsonProperty("worker_sid")] + public string WorkerSid { get; private set; } + /// + /// The SID of the Workspace that contains the WorkerChannel + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the WorkerChannel statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkerStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsOptions.cs index 393dbad2b..c977649ff 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsOptions.cs @@ -9,71 +9,71 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// FetchWorkersCumulativeStatisticsOptions + /// + public class FetchWorkersCumulativeStatisticsOptions : IOptions + { /// - /// FetchWorkersCumulativeStatisticsOptions + /// The SID of the Workspace with the resource to fetch /// - public class FetchWorkersCumulativeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the resource to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate statistics from on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate cumulative statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkersCumulativeStatisticsOptions - /// - /// The SID of the Workspace with the resource to fetch - public FetchWorkersCumulativeStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate statistics from on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate cumulative statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkersCumulativeStatisticsOptions + /// + /// The SID of the Workspace with the resource to fetch + public FetchWorkersCumulativeStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsResource.cs index ece29b00a..7106493aa 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersCumulativeStatisticsResource.cs @@ -16,178 +16,178 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class WorkersCumulativeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkersCumulativeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/CumulativeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkersCumulativeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkersCumulativeStatistics - public static WorkersCumulativeStatisticsResource Fetch(FetchWorkersCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkersCumulativeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkersCumulativeStatistics - public static WorkersCumulativeStatisticsResource Fetch(string pathWorkspaceSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersCumulativeStatisticsOptions(pathWorkspaceSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Only calculate statistics from on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersCumulativeStatisticsOptions(pathWorkspaceSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkersCumulativeStatisticsResource object - /// - /// Raw JSON string - /// WorkersCumulativeStatisticsResource object represented by the provided JSON - public static WorkersCumulativeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The beginning of the interval during which these statistics were calculated - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end of the interval during which these statistics were calculated - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The minimum, average, maximum, and total time that Workers spent in each Activity - /// - [JsonProperty("activity_durations")] - public List ActivityDurations { get; private set; } - /// - /// The total number of Reservations that were created - /// - [JsonProperty("reservations_created")] - public int? ReservationsCreated { get; private set; } - /// - /// The total number of Reservations that were accepted - /// - [JsonProperty("reservations_accepted")] - public int? ReservationsAccepted { get; private set; } - /// - /// The total number of Reservations that were rejected - /// - [JsonProperty("reservations_rejected")] - public int? ReservationsRejected { get; private set; } - /// - /// The total number of Reservations that were timed out - /// - [JsonProperty("reservations_timed_out")] - public int? ReservationsTimedOut { get; private set; } - /// - /// The total number of Reservations that were canceled - /// - [JsonProperty("reservations_canceled")] - public int? ReservationsCanceled { get; private set; } - /// - /// The total number of Reservations that were rescinded - /// - [JsonProperty("reservations_rescinded")] - public int? ReservationsRescinded { get; private set; } - /// - /// The SID of the Workspace that contains the Workers - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workers statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkersCumulativeStatisticsResource() - { - - } - } +{ + + public class WorkersCumulativeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkersCumulativeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/CumulativeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkersCumulativeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkersCumulativeStatistics + public static WorkersCumulativeStatisticsResource Fetch(FetchWorkersCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkersCumulativeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkersCumulativeStatistics + public static WorkersCumulativeStatisticsResource Fetch(string pathWorkspaceSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersCumulativeStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Only calculate statistics from on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersCumulativeStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkersCumulativeStatisticsResource object + /// + /// Raw JSON string + /// WorkersCumulativeStatisticsResource object represented by the provided JSON + public static WorkersCumulativeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The beginning of the interval during which these statistics were calculated + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end of the interval during which these statistics were calculated + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The minimum, average, maximum, and total time that Workers spent in each Activity + /// + [JsonProperty("activity_durations")] + public List ActivityDurations { get; private set; } + /// + /// The total number of Reservations that were created + /// + [JsonProperty("reservations_created")] + public int? ReservationsCreated { get; private set; } + /// + /// The total number of Reservations that were accepted + /// + [JsonProperty("reservations_accepted")] + public int? ReservationsAccepted { get; private set; } + /// + /// The total number of Reservations that were rejected + /// + [JsonProperty("reservations_rejected")] + public int? ReservationsRejected { get; private set; } + /// + /// The total number of Reservations that were timed out + /// + [JsonProperty("reservations_timed_out")] + public int? ReservationsTimedOut { get; private set; } + /// + /// The total number of Reservations that were canceled + /// + [JsonProperty("reservations_canceled")] + public int? ReservationsCanceled { get; private set; } + /// + /// The total number of Reservations that were rescinded + /// + [JsonProperty("reservations_rescinded")] + public int? ReservationsRescinded { get; private set; } + /// + /// The SID of the Workspace that contains the Workers + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workers statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkersCumulativeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsOptions.cs index e57788860..45eea726f 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// FetchWorkersRealTimeStatisticsOptions + /// + public class FetchWorkersRealTimeStatisticsOptions : IOptions + { /// - /// FetchWorkersRealTimeStatisticsOptions + /// The SID of the Workspace with the resource to fetch /// - public class FetchWorkersRealTimeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the resource to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate real-time statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkersRealTimeStatisticsOptions - /// - /// The SID of the Workspace with the resource to fetch - public FetchWorkersRealTimeStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate real-time statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkersRealTimeStatisticsOptions + /// + /// The SID of the Workspace with the resource to fetch + public FetchWorkersRealTimeStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsResource.cs index 860cd6bb9..898628253 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersRealTimeStatisticsResource.cs @@ -16,131 +16,131 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class WorkersRealTimeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkersRealTimeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/RealTimeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkersRealTimeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkersRealTimeStatistics - public static WorkersRealTimeStatisticsResource Fetch(FetchWorkersRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkersRealTimeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkersRealTimeStatistics - public static WorkersRealTimeStatisticsResource Fetch(string pathWorkspaceSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersRealTimeStatisticsOptions(pathWorkspaceSid){TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersRealTimeStatisticsOptions(pathWorkspaceSid){TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkersRealTimeStatisticsResource object - /// - /// Raw JSON string - /// WorkersRealTimeStatisticsResource object represented by the provided JSON - public static WorkersRealTimeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number of current Workers by Activity - /// - [JsonProperty("activity_statistics")] - public List ActivityStatistics { get; private set; } - /// - /// The total number of Workers - /// - [JsonProperty("total_workers")] - public int? TotalWorkers { get; private set; } - /// - /// The SID of the Workspace that contains the Workers - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workers statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkersRealTimeStatisticsResource() - { - - } - } +{ + + public class WorkersRealTimeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkersRealTimeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/RealTimeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkersRealTimeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkersRealTimeStatistics + public static WorkersRealTimeStatisticsResource Fetch(FetchWorkersRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkersRealTimeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkersRealTimeStatistics + public static WorkersRealTimeStatisticsResource Fetch(string pathWorkspaceSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersRealTimeStatisticsOptions(pathWorkspaceSid) { TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersRealTimeStatisticsOptions(pathWorkspaceSid) { TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkersRealTimeStatisticsResource object + /// + /// Raw JSON string + /// WorkersRealTimeStatisticsResource object represented by the provided JSON + public static WorkersRealTimeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number of current Workers by Activity + /// + [JsonProperty("activity_statistics")] + public List ActivityStatistics { get; private set; } + /// + /// The total number of Workers + /// + [JsonProperty("total_workers")] + public int? TotalWorkers { get; private set; } + /// + /// The SID of the Workspace that contains the Workers + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workers statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkersRealTimeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsOptions.cs index e899d3570..fc7739ad1 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsOptions.cs @@ -9,98 +9,98 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - +{ + + /// + /// FetchWorkersStatisticsOptions + /// + public class FetchWorkersStatisticsOptions : IOptions + { /// - /// FetchWorkersStatisticsOptions + /// The SID of the Workspace with the Worker to fetch /// - public class FetchWorkersStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the Worker to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate statistics from this date and time and earlier - /// - public DateTime? EndDate { get; set; } - /// - /// The SID of the TaskQueue for which to fetch Worker statistics - /// - public string TaskQueueSid { get; set; } - /// - /// The friendly_name of the TaskQueue for which to fetch Worker statistics - /// - public string TaskQueueName { get; set; } - /// - /// Only include Workers with `friendly_name` values that match this parameter - /// - public string FriendlyName { get; set; } - /// - /// Only calculate statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkersStatisticsOptions - /// - /// The SID of the Workspace with the Worker to fetch - public FetchWorkersStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (TaskQueueSid != null) - { - p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); - } - - if (TaskQueueName != null) - { - p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate statistics from this date and time and earlier + /// + public DateTime? EndDate { get; set; } + /// + /// The SID of the TaskQueue for which to fetch Worker statistics + /// + public string TaskQueueSid { get; set; } + /// + /// The friendly_name of the TaskQueue for which to fetch Worker statistics + /// + public string TaskQueueName { get; set; } + /// + /// Only include Workers with `friendly_name` values that match this parameter + /// + public string FriendlyName { get; set; } + /// + /// Only calculate statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkersStatisticsOptions + /// + /// The SID of the Workspace with the Worker to fetch + public FetchWorkersStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (TaskQueueSid != null) + { + p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); + } + + if (TaskQueueName != null) + { + p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsResource.cs index 1aab8fdb9..ccb67ea82 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Worker/WorkersStatisticsResource.cs @@ -16,154 +16,154 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Worker -{ - - public class WorkersStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkersStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkersStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkersStatistics - public static WorkersStatisticsResource Fetch(FetchWorkersStatisticsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkersStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Worker to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// The SID of the TaskQueue for which to fetch Worker statistics - /// The friendly_name of the TaskQueue for which to fetch Worker statistics - /// Only include Workers with `friendly_name` values that match this parameter - /// Only calculate statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkersStatistics - public static WorkersStatisticsResource Fetch(string pathWorkspaceSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskQueueSid = null, - string taskQueueName = null, - string friendlyName = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersStatisticsOptions(pathWorkspaceSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, FriendlyName = friendlyName, TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Worker to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// The SID of the TaskQueue for which to fetch Worker statistics - /// The friendly_name of the TaskQueue for which to fetch Worker statistics - /// Only include Workers with `friendly_name` values that match this parameter - /// Only calculate statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkersStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskQueueSid = null, - string taskQueueName = null, - string friendlyName = null, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkersStatisticsOptions(pathWorkspaceSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, FriendlyName = friendlyName, TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkersStatisticsResource object - /// - /// Raw JSON string - /// WorkersStatisticsResource object represented by the provided JSON - public static WorkersStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// An object that contains the real-time statistics for the Worker - /// - [JsonProperty("realtime")] - public object Realtime { get; private set; } - /// - /// An object that contains the cumulative statistics for the Worker - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Workspace that contains the Worker - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Worker statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkersStatisticsResource() - { - - } - } +{ + + public class WorkersStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkersStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkersStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkersStatistics + public static WorkersStatisticsResource Fetch(FetchWorkersStatisticsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkersStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkersStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Worker to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// The SID of the TaskQueue for which to fetch Worker statistics + /// The friendly_name of the TaskQueue for which to fetch Worker statistics + /// Only include Workers with `friendly_name` values that match this parameter + /// Only calculate statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkersStatistics + public static WorkersStatisticsResource Fetch(string pathWorkspaceSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskQueueSid = null, + string taskQueueName = null, + string friendlyName = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersStatisticsOptions(pathWorkspaceSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, FriendlyName = friendlyName, TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Worker to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// The SID of the TaskQueue for which to fetch Worker statistics + /// The friendly_name of the TaskQueue for which to fetch Worker statistics + /// Only include Workers with `friendly_name` values that match this parameter + /// Only calculate statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkersStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskQueueSid = null, + string taskQueueName = null, + string friendlyName = null, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkersStatisticsOptions(pathWorkspaceSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskQueueSid = taskQueueSid, TaskQueueName = taskQueueName, FriendlyName = friendlyName, TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkersStatisticsResource object + /// + /// Raw JSON string + /// WorkersStatisticsResource object represented by the provided JSON + public static WorkersStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// An object that contains the real-time statistics for the Worker + /// + [JsonProperty("realtime")] + public object Realtime { get; private set; } + /// + /// An object that contains the cumulative statistics for the Worker + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Workspace that contains the Worker + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Worker statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkersStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerOptions.cs index dc61f1491..dfd111ee1 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerOptions.cs @@ -9,338 +9,338 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// ReadWorkerOptions + /// + public class ReadWorkerOptions : ReadOptions + { /// - /// ReadWorkerOptions - /// - public class ReadWorkerOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Workers to read - /// - public string PathWorkspaceSid { get; } - /// - /// The activity_name of the Worker resources to read - /// - public string ActivityName { get; set; } - /// - /// The activity_sid of the Worker resources to read - /// - public string ActivitySid { get; set; } - /// - /// Whether to return Worker resources that are available or unavailable - /// - public string Available { get; set; } - /// - /// The friendly_name of the Worker resources to read - /// - public string FriendlyName { get; set; } - /// - /// Filter by Workers that would match an expression on a TaskQueue - /// - public string TargetWorkersExpression { get; set; } - /// - /// The friendly_name of the TaskQueue that the Workers to read are eligible for - /// - public string TaskQueueName { get; set; } - /// - /// The SID of the TaskQueue that the Workers to read are eligible for - /// - public string TaskQueueSid { get; set; } - - /// - /// Construct a new ReadWorkerOptions - /// - /// The SID of the Workspace with the Workers to read - public ReadWorkerOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ActivityName != null) - { - p.Add(new KeyValuePair("ActivityName", ActivityName)); - } - - if (ActivitySid != null) - { - p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); - } - - if (Available != null) - { - p.Add(new KeyValuePair("Available", Available)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (TargetWorkersExpression != null) - { - p.Add(new KeyValuePair("TargetWorkersExpression", TargetWorkersExpression)); - } - - if (TaskQueueName != null) - { - p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); - } - - if (TaskQueueSid != null) - { - p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Workspace with the Workers to read + /// + public string PathWorkspaceSid { get; } /// - /// CreateWorkerOptions - /// - public class CreateWorkerOptions : IOptions - { - /// - /// The SID of the Workspace that the new Worker belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// The SID of a valid Activity that describes the new Worker's initial state - /// - public string ActivitySid { get; set; } - /// - /// A valid JSON string that describes the new Worker - /// - public string Attributes { get; set; } - - /// - /// Construct a new CreateWorkerOptions - /// - /// The SID of the Workspace that the new Worker belongs to - /// A string to describe the resource - public CreateWorkerOptions(string pathWorkspaceSid, string friendlyName) - { - PathWorkspaceSid = pathWorkspaceSid; - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ActivitySid != null) - { - p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - return p; - } - } - + /// The activity_name of the Worker resources to read + /// + public string ActivityName { get; set; } /// - /// FetchWorkerOptions - /// - public class FetchWorkerOptions : IOptions - { - /// - /// The SID of the Workspace with the Worker to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWorkerOptions - /// - /// The SID of the Workspace with the Worker to fetch - /// The SID of the resource to fetch - public FetchWorkerOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The activity_sid of the Worker resources to read + /// + public string ActivitySid { get; set; } /// - /// UpdateWorkerOptions - /// - public class UpdateWorkerOptions : IOptions - { - /// - /// The SID of the Workspace with the Worker to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to update - /// - public string PathSid { get; } - /// - /// The SID of the Activity that describes the Worker's initial state - /// - public string ActivitySid { get; set; } - /// - /// The JSON string that describes the Worker - /// - public string Attributes { get; set; } - /// - /// A string to describe the Worker - /// - public string FriendlyName { get; set; } - /// - /// Whether to reject the Worker's pending reservations - /// - public bool? RejectPendingReservations { get; set; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new UpdateWorkerOptions - /// - /// The SID of the Workspace with the Worker to update - /// The SID of the resource to update - public UpdateWorkerOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ActivitySid != null) - { - p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Attributes)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (RejectPendingReservations != null) - { - p.Add(new KeyValuePair("RejectPendingReservations", RejectPendingReservations.Value.ToString().ToLower())); - } - - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } - + /// Whether to return Worker resources that are available or unavailable + /// + public string Available { get; set; } /// - /// DeleteWorkerOptions - /// - public class DeleteWorkerOptions : IOptions - { - /// - /// The SID of the Workspace with the Worker to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - /// - /// The If-Match HTTP request header - /// - public string IfMatch { get; set; } - - /// - /// Construct a new DeleteWorkerOptions - /// - /// The SID of the Workspace with the Worker to delete - /// The SID of the resource to delete - public DeleteWorkerOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - - /// - /// Generate the necessary header parameters - /// - public List> GetHeaderParams() - { - var p = new List>(); - if (IfMatch != null) - { - p.Add(new KeyValuePair("If-Match", IfMatch)); - } - - return p; - } - } + /// The friendly_name of the Worker resources to read + /// + public string FriendlyName { get; set; } + /// + /// Filter by Workers that would match an expression on a TaskQueue + /// + public string TargetWorkersExpression { get; set; } + /// + /// The friendly_name of the TaskQueue that the Workers to read are eligible for + /// + public string TaskQueueName { get; set; } + /// + /// The SID of the TaskQueue that the Workers to read are eligible for + /// + public string TaskQueueSid { get; set; } + + /// + /// Construct a new ReadWorkerOptions + /// + /// The SID of the Workspace with the Workers to read + public ReadWorkerOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ActivityName != null) + { + p.Add(new KeyValuePair("ActivityName", ActivityName)); + } + + if (ActivitySid != null) + { + p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); + } + + if (Available != null) + { + p.Add(new KeyValuePair("Available", Available)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (TargetWorkersExpression != null) + { + p.Add(new KeyValuePair("TargetWorkersExpression", TargetWorkersExpression)); + } + + if (TaskQueueName != null) + { + p.Add(new KeyValuePair("TaskQueueName", TaskQueueName)); + } + + if (TaskQueueSid != null) + { + p.Add(new KeyValuePair("TaskQueueSid", TaskQueueSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateWorkerOptions + /// + public class CreateWorkerOptions : IOptions + { + /// + /// The SID of the Workspace that the new Worker belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + /// + /// The SID of a valid Activity that describes the new Worker's initial state + /// + public string ActivitySid { get; set; } + /// + /// A valid JSON string that describes the new Worker + /// + public string Attributes { get; set; } + + /// + /// Construct a new CreateWorkerOptions + /// + /// The SID of the Workspace that the new Worker belongs to + /// A string to describe the resource + public CreateWorkerOptions(string pathWorkspaceSid, string friendlyName) + { + PathWorkspaceSid = pathWorkspaceSid; + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ActivitySid != null) + { + p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + return p; + } + } + + /// + /// FetchWorkerOptions + /// + public class FetchWorkerOptions : IOptions + { + /// + /// The SID of the Workspace with the Worker to fetch + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWorkerOptions + /// + /// The SID of the Workspace with the Worker to fetch + /// The SID of the resource to fetch + public FetchWorkerOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateWorkerOptions + /// + public class UpdateWorkerOptions : IOptions + { + /// + /// The SID of the Workspace with the Worker to update + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to update + /// + public string PathSid { get; } + /// + /// The SID of the Activity that describes the Worker's initial state + /// + public string ActivitySid { get; set; } + /// + /// The JSON string that describes the Worker + /// + public string Attributes { get; set; } + /// + /// A string to describe the Worker + /// + public string FriendlyName { get; set; } + /// + /// Whether to reject the Worker's pending reservations + /// + public bool? RejectPendingReservations { get; set; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new UpdateWorkerOptions + /// + /// The SID of the Workspace with the Worker to update + /// The SID of the resource to update + public UpdateWorkerOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ActivitySid != null) + { + p.Add(new KeyValuePair("ActivitySid", ActivitySid.ToString())); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Attributes)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (RejectPendingReservations != null) + { + p.Add(new KeyValuePair("RejectPendingReservations", RejectPendingReservations.Value.ToString().ToLower())); + } + + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } + + /// + /// DeleteWorkerOptions + /// + public class DeleteWorkerOptions : IOptions + { + /// + /// The SID of the Workspace with the Worker to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource to delete + /// + public string PathSid { get; } + /// + /// The If-Match HTTP request header + /// + public string IfMatch { get; set; } + + /// + /// Construct a new DeleteWorkerOptions + /// + /// The SID of the Workspace with the Worker to delete + /// The SID of the resource to delete + public DeleteWorkerOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + + /// + /// Generate the necessary header parameters + /// + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerResource.cs index f347b6a0c..852866acb 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkerResource.cs @@ -16,577 +16,577 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class WorkerResource : Resource - { - private static Request BuildReadRequest(ReadWorkerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Worker parameters - /// Client to make requests to Twilio - /// A single instance of Worker - public static ResourceSet Read(ReadWorkerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("workers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Worker parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("workers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Workers to read - /// The activity_name of the Worker resources to read - /// The activity_sid of the Worker resources to read - /// Whether to return Worker resources that are available or unavailable - /// The friendly_name of the Worker resources to read - /// Filter by Workers that would match an expression on a TaskQueue - /// The friendly_name of the TaskQueue that the Workers to read are eligible for - /// The SID of the TaskQueue that the Workers to read are eligible for - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Worker - public static ResourceSet Read(string pathWorkspaceSid, - string activityName = null, - string activitySid = null, - string available = null, - string friendlyName = null, - string targetWorkersExpression = null, - string taskQueueName = null, - string taskQueueSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkerOptions(pathWorkspaceSid){ActivityName = activityName, ActivitySid = activitySid, Available = available, FriendlyName = friendlyName, TargetWorkersExpression = targetWorkersExpression, TaskQueueName = taskQueueName, TaskQueueSid = taskQueueSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Workers to read - /// The activity_name of the Worker resources to read - /// The activity_sid of the Worker resources to read - /// Whether to return Worker resources that are available or unavailable - /// The friendly_name of the Worker resources to read - /// Filter by Workers that would match an expression on a TaskQueue - /// The friendly_name of the TaskQueue that the Workers to read are eligible for - /// The SID of the TaskQueue that the Workers to read are eligible for - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string activityName = null, - string activitySid = null, - string available = null, - string friendlyName = null, - string targetWorkersExpression = null, - string taskQueueName = null, - string taskQueueSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkerOptions(pathWorkspaceSid){ActivityName = activityName, ActivitySid = activitySid, Available = available, FriendlyName = friendlyName, TargetWorkersExpression = targetWorkersExpression, TaskQueueName = taskQueueName, TaskQueueSid = taskQueueSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("workers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workers", response.Content); - } - - private static Request BuildCreateRequest(CreateWorkerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Worker parameters - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Create(CreateWorkerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Worker parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task CreateAsync(CreateWorkerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new Worker belongs to - /// A string to describe the resource - /// The SID of a valid Activity that describes the new Worker's initial state - /// A valid JSON string that describes the new Worker - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Create(string pathWorkspaceSid, - string friendlyName, - string activitySid = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName){ActivitySid = activitySid, Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new Worker belongs to - /// A string to describe the resource - /// The SID of a valid Activity that describes the new Worker's initial state - /// A valid JSON string that describes the new Worker - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - string friendlyName, - string activitySid = null, - string attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName){ActivitySid = activitySid, Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchWorkerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Worker parameters - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Fetch(FetchWorkerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Worker parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Worker to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWorkerOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Worker to fetch - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWorkerOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWorkerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// update - /// - /// Update Worker parameters - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Update(UpdateWorkerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Worker parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the Worker to update - /// The SID of the resource to update - /// The SID of the Activity that describes the Worker's initial state - /// The JSON string that describes the Worker - /// A string to describe the Worker - /// Whether to reject the Worker's pending reservations - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Worker - public static WorkerResource Update(string pathWorkspaceSid, - string pathSid, - string activitySid = null, - string attributes = null, - string friendlyName = null, - bool? rejectPendingReservations = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkerOptions(pathWorkspaceSid, pathSid){ActivitySid = activitySid, Attributes = attributes, FriendlyName = friendlyName, RejectPendingReservations = rejectPendingReservations, IfMatch = ifMatch}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the Worker to update - /// The SID of the resource to update - /// The SID of the Activity that describes the Worker's initial state - /// The JSON string that describes the Worker - /// A string to describe the Worker - /// Whether to reject the Worker's pending reservations - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string activitySid = null, - string attributes = null, - string friendlyName = null, - bool? rejectPendingReservations = null, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkerOptions(pathWorkspaceSid, pathSid){ActivitySid = activitySid, Attributes = attributes, FriendlyName = friendlyName, RejectPendingReservations = rejectPendingReservations, IfMatch = ifMatch}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWorkerOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: options.GetHeaderParams() - ); - } - - /// - /// delete - /// - /// Delete Worker parameters - /// Client to make requests to Twilio - /// A single instance of Worker - public static bool Delete(DeleteWorkerOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Worker parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkerOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the Worker to delete - /// The SID of the resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// A single instance of Worker - public static bool Delete(string pathWorkspaceSid, - string pathSid, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteWorkerOptions(pathWorkspaceSid, pathSid){IfMatch = ifMatch}; - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the Worker to delete - /// The SID of the resource to delete - /// The If-Match HTTP request header - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Worker - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - string ifMatch = null, - ITwilioRestClient client = null) - { - var options = new DeleteWorkerOptions(pathWorkspaceSid, pathSid){IfMatch = ifMatch}; - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkerResource object - /// - /// Raw JSON string - /// WorkerResource object represented by the provided JSON - public static WorkerResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The friendly_name of the Worker's current Activity - /// - [JsonProperty("activity_name")] - public string ActivityName { get; private set; } - /// - /// The SID of the Worker's current Activity - /// - [JsonProperty("activity_sid")] - public string ActivitySid { get; private set; } - /// - /// The JSON string that describes the Worker - /// - [JsonProperty("attributes")] - public string Attributes { get; private set; } - /// - /// Whether the Worker is available to perform tasks - /// - [JsonProperty("available")] - public bool? Available { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date and time in GMT of the last change to the Worker's activity - /// - [JsonProperty("date_status_changed")] - public DateTime? DateStatusChanged { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Workspace that contains the Worker - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Worker resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private WorkerResource() - { - - } - } +{ + + public class WorkerResource : Resource + { + private static Request BuildReadRequest(ReadWorkerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Worker parameters + /// Client to make requests to Twilio + /// A single instance of Worker + public static ResourceSet Read(ReadWorkerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("workers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Worker parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("workers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Workers to read + /// The activity_name of the Worker resources to read + /// The activity_sid of the Worker resources to read + /// Whether to return Worker resources that are available or unavailable + /// The friendly_name of the Worker resources to read + /// Filter by Workers that would match an expression on a TaskQueue + /// The friendly_name of the TaskQueue that the Workers to read are eligible for + /// The SID of the TaskQueue that the Workers to read are eligible for + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Worker + public static ResourceSet Read(string pathWorkspaceSid, + string activityName = null, + string activitySid = null, + string available = null, + string friendlyName = null, + string targetWorkersExpression = null, + string taskQueueName = null, + string taskQueueSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkerOptions(pathWorkspaceSid) { ActivityName = activityName, ActivitySid = activitySid, Available = available, FriendlyName = friendlyName, TargetWorkersExpression = targetWorkersExpression, TaskQueueName = taskQueueName, TaskQueueSid = taskQueueSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Workers to read + /// The activity_name of the Worker resources to read + /// The activity_sid of the Worker resources to read + /// Whether to return Worker resources that are available or unavailable + /// The friendly_name of the Worker resources to read + /// Filter by Workers that would match an expression on a TaskQueue + /// The friendly_name of the TaskQueue that the Workers to read are eligible for + /// The SID of the TaskQueue that the Workers to read are eligible for + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string activityName = null, + string activitySid = null, + string available = null, + string friendlyName = null, + string targetWorkersExpression = null, + string taskQueueName = null, + string taskQueueSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkerOptions(pathWorkspaceSid) { ActivityName = activityName, ActivitySid = activitySid, Available = available, FriendlyName = friendlyName, TargetWorkersExpression = targetWorkersExpression, TaskQueueName = taskQueueName, TaskQueueSid = taskQueueSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("workers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workers", response.Content); + } + + private static Request BuildCreateRequest(CreateWorkerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Worker parameters + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Create(CreateWorkerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Worker parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task CreateAsync(CreateWorkerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new Worker belongs to + /// A string to describe the resource + /// The SID of a valid Activity that describes the new Worker's initial state + /// A valid JSON string that describes the new Worker + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Create(string pathWorkspaceSid, + string friendlyName, + string activitySid = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName) { ActivitySid = activitySid, Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new Worker belongs to + /// A string to describe the resource + /// The SID of a valid Activity that describes the new Worker's initial state + /// A valid JSON string that describes the new Worker + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + string friendlyName, + string activitySid = null, + string attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName) { ActivitySid = activitySid, Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchWorkerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Worker parameters + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Fetch(FetchWorkerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Worker parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Worker to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWorkerOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Worker to fetch + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWorkerOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWorkerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// update + /// + /// Update Worker parameters + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Update(UpdateWorkerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Worker parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the Worker to update + /// The SID of the resource to update + /// The SID of the Activity that describes the Worker's initial state + /// The JSON string that describes the Worker + /// A string to describe the Worker + /// Whether to reject the Worker's pending reservations + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Worker + public static WorkerResource Update(string pathWorkspaceSid, + string pathSid, + string activitySid = null, + string attributes = null, + string friendlyName = null, + bool? rejectPendingReservations = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkerOptions(pathWorkspaceSid, pathSid) { ActivitySid = activitySid, Attributes = attributes, FriendlyName = friendlyName, RejectPendingReservations = rejectPendingReservations, IfMatch = ifMatch }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the Worker to update + /// The SID of the resource to update + /// The SID of the Activity that describes the Worker's initial state + /// The JSON string that describes the Worker + /// A string to describe the Worker + /// Whether to reject the Worker's pending reservations + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string activitySid = null, + string attributes = null, + string friendlyName = null, + bool? rejectPendingReservations = null, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkerOptions(pathWorkspaceSid, pathSid) { ActivitySid = activitySid, Attributes = attributes, FriendlyName = friendlyName, RejectPendingReservations = rejectPendingReservations, IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWorkerOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: options.GetHeaderParams() + ); + } + + /// + /// delete + /// + /// Delete Worker parameters + /// Client to make requests to Twilio + /// A single instance of Worker + public static bool Delete(DeleteWorkerOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Worker parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkerOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the Worker to delete + /// The SID of the resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// A single instance of Worker + public static bool Delete(string pathWorkspaceSid, + string pathSid, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteWorkerOptions(pathWorkspaceSid, pathSid) { IfMatch = ifMatch }; + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the Worker to delete + /// The SID of the resource to delete + /// The If-Match HTTP request header + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Worker + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + string ifMatch = null, + ITwilioRestClient client = null) + { + var options = new DeleteWorkerOptions(pathWorkspaceSid, pathSid) { IfMatch = ifMatch }; + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkerResource object + /// + /// Raw JSON string + /// WorkerResource object represented by the provided JSON + public static WorkerResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The friendly_name of the Worker's current Activity + /// + [JsonProperty("activity_name")] + public string ActivityName { get; private set; } + /// + /// The SID of the Worker's current Activity + /// + [JsonProperty("activity_sid")] + public string ActivitySid { get; private set; } + /// + /// The JSON string that describes the Worker + /// + [JsonProperty("attributes")] + public string Attributes { get; private set; } + /// + /// Whether the Worker is available to perform tasks + /// + [JsonProperty("available")] + public bool? Available { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date and time in GMT of the last change to the Worker's activity + /// + [JsonProperty("date_status_changed")] + public DateTime? DateStatusChanged { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Workspace that contains the Worker + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Worker resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private WorkerResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsOptions.cs index e5025e649..77c50aa5b 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - +{ + + /// + /// FetchWorkflowCumulativeStatisticsOptions + /// + public class FetchWorkflowCumulativeStatisticsOptions : IOptions + { /// - /// FetchWorkflowCumulativeStatisticsOptions + /// The SID of the Workspace with the resource to fetch /// - public class FetchWorkflowCumulativeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the resource to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value - /// - public string PathWorkflowSid { get; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate cumulative statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchWorkflowCumulativeStatisticsOptions - /// - /// The SID of the Workspace with the resource to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified Sid value - public FetchWorkflowCumulativeStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkflowSid = pathWorkflowSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value + /// + public string PathWorkflowSid { get; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate cumulative statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchWorkflowCumulativeStatisticsOptions + /// + /// The SID of the Workspace with the resource to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified Sid value + public FetchWorkflowCumulativeStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkflowSid = pathWorkflowSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsResource.cs index d41454245..235ff3121 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowCumulativeStatisticsResource.cs @@ -16,240 +16,240 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - - public class WorkflowCumulativeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkflowCumulativeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/CumulativeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkflowCumulativeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkflowCumulativeStatistics - public static WorkflowCumulativeStatisticsResource Fetch(FetchWorkflowCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkflowCumulativeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified Sid value - /// Only include usage that occurred on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of WorkflowCumulativeStatistics - public static WorkflowCumulativeStatisticsResource Fetch(string pathWorkspaceSid, - string pathWorkflowSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowCumulativeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the resource to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified Sid value - /// Only include usage that occurred on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkflowSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowCumulativeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkflowCumulativeStatisticsResource object - /// - /// Raw JSON string - /// WorkflowCumulativeStatisticsResource object represented by the provided JSON - public static WorkflowCumulativeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The average time in seconds between Task creation and acceptance - /// - [JsonProperty("avg_task_acceptance_time")] - public int? AvgTaskAcceptanceTime { get; private set; } - /// - /// The beginning of the interval during which these statistics were calculated - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end of the interval during which these statistics were calculated - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The total number of Reservations that were created for Workers - /// - [JsonProperty("reservations_created")] - public int? ReservationsCreated { get; private set; } - /// - /// The total number of Reservations accepted by Workers - /// - [JsonProperty("reservations_accepted")] - public int? ReservationsAccepted { get; private set; } - /// - /// The total number of Reservations that were rejected - /// - [JsonProperty("reservations_rejected")] - public int? ReservationsRejected { get; private set; } - /// - /// The total number of Reservations that were timed out - /// - [JsonProperty("reservations_timed_out")] - public int? ReservationsTimedOut { get; private set; } - /// - /// The total number of Reservations that were canceled - /// - [JsonProperty("reservations_canceled")] - public int? ReservationsCanceled { get; private set; } - /// - /// The total number of Reservations that were rescinded - /// - [JsonProperty("reservations_rescinded")] - public int? ReservationsRescinded { get; private set; } - /// - /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds - /// - [JsonProperty("split_by_wait_time")] - public object SplitByWaitTime { get; private set; } - /// - /// The wait duration statistics for Tasks that were accepted - /// - [JsonProperty("wait_duration_until_accepted")] - public object WaitDurationUntilAccepted { get; private set; } - /// - /// The wait duration statistics for Tasks that were canceled - /// - [JsonProperty("wait_duration_until_canceled")] - public object WaitDurationUntilCanceled { get; private set; } - /// - /// The total number of Tasks that were canceled - /// - [JsonProperty("tasks_canceled")] - public int? TasksCanceled { get; private set; } - /// - /// The total number of Tasks that were completed - /// - [JsonProperty("tasks_completed")] - public int? TasksCompleted { get; private set; } - /// - /// The total number of Tasks that entered the Workflow - /// - [JsonProperty("tasks_entered")] - public int? TasksEntered { get; private set; } - /// - /// The total number of Tasks that were deleted - /// - [JsonProperty("tasks_deleted")] - public int? TasksDeleted { get; private set; } - /// - /// The total number of Tasks that were moved from one queue to another - /// - [JsonProperty("tasks_moved")] - public int? TasksMoved { get; private set; } - /// - /// The total number of Tasks that were timed out of their Workflows - /// - [JsonProperty("tasks_timed_out_in_workflow")] - public int? TasksTimedOutInWorkflow { get; private set; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value - /// - [JsonProperty("workflow_sid")] - public string WorkflowSid { get; private set; } - /// - /// The SID of the Workspace that contains the Workflow. - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workflow statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkflowCumulativeStatisticsResource() - { - - } - } +{ + + public class WorkflowCumulativeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkflowCumulativeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/CumulativeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkflowCumulativeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkflowCumulativeStatistics + public static WorkflowCumulativeStatisticsResource Fetch(FetchWorkflowCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkflowCumulativeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified Sid value + /// Only include usage that occurred on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of WorkflowCumulativeStatistics + public static WorkflowCumulativeStatisticsResource Fetch(string pathWorkspaceSid, + string pathWorkflowSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowCumulativeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the resource to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified Sid value + /// Only include usage that occurred on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkflowSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowCumulativeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkflowCumulativeStatisticsResource object + /// + /// Raw JSON string + /// WorkflowCumulativeStatisticsResource object represented by the provided JSON + public static WorkflowCumulativeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The average time in seconds between Task creation and acceptance + /// + [JsonProperty("avg_task_acceptance_time")] + public int? AvgTaskAcceptanceTime { get; private set; } + /// + /// The beginning of the interval during which these statistics were calculated + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end of the interval during which these statistics were calculated + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The total number of Reservations that were created for Workers + /// + [JsonProperty("reservations_created")] + public int? ReservationsCreated { get; private set; } + /// + /// The total number of Reservations accepted by Workers + /// + [JsonProperty("reservations_accepted")] + public int? ReservationsAccepted { get; private set; } + /// + /// The total number of Reservations that were rejected + /// + [JsonProperty("reservations_rejected")] + public int? ReservationsRejected { get; private set; } + /// + /// The total number of Reservations that were timed out + /// + [JsonProperty("reservations_timed_out")] + public int? ReservationsTimedOut { get; private set; } + /// + /// The total number of Reservations that were canceled + /// + [JsonProperty("reservations_canceled")] + public int? ReservationsCanceled { get; private set; } + /// + /// The total number of Reservations that were rescinded + /// + [JsonProperty("reservations_rescinded")] + public int? ReservationsRescinded { get; private set; } + /// + /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds + /// + [JsonProperty("split_by_wait_time")] + public object SplitByWaitTime { get; private set; } + /// + /// The wait duration statistics for Tasks that were accepted + /// + [JsonProperty("wait_duration_until_accepted")] + public object WaitDurationUntilAccepted { get; private set; } + /// + /// The wait duration statistics for Tasks that were canceled + /// + [JsonProperty("wait_duration_until_canceled")] + public object WaitDurationUntilCanceled { get; private set; } + /// + /// The total number of Tasks that were canceled + /// + [JsonProperty("tasks_canceled")] + public int? TasksCanceled { get; private set; } + /// + /// The total number of Tasks that were completed + /// + [JsonProperty("tasks_completed")] + public int? TasksCompleted { get; private set; } + /// + /// The total number of Tasks that entered the Workflow + /// + [JsonProperty("tasks_entered")] + public int? TasksEntered { get; private set; } + /// + /// The total number of Tasks that were deleted + /// + [JsonProperty("tasks_deleted")] + public int? TasksDeleted { get; private set; } + /// + /// The total number of Tasks that were moved from one queue to another + /// + [JsonProperty("tasks_moved")] + public int? TasksMoved { get; private set; } + /// + /// The total number of Tasks that were timed out of their Workflows + /// + [JsonProperty("tasks_timed_out_in_workflow")] + public int? TasksTimedOutInWorkflow { get; private set; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value + /// + [JsonProperty("workflow_sid")] + public string WorkflowSid { get; private set; } + /// + /// The SID of the Workspace that contains the Workflow. + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workflow statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkflowCumulativeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsOptions.cs index 0667f2e91..c64a8a0ea 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsOptions.cs @@ -9,51 +9,51 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - +{ + + /// + /// FetchWorkflowRealTimeStatisticsOptions + /// + public class FetchWorkflowRealTimeStatisticsOptions : IOptions + { /// - /// FetchWorkflowRealTimeStatisticsOptions + /// The SID of the Workspace with the Workflow to fetch /// - public class FetchWorkflowRealTimeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the Workflow to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value - /// - public string PathWorkflowSid { get; } - /// - /// Only calculate real-time statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkflowRealTimeStatisticsOptions - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - public FetchWorkflowRealTimeStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkflowSid = pathWorkflowSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value + /// + public string PathWorkflowSid { get; } + /// + /// Only calculate real-time statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkflowRealTimeStatisticsOptions + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + public FetchWorkflowRealTimeStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkflowSid = pathWorkflowSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsResource.cs index 8e3075c7b..6cb973585 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowRealTimeStatisticsResource.cs @@ -16,157 +16,157 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - - public class WorkflowRealTimeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkflowRealTimeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/RealTimeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkflowRealTimeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkflowRealTimeStatistics - public static WorkflowRealTimeStatisticsResource Fetch(FetchWorkflowRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkflowRealTimeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkflowRealTimeStatistics - public static WorkflowRealTimeStatisticsResource Fetch(string pathWorkspaceSid, - string pathWorkflowSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowRealTimeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkflowSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowRealTimeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkflowRealTimeStatisticsResource object - /// - /// Raw JSON string - /// WorkflowRealTimeStatisticsResource object represented by the provided JSON - public static WorkflowRealTimeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The age of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_age")] - public int? LongestTaskWaitingAge { get; private set; } - /// - /// The SID of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_sid")] - public string LongestTaskWaitingSid { get; private set; } - /// - /// The number of Tasks by priority - /// - [JsonProperty("tasks_by_priority")] - public object TasksByPriority { get; private set; } - /// - /// The number of Tasks by their current status - /// - [JsonProperty("tasks_by_status")] - public object TasksByStatus { get; private set; } - /// - /// The total number of Tasks - /// - [JsonProperty("total_tasks")] - public int? TotalTasks { get; private set; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value - /// - [JsonProperty("workflow_sid")] - public string WorkflowSid { get; private set; } - /// - /// The SID of the Workspace that contains the Workflow. - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workflow statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkflowRealTimeStatisticsResource() - { - - } - } +{ + + public class WorkflowRealTimeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkflowRealTimeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/RealTimeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkflowRealTimeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkflowRealTimeStatistics + public static WorkflowRealTimeStatisticsResource Fetch(FetchWorkflowRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkflowRealTimeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkflowRealTimeStatistics + public static WorkflowRealTimeStatisticsResource Fetch(string pathWorkspaceSid, + string pathWorkflowSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowRealTimeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkflowSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowRealTimeStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkflowRealTimeStatisticsResource object + /// + /// Raw JSON string + /// WorkflowRealTimeStatisticsResource object represented by the provided JSON + public static WorkflowRealTimeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The age of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_age")] + public int? LongestTaskWaitingAge { get; private set; } + /// + /// The SID of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_sid")] + public string LongestTaskWaitingSid { get; private set; } + /// + /// The number of Tasks by priority + /// + [JsonProperty("tasks_by_priority")] + public object TasksByPriority { get; private set; } + /// + /// The number of Tasks by their current status + /// + [JsonProperty("tasks_by_status")] + public object TasksByStatus { get; private set; } + /// + /// The total number of Tasks + /// + [JsonProperty("total_tasks")] + public int? TotalTasks { get; private set; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value + /// + [JsonProperty("workflow_sid")] + public string WorkflowSid { get; private set; } + /// + /// The SID of the Workspace that contains the Workflow. + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workflow statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkflowRealTimeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsOptions.cs index a96462281..170e09fdc 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsOptions.cs @@ -9,87 +9,87 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - +{ + + /// + /// FetchWorkflowStatisticsOptions + /// + public class FetchWorkflowStatisticsOptions : IOptions + { /// - /// FetchWorkflowStatisticsOptions + /// The SID of the Workspace with the Workflow to fetch /// - public class FetchWorkflowStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace with the Workflow to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value - /// - public string PathWorkflowSid { get; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate statistics from this date and time and earlier - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate real-time statistics on this TaskChannel. - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchWorkflowStatisticsOptions - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - public FetchWorkflowStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathWorkflowSid = pathWorkflowSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value + /// + public string PathWorkflowSid { get; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate statistics from this date and time and earlier + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate real-time statistics on this TaskChannel. + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchWorkflowStatisticsOptions + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + public FetchWorkflowStatisticsOptions(string pathWorkspaceSid, string pathWorkflowSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathWorkflowSid = pathWorkflowSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsResource.cs index 6e284f953..e7c1a365b 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/Workflow/WorkflowStatisticsResource.cs @@ -16,160 +16,160 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace.Workflow -{ - - public class WorkflowStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkflowStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkflowStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkflowStatistics - public static WorkflowStatisticsResource Fetch(FetchWorkflowStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkflowStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// Only calculate real-time statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of WorkflowStatistics - public static WorkflowStatisticsResource Fetch(string pathWorkspaceSid, - string pathWorkflowSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// Returns the list of Tasks that are being controlled by the Workflow with the - /// specified SID value - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// Only calculate real-time statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkflowStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathWorkflowSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowStatisticsOptions(pathWorkspaceSid, pathWorkflowSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkflowStatisticsResource object - /// - /// Raw JSON string - /// WorkflowStatisticsResource object represented by the provided JSON - public static WorkflowStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// An object that contains the cumulative statistics for the Workflow - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// An object that contains the real-time statistics for the Workflow - /// - [JsonProperty("realtime")] - public object Realtime { get; private set; } - /// - /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value - /// - [JsonProperty("workflow_sid")] - public string WorkflowSid { get; private set; } - /// - /// The SID of the Workspace that contains the Workflow - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workflow statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkflowStatisticsResource() - { - - } - } +{ + + public class WorkflowStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkflowStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathWorkflowSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkflowStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkflowStatistics + public static WorkflowStatisticsResource Fetch(FetchWorkflowStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkflowStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// Only calculate real-time statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of WorkflowStatistics + public static WorkflowStatisticsResource Fetch(string pathWorkspaceSid, + string pathWorkflowSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// Returns the list of Tasks that are being controlled by the Workflow with the + /// specified SID value + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// Only calculate real-time statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkflowStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathWorkflowSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowStatisticsOptions(pathWorkspaceSid, pathWorkflowSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkflowStatisticsResource object + /// + /// Raw JSON string + /// WorkflowStatisticsResource object represented by the provided JSON + public static WorkflowStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// An object that contains the cumulative statistics for the Workflow + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// An object that contains the real-time statistics for the Workflow + /// + [JsonProperty("realtime")] + public object Realtime { get; private set; } + /// + /// Returns the list of Tasks that are being controlled by the Workflow with the specified SID value + /// + [JsonProperty("workflow_sid")] + public string WorkflowSid { get; private set; } + /// + /// The SID of the Workspace that contains the Workflow + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workflow statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkflowStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowOptions.cs index cd707181a..994bb16e2 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowOptions.cs @@ -9,286 +9,286 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchWorkflowOptions + /// + public class FetchWorkflowOptions : IOptions + { /// - /// FetchWorkflowOptions + /// The SID of the Workspace with the Workflow to fetch /// - public class FetchWorkflowOptions : IOptions - { - /// - /// The SID of the Workspace with the Workflow to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWorkflowOptions - /// - /// The SID of the Workspace with the Workflow to fetch - /// The SID of the resource - public FetchWorkflowOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathWorkspaceSid { get; } /// - /// UpdateWorkflowOptions + /// The SID of the resource /// - public class UpdateWorkflowOptions : IOptions - { - /// - /// The SID of the Workspace with the Workflow to update - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the resource - /// - public string PathSid { get; } - /// - /// descriptive string that you create to describe the Workflow resource - /// - public string FriendlyName { get; set; } - /// - /// The URL from your application that will process task assignment events - /// - public Uri AssignmentCallbackUrl { get; set; } - /// - /// The URL that we should call when a call to the `assignment_callback_url` fails - /// - public Uri FallbackAssignmentCallbackUrl { get; set; } - /// - /// A JSON string that contains the rules to apply to the Workflow - /// - public string Configuration { get; set; } - /// - /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker - /// - public int? TaskReservationTimeout { get; set; } - /// - /// Whether or not to re-evaluate Tasks - /// - public string ReEvaluateTasks { get; set; } - - /// - /// Construct a new UpdateWorkflowOptions - /// - /// The SID of the Workspace with the Workflow to update - /// The SID of the resource - public UpdateWorkflowOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (AssignmentCallbackUrl != null) - { - p.Add(new KeyValuePair("AssignmentCallbackUrl", Serializers.Url(AssignmentCallbackUrl))); - } - - if (FallbackAssignmentCallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackAssignmentCallbackUrl", Serializers.Url(FallbackAssignmentCallbackUrl))); - } - - if (Configuration != null) - { - p.Add(new KeyValuePair("Configuration", Configuration)); - } - - if (TaskReservationTimeout != null) - { - p.Add(new KeyValuePair("TaskReservationTimeout", TaskReservationTimeout.ToString())); - } - - if (ReEvaluateTasks != null) - { - p.Add(new KeyValuePair("ReEvaluateTasks", ReEvaluateTasks)); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteWorkflowOptions + /// Construct a new FetchWorkflowOptions /// - public class DeleteWorkflowOptions : IOptions - { - /// - /// The SID of the Workspace with the Workflow to delete - /// - public string PathWorkspaceSid { get; } - /// - /// The SID of the Workflow resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWorkflowOptions - /// - /// The SID of the Workspace with the Workflow to delete - /// The SID of the Workflow resource to delete - public DeleteWorkflowOptions(string pathWorkspaceSid, string pathSid) - { - PathWorkspaceSid = pathWorkspaceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Workspace with the Workflow to fetch + /// The SID of the resource + public FetchWorkflowOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + /// - /// ReadWorkflowOptions + /// Generate the necessary parameters /// - public class ReadWorkflowOptions : ReadOptions - { - /// - /// The SID of the Workspace with the Workflow to read - /// - public string PathWorkspaceSid { get; } - /// - /// The friendly_name of the Workflow resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new ReadWorkflowOptions - /// - /// The SID of the Workspace with the Workflow to read - public ReadWorkflowOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateWorkflowOptions + /// + public class UpdateWorkflowOptions : IOptions + { /// - /// CreateWorkflowOptions + /// The SID of the Workspace with the Workflow to update /// - public class CreateWorkflowOptions : IOptions - { - /// - /// The SID of the Workspace that the new Workflow to create belongs to - /// - public string PathWorkspaceSid { get; } - /// - /// descriptive string that you create to describe the Workflow resource - /// - public string FriendlyName { get; } - /// - /// A JSON string that contains the rules to apply to the Workflow - /// - public string Configuration { get; } - /// - /// The URL from your application that will process task assignment events - /// - public Uri AssignmentCallbackUrl { get; set; } - /// - /// The URL that we should call when a call to the `assignment_callback_url` fails - /// - public Uri FallbackAssignmentCallbackUrl { get; set; } - /// - /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker - /// - public int? TaskReservationTimeout { get; set; } - - /// - /// Construct a new CreateWorkflowOptions - /// - /// The SID of the Workspace that the new Workflow to create belongs to - /// descriptive string that you create to describe the Workflow resource - /// A JSON string that contains the rules to apply to the Workflow - public CreateWorkflowOptions(string pathWorkspaceSid, string friendlyName, string configuration) - { - PathWorkspaceSid = pathWorkspaceSid; - FriendlyName = friendlyName; - Configuration = configuration; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Configuration != null) - { - p.Add(new KeyValuePair("Configuration", Configuration)); - } - - if (AssignmentCallbackUrl != null) - { - p.Add(new KeyValuePair("AssignmentCallbackUrl", Serializers.Url(AssignmentCallbackUrl))); - } - - if (FallbackAssignmentCallbackUrl != null) - { - p.Add(new KeyValuePair("FallbackAssignmentCallbackUrl", Serializers.Url(FallbackAssignmentCallbackUrl))); - } - - if (TaskReservationTimeout != null) - { - p.Add(new KeyValuePair("TaskReservationTimeout", TaskReservationTimeout.ToString())); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// The SID of the resource + /// + public string PathSid { get; } + /// + /// descriptive string that you create to describe the Workflow resource + /// + public string FriendlyName { get; set; } + /// + /// The URL from your application that will process task assignment events + /// + public Uri AssignmentCallbackUrl { get; set; } + /// + /// The URL that we should call when a call to the `assignment_callback_url` fails + /// + public Uri FallbackAssignmentCallbackUrl { get; set; } + /// + /// A JSON string that contains the rules to apply to the Workflow + /// + public string Configuration { get; set; } + /// + /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker + /// + public int? TaskReservationTimeout { get; set; } + /// + /// Whether or not to re-evaluate Tasks + /// + public string ReEvaluateTasks { get; set; } + + /// + /// Construct a new UpdateWorkflowOptions + /// + /// The SID of the Workspace with the Workflow to update + /// The SID of the resource + public UpdateWorkflowOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (AssignmentCallbackUrl != null) + { + p.Add(new KeyValuePair("AssignmentCallbackUrl", Serializers.Url(AssignmentCallbackUrl))); + } + + if (FallbackAssignmentCallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackAssignmentCallbackUrl", Serializers.Url(FallbackAssignmentCallbackUrl))); + } + + if (Configuration != null) + { + p.Add(new KeyValuePair("Configuration", Configuration)); + } + + if (TaskReservationTimeout != null) + { + p.Add(new KeyValuePair("TaskReservationTimeout", TaskReservationTimeout.ToString())); + } + + if (ReEvaluateTasks != null) + { + p.Add(new KeyValuePair("ReEvaluateTasks", ReEvaluateTasks)); + } + + return p; + } + } + + /// + /// DeleteWorkflowOptions + /// + public class DeleteWorkflowOptions : IOptions + { + /// + /// The SID of the Workspace with the Workflow to delete + /// + public string PathWorkspaceSid { get; } + /// + /// The SID of the Workflow resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWorkflowOptions + /// + /// The SID of the Workspace with the Workflow to delete + /// The SID of the Workflow resource to delete + public DeleteWorkflowOptions(string pathWorkspaceSid, string pathSid) + { + PathWorkspaceSid = pathWorkspaceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadWorkflowOptions + /// + public class ReadWorkflowOptions : ReadOptions + { + /// + /// The SID of the Workspace with the Workflow to read + /// + public string PathWorkspaceSid { get; } + /// + /// The friendly_name of the Workflow resources to read + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new ReadWorkflowOptions + /// + /// The SID of the Workspace with the Workflow to read + public ReadWorkflowOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateWorkflowOptions + /// + public class CreateWorkflowOptions : IOptions + { + /// + /// The SID of the Workspace that the new Workflow to create belongs to + /// + public string PathWorkspaceSid { get; } + /// + /// descriptive string that you create to describe the Workflow resource + /// + public string FriendlyName { get; } + /// + /// A JSON string that contains the rules to apply to the Workflow + /// + public string Configuration { get; } + /// + /// The URL from your application that will process task assignment events + /// + public Uri AssignmentCallbackUrl { get; set; } + /// + /// The URL that we should call when a call to the `assignment_callback_url` fails + /// + public Uri FallbackAssignmentCallbackUrl { get; set; } + /// + /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker + /// + public int? TaskReservationTimeout { get; set; } + + /// + /// Construct a new CreateWorkflowOptions + /// + /// The SID of the Workspace that the new Workflow to create belongs to + /// descriptive string that you create to describe the Workflow resource + /// A JSON string that contains the rules to apply to the Workflow + public CreateWorkflowOptions(string pathWorkspaceSid, string friendlyName, string configuration) + { + PathWorkspaceSid = pathWorkspaceSid; + FriendlyName = friendlyName; + Configuration = configuration; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Configuration != null) + { + p.Add(new KeyValuePair("Configuration", Configuration)); + } + + if (AssignmentCallbackUrl != null) + { + p.Add(new KeyValuePair("AssignmentCallbackUrl", Serializers.Url(AssignmentCallbackUrl))); + } + + if (FallbackAssignmentCallbackUrl != null) + { + p.Add(new KeyValuePair("FallbackAssignmentCallbackUrl", Serializers.Url(FallbackAssignmentCallbackUrl))); + } + + if (TaskReservationTimeout != null) + { + p.Add(new KeyValuePair("TaskReservationTimeout", TaskReservationTimeout.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowResource.cs index 642c40dd0..8aef63098 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkflowResource.cs @@ -16,567 +16,567 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class WorkflowResource : Resource - { - private static Request BuildFetchRequest(FetchWorkflowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Workflow parameters - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Fetch(FetchWorkflowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Workflow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// The SID of the resource - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWorkflowOptions(pathWorkspaceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace with the Workflow to fetch - /// The SID of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWorkflowOptions(pathWorkspaceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWorkflowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Workflow parameters - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Update(UpdateWorkflowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Workflow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkflowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Workspace with the Workflow to update - /// The SID of the resource - /// descriptive string that you create to describe the Workflow resource - /// The URL from your application that will process task assignment events - /// The URL that we should call when a call to the - /// `assignment_callback_url` fails - /// A JSON string that contains the rules to apply to the Workflow - /// How long TaskRouter will wait for a confirmation response from your - /// application after it assigns a Task to a Worker - /// Whether or not to re-evaluate Tasks - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Update(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - Uri assignmentCallbackUrl = null, - Uri fallbackAssignmentCallbackUrl = null, - string configuration = null, - int? taskReservationTimeout = null, - string reEvaluateTasks = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkflowOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, Configuration = configuration, TaskReservationTimeout = taskReservationTimeout, ReEvaluateTasks = reEvaluateTasks}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Workspace with the Workflow to update - /// The SID of the resource - /// descriptive string that you create to describe the Workflow resource - /// The URL from your application that will process task assignment events - /// The URL that we should call when a call to the - /// `assignment_callback_url` fails - /// A JSON string that contains the rules to apply to the Workflow - /// How long TaskRouter will wait for a confirmation response from your - /// application after it assigns a Task to a Worker - /// Whether or not to re-evaluate Tasks - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, - string pathSid, - string friendlyName = null, - Uri assignmentCallbackUrl = null, - Uri fallbackAssignmentCallbackUrl = null, - string configuration = null, - int? taskReservationTimeout = null, - string reEvaluateTasks = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkflowOptions(pathWorkspaceSid, pathSid){FriendlyName = friendlyName, AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, Configuration = configuration, TaskReservationTimeout = taskReservationTimeout, ReEvaluateTasks = reEvaluateTasks}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWorkflowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Workflow parameters - /// Client to make requests to Twilio - /// A single instance of Workflow - public static bool Delete(DeleteWorkflowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Workflow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkflowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Workspace with the Workflow to delete - /// The SID of the Workflow resource to delete - /// Client to make requests to Twilio - /// A single instance of Workflow - public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWorkflowOptions(pathWorkspaceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Workspace with the Workflow to delete - /// The SID of the Workflow resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWorkflowOptions(pathWorkspaceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadWorkflowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Workflow parameters - /// Client to make requests to Twilio - /// A single instance of Workflow - public static ResourceSet Read(ReadWorkflowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("workflows", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Workflow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkflowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("workflows", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Workspace with the Workflow to read - /// The friendly_name of the Workflow resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Workflow - public static ResourceSet Read(string pathWorkspaceSid, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkflowOptions(pathWorkspaceSid){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Workspace with the Workflow to read - /// The friendly_name of the Workflow resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkflowOptions(pathWorkspaceSid){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("workflows", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workflows", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workflows", response.Content); - } - - private static Request BuildCreateRequest(CreateWorkflowOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Workflow parameters - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Create(CreateWorkflowOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Workflow parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task CreateAsync(CreateWorkflowOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Workspace that the new Workflow to create belongs to - /// descriptive string that you create to describe the Workflow resource - /// A JSON string that contains the rules to apply to the Workflow - /// The URL from your application that will process task assignment events - /// The URL that we should call when a call to the - /// `assignment_callback_url` fails - /// How long TaskRouter will wait for a confirmation response from your - /// application after it assigns a Task to a Worker - /// Client to make requests to Twilio - /// A single instance of Workflow - public static WorkflowResource Create(string pathWorkspaceSid, - string friendlyName, - string configuration, - Uri assignmentCallbackUrl = null, - Uri fallbackAssignmentCallbackUrl = null, - int? taskReservationTimeout = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkflowOptions(pathWorkspaceSid, friendlyName, configuration){AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, TaskReservationTimeout = taskReservationTimeout}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Workspace that the new Workflow to create belongs to - /// descriptive string that you create to describe the Workflow resource - /// A JSON string that contains the rules to apply to the Workflow - /// The URL from your application that will process task assignment events - /// The URL that we should call when a call to the - /// `assignment_callback_url` fails - /// How long TaskRouter will wait for a confirmation response from your - /// application after it assigns a Task to a Worker - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workflow - public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, - string friendlyName, - string configuration, - Uri assignmentCallbackUrl = null, - Uri fallbackAssignmentCallbackUrl = null, - int? taskReservationTimeout = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkflowOptions(pathWorkspaceSid, friendlyName, configuration){AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, TaskReservationTimeout = taskReservationTimeout}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkflowResource object - /// - /// Raw JSON string - /// WorkflowResource object represented by the provided JSON - public static WorkflowResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The URL that we call when a task managed by the Workflow is assigned to a Worker - /// - [JsonProperty("assignment_callback_url")] - public Uri AssignmentCallbackUrl { get; private set; } - /// - /// A JSON string that contains the Workflow's configuration - /// - [JsonProperty("configuration")] - public string Configuration { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The MIME type of the document - /// - [JsonProperty("document_content_type")] - public string DocumentContentType { get; private set; } - /// - /// The URL that we call when a call to the `assignment_callback_url` fails - /// - [JsonProperty("fallback_assignment_callback_url")] - public Uri FallbackAssignmentCallbackUrl { get; private set; } - /// - /// The string that you assigned to describe the Workflow resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker - /// - [JsonProperty("task_reservation_timeout")] - public int? TaskReservationTimeout { get; private set; } - /// - /// The SID of the Workspace that contains the Workflow - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workflow resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private WorkflowResource() - { - - } - } +{ + + public class WorkflowResource : Resource + { + private static Request BuildFetchRequest(FetchWorkflowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Workflow parameters + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Fetch(FetchWorkflowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Workflow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkflowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// The SID of the resource + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Fetch(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWorkflowOptions(pathWorkspaceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace with the Workflow to fetch + /// The SID of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWorkflowOptions(pathWorkspaceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWorkflowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Workflow parameters + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Update(UpdateWorkflowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Workflow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkflowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Workspace with the Workflow to update + /// The SID of the resource + /// descriptive string that you create to describe the Workflow resource + /// The URL from your application that will process task assignment events + /// The URL that we should call when a call to the + /// `assignment_callback_url` fails + /// A JSON string that contains the rules to apply to the Workflow + /// How long TaskRouter will wait for a confirmation response from your + /// application after it assigns a Task to a Worker + /// Whether or not to re-evaluate Tasks + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Update(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + Uri assignmentCallbackUrl = null, + Uri fallbackAssignmentCallbackUrl = null, + string configuration = null, + int? taskReservationTimeout = null, + string reEvaluateTasks = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkflowOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, Configuration = configuration, TaskReservationTimeout = taskReservationTimeout, ReEvaluateTasks = reEvaluateTasks }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Workspace with the Workflow to update + /// The SID of the resource + /// descriptive string that you create to describe the Workflow resource + /// The URL from your application that will process task assignment events + /// The URL that we should call when a call to the + /// `assignment_callback_url` fails + /// A JSON string that contains the rules to apply to the Workflow + /// How long TaskRouter will wait for a confirmation response from your + /// application after it assigns a Task to a Worker + /// Whether or not to re-evaluate Tasks + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task UpdateAsync(string pathWorkspaceSid, + string pathSid, + string friendlyName = null, + Uri assignmentCallbackUrl = null, + Uri fallbackAssignmentCallbackUrl = null, + string configuration = null, + int? taskReservationTimeout = null, + string reEvaluateTasks = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkflowOptions(pathWorkspaceSid, pathSid) { FriendlyName = friendlyName, AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, Configuration = configuration, TaskReservationTimeout = taskReservationTimeout, ReEvaluateTasks = reEvaluateTasks }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWorkflowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Workflow parameters + /// Client to make requests to Twilio + /// A single instance of Workflow + public static bool Delete(DeleteWorkflowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Workflow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkflowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Workspace with the Workflow to delete + /// The SID of the Workflow resource to delete + /// Client to make requests to Twilio + /// A single instance of Workflow + public static bool Delete(string pathWorkspaceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWorkflowOptions(pathWorkspaceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Workspace with the Workflow to delete + /// The SID of the Workflow resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task DeleteAsync(string pathWorkspaceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWorkflowOptions(pathWorkspaceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadWorkflowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Workflow parameters + /// Client to make requests to Twilio + /// A single instance of Workflow + public static ResourceSet Read(ReadWorkflowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("workflows", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Workflow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkflowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("workflows", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Workspace with the Workflow to read + /// The friendly_name of the Workflow resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Workflow + public static ResourceSet Read(string pathWorkspaceSid, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkflowOptions(pathWorkspaceSid) { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Workspace with the Workflow to read + /// The friendly_name of the Workflow resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task> ReadAsync(string pathWorkspaceSid, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkflowOptions(pathWorkspaceSid) { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("workflows", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workflows", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workflows", response.Content); + } + + private static Request BuildCreateRequest(CreateWorkflowOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workflows", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Workflow parameters + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Create(CreateWorkflowOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Workflow parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task CreateAsync(CreateWorkflowOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Workspace that the new Workflow to create belongs to + /// descriptive string that you create to describe the Workflow resource + /// A JSON string that contains the rules to apply to the Workflow + /// The URL from your application that will process task assignment events + /// The URL that we should call when a call to the + /// `assignment_callback_url` fails + /// How long TaskRouter will wait for a confirmation response from your + /// application after it assigns a Task to a Worker + /// Client to make requests to Twilio + /// A single instance of Workflow + public static WorkflowResource Create(string pathWorkspaceSid, + string friendlyName, + string configuration, + Uri assignmentCallbackUrl = null, + Uri fallbackAssignmentCallbackUrl = null, + int? taskReservationTimeout = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkflowOptions(pathWorkspaceSid, friendlyName, configuration) { AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, TaskReservationTimeout = taskReservationTimeout }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Workspace that the new Workflow to create belongs to + /// descriptive string that you create to describe the Workflow resource + /// A JSON string that contains the rules to apply to the Workflow + /// The URL from your application that will process task assignment events + /// The URL that we should call when a call to the + /// `assignment_callback_url` fails + /// How long TaskRouter will wait for a confirmation response from your + /// application after it assigns a Task to a Worker + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workflow + public static async System.Threading.Tasks.Task CreateAsync(string pathWorkspaceSid, + string friendlyName, + string configuration, + Uri assignmentCallbackUrl = null, + Uri fallbackAssignmentCallbackUrl = null, + int? taskReservationTimeout = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkflowOptions(pathWorkspaceSid, friendlyName, configuration) { AssignmentCallbackUrl = assignmentCallbackUrl, FallbackAssignmentCallbackUrl = fallbackAssignmentCallbackUrl, TaskReservationTimeout = taskReservationTimeout }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkflowResource object + /// + /// Raw JSON string + /// WorkflowResource object represented by the provided JSON + public static WorkflowResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The URL that we call when a task managed by the Workflow is assigned to a Worker + /// + [JsonProperty("assignment_callback_url")] + public Uri AssignmentCallbackUrl { get; private set; } + /// + /// A JSON string that contains the Workflow's configuration + /// + [JsonProperty("configuration")] + public string Configuration { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The MIME type of the document + /// + [JsonProperty("document_content_type")] + public string DocumentContentType { get; private set; } + /// + /// The URL that we call when a call to the `assignment_callback_url` fails + /// + [JsonProperty("fallback_assignment_callback_url")] + public Uri FallbackAssignmentCallbackUrl { get; private set; } + /// + /// The string that you assigned to describe the Workflow resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker + /// + [JsonProperty("task_reservation_timeout")] + public int? TaskReservationTimeout { get; private set; } + /// + /// The SID of the Workspace that contains the Workflow + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workflow resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private WorkflowResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsOptions.cs index 3fc12c82d..9c7a103a9 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsOptions.cs @@ -9,80 +9,80 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchWorkspaceCumulativeStatisticsOptions + /// + public class FetchWorkspaceCumulativeStatisticsOptions : IOptions + { /// - /// FetchWorkspaceCumulativeStatisticsOptions + /// The SID of the Workspace to fetch /// - public class FetchWorkspaceCumulativeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate cumulative statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchWorkspaceCumulativeStatisticsOptions - /// - /// The SID of the Workspace to fetch - public FetchWorkspaceCumulativeStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate cumulative statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchWorkspaceCumulativeStatisticsOptions + /// + /// The SID of the Workspace to fetch + public FetchWorkspaceCumulativeStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsResource.cs index 52c768baf..ff7937b9e 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceCumulativeStatisticsResource.cs @@ -16,229 +16,229 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class WorkspaceCumulativeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkspaceCumulativeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/CumulativeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkspaceCumulativeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkspaceCumulativeStatistics - public static WorkspaceCumulativeStatisticsResource Fetch(FetchWorkspaceCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkspaceCumulativeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceCumulativeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only include usage that occurred on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of WorkspaceCumulativeStatistics - public static WorkspaceCumulativeStatisticsResource Fetch(string pathWorkspaceSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceCumulativeStatisticsOptions(pathWorkspaceSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only include usage that occurred on or before this date - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate cumulative statistics on this TaskChannel - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceCumulativeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - DateTime? endDate = null, - int? minutes = null, - DateTime? startDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceCumulativeStatisticsOptions(pathWorkspaceSid){EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkspaceCumulativeStatisticsResource object - /// - /// Raw JSON string - /// WorkspaceCumulativeStatisticsResource object represented by the provided JSON - public static WorkspaceCumulativeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The average time in seconds between Task creation and acceptance - /// - [JsonProperty("avg_task_acceptance_time")] - public int? AvgTaskAcceptanceTime { get; private set; } - /// - /// The beginning of the interval during which these statistics were calculated - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The end of the interval during which these statistics were calculated - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The total number of Reservations that were created for Workers - /// - [JsonProperty("reservations_created")] - public int? ReservationsCreated { get; private set; } - /// - /// The total number of Reservations accepted by Workers - /// - [JsonProperty("reservations_accepted")] - public int? ReservationsAccepted { get; private set; } - /// - /// The total number of Reservations that were rejected - /// - [JsonProperty("reservations_rejected")] - public int? ReservationsRejected { get; private set; } - /// - /// The total number of Reservations that were timed out - /// - [JsonProperty("reservations_timed_out")] - public int? ReservationsTimedOut { get; private set; } - /// - /// The total number of Reservations that were canceled - /// - [JsonProperty("reservations_canceled")] - public int? ReservationsCanceled { get; private set; } - /// - /// The total number of Reservations that were rescinded - /// - [JsonProperty("reservations_rescinded")] - public int? ReservationsRescinded { get; private set; } - /// - /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds - /// - [JsonProperty("split_by_wait_time")] - public object SplitByWaitTime { get; private set; } - /// - /// The wait duration statistics for Tasks that were accepted - /// - [JsonProperty("wait_duration_until_accepted")] - public object WaitDurationUntilAccepted { get; private set; } - /// - /// The wait duration statistics for Tasks that were canceled - /// - [JsonProperty("wait_duration_until_canceled")] - public object WaitDurationUntilCanceled { get; private set; } - /// - /// The total number of Tasks that were canceled - /// - [JsonProperty("tasks_canceled")] - public int? TasksCanceled { get; private set; } - /// - /// The total number of Tasks that were completed - /// - [JsonProperty("tasks_completed")] - public int? TasksCompleted { get; private set; } - /// - /// The total number of Tasks created - /// - [JsonProperty("tasks_created")] - public int? TasksCreated { get; private set; } - /// - /// The total number of Tasks that were deleted - /// - [JsonProperty("tasks_deleted")] - public int? TasksDeleted { get; private set; } - /// - /// The total number of Tasks that were moved from one queue to another - /// - [JsonProperty("tasks_moved")] - public int? TasksMoved { get; private set; } - /// - /// The total number of Tasks that were timed out of their Workflows - /// - [JsonProperty("tasks_timed_out_in_workflow")] - public int? TasksTimedOutInWorkflow { get; private set; } - /// - /// The SID of the Workspace - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workspace statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkspaceCumulativeStatisticsResource() - { - - } - } +{ + + public class WorkspaceCumulativeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkspaceCumulativeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/CumulativeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkspaceCumulativeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkspaceCumulativeStatistics + public static WorkspaceCumulativeStatisticsResource Fetch(FetchWorkspaceCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkspaceCumulativeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceCumulativeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only include usage that occurred on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of WorkspaceCumulativeStatistics + public static WorkspaceCumulativeStatisticsResource Fetch(string pathWorkspaceSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceCumulativeStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only include usage that occurred on or before this date + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate cumulative statistics on this TaskChannel + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceCumulativeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + DateTime? endDate = null, + int? minutes = null, + DateTime? startDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceCumulativeStatisticsOptions(pathWorkspaceSid) { EndDate = endDate, Minutes = minutes, StartDate = startDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkspaceCumulativeStatisticsResource object + /// + /// Raw JSON string + /// WorkspaceCumulativeStatisticsResource object represented by the provided JSON + public static WorkspaceCumulativeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The average time in seconds between Task creation and acceptance + /// + [JsonProperty("avg_task_acceptance_time")] + public int? AvgTaskAcceptanceTime { get; private set; } + /// + /// The beginning of the interval during which these statistics were calculated + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The end of the interval during which these statistics were calculated + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The total number of Reservations that were created for Workers + /// + [JsonProperty("reservations_created")] + public int? ReservationsCreated { get; private set; } + /// + /// The total number of Reservations accepted by Workers + /// + [JsonProperty("reservations_accepted")] + public int? ReservationsAccepted { get; private set; } + /// + /// The total number of Reservations that were rejected + /// + [JsonProperty("reservations_rejected")] + public int? ReservationsRejected { get; private set; } + /// + /// The total number of Reservations that were timed out + /// + [JsonProperty("reservations_timed_out")] + public int? ReservationsTimedOut { get; private set; } + /// + /// The total number of Reservations that were canceled + /// + [JsonProperty("reservations_canceled")] + public int? ReservationsCanceled { get; private set; } + /// + /// The total number of Reservations that were rescinded + /// + [JsonProperty("reservations_rescinded")] + public int? ReservationsRescinded { get; private set; } + /// + /// A list of objects that describe the Tasks canceled and reservations accepted above and below the specified thresholds + /// + [JsonProperty("split_by_wait_time")] + public object SplitByWaitTime { get; private set; } + /// + /// The wait duration statistics for Tasks that were accepted + /// + [JsonProperty("wait_duration_until_accepted")] + public object WaitDurationUntilAccepted { get; private set; } + /// + /// The wait duration statistics for Tasks that were canceled + /// + [JsonProperty("wait_duration_until_canceled")] + public object WaitDurationUntilCanceled { get; private set; } + /// + /// The total number of Tasks that were canceled + /// + [JsonProperty("tasks_canceled")] + public int? TasksCanceled { get; private set; } + /// + /// The total number of Tasks that were completed + /// + [JsonProperty("tasks_completed")] + public int? TasksCompleted { get; private set; } + /// + /// The total number of Tasks created + /// + [JsonProperty("tasks_created")] + public int? TasksCreated { get; private set; } + /// + /// The total number of Tasks that were deleted + /// + [JsonProperty("tasks_deleted")] + public int? TasksDeleted { get; private set; } + /// + /// The total number of Tasks that were moved from one queue to another + /// + [JsonProperty("tasks_moved")] + public int? TasksMoved { get; private set; } + /// + /// The total number of Tasks that were timed out of their Workflows + /// + [JsonProperty("tasks_timed_out_in_workflow")] + public int? TasksTimedOutInWorkflow { get; private set; } + /// + /// The SID of the Workspace + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workspace statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkspaceCumulativeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsOptions.cs index 4cec41153..34bb39067 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchWorkspaceRealTimeStatisticsOptions + /// + public class FetchWorkspaceRealTimeStatisticsOptions : IOptions + { /// - /// FetchWorkspaceRealTimeStatisticsOptions + /// The SID of the Workspace to fetch /// - public class FetchWorkspaceRealTimeStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate real-time statistics on this TaskChannel - /// - public string TaskChannel { get; set; } - - /// - /// Construct a new FetchWorkspaceRealTimeStatisticsOptions - /// - /// The SID of the Workspace to fetch - public FetchWorkspaceRealTimeStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate real-time statistics on this TaskChannel + /// + public string TaskChannel { get; set; } + + /// + /// Construct a new FetchWorkspaceRealTimeStatisticsOptions + /// + /// The SID of the Workspace to fetch + public FetchWorkspaceRealTimeStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsResource.cs index 7b8aabdee..4c6b7e39d 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceRealTimeStatisticsResource.cs @@ -16,156 +16,156 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class WorkspaceRealTimeStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkspaceRealTimeStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/RealTimeStatistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkspaceRealTimeStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkspaceRealTimeStatistics - public static WorkspaceRealTimeStatisticsResource Fetch(FetchWorkspaceRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkspaceRealTimeStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceRealTimeStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// A single instance of WorkspaceRealTimeStatistics - public static WorkspaceRealTimeStatisticsResource Fetch(string pathWorkspaceSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceRealTimeStatisticsOptions(pathWorkspaceSid){TaskChannel = taskChannel}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only calculate real-time statistics on this TaskChannel - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceRealTimeStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - string taskChannel = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceRealTimeStatisticsOptions(pathWorkspaceSid){TaskChannel = taskChannel}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkspaceRealTimeStatisticsResource object - /// - /// Raw JSON string - /// WorkspaceRealTimeStatisticsResource object represented by the provided JSON - public static WorkspaceRealTimeStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The number of current Workers by Activity - /// - [JsonProperty("activity_statistics")] - public List ActivityStatistics { get; private set; } - /// - /// The age of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_age")] - public int? LongestTaskWaitingAge { get; private set; } - /// - /// The SID of the longest waiting Task - /// - [JsonProperty("longest_task_waiting_sid")] - public string LongestTaskWaitingSid { get; private set; } - /// - /// The number of Tasks by priority - /// - [JsonProperty("tasks_by_priority")] - public object TasksByPriority { get; private set; } - /// - /// The number of Tasks by their current status - /// - [JsonProperty("tasks_by_status")] - public object TasksByStatus { get; private set; } - /// - /// The total number of Tasks - /// - [JsonProperty("total_tasks")] - public int? TotalTasks { get; private set; } - /// - /// The total number of Workers in the Workspace - /// - [JsonProperty("total_workers")] - public int? TotalWorkers { get; private set; } - /// - /// The SID of the Workspace - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workspace statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkspaceRealTimeStatisticsResource() - { - - } - } +{ + + public class WorkspaceRealTimeStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkspaceRealTimeStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/RealTimeStatistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkspaceRealTimeStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkspaceRealTimeStatistics + public static WorkspaceRealTimeStatisticsResource Fetch(FetchWorkspaceRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkspaceRealTimeStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceRealTimeStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// A single instance of WorkspaceRealTimeStatistics + public static WorkspaceRealTimeStatisticsResource Fetch(string pathWorkspaceSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceRealTimeStatisticsOptions(pathWorkspaceSid) { TaskChannel = taskChannel }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only calculate real-time statistics on this TaskChannel + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceRealTimeStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + string taskChannel = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceRealTimeStatisticsOptions(pathWorkspaceSid) { TaskChannel = taskChannel }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkspaceRealTimeStatisticsResource object + /// + /// Raw JSON string + /// WorkspaceRealTimeStatisticsResource object represented by the provided JSON + public static WorkspaceRealTimeStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The number of current Workers by Activity + /// + [JsonProperty("activity_statistics")] + public List ActivityStatistics { get; private set; } + /// + /// The age of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_age")] + public int? LongestTaskWaitingAge { get; private set; } + /// + /// The SID of the longest waiting Task + /// + [JsonProperty("longest_task_waiting_sid")] + public string LongestTaskWaitingSid { get; private set; } + /// + /// The number of Tasks by priority + /// + [JsonProperty("tasks_by_priority")] + public object TasksByPriority { get; private set; } + /// + /// The number of Tasks by their current status + /// + [JsonProperty("tasks_by_status")] + public object TasksByStatus { get; private set; } + /// + /// The total number of Tasks + /// + [JsonProperty("total_tasks")] + public int? TotalTasks { get; private set; } + /// + /// The total number of Workers in the Workspace + /// + [JsonProperty("total_workers")] + public int? TotalWorkers { get; private set; } + /// + /// The SID of the Workspace + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workspace statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkspaceRealTimeStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsOptions.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsOptions.cs index 8525700a4..94a0b7f7f 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsOptions.cs @@ -9,80 +9,80 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - +{ + + /// + /// FetchWorkspaceStatisticsOptions + /// + public class FetchWorkspaceStatisticsOptions : IOptions + { /// - /// FetchWorkspaceStatisticsOptions + /// The SID of the Workspace to fetch /// - public class FetchWorkspaceStatisticsOptions : IOptions - { - /// - /// The SID of the Workspace to fetch - /// - public string PathWorkspaceSid { get; } - /// - /// Only calculate statistics since this many minutes in the past - /// - public int? Minutes { get; set; } - /// - /// Only calculate statistics from on or after this date - /// - public DateTime? StartDate { get; set; } - /// - /// Only calculate statistics from this date and time and earlier - /// - public DateTime? EndDate { get; set; } - /// - /// Only calculate statistics on this TaskChannel. - /// - public string TaskChannel { get; set; } - /// - /// A comma separated list of values that describes the thresholds to calculate statistics on - /// - public string SplitByWaitTime { get; set; } - - /// - /// Construct a new FetchWorkspaceStatisticsOptions - /// - /// The SID of the Workspace to fetch - public FetchWorkspaceStatisticsOptions(string pathWorkspaceSid) - { - PathWorkspaceSid = pathWorkspaceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Minutes != null) - { - p.Add(new KeyValuePair("Minutes", Minutes.ToString())); - } - - if (StartDate != null) - { - p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); - } - - if (EndDate != null) - { - p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); - } - - if (TaskChannel != null) - { - p.Add(new KeyValuePair("TaskChannel", TaskChannel)); - } - - if (SplitByWaitTime != null) - { - p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); - } - - return p; - } - } + public string PathWorkspaceSid { get; } + /// + /// Only calculate statistics since this many minutes in the past + /// + public int? Minutes { get; set; } + /// + /// Only calculate statistics from on or after this date + /// + public DateTime? StartDate { get; set; } + /// + /// Only calculate statistics from this date and time and earlier + /// + public DateTime? EndDate { get; set; } + /// + /// Only calculate statistics on this TaskChannel. + /// + public string TaskChannel { get; set; } + /// + /// A comma separated list of values that describes the thresholds to calculate statistics on + /// + public string SplitByWaitTime { get; set; } + + /// + /// Construct a new FetchWorkspaceStatisticsOptions + /// + /// The SID of the Workspace to fetch + public FetchWorkspaceStatisticsOptions(string pathWorkspaceSid) + { + PathWorkspaceSid = pathWorkspaceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Minutes != null) + { + p.Add(new KeyValuePair("Minutes", Minutes.ToString())); + } + + if (StartDate != null) + { + p.Add(new KeyValuePair("StartDate", Serializers.DateTimeIso8601(StartDate))); + } + + if (EndDate != null) + { + p.Add(new KeyValuePair("EndDate", Serializers.DateTimeIso8601(EndDate))); + } + + if (TaskChannel != null) + { + p.Add(new KeyValuePair("TaskChannel", TaskChannel)); + } + + if (SplitByWaitTime != null) + { + p.Add(new KeyValuePair("SplitByWaitTime", SplitByWaitTime)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsResource.cs b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsResource.cs index dbf43b77c..afbcdf6cf 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/WorkspaceStatisticsResource.cs @@ -16,149 +16,149 @@ using Twilio.Http; namespace Twilio.Rest.Taskrouter.V1.Workspace -{ - - public class WorkspaceStatisticsResource : Resource - { - private static Request BuildFetchRequest(FetchWorkspaceStatisticsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathWorkspaceSid + "/Statistics", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch WorkspaceStatistics parameters - /// Client to make requests to Twilio - /// A single instance of WorkspaceStatistics - public static WorkspaceStatisticsResource Fetch(FetchWorkspaceStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch WorkspaceStatistics parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceStatistics - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceStatisticsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// Only calculate statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// A single instance of WorkspaceStatistics - public static WorkspaceStatisticsResource Fetch(string pathWorkspaceSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceStatisticsOptions(pathWorkspaceSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Workspace to fetch - /// Only calculate statistics since this many minutes in the past - /// Only calculate statistics from on or after this date - /// Only calculate statistics from this date and time and earlier - /// Only calculate statistics on this TaskChannel. - /// A comma separated list of values that describes the thresholds to calculate - /// statistics on - /// Client to make requests to Twilio - /// Task that resolves to A single instance of WorkspaceStatistics - public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, - int? minutes = null, - DateTime? startDate = null, - DateTime? endDate = null, - string taskChannel = null, - string splitByWaitTime = null, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceStatisticsOptions(pathWorkspaceSid){Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime}; - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkspaceStatisticsResource object - /// - /// Raw JSON string - /// WorkspaceStatisticsResource object represented by the provided JSON - public static WorkspaceStatisticsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// n object that contains the real-time statistics for the Workspace - /// - [JsonProperty("realtime")] - public object Realtime { get; private set; } - /// - /// An object that contains the cumulative statistics for the Workspace - /// - [JsonProperty("cumulative")] - public object Cumulative { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Workspace - /// - [JsonProperty("workspace_sid")] - public string WorkspaceSid { get; private set; } - /// - /// The absolute URL of the Workspace statistics resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WorkspaceStatisticsResource() - { - - } - } +{ + + public class WorkspaceStatisticsResource : Resource + { + private static Request BuildFetchRequest(FetchWorkspaceStatisticsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathWorkspaceSid + "/Statistics", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch WorkspaceStatistics parameters + /// Client to make requests to Twilio + /// A single instance of WorkspaceStatistics + public static WorkspaceStatisticsResource Fetch(FetchWorkspaceStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch WorkspaceStatistics parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceStatistics + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceStatisticsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// Only calculate statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// A single instance of WorkspaceStatistics + public static WorkspaceStatisticsResource Fetch(string pathWorkspaceSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceStatisticsOptions(pathWorkspaceSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Workspace to fetch + /// Only calculate statistics since this many minutes in the past + /// Only calculate statistics from on or after this date + /// Only calculate statistics from this date and time and earlier + /// Only calculate statistics on this TaskChannel. + /// A comma separated list of values that describes the thresholds to calculate + /// statistics on + /// Client to make requests to Twilio + /// Task that resolves to A single instance of WorkspaceStatistics + public static async System.Threading.Tasks.Task FetchAsync(string pathWorkspaceSid, + int? minutes = null, + DateTime? startDate = null, + DateTime? endDate = null, + string taskChannel = null, + string splitByWaitTime = null, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceStatisticsOptions(pathWorkspaceSid) { Minutes = minutes, StartDate = startDate, EndDate = endDate, TaskChannel = taskChannel, SplitByWaitTime = splitByWaitTime }; + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkspaceStatisticsResource object + /// + /// Raw JSON string + /// WorkspaceStatisticsResource object represented by the provided JSON + public static WorkspaceStatisticsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// n object that contains the real-time statistics for the Workspace + /// + [JsonProperty("realtime")] + public object Realtime { get; private set; } + /// + /// An object that contains the cumulative statistics for the Workspace + /// + [JsonProperty("cumulative")] + public object Cumulative { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Workspace + /// + [JsonProperty("workspace_sid")] + public string WorkspaceSid { get; private set; } + /// + /// The absolute URL of the Workspace statistics resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WorkspaceStatisticsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/WorkspaceOptions.cs b/src/Twilio/Rest/Taskrouter/V1/WorkspaceOptions.cs index e8d1f71c0..528954d64 100644 --- a/src/Twilio/Rest/Taskrouter/V1/WorkspaceOptions.cs +++ b/src/Twilio/Rest/Taskrouter/V1/WorkspaceOptions.cs @@ -9,265 +9,265 @@ using Twilio.Converters; namespace Twilio.Rest.Taskrouter.V1 -{ - +{ + + /// + /// FetchWorkspaceOptions + /// + public class FetchWorkspaceOptions : IOptions + { /// - /// FetchWorkspaceOptions + /// The SID of the resource to fetch /// - public class FetchWorkspaceOptions : IOptions - { - /// - /// The SID of the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWorkspaceOptions - /// - /// The SID of the resource to fetch - public FetchWorkspaceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// UpdateWorkspaceOptions + /// Construct a new FetchWorkspaceOptions /// - public class UpdateWorkspaceOptions : IOptions - { - /// - /// The SID of the resource to update - /// - public string PathSid { get; } - /// - /// The SID of the Activity that will be used when new Workers are created in the Workspace - /// - public string DefaultActivitySid { get; set; } - /// - /// The URL we should call when an event occurs - /// - public Uri EventCallbackUrl { get; set; } - /// - /// The list of Workspace events for which to call event_callback_url - /// - public string EventsFilter { get; set; } - /// - /// A string to describe the Workspace resource - /// - public string FriendlyName { get; set; } - /// - /// Whether multi-tasking is enabled - /// - public bool? MultiTaskEnabled { get; set; } - /// - /// The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response - /// - public string TimeoutActivitySid { get; set; } - /// - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues - /// - public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; set; } - - /// - /// Construct a new UpdateWorkspaceOptions - /// - /// The SID of the resource to update - public UpdateWorkspaceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DefaultActivitySid != null) - { - p.Add(new KeyValuePair("DefaultActivitySid", DefaultActivitySid.ToString())); - } - - if (EventCallbackUrl != null) - { - p.Add(new KeyValuePair("EventCallbackUrl", Serializers.Url(EventCallbackUrl))); - } - - if (EventsFilter != null) - { - p.Add(new KeyValuePair("EventsFilter", EventsFilter)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (MultiTaskEnabled != null) - { - p.Add(new KeyValuePair("MultiTaskEnabled", MultiTaskEnabled.Value.ToString().ToLower())); - } - - if (TimeoutActivitySid != null) - { - p.Add(new KeyValuePair("TimeoutActivitySid", TimeoutActivitySid.ToString())); - } - - if (PrioritizeQueueOrder != null) - { - p.Add(new KeyValuePair("PrioritizeQueueOrder", PrioritizeQueueOrder.ToString())); - } - - return p; - } - } - + /// The SID of the resource to fetch + public FetchWorkspaceOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// ReadWorkspaceOptions + /// Generate the necessary parameters /// - public class ReadWorkspaceOptions : ReadOptions - { - /// - /// The friendly_name of the Workspace resources to read - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateWorkspaceOptions + /// + public class UpdateWorkspaceOptions : IOptions + { /// - /// CreateWorkspaceOptions + /// The SID of the resource to update /// - public class CreateWorkspaceOptions : IOptions - { - /// - /// A string to describe the Workspace resource - /// - public string FriendlyName { get; } - /// - /// The URL we should call when an event occurs - /// - public Uri EventCallbackUrl { get; set; } - /// - /// The list of Workspace events for which to call event_callback_url - /// - public string EventsFilter { get; set; } - /// - /// Whether multi-tasking is enabled - /// - public bool? MultiTaskEnabled { get; set; } - /// - /// An available template name - /// - public string Template { get; set; } - /// - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues - /// - public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; set; } - - /// - /// Construct a new CreateWorkspaceOptions - /// - /// A string to describe the Workspace resource - public CreateWorkspaceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (EventCallbackUrl != null) - { - p.Add(new KeyValuePair("EventCallbackUrl", Serializers.Url(EventCallbackUrl))); - } - - if (EventsFilter != null) - { - p.Add(new KeyValuePair("EventsFilter", EventsFilter)); - } - - if (MultiTaskEnabled != null) - { - p.Add(new KeyValuePair("MultiTaskEnabled", MultiTaskEnabled.Value.ToString().ToLower())); - } - - if (Template != null) - { - p.Add(new KeyValuePair("Template", Template)); - } - - if (PrioritizeQueueOrder != null) - { - p.Add(new KeyValuePair("PrioritizeQueueOrder", PrioritizeQueueOrder.ToString())); - } - - return p; - } - } - + public string PathSid { get; } /// - /// DeleteWorkspaceOptions + /// The SID of the Activity that will be used when new Workers are created in the Workspace /// - public class DeleteWorkspaceOptions : IOptions - { - /// - /// The SID of the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWorkspaceOptions - /// - /// The SID of the resource to delete - public DeleteWorkspaceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string DefaultActivitySid { get; set; } + /// + /// The URL we should call when an event occurs + /// + public Uri EventCallbackUrl { get; set; } + /// + /// The list of Workspace events for which to call event_callback_url + /// + public string EventsFilter { get; set; } + /// + /// A string to describe the Workspace resource + /// + public string FriendlyName { get; set; } + /// + /// Whether multi-tasking is enabled + /// + public bool? MultiTaskEnabled { get; set; } + /// + /// The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response + /// + public string TimeoutActivitySid { get; set; } + /// + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues + /// + public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; set; } + + /// + /// Construct a new UpdateWorkspaceOptions + /// + /// The SID of the resource to update + public UpdateWorkspaceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DefaultActivitySid != null) + { + p.Add(new KeyValuePair("DefaultActivitySid", DefaultActivitySid.ToString())); + } + + if (EventCallbackUrl != null) + { + p.Add(new KeyValuePair("EventCallbackUrl", Serializers.Url(EventCallbackUrl))); + } + + if (EventsFilter != null) + { + p.Add(new KeyValuePair("EventsFilter", EventsFilter)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (MultiTaskEnabled != null) + { + p.Add(new KeyValuePair("MultiTaskEnabled", MultiTaskEnabled.Value.ToString().ToLower())); + } + + if (TimeoutActivitySid != null) + { + p.Add(new KeyValuePair("TimeoutActivitySid", TimeoutActivitySid.ToString())); + } + + if (PrioritizeQueueOrder != null) + { + p.Add(new KeyValuePair("PrioritizeQueueOrder", PrioritizeQueueOrder.ToString())); + } + + return p; + } + } + + /// + /// ReadWorkspaceOptions + /// + public class ReadWorkspaceOptions : ReadOptions + { + /// + /// The friendly_name of the Workspace resources to read + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// CreateWorkspaceOptions + /// + public class CreateWorkspaceOptions : IOptions + { + /// + /// A string to describe the Workspace resource + /// + public string FriendlyName { get; } + /// + /// The URL we should call when an event occurs + /// + public Uri EventCallbackUrl { get; set; } + /// + /// The list of Workspace events for which to call event_callback_url + /// + public string EventsFilter { get; set; } + /// + /// Whether multi-tasking is enabled + /// + public bool? MultiTaskEnabled { get; set; } + /// + /// An available template name + /// + public string Template { get; set; } + /// + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues + /// + public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; set; } + + /// + /// Construct a new CreateWorkspaceOptions + /// + /// A string to describe the Workspace resource + public CreateWorkspaceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (EventCallbackUrl != null) + { + p.Add(new KeyValuePair("EventCallbackUrl", Serializers.Url(EventCallbackUrl))); + } + + if (EventsFilter != null) + { + p.Add(new KeyValuePair("EventsFilter", EventsFilter)); + } + + if (MultiTaskEnabled != null) + { + p.Add(new KeyValuePair("MultiTaskEnabled", MultiTaskEnabled.Value.ToString().ToLower())); + } + + if (Template != null) + { + p.Add(new KeyValuePair("Template", Template)); + } + + if (PrioritizeQueueOrder != null) + { + p.Add(new KeyValuePair("PrioritizeQueueOrder", PrioritizeQueueOrder.ToString())); + } + + return p; + } + } + + /// + /// DeleteWorkspaceOptions + /// + public class DeleteWorkspaceOptions : IOptions + { + /// + /// The SID of the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWorkspaceOptions + /// + /// The SID of the resource to delete + public DeleteWorkspaceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Taskrouter/V1/WorkspaceResource.cs b/src/Twilio/Rest/Taskrouter/V1/WorkspaceResource.cs index d3a37fefb..15227b498 100644 --- a/src/Twilio/Rest/Taskrouter/V1/WorkspaceResource.cs +++ b/src/Twilio/Rest/Taskrouter/V1/WorkspaceResource.cs @@ -17,580 +17,580 @@ using Twilio.Types; namespace Twilio.Rest.Taskrouter.V1 -{ - - public class WorkspaceResource : Resource - { - public sealed class QueueOrderEnum : StringEnum - { - private QueueOrderEnum(string value) : base(value) {} - public QueueOrderEnum() {} - public static implicit operator QueueOrderEnum(string value) - { - return new QueueOrderEnum(value); - } - - public static readonly QueueOrderEnum Fifo = new QueueOrderEnum("FIFO"); - public static readonly QueueOrderEnum Lifo = new QueueOrderEnum("LIFO"); - } - - private static Request BuildFetchRequest(FetchWorkspaceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Workspace parameters - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Fetch(FetchWorkspaceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Workspace parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWorkspaceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWorkspaceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWorkspaceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Workspace parameters - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Update(UpdateWorkspaceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Workspace parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkspaceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the resource to update - /// The SID of the Activity that will be used when new Workers are created in the - /// Workspace - /// The URL we should call when an event occurs - /// The list of Workspace events for which to call event_callback_url - /// A string to describe the Workspace resource - /// Whether multi-tasking is enabled - /// The SID of the Activity that will be assigned to a Worker when a Task reservation - /// times out without a response - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both - /// types of TaskQueues - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Update(string pathSid, - string defaultActivitySid = null, - Uri eventCallbackUrl = null, - string eventsFilter = null, - string friendlyName = null, - bool? multiTaskEnabled = null, - string timeoutActivitySid = null, - WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkspaceOptions(pathSid){DefaultActivitySid = defaultActivitySid, EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, FriendlyName = friendlyName, MultiTaskEnabled = multiTaskEnabled, TimeoutActivitySid = timeoutActivitySid, PrioritizeQueueOrder = prioritizeQueueOrder}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the resource to update - /// The SID of the Activity that will be used when new Workers are created in the - /// Workspace - /// The URL we should call when an event occurs - /// The list of Workspace events for which to call event_callback_url - /// A string to describe the Workspace resource - /// Whether multi-tasking is enabled - /// The SID of the Activity that will be assigned to a Worker when a Task reservation - /// times out without a response - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both - /// types of TaskQueues - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string defaultActivitySid = null, - Uri eventCallbackUrl = null, - string eventsFilter = null, - string friendlyName = null, - bool? multiTaskEnabled = null, - string timeoutActivitySid = null, - WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, - ITwilioRestClient client = null) - { - var options = new UpdateWorkspaceOptions(pathSid){DefaultActivitySid = defaultActivitySid, EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, FriendlyName = friendlyName, MultiTaskEnabled = multiTaskEnabled, TimeoutActivitySid = timeoutActivitySid, PrioritizeQueueOrder = prioritizeQueueOrder}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadWorkspaceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Taskrouter, - "/v1/Workspaces", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Workspace parameters - /// Client to make requests to Twilio - /// A single instance of Workspace - public static ResourceSet Read(ReadWorkspaceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("workspaces", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Workspace parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkspaceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("workspaces", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The friendly_name of the Workspace resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Workspace - public static ResourceSet Read(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkspaceOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The friendly_name of the Workspace resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWorkspaceOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("workspaces", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workspaces", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Taskrouter) - ); - - var response = client.Request(request); - return Page.FromJson("workspaces", response.Content); - } - - private static Request BuildCreateRequest(CreateWorkspaceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Taskrouter, - "/v1/Workspaces", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Workspace parameters - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Create(CreateWorkspaceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Workspace parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task CreateAsync(CreateWorkspaceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the Workspace resource - /// The URL we should call when an event occurs - /// The list of Workspace events for which to call event_callback_url - /// Whether multi-tasking is enabled - /// An available template name - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both - /// types of TaskQueues - /// Client to make requests to Twilio - /// A single instance of Workspace - public static WorkspaceResource Create(string friendlyName, - Uri eventCallbackUrl = null, - string eventsFilter = null, - bool? multiTaskEnabled = null, - string template = null, - WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkspaceOptions(friendlyName){EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, MultiTaskEnabled = multiTaskEnabled, Template = template, PrioritizeQueueOrder = prioritizeQueueOrder}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the Workspace resource - /// The URL we should call when an event occurs - /// The list of Workspace events for which to call event_callback_url - /// Whether multi-tasking is enabled - /// An available template name - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both - /// types of TaskQueues - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - Uri eventCallbackUrl = null, - string eventsFilter = null, - bool? multiTaskEnabled = null, - string template = null, - WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, - ITwilioRestClient client = null) - { - var options = new CreateWorkspaceOptions(friendlyName){EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, MultiTaskEnabled = multiTaskEnabled, Template = template, PrioritizeQueueOrder = prioritizeQueueOrder}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWorkspaceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Taskrouter, - "/v1/Workspaces/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Workspace parameters - /// Client to make requests to Twilio - /// A single instance of Workspace - public static bool Delete(DeleteWorkspaceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Workspace parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkspaceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// A single instance of Workspace - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWorkspaceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Workspace - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWorkspaceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a WorkspaceResource object - /// - /// Raw JSON string - /// WorkspaceResource object represented by the provided JSON - public static WorkspaceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The name of the default activity - /// - [JsonProperty("default_activity_name")] - public string DefaultActivityName { get; private set; } - /// - /// The SID of the Activity that will be used when new Workers are created in the Workspace - /// - [JsonProperty("default_activity_sid")] - public string DefaultActivitySid { get; private set; } - /// - /// The URL we call when an event occurs - /// - [JsonProperty("event_callback_url")] - public Uri EventCallbackUrl { get; private set; } - /// - /// The list of Workspace events for which to call event_callback_url - /// - [JsonProperty("events_filter")] - public string EventsFilter { get; private set; } - /// - /// The string that you assigned to describe the Workspace resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Whether multi-tasking is enabled - /// - [JsonProperty("multi_task_enabled")] - public bool? MultiTaskEnabled { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The name of the timeout activity - /// - [JsonProperty("timeout_activity_name")] - public string TimeoutActivityName { get; private set; } - /// - /// The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response - /// - [JsonProperty("timeout_activity_sid")] - public string TimeoutActivitySid { get; private set; } - /// - /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues - /// - [JsonProperty("prioritize_queue_order")] - [JsonConverter(typeof(StringEnumConverter))] - public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; private set; } - /// - /// The absolute URL of the Workspace resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private WorkspaceResource() - { - - } - } +{ + + public class WorkspaceResource : Resource + { + public sealed class QueueOrderEnum : StringEnum + { + private QueueOrderEnum(string value) : base(value) { } + public QueueOrderEnum() { } + public static implicit operator QueueOrderEnum(string value) + { + return new QueueOrderEnum(value); + } + + public static readonly QueueOrderEnum Fifo = new QueueOrderEnum("FIFO"); + public static readonly QueueOrderEnum Lifo = new QueueOrderEnum("LIFO"); + } + + private static Request BuildFetchRequest(FetchWorkspaceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Workspace parameters + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Fetch(FetchWorkspaceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Workspace parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task FetchAsync(FetchWorkspaceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWorkspaceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWorkspaceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWorkspaceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Workspace parameters + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Update(UpdateWorkspaceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Workspace parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWorkspaceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the resource to update + /// The SID of the Activity that will be used when new Workers are created in the + /// Workspace + /// The URL we should call when an event occurs + /// The list of Workspace events for which to call event_callback_url + /// A string to describe the Workspace resource + /// Whether multi-tasking is enabled + /// The SID of the Activity that will be assigned to a Worker when a Task reservation + /// times out without a response + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both + /// types of TaskQueues + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Update(string pathSid, + string defaultActivitySid = null, + Uri eventCallbackUrl = null, + string eventsFilter = null, + string friendlyName = null, + bool? multiTaskEnabled = null, + string timeoutActivitySid = null, + WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkspaceOptions(pathSid) { DefaultActivitySid = defaultActivitySid, EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, FriendlyName = friendlyName, MultiTaskEnabled = multiTaskEnabled, TimeoutActivitySid = timeoutActivitySid, PrioritizeQueueOrder = prioritizeQueueOrder }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the resource to update + /// The SID of the Activity that will be used when new Workers are created in the + /// Workspace + /// The URL we should call when an event occurs + /// The list of Workspace events for which to call event_callback_url + /// A string to describe the Workspace resource + /// Whether multi-tasking is enabled + /// The SID of the Activity that will be assigned to a Worker when a Task reservation + /// times out without a response + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both + /// types of TaskQueues + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string defaultActivitySid = null, + Uri eventCallbackUrl = null, + string eventsFilter = null, + string friendlyName = null, + bool? multiTaskEnabled = null, + string timeoutActivitySid = null, + WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, + ITwilioRestClient client = null) + { + var options = new UpdateWorkspaceOptions(pathSid) { DefaultActivitySid = defaultActivitySid, EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, FriendlyName = friendlyName, MultiTaskEnabled = multiTaskEnabled, TimeoutActivitySid = timeoutActivitySid, PrioritizeQueueOrder = prioritizeQueueOrder }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadWorkspaceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Taskrouter, + "/v1/Workspaces", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Workspace parameters + /// Client to make requests to Twilio + /// A single instance of Workspace + public static ResourceSet Read(ReadWorkspaceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("workspaces", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Workspace parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task> ReadAsync(ReadWorkspaceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("workspaces", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The friendly_name of the Workspace resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Workspace + public static ResourceSet Read(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkspaceOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The friendly_name of the Workspace resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWorkspaceOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("workspaces", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workspaces", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Taskrouter) + ); + + var response = client.Request(request); + return Page.FromJson("workspaces", response.Content); + } + + private static Request BuildCreateRequest(CreateWorkspaceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Taskrouter, + "/v1/Workspaces", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Workspace parameters + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Create(CreateWorkspaceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Workspace parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task CreateAsync(CreateWorkspaceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the Workspace resource + /// The URL we should call when an event occurs + /// The list of Workspace events for which to call event_callback_url + /// Whether multi-tasking is enabled + /// An available template name + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both + /// types of TaskQueues + /// Client to make requests to Twilio + /// A single instance of Workspace + public static WorkspaceResource Create(string friendlyName, + Uri eventCallbackUrl = null, + string eventsFilter = null, + bool? multiTaskEnabled = null, + string template = null, + WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkspaceOptions(friendlyName) { EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, MultiTaskEnabled = multiTaskEnabled, Template = template, PrioritizeQueueOrder = prioritizeQueueOrder }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the Workspace resource + /// The URL we should call when an event occurs + /// The list of Workspace events for which to call event_callback_url + /// Whether multi-tasking is enabled + /// An available template name + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both + /// types of TaskQueues + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + Uri eventCallbackUrl = null, + string eventsFilter = null, + bool? multiTaskEnabled = null, + string template = null, + WorkspaceResource.QueueOrderEnum prioritizeQueueOrder = null, + ITwilioRestClient client = null) + { + var options = new CreateWorkspaceOptions(friendlyName) { EventCallbackUrl = eventCallbackUrl, EventsFilter = eventsFilter, MultiTaskEnabled = multiTaskEnabled, Template = template, PrioritizeQueueOrder = prioritizeQueueOrder }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWorkspaceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Taskrouter, + "/v1/Workspaces/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Workspace parameters + /// Client to make requests to Twilio + /// A single instance of Workspace + public static bool Delete(DeleteWorkspaceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Workspace parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWorkspaceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// A single instance of Workspace + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWorkspaceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Workspace + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWorkspaceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a WorkspaceResource object + /// + /// Raw JSON string + /// WorkspaceResource object represented by the provided JSON + public static WorkspaceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The name of the default activity + /// + [JsonProperty("default_activity_name")] + public string DefaultActivityName { get; private set; } + /// + /// The SID of the Activity that will be used when new Workers are created in the Workspace + /// + [JsonProperty("default_activity_sid")] + public string DefaultActivitySid { get; private set; } + /// + /// The URL we call when an event occurs + /// + [JsonProperty("event_callback_url")] + public Uri EventCallbackUrl { get; private set; } + /// + /// The list of Workspace events for which to call event_callback_url + /// + [JsonProperty("events_filter")] + public string EventsFilter { get; private set; } + /// + /// The string that you assigned to describe the Workspace resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Whether multi-tasking is enabled + /// + [JsonProperty("multi_task_enabled")] + public bool? MultiTaskEnabled { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The name of the timeout activity + /// + [JsonProperty("timeout_activity_name")] + public string TimeoutActivityName { get; private set; } + /// + /// The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response + /// + [JsonProperty("timeout_activity_sid")] + public string TimeoutActivitySid { get; private set; } + /// + /// The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues + /// + [JsonProperty("prioritize_queue_order")] + [JsonConverter(typeof(StringEnumConverter))] + public WorkspaceResource.QueueOrderEnum PrioritizeQueueOrder { get; private set; } + /// + /// The absolute URL of the Workspace resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private WorkspaceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListOptions.cs b/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListOptions.cs index cf5a2aaf2..b98beecad 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListOptions.cs @@ -9,150 +9,150 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1.Trunk -{ - +{ + + /// + /// FetchCredentialListOptions + /// + public class FetchCredentialListOptions : IOptions + { /// - /// FetchCredentialListOptions + /// The SID of the Trunk from which to fetch the credential list /// - public class FetchCredentialListOptions : IOptions - { - /// - /// The SID of the Trunk from which to fetch the credential list - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCredentialListOptions - /// - /// The SID of the Trunk from which to fetch the credential list - /// The unique string that identifies the resource - public FetchCredentialListOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathTrunkSid { get; } /// - /// DeleteCredentialListOptions + /// The unique string that identifies the resource /// - public class DeleteCredentialListOptions : IOptions - { - /// - /// The SID of the Trunk from which to delete the credential list - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCredentialListOptions - /// - /// The SID of the Trunk from which to delete the credential list - /// The unique string that identifies the resource - public DeleteCredentialListOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateCredentialListOptions + /// Construct a new FetchCredentialListOptions /// - public class CreateCredentialListOptions : IOptions - { - /// - /// The SID of the Trunk to associate the credential list with - /// - public string PathTrunkSid { get; } - /// - /// The SID of the Credential List that you want to associate with the trunk - /// - public string CredentialListSid { get; } - - /// - /// Construct a new CreateCredentialListOptions - /// - /// The SID of the Trunk to associate the credential list with - /// The SID of the Credential List that you want to associate with the trunk - public CreateCredentialListOptions(string pathTrunkSid, string credentialListSid) - { - PathTrunkSid = pathTrunkSid; - CredentialListSid = credentialListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (CredentialListSid != null) - { - p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); - } - - return p; - } - } - + /// The SID of the Trunk from which to fetch the credential list + /// The unique string that identifies the resource + public FetchCredentialListOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + /// - /// ReadCredentialListOptions + /// Generate the necessary parameters /// - public class ReadCredentialListOptions : ReadOptions - { - /// - /// The SID of the Trunk from which to read the credential lists - /// - public string PathTrunkSid { get; } - - /// - /// Construct a new ReadCredentialListOptions - /// - /// The SID of the Trunk from which to read the credential lists - public ReadCredentialListOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteCredentialListOptions + /// + public class DeleteCredentialListOptions : IOptions + { + /// + /// The SID of the Trunk from which to delete the credential list + /// + public string PathTrunkSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCredentialListOptions + /// + /// The SID of the Trunk from which to delete the credential list + /// The unique string that identifies the resource + public DeleteCredentialListOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateCredentialListOptions + /// + public class CreateCredentialListOptions : IOptions + { + /// + /// The SID of the Trunk to associate the credential list with + /// + public string PathTrunkSid { get; } + /// + /// The SID of the Credential List that you want to associate with the trunk + /// + public string CredentialListSid { get; } + + /// + /// Construct a new CreateCredentialListOptions + /// + /// The SID of the Trunk to associate the credential list with + /// The SID of the Credential List that you want to associate with the trunk + public CreateCredentialListOptions(string pathTrunkSid, string credentialListSid) + { + PathTrunkSid = pathTrunkSid; + CredentialListSid = credentialListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (CredentialListSid != null) + { + p.Add(new KeyValuePair("CredentialListSid", CredentialListSid.ToString())); + } + + return p; + } + } + + /// + /// ReadCredentialListOptions + /// + public class ReadCredentialListOptions : ReadOptions + { + /// + /// The SID of the Trunk from which to read the credential lists + /// + public string PathTrunkSid { get; } + + /// + /// Construct a new ReadCredentialListOptions + /// + /// The SID of the Trunk from which to read the credential lists + public ReadCredentialListOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListResource.cs b/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListResource.cs index 1d3cdefc1..017e36341 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListResource.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/CredentialListResource.cs @@ -16,414 +16,414 @@ using Twilio.Http; namespace Twilio.Rest.Trunking.V1.Trunk -{ - - public class CredentialListResource : Resource - { - private static Request BuildFetchRequest(FetchCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Fetch(FetchCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the credential list - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCredentialListOptions(pathTrunkSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the credential list - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCredentialListOptions(pathTrunkSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static bool Delete(DeleteCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Trunk from which to delete the credential list - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCredentialListOptions(pathTrunkSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Trunk from which to delete the credential list - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteCredentialListOptions(pathTrunkSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Create(CreateCredentialListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Trunk to associate the credential list with - /// The SID of the Credential List that you want to associate with the trunk - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static CredentialListResource Create(string pathTrunkSid, - string credentialListSid, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListOptions(pathTrunkSid, credentialListSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Trunk to associate the credential list with - /// The SID of the Credential List that you want to associate with the trunk - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, - string credentialListSid, - ITwilioRestClient client = null) - { - var options = new CreateCredentialListOptions(pathTrunkSid, credentialListSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCredentialListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read CredentialList parameters - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static ResourceSet Read(ReadCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read CredentialList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("credential_lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Trunk from which to read the credential lists - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CredentialList - public static ResourceSet Read(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Trunk from which to read the credential lists - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CredentialList - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCredentialListOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("credential_lists", response.Content); - } - - /// - /// Converts a JSON string into a CredentialListResource object - /// - /// Raw JSON string - /// CredentialListResource object represented by the provided JSON - public static CredentialListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Trunk the credential list in associated with - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CredentialListResource() - { - - } - } +{ + + public class CredentialListResource : Resource + { + private static Request BuildFetchRequest(FetchCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Fetch(FetchCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task FetchAsync(FetchCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the credential list + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCredentialListOptions(pathTrunkSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the credential list + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCredentialListOptions(pathTrunkSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static bool Delete(DeleteCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Trunk from which to delete the credential list + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCredentialListOptions(pathTrunkSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Trunk from which to delete the credential list + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteCredentialListOptions(pathTrunkSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Create(CreateCredentialListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task CreateAsync(CreateCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Trunk to associate the credential list with + /// The SID of the Credential List that you want to associate with the trunk + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static CredentialListResource Create(string pathTrunkSid, + string credentialListSid, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListOptions(pathTrunkSid, credentialListSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Trunk to associate the credential list with + /// The SID of the Credential List that you want to associate with the trunk + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, + string credentialListSid, + ITwilioRestClient client = null) + { + var options = new CreateCredentialListOptions(pathTrunkSid, credentialListSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCredentialListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/CredentialLists", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read CredentialList parameters + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static ResourceSet Read(ReadCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read CredentialList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task> ReadAsync(ReadCredentialListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("credential_lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Trunk from which to read the credential lists + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CredentialList + public static ResourceSet Read(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Trunk from which to read the credential lists + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CredentialList + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCredentialListOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("credential_lists", response.Content); + } + + /// + /// Converts a JSON string into a CredentialListResource object + /// + /// Raw JSON string + /// CredentialListResource object represented by the provided JSON + public static CredentialListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Trunk the credential list in associated with + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CredentialListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListOptions.cs b/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListOptions.cs index ea61790fb..69266a3c4 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListOptions.cs @@ -9,151 +9,151 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1.Trunk -{ - +{ + + /// + /// FetchIpAccessControlListOptions + /// + public class FetchIpAccessControlListOptions : IOptions + { /// - /// FetchIpAccessControlListOptions + /// The SID of the Trunk from which to fetch the IP Access Control List /// - public class FetchIpAccessControlListOptions : IOptions - { - /// - /// The SID of the Trunk from which to fetch the IP Access Control List - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpAccessControlListOptions - /// - /// The SID of the Trunk from which to fetch the IP Access Control List - /// The unique string that identifies the resource - public FetchIpAccessControlListOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathTrunkSid { get; } /// - /// Remove an associated IP Access Control List from a Trunk + /// The unique string that identifies the resource /// - public class DeleteIpAccessControlListOptions : IOptions - { - /// - /// The SID of the Trunk from which to delete the IP Access Control List - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIpAccessControlListOptions - /// - /// The SID of the Trunk from which to delete the IP Access Control List - /// The unique string that identifies the resource - public DeleteIpAccessControlListOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Associate an IP Access Control List with a Trunk + /// Construct a new FetchIpAccessControlListOptions /// - public class CreateIpAccessControlListOptions : IOptions - { - /// - /// The SID of the Trunk to associate the IP Access Control List with - /// - public string PathTrunkSid { get; } - /// - /// The SID of the IP Access Control List that you want to associate with the trunk - /// - public string IpAccessControlListSid { get; } - - /// - /// Construct a new CreateIpAccessControlListOptions - /// - /// The SID of the Trunk to associate the IP Access Control List with - /// The SID of the IP Access Control List that you want to associate with the - /// trunk - public CreateIpAccessControlListOptions(string pathTrunkSid, string ipAccessControlListSid) - { - PathTrunkSid = pathTrunkSid; - IpAccessControlListSid = ipAccessControlListSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpAccessControlListSid != null) - { - p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); - } - - return p; - } - } - + /// The SID of the Trunk from which to fetch the IP Access Control List + /// The unique string that identifies the resource + public FetchIpAccessControlListOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + /// - /// List all IP Access Control Lists for a Trunk + /// Generate the necessary parameters /// - public class ReadIpAccessControlListOptions : ReadOptions - { - /// - /// The SID of the Trunk from which to read the IP Access Control Lists - /// - public string PathTrunkSid { get; } - - /// - /// Construct a new ReadIpAccessControlListOptions - /// - /// The SID of the Trunk from which to read the IP Access Control Lists - public ReadIpAccessControlListOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an associated IP Access Control List from a Trunk + /// + public class DeleteIpAccessControlListOptions : IOptions + { + /// + /// The SID of the Trunk from which to delete the IP Access Control List + /// + public string PathTrunkSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIpAccessControlListOptions + /// + /// The SID of the Trunk from which to delete the IP Access Control List + /// The unique string that identifies the resource + public DeleteIpAccessControlListOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Associate an IP Access Control List with a Trunk + /// + public class CreateIpAccessControlListOptions : IOptions + { + /// + /// The SID of the Trunk to associate the IP Access Control List with + /// + public string PathTrunkSid { get; } + /// + /// The SID of the IP Access Control List that you want to associate with the trunk + /// + public string IpAccessControlListSid { get; } + + /// + /// Construct a new CreateIpAccessControlListOptions + /// + /// The SID of the Trunk to associate the IP Access Control List with + /// The SID of the IP Access Control List that you want to associate with the + /// trunk + public CreateIpAccessControlListOptions(string pathTrunkSid, string ipAccessControlListSid) + { + PathTrunkSid = pathTrunkSid; + IpAccessControlListSid = ipAccessControlListSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (IpAccessControlListSid != null) + { + p.Add(new KeyValuePair("IpAccessControlListSid", IpAccessControlListSid.ToString())); + } + + return p; + } + } + + /// + /// List all IP Access Control Lists for a Trunk + /// + public class ReadIpAccessControlListOptions : ReadOptions + { + /// + /// The SID of the Trunk from which to read the IP Access Control Lists + /// + public string PathTrunkSid { get; } + + /// + /// Construct a new ReadIpAccessControlListOptions + /// + /// The SID of the Trunk from which to read the IP Access Control Lists + public ReadIpAccessControlListOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListResource.cs b/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListResource.cs index f2bc0658c..cc3142af8 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListResource.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/IpAccessControlListResource.cs @@ -16,420 +16,420 @@ using Twilio.Http; namespace Twilio.Rest.Trunking.V1.Trunk -{ - - public class IpAccessControlListResource : Resource - { - private static Request BuildFetchRequest(FetchIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Fetch(FetchIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the IP Access Control List - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListOptions(pathTrunkSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the IP Access Control List - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchIpAccessControlListOptions(pathTrunkSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an associated IP Access Control List from a Trunk - /// - /// Delete IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static bool Delete(DeleteIpAccessControlListOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an associated IP Access Control List from a Trunk - /// - /// Delete IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an associated IP Access Control List from a Trunk - /// - /// The SID of the Trunk from which to delete the IP Access Control List - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListOptions(pathTrunkSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an associated IP Access Control List from a Trunk - /// - /// The SID of the Trunk from which to delete the IP Access Control List - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteIpAccessControlListOptions(pathTrunkSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Associate an IP Access Control List with a Trunk - /// - /// Create IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Create(CreateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Associate an IP Access Control List with a Trunk - /// - /// Create IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Associate an IP Access Control List with a Trunk - /// - /// The SID of the Trunk to associate the IP Access Control List with - /// The SID of the IP Access Control List that you want to associate with the - /// trunk - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static IpAccessControlListResource Create(string pathTrunkSid, - string ipAccessControlListSid, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListOptions(pathTrunkSid, ipAccessControlListSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Associate an IP Access Control List with a Trunk - /// - /// The SID of the Trunk to associate the IP Access Control List with - /// The SID of the IP Access Control List that you want to associate with the - /// trunk - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, - string ipAccessControlListSid, - ITwilioRestClient client = null) - { - var options = new CreateIpAccessControlListOptions(pathTrunkSid, ipAccessControlListSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadIpAccessControlListOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List all IP Access Control Lists for a Trunk - /// - /// Read IpAccessControlList parameters - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static ResourceSet Read(ReadIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_lists", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List all IP Access Control Lists for a Trunk - /// - /// Read IpAccessControlList parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_access_control_lists", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List all IP Access Control Lists for a Trunk - /// - /// The SID of the Trunk from which to read the IP Access Control Lists - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpAccessControlList - public static ResourceSet Read(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List all IP Access Control Lists for a Trunk - /// - /// The SID of the Trunk from which to read the IP Access Control Lists - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpAccessControlList - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpAccessControlListOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("ip_access_control_lists", response.Content); - } - - /// - /// Converts a JSON string into a IpAccessControlListResource object - /// - /// Raw JSON string - /// IpAccessControlListResource object represented by the provided JSON - public static IpAccessControlListResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Trunk the resource is associated with - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private IpAccessControlListResource() - { - - } - } +{ + + public class IpAccessControlListResource : Resource + { + private static Request BuildFetchRequest(FetchIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Fetch(FetchIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task FetchAsync(FetchIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the IP Access Control List + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListOptions(pathTrunkSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the IP Access Control List + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchIpAccessControlListOptions(pathTrunkSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an associated IP Access Control List from a Trunk + /// + /// Delete IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static bool Delete(DeleteIpAccessControlListOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an associated IP Access Control List from a Trunk + /// + /// Delete IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an associated IP Access Control List from a Trunk + /// + /// The SID of the Trunk from which to delete the IP Access Control List + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListOptions(pathTrunkSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an associated IP Access Control List from a Trunk + /// + /// The SID of the Trunk from which to delete the IP Access Control List + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteIpAccessControlListOptions(pathTrunkSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Associate an IP Access Control List with a Trunk + /// + /// Create IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Create(CreateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Associate an IP Access Control List with a Trunk + /// + /// Create IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task CreateAsync(CreateIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Associate an IP Access Control List with a Trunk + /// + /// The SID of the Trunk to associate the IP Access Control List with + /// The SID of the IP Access Control List that you want to associate with the + /// trunk + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static IpAccessControlListResource Create(string pathTrunkSid, + string ipAccessControlListSid, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListOptions(pathTrunkSid, ipAccessControlListSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Associate an IP Access Control List with a Trunk + /// + /// The SID of the Trunk to associate the IP Access Control List with + /// The SID of the IP Access Control List that you want to associate with the + /// trunk + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, + string ipAccessControlListSid, + ITwilioRestClient client = null) + { + var options = new CreateIpAccessControlListOptions(pathTrunkSid, ipAccessControlListSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadIpAccessControlListOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/IpAccessControlLists", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List all IP Access Control Lists for a Trunk + /// + /// Read IpAccessControlList parameters + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static ResourceSet Read(ReadIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_lists", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List all IP Access Control Lists for a Trunk + /// + /// Read IpAccessControlList parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpAccessControlListOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_access_control_lists", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List all IP Access Control Lists for a Trunk + /// + /// The SID of the Trunk from which to read the IP Access Control Lists + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpAccessControlList + public static ResourceSet Read(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List all IP Access Control Lists for a Trunk + /// + /// The SID of the Trunk from which to read the IP Access Control Lists + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpAccessControlList + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpAccessControlListOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("ip_access_control_lists", response.Content); + } + + /// + /// Converts a JSON string into a IpAccessControlListResource object + /// + /// Raw JSON string + /// IpAccessControlListResource object represented by the provided JSON + public static IpAccessControlListResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Trunk the resource is associated with + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private IpAccessControlListResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlOptions.cs b/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlOptions.cs index dfa3489ee..931427245 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlOptions.cs @@ -9,280 +9,280 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1.Trunk -{ - +{ + + /// + /// FetchOriginationUrlOptions + /// + public class FetchOriginationUrlOptions : IOptions + { /// - /// FetchOriginationUrlOptions + /// The SID of the Trunk from which to fetch the OriginationUrl /// - public class FetchOriginationUrlOptions : IOptions - { - /// - /// The SID of the Trunk from which to fetch the OriginationUrl - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchOriginationUrlOptions - /// - /// The SID of the Trunk from which to fetch the OriginationUrl - /// The unique string that identifies the resource - public FetchOriginationUrlOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathTrunkSid { get; } /// - /// DeleteOriginationUrlOptions + /// The unique string that identifies the resource /// - public class DeleteOriginationUrlOptions : IOptions - { - /// - /// The SID of the Trunk from which to delete the OriginationUrl - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteOriginationUrlOptions - /// - /// The SID of the Trunk from which to delete the OriginationUrl - /// The unique string that identifies the resource - public DeleteOriginationUrlOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateOriginationUrlOptions + /// Construct a new FetchOriginationUrlOptions /// - public class CreateOriginationUrlOptions : IOptions - { - /// - /// The SID of the Trunk to associate the resource with - /// - public string PathTrunkSid { get; } - /// - /// The value that determines the relative load the URI should receive compared to others with the same priority - /// - public int? Weight { get; } - /// - /// The relative importance of the URI - /// - public int? Priority { get; } - /// - /// Whether the URL is enabled - /// - public bool? Enabled { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// The SIP address you want Twilio to route your Origination calls to - /// - public Uri SipUrl { get; } - - /// - /// Construct a new CreateOriginationUrlOptions - /// - /// The SID of the Trunk to associate the resource with - /// The value that determines the relative load the URI should receive compared to others with - /// the same priority - /// The relative importance of the URI - /// Whether the URL is enabled - /// A string to describe the resource - /// The SIP address you want Twilio to route your Origination calls to - public CreateOriginationUrlOptions(string pathTrunkSid, - int? weight, - int? priority, - bool? enabled, - string friendlyName, - Uri sipUrl) - { - PathTrunkSid = pathTrunkSid; - Weight = weight; - Priority = priority; - Enabled = enabled; - FriendlyName = friendlyName; - SipUrl = sipUrl; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Weight != null) - { - p.Add(new KeyValuePair("Weight", Weight.ToString())); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SipUrl != null) - { - p.Add(new KeyValuePair("SipUrl", Serializers.Url(SipUrl))); - } - - return p; - } - } - + /// The SID of the Trunk from which to fetch the OriginationUrl + /// The unique string that identifies the resource + public FetchOriginationUrlOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + /// - /// ReadOriginationUrlOptions + /// Generate the necessary parameters /// - public class ReadOriginationUrlOptions : ReadOptions - { - /// - /// The SID of the Trunk from which to read the OriginationUrl - /// - public string PathTrunkSid { get; } - - /// - /// Construct a new ReadOriginationUrlOptions - /// - /// The SID of the Trunk from which to read the OriginationUrl - public ReadOriginationUrlOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteOriginationUrlOptions + /// + public class DeleteOriginationUrlOptions : IOptions + { /// - /// UpdateOriginationUrlOptions + /// The SID of the Trunk from which to delete the OriginationUrl /// - public class UpdateOriginationUrlOptions : IOptions - { - /// - /// The SID of the Trunk from which to update the OriginationUrl - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The value that determines the relative load the URI should receive compared to others with the same priority - /// - public int? Weight { get; set; } - /// - /// The relative importance of the URI - /// - public int? Priority { get; set; } - /// - /// Whether the URL is enabled - /// - public bool? Enabled { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The SIP address you want Twilio to route your Origination calls to - /// - public Uri SipUrl { get; set; } - - /// - /// Construct a new UpdateOriginationUrlOptions - /// - /// The SID of the Trunk from which to update the OriginationUrl - /// The unique string that identifies the resource - public UpdateOriginationUrlOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Weight != null) - { - p.Add(new KeyValuePair("Weight", Weight.ToString())); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (SipUrl != null) - { - p.Add(new KeyValuePair("SipUrl", Serializers.Url(SipUrl))); - } - - return p; - } - } + public string PathTrunkSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteOriginationUrlOptions + /// + /// The SID of the Trunk from which to delete the OriginationUrl + /// The unique string that identifies the resource + public DeleteOriginationUrlOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateOriginationUrlOptions + /// + public class CreateOriginationUrlOptions : IOptions + { + /// + /// The SID of the Trunk to associate the resource with + /// + public string PathTrunkSid { get; } + /// + /// The value that determines the relative load the URI should receive compared to others with the same priority + /// + public int? Weight { get; } + /// + /// The relative importance of the URI + /// + public int? Priority { get; } + /// + /// Whether the URL is enabled + /// + public bool? Enabled { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; } + /// + /// The SIP address you want Twilio to route your Origination calls to + /// + public Uri SipUrl { get; } + + /// + /// Construct a new CreateOriginationUrlOptions + /// + /// The SID of the Trunk to associate the resource with + /// The value that determines the relative load the URI should receive compared to others with + /// the same priority + /// The relative importance of the URI + /// Whether the URL is enabled + /// A string to describe the resource + /// The SIP address you want Twilio to route your Origination calls to + public CreateOriginationUrlOptions(string pathTrunkSid, + int? weight, + int? priority, + bool? enabled, + string friendlyName, + Uri sipUrl) + { + PathTrunkSid = pathTrunkSid; + Weight = weight; + Priority = priority; + Enabled = enabled; + FriendlyName = friendlyName; + SipUrl = sipUrl; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Weight != null) + { + p.Add(new KeyValuePair("Weight", Weight.ToString())); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SipUrl != null) + { + p.Add(new KeyValuePair("SipUrl", Serializers.Url(SipUrl))); + } + + return p; + } + } + + /// + /// ReadOriginationUrlOptions + /// + public class ReadOriginationUrlOptions : ReadOptions + { + /// + /// The SID of the Trunk from which to read the OriginationUrl + /// + public string PathTrunkSid { get; } + + /// + /// Construct a new ReadOriginationUrlOptions + /// + /// The SID of the Trunk from which to read the OriginationUrl + public ReadOriginationUrlOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateOriginationUrlOptions + /// + public class UpdateOriginationUrlOptions : IOptions + { + /// + /// The SID of the Trunk from which to update the OriginationUrl + /// + public string PathTrunkSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The value that determines the relative load the URI should receive compared to others with the same priority + /// + public int? Weight { get; set; } + /// + /// The relative importance of the URI + /// + public int? Priority { get; set; } + /// + /// Whether the URL is enabled + /// + public bool? Enabled { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The SIP address you want Twilio to route your Origination calls to + /// + public Uri SipUrl { get; set; } + + /// + /// Construct a new UpdateOriginationUrlOptions + /// + /// The SID of the Trunk from which to update the OriginationUrl + /// The unique string that identifies the resource + public UpdateOriginationUrlOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Weight != null) + { + p.Add(new KeyValuePair("Weight", Weight.ToString())); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (SipUrl != null) + { + p.Add(new KeyValuePair("SipUrl", Serializers.Url(SipUrl))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlResource.cs b/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlResource.cs index e818d1250..97d5e2745 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlResource.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/OriginationUrlResource.cs @@ -16,546 +16,546 @@ using Twilio.Http; namespace Twilio.Rest.Trunking.V1.Trunk -{ - - public class OriginationUrlResource : Resource - { - private static Request BuildFetchRequest(FetchOriginationUrlOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch OriginationUrl parameters - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Fetch(FetchOriginationUrlOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch OriginationUrl parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task FetchAsync(FetchOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the OriginationUrl - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchOriginationUrlOptions(pathTrunkSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the OriginationUrl - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchOriginationUrlOptions(pathTrunkSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteOriginationUrlOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete OriginationUrl parameters - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static bool Delete(DeleteOriginationUrlOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete OriginationUrl parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task DeleteAsync(DeleteOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Trunk from which to delete the OriginationUrl - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteOriginationUrlOptions(pathTrunkSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Trunk from which to delete the OriginationUrl - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteOriginationUrlOptions(pathTrunkSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateOriginationUrlOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create OriginationUrl parameters - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Create(CreateOriginationUrlOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create OriginationUrl parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task CreateAsync(CreateOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Trunk to associate the resource with - /// The value that determines the relative load the URI should receive compared to others with - /// the same priority - /// The relative importance of the URI - /// Whether the URL is enabled - /// A string to describe the resource - /// The SIP address you want Twilio to route your Origination calls to - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Create(string pathTrunkSid, - int? weight, - int? priority, - bool? enabled, - string friendlyName, - Uri sipUrl, - ITwilioRestClient client = null) - { - var options = new CreateOriginationUrlOptions(pathTrunkSid, weight, priority, enabled, friendlyName, sipUrl); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Trunk to associate the resource with - /// The value that determines the relative load the URI should receive compared to others with - /// the same priority - /// The relative importance of the URI - /// Whether the URL is enabled - /// A string to describe the resource - /// The SIP address you want Twilio to route your Origination calls to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, - int? weight, - int? priority, - bool? enabled, - string friendlyName, - Uri sipUrl, - ITwilioRestClient client = null) - { - var options = new CreateOriginationUrlOptions(pathTrunkSid, weight, priority, enabled, friendlyName, sipUrl); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadOriginationUrlOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read OriginationUrl parameters - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static ResourceSet Read(ReadOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("origination_urls", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read OriginationUrl parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task> ReadAsync(ReadOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("origination_urls", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Trunk from which to read the OriginationUrl - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static ResourceSet Read(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadOriginationUrlOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Trunk from which to read the OriginationUrl - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadOriginationUrlOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("origination_urls", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("origination_urls", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("origination_urls", response.Content); - } - - private static Request BuildUpdateRequest(UpdateOriginationUrlOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update OriginationUrl parameters - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Update(UpdateOriginationUrlOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update OriginationUrl parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task UpdateAsync(UpdateOriginationUrlOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Trunk from which to update the OriginationUrl - /// The unique string that identifies the resource - /// The value that determines the relative load the URI should receive compared to others with - /// the same priority - /// The relative importance of the URI - /// Whether the URL is enabled - /// A string to describe the resource - /// The SIP address you want Twilio to route your Origination calls to - /// Client to make requests to Twilio - /// A single instance of OriginationUrl - public static OriginationUrlResource Update(string pathTrunkSid, - string pathSid, - int? weight = null, - int? priority = null, - bool? enabled = null, - string friendlyName = null, - Uri sipUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateOriginationUrlOptions(pathTrunkSid, pathSid){Weight = weight, Priority = priority, Enabled = enabled, FriendlyName = friendlyName, SipUrl = sipUrl}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Trunk from which to update the OriginationUrl - /// The unique string that identifies the resource - /// The value that determines the relative load the URI should receive compared to others with - /// the same priority - /// The relative importance of the URI - /// Whether the URL is enabled - /// A string to describe the resource - /// The SIP address you want Twilio to route your Origination calls to - /// Client to make requests to Twilio - /// Task that resolves to A single instance of OriginationUrl - public static async System.Threading.Tasks.Task UpdateAsync(string pathTrunkSid, - string pathSid, - int? weight = null, - int? priority = null, - bool? enabled = null, - string friendlyName = null, - Uri sipUrl = null, - ITwilioRestClient client = null) - { - var options = new UpdateOriginationUrlOptions(pathTrunkSid, pathSid){Weight = weight, Priority = priority, Enabled = enabled, FriendlyName = friendlyName, SipUrl = sipUrl}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a OriginationUrlResource object - /// - /// Raw JSON string - /// OriginationUrlResource object represented by the provided JSON - public static OriginationUrlResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Trunk that owns the Origination URL - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The value that determines the relative load the URI should receive compared to others with the same priority - /// - [JsonProperty("weight")] - public int? Weight { get; private set; } - /// - /// Whether the URL is enabled - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The SIP address you want Twilio to route your Origination calls to - /// - [JsonProperty("sip_url")] - public Uri SipUrl { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The relative importance of the URI - /// - [JsonProperty("priority")] - public int? Priority { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private OriginationUrlResource() - { - - } - } +{ + + public class OriginationUrlResource : Resource + { + private static Request BuildFetchRequest(FetchOriginationUrlOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch OriginationUrl parameters + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Fetch(FetchOriginationUrlOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch OriginationUrl parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task FetchAsync(FetchOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the OriginationUrl + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchOriginationUrlOptions(pathTrunkSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the OriginationUrl + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchOriginationUrlOptions(pathTrunkSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteOriginationUrlOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete OriginationUrl parameters + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static bool Delete(DeleteOriginationUrlOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete OriginationUrl parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task DeleteAsync(DeleteOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Trunk from which to delete the OriginationUrl + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteOriginationUrlOptions(pathTrunkSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Trunk from which to delete the OriginationUrl + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteOriginationUrlOptions(pathTrunkSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateOriginationUrlOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create OriginationUrl parameters + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Create(CreateOriginationUrlOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create OriginationUrl parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task CreateAsync(CreateOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Trunk to associate the resource with + /// The value that determines the relative load the URI should receive compared to others with + /// the same priority + /// The relative importance of the URI + /// Whether the URL is enabled + /// A string to describe the resource + /// The SIP address you want Twilio to route your Origination calls to + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Create(string pathTrunkSid, + int? weight, + int? priority, + bool? enabled, + string friendlyName, + Uri sipUrl, + ITwilioRestClient client = null) + { + var options = new CreateOriginationUrlOptions(pathTrunkSid, weight, priority, enabled, friendlyName, sipUrl); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Trunk to associate the resource with + /// The value that determines the relative load the URI should receive compared to others with + /// the same priority + /// The relative importance of the URI + /// Whether the URL is enabled + /// A string to describe the resource + /// The SIP address you want Twilio to route your Origination calls to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, + int? weight, + int? priority, + bool? enabled, + string friendlyName, + Uri sipUrl, + ITwilioRestClient client = null) + { + var options = new CreateOriginationUrlOptions(pathTrunkSid, weight, priority, enabled, friendlyName, sipUrl); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadOriginationUrlOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read OriginationUrl parameters + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static ResourceSet Read(ReadOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("origination_urls", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read OriginationUrl parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task> ReadAsync(ReadOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("origination_urls", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Trunk from which to read the OriginationUrl + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static ResourceSet Read(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadOriginationUrlOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Trunk from which to read the OriginationUrl + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadOriginationUrlOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("origination_urls", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("origination_urls", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("origination_urls", response.Content); + } + + private static Request BuildUpdateRequest(UpdateOriginationUrlOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/OriginationUrls/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update OriginationUrl parameters + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Update(UpdateOriginationUrlOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update OriginationUrl parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task UpdateAsync(UpdateOriginationUrlOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Trunk from which to update the OriginationUrl + /// The unique string that identifies the resource + /// The value that determines the relative load the URI should receive compared to others with + /// the same priority + /// The relative importance of the URI + /// Whether the URL is enabled + /// A string to describe the resource + /// The SIP address you want Twilio to route your Origination calls to + /// Client to make requests to Twilio + /// A single instance of OriginationUrl + public static OriginationUrlResource Update(string pathTrunkSid, + string pathSid, + int? weight = null, + int? priority = null, + bool? enabled = null, + string friendlyName = null, + Uri sipUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateOriginationUrlOptions(pathTrunkSid, pathSid) { Weight = weight, Priority = priority, Enabled = enabled, FriendlyName = friendlyName, SipUrl = sipUrl }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Trunk from which to update the OriginationUrl + /// The unique string that identifies the resource + /// The value that determines the relative load the URI should receive compared to others with + /// the same priority + /// The relative importance of the URI + /// Whether the URL is enabled + /// A string to describe the resource + /// The SIP address you want Twilio to route your Origination calls to + /// Client to make requests to Twilio + /// Task that resolves to A single instance of OriginationUrl + public static async System.Threading.Tasks.Task UpdateAsync(string pathTrunkSid, + string pathSid, + int? weight = null, + int? priority = null, + bool? enabled = null, + string friendlyName = null, + Uri sipUrl = null, + ITwilioRestClient client = null) + { + var options = new UpdateOriginationUrlOptions(pathTrunkSid, pathSid) { Weight = weight, Priority = priority, Enabled = enabled, FriendlyName = friendlyName, SipUrl = sipUrl }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a OriginationUrlResource object + /// + /// Raw JSON string + /// OriginationUrlResource object represented by the provided JSON + public static OriginationUrlResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Trunk that owns the Origination URL + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The value that determines the relative load the URI should receive compared to others with the same priority + /// + [JsonProperty("weight")] + public int? Weight { get; private set; } + /// + /// Whether the URL is enabled + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The SIP address you want Twilio to route your Origination calls to + /// + [JsonProperty("sip_url")] + public Uri SipUrl { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The relative importance of the URI + /// + [JsonProperty("priority")] + public int? Priority { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private OriginationUrlResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberOptions.cs b/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberOptions.cs index 77ef7d956..5aef5ab80 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberOptions.cs @@ -9,151 +9,151 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1.Trunk -{ - +{ + + /// + /// FetchPhoneNumberOptions + /// + public class FetchPhoneNumberOptions : IOptions + { /// - /// FetchPhoneNumberOptions + /// The SID of the Trunk from which to fetch the PhoneNumber resource /// - public class FetchPhoneNumberOptions : IOptions - { - /// - /// The SID of the Trunk from which to fetch the PhoneNumber resource - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPhoneNumberOptions - /// - /// The SID of the Trunk from which to fetch the PhoneNumber resource - /// The unique string that identifies the resource - public FetchPhoneNumberOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathTrunkSid { get; } /// - /// DeletePhoneNumberOptions + /// The unique string that identifies the resource /// - public class DeletePhoneNumberOptions : IOptions - { - /// - /// The SID of the Trunk from which to delete the PhoneNumber resource - /// - public string PathTrunkSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeletePhoneNumberOptions - /// - /// The SID of the Trunk from which to delete the PhoneNumber resource - /// The unique string that identifies the resource - public DeletePhoneNumberOptions(string pathTrunkSid, string pathSid) - { - PathTrunkSid = pathTrunkSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreatePhoneNumberOptions + /// Construct a new FetchPhoneNumberOptions /// - public class CreatePhoneNumberOptions : IOptions - { - /// - /// The SID of the Trunk to associate the phone number with - /// - public string PathTrunkSid { get; } - /// - /// The SID of the Incoming Phone Number that you want to associate with the trunk - /// - public string PhoneNumberSid { get; } - - /// - /// Construct a new CreatePhoneNumberOptions - /// - /// The SID of the Trunk to associate the phone number with - /// The SID of the Incoming Phone Number that you want to associate with the trunk - /// - public CreatePhoneNumberOptions(string pathTrunkSid, string phoneNumberSid) - { - PathTrunkSid = pathTrunkSid; - PhoneNumberSid = phoneNumberSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PhoneNumberSid != null) - { - p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); - } - - return p; - } - } - + /// The SID of the Trunk from which to fetch the PhoneNumber resource + /// The unique string that identifies the resource + public FetchPhoneNumberOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + /// - /// ReadPhoneNumberOptions + /// Generate the necessary parameters /// - public class ReadPhoneNumberOptions : ReadOptions - { - /// - /// The SID of the Trunk from which to read the PhoneNumber resources - /// - public string PathTrunkSid { get; } - - /// - /// Construct a new ReadPhoneNumberOptions - /// - /// The SID of the Trunk from which to read the PhoneNumber resources - public ReadPhoneNumberOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeletePhoneNumberOptions + /// + public class DeletePhoneNumberOptions : IOptions + { + /// + /// The SID of the Trunk from which to delete the PhoneNumber resource + /// + public string PathTrunkSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeletePhoneNumberOptions + /// + /// The SID of the Trunk from which to delete the PhoneNumber resource + /// The unique string that identifies the resource + public DeletePhoneNumberOptions(string pathTrunkSid, string pathSid) + { + PathTrunkSid = pathTrunkSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreatePhoneNumberOptions + /// + public class CreatePhoneNumberOptions : IOptions + { + /// + /// The SID of the Trunk to associate the phone number with + /// + public string PathTrunkSid { get; } + /// + /// The SID of the Incoming Phone Number that you want to associate with the trunk + /// + public string PhoneNumberSid { get; } + + /// + /// Construct a new CreatePhoneNumberOptions + /// + /// The SID of the Trunk to associate the phone number with + /// The SID of the Incoming Phone Number that you want to associate with the trunk + /// + public CreatePhoneNumberOptions(string pathTrunkSid, string phoneNumberSid) + { + PathTrunkSid = pathTrunkSid; + PhoneNumberSid = phoneNumberSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PhoneNumberSid != null) + { + p.Add(new KeyValuePair("PhoneNumberSid", PhoneNumberSid.ToString())); + } + + return p; + } + } + + /// + /// ReadPhoneNumberOptions + /// + public class ReadPhoneNumberOptions : ReadOptions + { + /// + /// The SID of the Trunk from which to read the PhoneNumber resources + /// + public string PathTrunkSid { get; } + + /// + /// Construct a new ReadPhoneNumberOptions + /// + /// The SID of the Trunk from which to read the PhoneNumber resources + public ReadPhoneNumberOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberResource.cs b/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberResource.cs index 4e61e05d8..456f9bf4a 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberResource.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/PhoneNumberResource.cs @@ -17,530 +17,530 @@ using Twilio.Types; namespace Twilio.Rest.Trunking.V1.Trunk -{ - - public class PhoneNumberResource : Resource - { - public sealed class AddressRequirementEnum : StringEnum - { - private AddressRequirementEnum(string value) : base(value) {} - public AddressRequirementEnum() {} - public static implicit operator AddressRequirementEnum(string value) - { - return new AddressRequirementEnum(value); - } - - public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); - public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); - public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); - public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); - } - - private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the PhoneNumber resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathTrunkSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the PhoneNumber resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPhoneNumberOptions(pathTrunkSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Trunk from which to delete the PhoneNumber resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathTrunkSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Trunk from which to delete the PhoneNumber resource - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeletePhoneNumberOptions(pathTrunkSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Trunk to associate the phone number with - /// The SID of the Incoming Phone Number that you want to associate with the trunk - /// - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static PhoneNumberResource Create(string pathTrunkSid, string phoneNumberSid, ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathTrunkSid, phoneNumberSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Trunk to associate the phone number with - /// The SID of the Incoming Phone Number that you want to associate with the trunk - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, - string phoneNumberSid, - ITwilioRestClient client = null) - { - var options = new CreatePhoneNumberOptions(pathTrunkSid, phoneNumberSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read PhoneNumber parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("phone_numbers", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Trunk from which to read the PhoneNumber resources - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PhoneNumber - public static ResourceSet Read(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Trunk from which to read the PhoneNumber resources - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PhoneNumber - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPhoneNumberOptions(pathTrunkSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("phone_numbers", response.Content); - } - - /// - /// Converts a JSON string into a PhoneNumberResource object - /// - /// Raw JSON string - /// PhoneNumberResource object represented by the provided JSON - public static PhoneNumberResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Whether the phone number requires an Address registered with Twilio - /// - [JsonProperty("address_requirements")] - [JsonConverter(typeof(StringEnumConverter))] - public PhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } - /// - /// The API version used to start a new TwiML session - /// - [JsonProperty("api_version")] - public string ApiVersion { get; private set; } - /// - /// Whether the phone number is new to the Twilio platform - /// - [JsonProperty("beta")] - public bool? Beta { get; private set; } - /// - /// Indicate if a phone can receive calls or messages - /// - [JsonProperty("capabilities")] - public Dictionary Capabilities { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// The phone number in E.164 format - /// - [JsonProperty("phone_number")] - [JsonConverter(typeof(PhoneNumberConverter))] - public Types.PhoneNumber PhoneNumber { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the application that handles SMS messages sent to the phone number - /// - [JsonProperty("sms_application_sid")] - public string SmsApplicationSid { get; private set; } - /// - /// The HTTP method used with sms_fallback_url - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// The URL that we call when an error occurs while retrieving or executing the TwiML - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// The HTTP method to use with sms_url - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// The URL we call when the phone number receives an incoming SMS message - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The SID of the Trunk that handles calls to the phone number - /// - [JsonProperty("trunk_sid")] - public string TrunkSid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The SID of the application that handles calls to the phone number - /// - [JsonProperty("voice_application_sid")] - public string VoiceApplicationSid { get; private set; } - /// - /// Whether to lookup the caller's name - /// - [JsonProperty("voice_caller_id_lookup")] - public bool? VoiceCallerIdLookup { get; private set; } - /// - /// The HTTP method that we use to call voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL we call when an error occurs in TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with the voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when the phone number receives a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - - private PhoneNumberResource() - { - - } - } +{ + + public class PhoneNumberResource : Resource + { + public sealed class AddressRequirementEnum : StringEnum + { + private AddressRequirementEnum(string value) : base(value) { } + public AddressRequirementEnum() { } + public static implicit operator AddressRequirementEnum(string value) + { + return new AddressRequirementEnum(value); + } + + public static readonly AddressRequirementEnum None = new AddressRequirementEnum("none"); + public static readonly AddressRequirementEnum Any = new AddressRequirementEnum("any"); + public static readonly AddressRequirementEnum Local = new AddressRequirementEnum("local"); + public static readonly AddressRequirementEnum Foreign = new AddressRequirementEnum("foreign"); + } + + private static Request BuildFetchRequest(FetchPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(FetchPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(FetchPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the PhoneNumber resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Fetch(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathTrunkSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the PhoneNumber resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPhoneNumberOptions(pathTrunkSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeletePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(DeletePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(DeletePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Trunk from which to delete the PhoneNumber resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static bool Delete(string pathTrunkSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathTrunkSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Trunk from which to delete the PhoneNumber resource + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrunkSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeletePhoneNumberOptions(pathTrunkSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreatePhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(CreatePhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(CreatePhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Trunk to associate the phone number with + /// The SID of the Incoming Phone Number that you want to associate with the trunk + /// + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static PhoneNumberResource Create(string pathTrunkSid, string phoneNumberSid, ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathTrunkSid, phoneNumberSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Trunk to associate the phone number with + /// The SID of the Incoming Phone Number that you want to associate with the trunk + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task CreateAsync(string pathTrunkSid, + string phoneNumberSid, + ITwilioRestClient client = null) + { + var options = new CreatePhoneNumberOptions(pathTrunkSid, phoneNumberSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPhoneNumberOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/PhoneNumbers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(ReadPhoneNumberOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read PhoneNumber parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(ReadPhoneNumberOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("phone_numbers", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Trunk from which to read the PhoneNumber resources + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PhoneNumber + public static ResourceSet Read(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Trunk from which to read the PhoneNumber resources + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PhoneNumber + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrunkSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPhoneNumberOptions(pathTrunkSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("phone_numbers", response.Content); + } + + /// + /// Converts a JSON string into a PhoneNumberResource object + /// + /// Raw JSON string + /// PhoneNumberResource object represented by the provided JSON + public static PhoneNumberResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Whether the phone number requires an Address registered with Twilio + /// + [JsonProperty("address_requirements")] + [JsonConverter(typeof(StringEnumConverter))] + public PhoneNumberResource.AddressRequirementEnum AddressRequirements { get; private set; } + /// + /// The API version used to start a new TwiML session + /// + [JsonProperty("api_version")] + public string ApiVersion { get; private set; } + /// + /// Whether the phone number is new to the Twilio platform + /// + [JsonProperty("beta")] + public bool? Beta { get; private set; } + /// + /// Indicate if a phone can receive calls or messages + /// + [JsonProperty("capabilities")] + public Dictionary Capabilities { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// The phone number in E.164 format + /// + [JsonProperty("phone_number")] + [JsonConverter(typeof(PhoneNumberConverter))] + public Types.PhoneNumber PhoneNumber { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the application that handles SMS messages sent to the phone number + /// + [JsonProperty("sms_application_sid")] + public string SmsApplicationSid { get; private set; } + /// + /// The HTTP method used with sms_fallback_url + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// The URL that we call when an error occurs while retrieving or executing the TwiML + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// The HTTP method to use with sms_url + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// The URL we call when the phone number receives an incoming SMS message + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The SID of the Trunk that handles calls to the phone number + /// + [JsonProperty("trunk_sid")] + public string TrunkSid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The SID of the application that handles calls to the phone number + /// + [JsonProperty("voice_application_sid")] + public string VoiceApplicationSid { get; private set; } + /// + /// Whether to lookup the caller's name + /// + [JsonProperty("voice_caller_id_lookup")] + public bool? VoiceCallerIdLookup { get; private set; } + /// + /// The HTTP method that we use to call voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL we call when an error occurs in TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with the voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when the phone number receives a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + + private PhoneNumberResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/RecordingOptions.cs b/src/Twilio/Rest/Trunking/V1/Trunk/RecordingOptions.cs index 1b6933ad4..cd34f250f 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/RecordingOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/RecordingOptions.cs @@ -9,82 +9,82 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1.Trunk -{ - +{ + + /// + /// FetchRecordingOptions + /// + public class FetchRecordingOptions : IOptions + { /// - /// FetchRecordingOptions + /// The SID of the Trunk from which to fetch the recording settings. /// - public class FetchRecordingOptions : IOptions - { - /// - /// The SID of the Trunk from which to fetch the recording settings. - /// - public string PathTrunkSid { get; } - - /// - /// Construct a new FetchRecordingOptions - /// - /// The SID of the Trunk from which to fetch the recording settings. - public FetchRecordingOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathTrunkSid { get; } + /// - /// UpdateRecordingOptions + /// Construct a new FetchRecordingOptions /// - public class UpdateRecordingOptions : IOptions - { - /// - /// The SID of the Trunk. - /// - public string PathTrunkSid { get; } - /// - /// The recording mode for the trunk. - /// - public RecordingResource.RecordingModeEnum Mode { get; set; } - /// - /// The recording trim setting for the trunk. - /// - public RecordingResource.RecordingTrimEnum Trim { get; set; } - - /// - /// Construct a new UpdateRecordingOptions - /// - /// The SID of the Trunk. - public UpdateRecordingOptions(string pathTrunkSid) - { - PathTrunkSid = pathTrunkSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Mode != null) - { - p.Add(new KeyValuePair("Mode", Mode.ToString())); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim.ToString())); - } - - return p; - } - } + /// The SID of the Trunk from which to fetch the recording settings. + public FetchRecordingOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// UpdateRecordingOptions + /// + public class UpdateRecordingOptions : IOptions + { + /// + /// The SID of the Trunk. + /// + public string PathTrunkSid { get; } + /// + /// The recording mode for the trunk. + /// + public RecordingResource.RecordingModeEnum Mode { get; set; } + /// + /// The recording trim setting for the trunk. + /// + public RecordingResource.RecordingTrimEnum Trim { get; set; } + + /// + /// Construct a new UpdateRecordingOptions + /// + /// The SID of the Trunk. + public UpdateRecordingOptions(string pathTrunkSid) + { + PathTrunkSid = pathTrunkSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Mode != null) + { + p.Add(new KeyValuePair("Mode", Mode.ToString())); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/Trunk/RecordingResource.cs b/src/Twilio/Rest/Trunking/V1/Trunk/RecordingResource.cs index 477071245..33f45edf5 100644 --- a/src/Twilio/Rest/Trunking/V1/Trunk/RecordingResource.cs +++ b/src/Twilio/Rest/Trunking/V1/Trunk/RecordingResource.cs @@ -17,217 +17,217 @@ using Twilio.Types; namespace Twilio.Rest.Trunking.V1.Trunk -{ - - public class RecordingResource : Resource - { - public sealed class RecordingModeEnum : StringEnum - { - private RecordingModeEnum(string value) : base(value) {} - public RecordingModeEnum() {} - public static implicit operator RecordingModeEnum(string value) - { - return new RecordingModeEnum(value); - } - - public static readonly RecordingModeEnum DoNotRecord = new RecordingModeEnum("do-not-record"); - public static readonly RecordingModeEnum RecordFromRinging = new RecordingModeEnum("record-from-ringing"); - public static readonly RecordingModeEnum RecordFromAnswer = new RecordingModeEnum("record-from-answer"); - public static readonly RecordingModeEnum RecordFromRingingDual = new RecordingModeEnum("record-from-ringing-dual"); - public static readonly RecordingModeEnum RecordFromAnswerDual = new RecordingModeEnum("record-from-answer-dual"); - } - - public sealed class RecordingTrimEnum : StringEnum - { - private RecordingTrimEnum(string value) : base(value) {} - public RecordingTrimEnum() {} - public static implicit operator RecordingTrimEnum(string value) - { - return new RecordingTrimEnum(value); - } - - public static readonly RecordingTrimEnum TrimSilence = new RecordingTrimEnum("trim-silence"); - public static readonly RecordingTrimEnum DoNotTrim = new RecordingTrimEnum("do-not-trim"); - } - - private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/Recording", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the recording settings. - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(string pathTrunkSid, ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathTrunkSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Trunk from which to fetch the recording settings. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathTrunkSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathTrunkSid + "/Recording", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Trunk. - /// The recording mode for the trunk. - /// The recording trim setting for the trunk. - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Update(string pathTrunkSid, - RecordingResource.RecordingModeEnum mode = null, - RecordingResource.RecordingTrimEnum trim = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathTrunkSid){Mode = mode, Trim = trim}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Trunk. - /// The recording mode for the trunk. - /// The recording trim setting for the trunk. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task UpdateAsync(string pathTrunkSid, - RecordingResource.RecordingModeEnum mode = null, - RecordingResource.RecordingTrimEnum trim = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingOptions(pathTrunkSid){Mode = mode, Trim = trim}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RecordingResource object - /// - /// Raw JSON string - /// RecordingResource object represented by the provided JSON - public static RecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The recording mode for the trunk. - /// - [JsonProperty("mode")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.RecordingModeEnum Mode { get; private set; } - /// - /// The recording trim setting for the trunk. - /// - [JsonProperty("trim")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.RecordingTrimEnum Trim { get; private set; } - - private RecordingResource() - { - - } - } +{ + + public class RecordingResource : Resource + { + public sealed class RecordingModeEnum : StringEnum + { + private RecordingModeEnum(string value) : base(value) { } + public RecordingModeEnum() { } + public static implicit operator RecordingModeEnum(string value) + { + return new RecordingModeEnum(value); + } + + public static readonly RecordingModeEnum DoNotRecord = new RecordingModeEnum("do-not-record"); + public static readonly RecordingModeEnum RecordFromRinging = new RecordingModeEnum("record-from-ringing"); + public static readonly RecordingModeEnum RecordFromAnswer = new RecordingModeEnum("record-from-answer"); + public static readonly RecordingModeEnum RecordFromRingingDual = new RecordingModeEnum("record-from-ringing-dual"); + public static readonly RecordingModeEnum RecordFromAnswerDual = new RecordingModeEnum("record-from-answer-dual"); + } + + public sealed class RecordingTrimEnum : StringEnum + { + private RecordingTrimEnum(string value) : base(value) { } + public RecordingTrimEnum() { } + public static implicit operator RecordingTrimEnum(string value) + { + return new RecordingTrimEnum(value); + } + + public static readonly RecordingTrimEnum TrimSilence = new RecordingTrimEnum("trim-silence"); + public static readonly RecordingTrimEnum DoNotTrim = new RecordingTrimEnum("do-not-trim"); + } + + private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/Recording", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the recording settings. + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(string pathTrunkSid, ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathTrunkSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Trunk from which to fetch the recording settings. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(string pathTrunkSid, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathTrunkSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathTrunkSid + "/Recording", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(UpdateRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Trunk. + /// The recording mode for the trunk. + /// The recording trim setting for the trunk. + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Update(string pathTrunkSid, + RecordingResource.RecordingModeEnum mode = null, + RecordingResource.RecordingTrimEnum trim = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathTrunkSid) { Mode = mode, Trim = trim }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Trunk. + /// The recording mode for the trunk. + /// The recording trim setting for the trunk. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task UpdateAsync(string pathTrunkSid, + RecordingResource.RecordingModeEnum mode = null, + RecordingResource.RecordingTrimEnum trim = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingOptions(pathTrunkSid) { Mode = mode, Trim = trim }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RecordingResource object + /// + /// Raw JSON string + /// RecordingResource object represented by the provided JSON + public static RecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The recording mode for the trunk. + /// + [JsonProperty("mode")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.RecordingModeEnum Mode { get; private set; } + /// + /// The recording trim setting for the trunk. + /// + [JsonProperty("trim")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.RecordingTrimEnum Trim { get; private set; } + + private RecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/TrunkOptions.cs b/src/Twilio/Rest/Trunking/V1/TrunkOptions.cs index 2a80ebdf5..bdfd11a90 100644 --- a/src/Twilio/Rest/Trunking/V1/TrunkOptions.cs +++ b/src/Twilio/Rest/Trunking/V1/TrunkOptions.cs @@ -9,273 +9,273 @@ using Twilio.Converters; namespace Twilio.Rest.Trunking.V1 -{ - +{ + + /// + /// FetchTrunkOptions + /// + public class FetchTrunkOptions : IOptions + { /// - /// FetchTrunkOptions + /// The unique string that identifies the resource /// - public class FetchTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTrunkOptions - /// - /// The unique string that identifies the resource - public FetchTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteTrunkOptions + /// Construct a new FetchTrunkOptions /// - public class DeleteTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTrunkOptions - /// - /// The unique string that identifies the resource - public DeleteTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource + public FetchTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// CreateTrunkOptions + /// Generate the necessary parameters /// - public class CreateTrunkOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// - public string DomainName { get; set; } - /// - /// The HTTP URL that we should call if an error occurs while sending SIP traffic towards your configured Origination URL - /// - public Uri DisasterRecoveryUrl { get; set; } - /// - /// The HTTP method we should use to call the disaster_recovery_url - /// - public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; set; } - /// - /// The call transfer settings for the trunk - /// - public TrunkResource.TransferSettingEnum TransferMode { get; set; } - /// - /// Whether Secure Trunking is enabled for the trunk - /// - public bool? Secure { get; set; } - /// - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// - public bool? CnamLookupEnabled { get; set; } - /// - /// Caller Id for transfer target - /// - public TrunkResource.TransferCallerIdEnum TransferCallerId { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DomainName != null) - { - p.Add(new KeyValuePair("DomainName", DomainName)); - } - - if (DisasterRecoveryUrl != null) - { - p.Add(new KeyValuePair("DisasterRecoveryUrl", Serializers.Url(DisasterRecoveryUrl))); - } - - if (DisasterRecoveryMethod != null) - { - p.Add(new KeyValuePair("DisasterRecoveryMethod", DisasterRecoveryMethod.ToString())); - } - - if (TransferMode != null) - { - p.Add(new KeyValuePair("TransferMode", TransferMode.ToString())); - } - - if (Secure != null) - { - p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); - } - - if (CnamLookupEnabled != null) - { - p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); - } - - if (TransferCallerId != null) - { - p.Add(new KeyValuePair("TransferCallerId", TransferCallerId.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// DeleteTrunkOptions + /// + public class DeleteTrunkOptions : IOptions + { /// - /// ReadTrunkOptions + /// The unique string that identifies the resource /// - public class ReadTrunkOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// UpdateTrunkOptions + /// Construct a new DeleteTrunkOptions /// - public class UpdateTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// - public string DomainName { get; set; } - /// - /// The HTTP URL that we should call if an error occurs while sending SIP traffic towards your configured Origination URL - /// - public Uri DisasterRecoveryUrl { get; set; } - /// - /// The HTTP method we should use to call the disaster_recovery_url - /// - public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; set; } - /// - /// The call transfer settings for the trunk - /// - public TrunkResource.TransferSettingEnum TransferMode { get; set; } - /// - /// Whether Secure Trunking is enabled for the trunk - /// - public bool? Secure { get; set; } - /// - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// - public bool? CnamLookupEnabled { get; set; } - /// - /// Caller Id for transfer target - /// - public TrunkResource.TransferCallerIdEnum TransferCallerId { get; set; } - - /// - /// Construct a new UpdateTrunkOptions - /// - /// The unique string that identifies the resource - public UpdateTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DomainName != null) - { - p.Add(new KeyValuePair("DomainName", DomainName)); - } - - if (DisasterRecoveryUrl != null) - { - p.Add(new KeyValuePair("DisasterRecoveryUrl", Serializers.Url(DisasterRecoveryUrl))); - } - - if (DisasterRecoveryMethod != null) - { - p.Add(new KeyValuePair("DisasterRecoveryMethod", DisasterRecoveryMethod.ToString())); - } - - if (TransferMode != null) - { - p.Add(new KeyValuePair("TransferMode", TransferMode.ToString())); - } - - if (Secure != null) - { - p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); - } - - if (CnamLookupEnabled != null) - { - p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); - } - - if (TransferCallerId != null) - { - p.Add(new KeyValuePair("TransferCallerId", TransferCallerId.ToString())); - } - - return p; - } - } + /// The unique string that identifies the resource + public DeleteTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateTrunkOptions + /// + public class CreateTrunkOptions : IOptions + { + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// + public string DomainName { get; set; } + /// + /// The HTTP URL that we should call if an error occurs while sending SIP traffic towards your configured Origination URL + /// + public Uri DisasterRecoveryUrl { get; set; } + /// + /// The HTTP method we should use to call the disaster_recovery_url + /// + public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; set; } + /// + /// The call transfer settings for the trunk + /// + public TrunkResource.TransferSettingEnum TransferMode { get; set; } + /// + /// Whether Secure Trunking is enabled for the trunk + /// + public bool? Secure { get; set; } + /// + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// + public bool? CnamLookupEnabled { get; set; } + /// + /// Caller Id for transfer target + /// + public TrunkResource.TransferCallerIdEnum TransferCallerId { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DomainName != null) + { + p.Add(new KeyValuePair("DomainName", DomainName)); + } + + if (DisasterRecoveryUrl != null) + { + p.Add(new KeyValuePair("DisasterRecoveryUrl", Serializers.Url(DisasterRecoveryUrl))); + } + + if (DisasterRecoveryMethod != null) + { + p.Add(new KeyValuePair("DisasterRecoveryMethod", DisasterRecoveryMethod.ToString())); + } + + if (TransferMode != null) + { + p.Add(new KeyValuePair("TransferMode", TransferMode.ToString())); + } + + if (Secure != null) + { + p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); + } + + if (CnamLookupEnabled != null) + { + p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); + } + + if (TransferCallerId != null) + { + p.Add(new KeyValuePair("TransferCallerId", TransferCallerId.ToString())); + } + + return p; + } + } + + /// + /// ReadTrunkOptions + /// + public class ReadTrunkOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateTrunkOptions + /// + public class UpdateTrunkOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// + public string DomainName { get; set; } + /// + /// The HTTP URL that we should call if an error occurs while sending SIP traffic towards your configured Origination URL + /// + public Uri DisasterRecoveryUrl { get; set; } + /// + /// The HTTP method we should use to call the disaster_recovery_url + /// + public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; set; } + /// + /// The call transfer settings for the trunk + /// + public TrunkResource.TransferSettingEnum TransferMode { get; set; } + /// + /// Whether Secure Trunking is enabled for the trunk + /// + public bool? Secure { get; set; } + /// + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// + public bool? CnamLookupEnabled { get; set; } + /// + /// Caller Id for transfer target + /// + public TrunkResource.TransferCallerIdEnum TransferCallerId { get; set; } + + /// + /// Construct a new UpdateTrunkOptions + /// + /// The unique string that identifies the resource + public UpdateTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DomainName != null) + { + p.Add(new KeyValuePair("DomainName", DomainName)); + } + + if (DisasterRecoveryUrl != null) + { + p.Add(new KeyValuePair("DisasterRecoveryUrl", Serializers.Url(DisasterRecoveryUrl))); + } + + if (DisasterRecoveryMethod != null) + { + p.Add(new KeyValuePair("DisasterRecoveryMethod", DisasterRecoveryMethod.ToString())); + } + + if (TransferMode != null) + { + p.Add(new KeyValuePair("TransferMode", TransferMode.ToString())); + } + + if (Secure != null) + { + p.Add(new KeyValuePair("Secure", Secure.Value.ToString().ToLower())); + } + + if (CnamLookupEnabled != null) + { + p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); + } + + if (TransferCallerId != null) + { + p.Add(new KeyValuePair("TransferCallerId", TransferCallerId.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trunking/V1/TrunkResource.cs b/src/Twilio/Rest/Trunking/V1/TrunkResource.cs index 39e074902..e66964032 100644 --- a/src/Twilio/Rest/Trunking/V1/TrunkResource.cs +++ b/src/Twilio/Rest/Trunking/V1/TrunkResource.cs @@ -17,610 +17,610 @@ using Twilio.Types; namespace Twilio.Rest.Trunking.V1 -{ - - public class TrunkResource : Resource - { - public sealed class TransferSettingEnum : StringEnum - { - private TransferSettingEnum(string value) : base(value) {} - public TransferSettingEnum() {} - public static implicit operator TransferSettingEnum(string value) - { - return new TransferSettingEnum(value); - } - - public static readonly TransferSettingEnum DisableAll = new TransferSettingEnum("disable-all"); - public static readonly TransferSettingEnum EnableAll = new TransferSettingEnum("enable-all"); - public static readonly TransferSettingEnum SipOnly = new TransferSettingEnum("sip-only"); - } - - public sealed class TransferCallerIdEnum : StringEnum - { - private TransferCallerIdEnum(string value) : base(value) {} - public TransferCallerIdEnum() {} - public static implicit operator TransferCallerIdEnum(string value) - { - return new TransferCallerIdEnum(value); - } - - public static readonly TransferCallerIdEnum FromTransferee = new TransferCallerIdEnum("from-transferee"); - public static readonly TransferCallerIdEnum FromTransferor = new TransferCallerIdEnum("from-transferor"); - } - - private static Request BuildFetchRequest(FetchTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Trunk parameters - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Fetch(FetchTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Trunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task FetchAsync(FetchTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTrunkOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrunkOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete Trunk parameters - /// Client to make requests to Twilio - /// A single instance of Trunk - public static bool Delete(DeleteTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete Trunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Trunk - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrunkOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrunkOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Trunk parameters - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Create(CreateTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Trunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task CreateAsync(CreateTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// The HTTP URL that we should call if an error occurs while sending SIP traffic - /// towards your configured Origination URL - /// The HTTP method we should use to call the disaster_recovery_url - /// The call transfer settings for the trunk - /// Whether Secure Trunking is enabled for the trunk - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// Caller Id for transfer target - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Create(string friendlyName = null, - string domainName = null, - Uri disasterRecoveryUrl = null, - Twilio.Http.HttpMethod disasterRecoveryMethod = null, - TrunkResource.TransferSettingEnum transferMode = null, - bool? secure = null, - bool? cnamLookupEnabled = null, - TrunkResource.TransferCallerIdEnum transferCallerId = null, - ITwilioRestClient client = null) - { - var options = new CreateTrunkOptions(){FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// The HTTP URL that we should call if an error occurs while sending SIP traffic - /// towards your configured Origination URL - /// The HTTP method we should use to call the disaster_recovery_url - /// The call transfer settings for the trunk - /// Whether Secure Trunking is enabled for the trunk - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// Caller Id for transfer target - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - string domainName = null, - Uri disasterRecoveryUrl = null, - Twilio.Http.HttpMethod disasterRecoveryMethod = null, - TrunkResource.TransferSettingEnum transferMode = null, - bool? secure = null, - bool? cnamLookupEnabled = null, - TrunkResource.TransferCallerIdEnum transferCallerId = null, - ITwilioRestClient client = null) - { - var options = new CreateTrunkOptions(){FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trunking, - "/v1/Trunks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Trunk parameters - /// Client to make requests to Twilio - /// A single instance of Trunk - public static ResourceSet Read(ReadTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("trunks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Trunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task> ReadAsync(ReadTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("trunks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Trunk - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrunkOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrunkOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("trunks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("trunks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trunking) - ); - - var response = client.Request(request); - return Page.FromJson("trunks", response.Content); - } - - private static Request BuildUpdateRequest(UpdateTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trunking, - "/v1/Trunks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Trunk parameters - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Update(UpdateTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Trunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// The HTTP URL that we should call if an error occurs while sending SIP traffic - /// towards your configured Origination URL - /// The HTTP method we should use to call the disaster_recovery_url - /// The call transfer settings for the trunk - /// Whether Secure Trunking is enabled for the trunk - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// Caller Id for transfer target - /// Client to make requests to Twilio - /// A single instance of Trunk - public static TrunkResource Update(string pathSid, - string friendlyName = null, - string domainName = null, - Uri disasterRecoveryUrl = null, - Twilio.Http.HttpMethod disasterRecoveryMethod = null, - TrunkResource.TransferSettingEnum transferMode = null, - bool? secure = null, - bool? cnamLookupEnabled = null, - TrunkResource.TransferCallerIdEnum transferCallerId = null, - ITwilioRestClient client = null) - { - var options = new UpdateTrunkOptions(pathSid){FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// The HTTP URL that we should call if an error occurs while sending SIP traffic - /// towards your configured Origination URL - /// The HTTP method we should use to call the disaster_recovery_url - /// The call transfer settings for the trunk - /// Whether Secure Trunking is enabled for the trunk - /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk - /// Caller Id for transfer target - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Trunk - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - string domainName = null, - Uri disasterRecoveryUrl = null, - Twilio.Http.HttpMethod disasterRecoveryMethod = null, - TrunkResource.TransferSettingEnum transferMode = null, - bool? secure = null, - bool? cnamLookupEnabled = null, - TrunkResource.TransferCallerIdEnum transferCallerId = null, - ITwilioRestClient client = null) - { - var options = new UpdateTrunkOptions(pathSid){FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TrunkResource object - /// - /// Raw JSON string - /// TrunkResource object represented by the provided JSON - public static TrunkResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique address you reserve on Twilio to which you route your SIP traffic - /// - [JsonProperty("domain_name")] - public string DomainName { get; private set; } - /// - /// The HTTP method we use to call the disaster_recovery_url - /// - [JsonProperty("disaster_recovery_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; private set; } - /// - /// The HTTP URL that we call if an error occurs while sending SIP traffic towards your configured Origination URL - /// - [JsonProperty("disaster_recovery_url")] - public Uri DisasterRecoveryUrl { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Whether Secure Trunking is enabled for the trunk - /// - [JsonProperty("secure")] - public bool? Secure { get; private set; } - /// - /// The recording settings for the trunk - /// - [JsonProperty("recording")] - public object Recording { get; private set; } - /// - /// The call transfer settings for the trunk - /// - [JsonProperty("transfer_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public TrunkResource.TransferSettingEnum TransferMode { get; private set; } - /// - /// Caller Id for transfer target - /// - [JsonProperty("transfer_caller_id")] - [JsonConverter(typeof(StringEnumConverter))] - public TrunkResource.TransferCallerIdEnum TransferCallerId { get; private set; } - /// - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// - [JsonProperty("cnam_lookup_enabled")] - public bool? CnamLookupEnabled { get; private set; } - /// - /// The types of authentication mapped to the domain - /// - [JsonProperty("auth_type")] - public string AuthType { get; private set; } - /// - /// Reserved - /// - [JsonProperty("auth_type_set")] - public List AuthTypeSet { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private TrunkResource() - { - - } - } +{ + + public class TrunkResource : Resource + { + public sealed class TransferSettingEnum : StringEnum + { + private TransferSettingEnum(string value) : base(value) { } + public TransferSettingEnum() { } + public static implicit operator TransferSettingEnum(string value) + { + return new TransferSettingEnum(value); + } + + public static readonly TransferSettingEnum DisableAll = new TransferSettingEnum("disable-all"); + public static readonly TransferSettingEnum EnableAll = new TransferSettingEnum("enable-all"); + public static readonly TransferSettingEnum SipOnly = new TransferSettingEnum("sip-only"); + } + + public sealed class TransferCallerIdEnum : StringEnum + { + private TransferCallerIdEnum(string value) : base(value) { } + public TransferCallerIdEnum() { } + public static implicit operator TransferCallerIdEnum(string value) + { + return new TransferCallerIdEnum(value); + } + + public static readonly TransferCallerIdEnum FromTransferee = new TransferCallerIdEnum("from-transferee"); + public static readonly TransferCallerIdEnum FromTransferor = new TransferCallerIdEnum("from-transferor"); + } + + private static Request BuildFetchRequest(FetchTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Trunk parameters + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Fetch(FetchTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Trunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task FetchAsync(FetchTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTrunkOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrunkOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete Trunk parameters + /// Client to make requests to Twilio + /// A single instance of Trunk + public static bool Delete(DeleteTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete Trunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Trunk + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrunkOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrunkOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Trunk parameters + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Create(CreateTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Trunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task CreateAsync(CreateTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// The HTTP URL that we should call if an error occurs while sending SIP traffic + /// towards your configured Origination URL + /// The HTTP method we should use to call the disaster_recovery_url + /// The call transfer settings for the trunk + /// Whether Secure Trunking is enabled for the trunk + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// Caller Id for transfer target + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Create(string friendlyName = null, + string domainName = null, + Uri disasterRecoveryUrl = null, + Twilio.Http.HttpMethod disasterRecoveryMethod = null, + TrunkResource.TransferSettingEnum transferMode = null, + bool? secure = null, + bool? cnamLookupEnabled = null, + TrunkResource.TransferCallerIdEnum transferCallerId = null, + ITwilioRestClient client = null) + { + var options = new CreateTrunkOptions() { FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// The HTTP URL that we should call if an error occurs while sending SIP traffic + /// towards your configured Origination URL + /// The HTTP method we should use to call the disaster_recovery_url + /// The call transfer settings for the trunk + /// Whether Secure Trunking is enabled for the trunk + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// Caller Id for transfer target + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + string domainName = null, + Uri disasterRecoveryUrl = null, + Twilio.Http.HttpMethod disasterRecoveryMethod = null, + TrunkResource.TransferSettingEnum transferMode = null, + bool? secure = null, + bool? cnamLookupEnabled = null, + TrunkResource.TransferCallerIdEnum transferCallerId = null, + ITwilioRestClient client = null) + { + var options = new CreateTrunkOptions() { FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trunking, + "/v1/Trunks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Trunk parameters + /// Client to make requests to Twilio + /// A single instance of Trunk + public static ResourceSet Read(ReadTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("trunks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Trunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task> ReadAsync(ReadTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("trunks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Trunk + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrunkOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrunkOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("trunks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("trunks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trunking) + ); + + var response = client.Request(request); + return Page.FromJson("trunks", response.Content); + } + + private static Request BuildUpdateRequest(UpdateTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trunking, + "/v1/Trunks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Trunk parameters + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Update(UpdateTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Trunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// The HTTP URL that we should call if an error occurs while sending SIP traffic + /// towards your configured Origination URL + /// The HTTP method we should use to call the disaster_recovery_url + /// The call transfer settings for the trunk + /// Whether Secure Trunking is enabled for the trunk + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// Caller Id for transfer target + /// Client to make requests to Twilio + /// A single instance of Trunk + public static TrunkResource Update(string pathSid, + string friendlyName = null, + string domainName = null, + Uri disasterRecoveryUrl = null, + Twilio.Http.HttpMethod disasterRecoveryMethod = null, + TrunkResource.TransferSettingEnum transferMode = null, + bool? secure = null, + bool? cnamLookupEnabled = null, + TrunkResource.TransferCallerIdEnum transferCallerId = null, + ITwilioRestClient client = null) + { + var options = new UpdateTrunkOptions(pathSid) { FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// The HTTP URL that we should call if an error occurs while sending SIP traffic + /// towards your configured Origination URL + /// The HTTP method we should use to call the disaster_recovery_url + /// The call transfer settings for the trunk + /// Whether Secure Trunking is enabled for the trunk + /// Whether Caller ID Name (CNAM) lookup should be enabled for the trunk + /// Caller Id for transfer target + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Trunk + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + string domainName = null, + Uri disasterRecoveryUrl = null, + Twilio.Http.HttpMethod disasterRecoveryMethod = null, + TrunkResource.TransferSettingEnum transferMode = null, + bool? secure = null, + bool? cnamLookupEnabled = null, + TrunkResource.TransferCallerIdEnum transferCallerId = null, + ITwilioRestClient client = null) + { + var options = new UpdateTrunkOptions(pathSid) { FriendlyName = friendlyName, DomainName = domainName, DisasterRecoveryUrl = disasterRecoveryUrl, DisasterRecoveryMethod = disasterRecoveryMethod, TransferMode = transferMode, Secure = secure, CnamLookupEnabled = cnamLookupEnabled, TransferCallerId = transferCallerId }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TrunkResource object + /// + /// Raw JSON string + /// TrunkResource object represented by the provided JSON + public static TrunkResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique address you reserve on Twilio to which you route your SIP traffic + /// + [JsonProperty("domain_name")] + public string DomainName { get; private set; } + /// + /// The HTTP method we use to call the disaster_recovery_url + /// + [JsonProperty("disaster_recovery_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod DisasterRecoveryMethod { get; private set; } + /// + /// The HTTP URL that we call if an error occurs while sending SIP traffic towards your configured Origination URL + /// + [JsonProperty("disaster_recovery_url")] + public Uri DisasterRecoveryUrl { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Whether Secure Trunking is enabled for the trunk + /// + [JsonProperty("secure")] + public bool? Secure { get; private set; } + /// + /// The recording settings for the trunk + /// + [JsonProperty("recording")] + public object Recording { get; private set; } + /// + /// The call transfer settings for the trunk + /// + [JsonProperty("transfer_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public TrunkResource.TransferSettingEnum TransferMode { get; private set; } + /// + /// Caller Id for transfer target + /// + [JsonProperty("transfer_caller_id")] + [JsonConverter(typeof(StringEnumConverter))] + public TrunkResource.TransferCallerIdEnum TransferCallerId { get; private set; } + /// + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// + [JsonProperty("cnam_lookup_enabled")] + public bool? CnamLookupEnabled { get; private set; } + /// + /// The types of authentication mapped to the domain + /// + [JsonProperty("auth_type")] + public string AuthType { get; private set; } + /// + /// Reserved + /// + [JsonProperty("auth_type_set")] + public List AuthTypeSet { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private TrunkResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentOptions.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentOptions.cs index ec63b1764..d3ccbcf03 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentOptions.cs @@ -9,181 +9,181 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - +{ + + /// + /// Create a new Assigned Item. + /// + public class CreateCustomerProfilesChannelEndpointAssignmentOptions : IOptions + { /// - /// Create a new Assigned Item. - /// - public class CreateCustomerProfilesChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The type of channel endpoint - /// - public string ChannelEndpointType { get; } - /// - /// The sid of an channel endpoint - /// - public string ChannelEndpointSid { get; } - - /// - /// Construct a new CreateCustomerProfilesChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - public CreateCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, - string channelEndpointType, - string channelEndpointSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - ChannelEndpointType = channelEndpointType; - ChannelEndpointSid = channelEndpointSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ChannelEndpointType != null) - { - p.Add(new KeyValuePair("ChannelEndpointType", ChannelEndpointType)); - } - - if (ChannelEndpointSid != null) - { - p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } /// - /// Retrieve a list of all Assigned Items for an account. - /// - public class ReadCustomerProfilesChannelEndpointAssignmentOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The sid of an channel endpoint - /// - public string ChannelEndpointSid { get; set; } - /// - /// comma separated list of channel endpoint sids - /// - public string ChannelEndpointSids { get; set; } - - /// - /// Construct a new ReadCustomerProfilesChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - public ReadCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ChannelEndpointSid != null) - { - p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); - } - - if (ChannelEndpointSids != null) - { - p.Add(new KeyValuePair("ChannelEndpointSids", ChannelEndpointSids)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of channel endpoint + /// + public string ChannelEndpointType { get; } /// - /// Fetch specific Assigned Item Instance. - /// - public class FetchCustomerProfilesChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCustomerProfilesChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public FetchCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, string pathSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid of an channel endpoint + /// + public string ChannelEndpointSid { get; } + /// - /// Remove an Assignment Item Instance. - /// - public class DeleteCustomerProfilesChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCustomerProfilesChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public DeleteCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, string pathSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateCustomerProfilesChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + public CreateCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, + string channelEndpointType, + string channelEndpointSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + ChannelEndpointType = channelEndpointType; + ChannelEndpointSid = channelEndpointSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ChannelEndpointType != null) + { + p.Add(new KeyValuePair("ChannelEndpointType", ChannelEndpointType)); + } + + if (ChannelEndpointSid != null) + { + p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + public class ReadCustomerProfilesChannelEndpointAssignmentOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + /// + /// The sid of an channel endpoint + /// + public string ChannelEndpointSid { get; set; } + /// + /// comma separated list of channel endpoint sids + /// + public string ChannelEndpointSids { get; set; } + + /// + /// Construct a new ReadCustomerProfilesChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + public ReadCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ChannelEndpointSid != null) + { + p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); + } + + if (ChannelEndpointSids != null) + { + p.Add(new KeyValuePair("ChannelEndpointSids", ChannelEndpointSids)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Assigned Item Instance. + /// + public class FetchCustomerProfilesChannelEndpointAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCustomerProfilesChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public FetchCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, string pathSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an Assignment Item Instance. + /// + public class DeleteCustomerProfilesChannelEndpointAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCustomerProfilesChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public DeleteCustomerProfilesChannelEndpointAssignmentOptions(string pathCustomerProfileSid, string pathSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentResource.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentResource.cs index d7c405c6c..f4f8ffcaf 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesChannelEndpointAssignmentResource.cs @@ -16,438 +16,438 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - - public class CustomerProfilesChannelEndpointAssignmentResource : Resource - { - private static Request BuildCreateRequest(CreateCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Assigned Item. - /// - /// Create CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static CustomerProfilesChannelEndpointAssignmentResource Create(CreateCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// Create CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static CustomerProfilesChannelEndpointAssignmentResource Create(string pathCustomerProfileSid, - string channelEndpointType, - string channelEndpointSid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, channelEndpointType, channelEndpointSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, - string channelEndpointType, - string channelEndpointSid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, channelEndpointType, channelEndpointSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static ResourceSet Read(ReadCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// The sid of an channel endpoint - /// comma separated list of channel endpoint sids - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static ResourceSet Read(string pathCustomerProfileSid, - string channelEndpointSid = null, - string channelEndpointSids = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid){ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// The sid of an channel endpoint - /// comma separated list of channel endpoint sids - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, - string channelEndpointSid = null, - string channelEndpointSids = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid){ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, - ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static CustomerProfilesChannelEndpointAssignmentResource Fetch(FetchCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static CustomerProfilesChannelEndpointAssignmentResource Fetch(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Assignment Item Instance. - /// - /// Delete CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static bool Delete(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// Delete CustomerProfilesChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesChannelEndpointAssignment - public static bool Delete(string pathCustomerProfileSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment - public static async System.Threading.Tasks.Task DeleteAsync(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CustomerProfilesChannelEndpointAssignmentResource object - /// - /// Raw JSON string - /// CustomerProfilesChannelEndpointAssignmentResource object represented by the provided JSON - public static CustomerProfilesChannelEndpointAssignmentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the CustomerProfile resource. - /// - [JsonProperty("customer_profile_sid")] - public string CustomerProfileSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The type of channel endpoint - /// - [JsonProperty("channel_endpoint_type")] - public string ChannelEndpointType { get; private set; } - /// - /// The sid of an channel endpoint - /// - [JsonProperty("channel_endpoint_sid")] - public string ChannelEndpointSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Identity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CustomerProfilesChannelEndpointAssignmentResource() - { - - } - } +{ + + public class CustomerProfilesChannelEndpointAssignmentResource : Resource + { + private static Request BuildCreateRequest(CreateCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Assigned Item. + /// + /// Create CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static CustomerProfilesChannelEndpointAssignmentResource Create(CreateCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// Create CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static CustomerProfilesChannelEndpointAssignmentResource Create(string pathCustomerProfileSid, + string channelEndpointType, + string channelEndpointSid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, channelEndpointType, channelEndpointSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, + string channelEndpointType, + string channelEndpointSid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, channelEndpointType, channelEndpointSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static ResourceSet Read(ReadCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// The sid of an channel endpoint + /// comma separated list of channel endpoint sids + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static ResourceSet Read(string pathCustomerProfileSid, + string channelEndpointSid = null, + string channelEndpointSids = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid) { ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// The sid of an channel endpoint + /// comma separated list of channel endpoint sids + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, + string channelEndpointSid = null, + string channelEndpointSids = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid) { ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, + ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static CustomerProfilesChannelEndpointAssignmentResource Fetch(FetchCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static CustomerProfilesChannelEndpointAssignmentResource Fetch(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/ChannelEndpointAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Assignment Item Instance. + /// + /// Delete CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static bool Delete(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// Delete CustomerProfilesChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesChannelEndpointAssignment + public static bool Delete(string pathCustomerProfileSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesChannelEndpointAssignment + public static async System.Threading.Tasks.Task DeleteAsync(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesChannelEndpointAssignmentOptions(pathCustomerProfileSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CustomerProfilesChannelEndpointAssignmentResource object + /// + /// Raw JSON string + /// CustomerProfilesChannelEndpointAssignmentResource object represented by the provided JSON + public static CustomerProfilesChannelEndpointAssignmentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the CustomerProfile resource. + /// + [JsonProperty("customer_profile_sid")] + public string CustomerProfileSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The type of channel endpoint + /// + [JsonProperty("channel_endpoint_type")] + public string ChannelEndpointType { get; private set; } + /// + /// The sid of an channel endpoint + /// + [JsonProperty("channel_endpoint_sid")] + public string ChannelEndpointSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Identity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CustomerProfilesChannelEndpointAssignmentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsOptions.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsOptions.cs index 502ef7136..07527fc1c 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsOptions.cs @@ -9,150 +9,150 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - +{ + + /// + /// Create a new Assigned Item. + /// + public class CreateCustomerProfilesEntityAssignmentsOptions : IOptions + { /// - /// Create a new Assigned Item. + /// The unique string that identifies the resource. /// - public class CreateCustomerProfilesEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The sid of an object bag - /// - public string ObjectSid { get; } - - /// - /// Construct a new CreateCustomerProfilesEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - public CreateCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string objectSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - ObjectSid = objectSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ObjectSid != null) - { - p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); - } - - return p; - } - } - + public string PathCustomerProfileSid { get; } /// - /// Retrieve a list of all Assigned Items for an account. + /// The sid of an object bag /// - public class ReadCustomerProfilesEntityAssignmentsOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - - /// - /// Construct a new ReadCustomerProfilesEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - public ReadCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string ObjectSid { get; } + /// - /// Fetch specific Assigned Item Instance. + /// Construct a new CreateCustomerProfilesEntityAssignmentsOptions /// - public class FetchCustomerProfilesEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCustomerProfilesEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public FetchCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string pathSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource. + /// The sid of an object bag + public CreateCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string objectSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + ObjectSid = objectSid; + } + /// - /// Remove an Assignment Item Instance. + /// Generate the necessary parameters /// - public class DeleteCustomerProfilesEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCustomerProfilesEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public DeleteCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string pathSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (ObjectSid != null) + { + p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + public class ReadCustomerProfilesEntityAssignmentsOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + + /// + /// Construct a new ReadCustomerProfilesEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + public ReadCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Assigned Item Instance. + /// + public class FetchCustomerProfilesEntityAssignmentsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCustomerProfilesEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public FetchCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string pathSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an Assignment Item Instance. + /// + public class DeleteCustomerProfilesEntityAssignmentsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCustomerProfilesEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public DeleteCustomerProfilesEntityAssignmentsOptions(string pathCustomerProfileSid, string pathSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsResource.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsResource.cs index a6e68fd5a..6de6d7e05 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEntityAssignmentsResource.cs @@ -16,419 +16,419 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - - public class CustomerProfilesEntityAssignmentsResource : Resource - { - private static Request BuildCreateRequest(CreateCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Assigned Item. - /// - /// Create CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static CustomerProfilesEntityAssignmentsResource Create(CreateCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// Create CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static CustomerProfilesEntityAssignmentsResource Create(string pathCustomerProfileSid, - string objectSid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, objectSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, - string objectSid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, objectSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static ResourceSet Read(ReadCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static ResourceSet Read(string pathCustomerProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static CustomerProfilesEntityAssignmentsResource Fetch(FetchCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static CustomerProfilesEntityAssignmentsResource Fetch(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Assignment Item Instance. - /// - /// Delete CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static bool Delete(DeleteCustomerProfilesEntityAssignmentsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// Delete CustomerProfilesEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEntityAssignments - public static bool Delete(string pathCustomerProfileSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEntityAssignments - public static async System.Threading.Tasks.Task DeleteAsync(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CustomerProfilesEntityAssignmentsResource object - /// - /// Raw JSON string - /// CustomerProfilesEntityAssignmentsResource object represented by the provided JSON - public static CustomerProfilesEntityAssignmentsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the CustomerProfile resource. - /// - [JsonProperty("customer_profile_sid")] - public string CustomerProfileSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The sid of an object bag - /// - [JsonProperty("object_sid")] - public string ObjectSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Identity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CustomerProfilesEntityAssignmentsResource() - { - - } - } +{ + + public class CustomerProfilesEntityAssignmentsResource : Resource + { + private static Request BuildCreateRequest(CreateCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Assigned Item. + /// + /// Create CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static CustomerProfilesEntityAssignmentsResource Create(CreateCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// Create CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static CustomerProfilesEntityAssignmentsResource Create(string pathCustomerProfileSid, + string objectSid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, objectSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, + string objectSid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, objectSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static ResourceSet Read(ReadCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static ResourceSet Read(string pathCustomerProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static CustomerProfilesEntityAssignmentsResource Fetch(FetchCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static CustomerProfilesEntityAssignmentsResource Fetch(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/EntityAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Assignment Item Instance. + /// + /// Delete CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static bool Delete(DeleteCustomerProfilesEntityAssignmentsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// Delete CustomerProfilesEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEntityAssignments + public static bool Delete(string pathCustomerProfileSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEntityAssignments + public static async System.Threading.Tasks.Task DeleteAsync(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesEntityAssignmentsOptions(pathCustomerProfileSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CustomerProfilesEntityAssignmentsResource object + /// + /// Raw JSON string + /// CustomerProfilesEntityAssignmentsResource object represented by the provided JSON + public static CustomerProfilesEntityAssignmentsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the CustomerProfile resource. + /// + [JsonProperty("customer_profile_sid")] + public string CustomerProfileSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The sid of an object bag + /// + [JsonProperty("object_sid")] + public string ObjectSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Identity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CustomerProfilesEntityAssignmentsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsOptions.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsOptions.cs index d1daa92ac..ed41c4e69 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsOptions.cs @@ -9,115 +9,115 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - +{ + + /// + /// Create a new Evaluation + /// + public class CreateCustomerProfilesEvaluationsOptions : IOptions + { /// - /// Create a new Evaluation + /// The unique string that identifies the resource. /// - public class CreateCustomerProfilesEvaluationsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string of a policy - /// - public string PolicySid { get; } - - /// - /// Construct a new CreateCustomerProfilesEvaluationsOptions - /// - /// The unique string that identifies the resource. - /// The unique string of a policy - public CreateCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid, string policySid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PolicySid = policySid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - return p; - } - } - + public string PathCustomerProfileSid { get; } /// - /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// The unique string of a policy /// - public class ReadCustomerProfilesEvaluationsOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathCustomerProfileSid { get; } - - /// - /// Construct a new ReadCustomerProfilesEvaluationsOptions - /// - /// The unique string that identifies the resource. - public ReadCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PolicySid { get; } + /// - /// Fetch specific Evaluation Instance. + /// Construct a new CreateCustomerProfilesEvaluationsOptions /// - public class FetchCustomerProfilesEvaluationsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathCustomerProfileSid { get; } - /// - /// The unique string that identifies the Evaluation resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCustomerProfilesEvaluationsOptions - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - public FetchCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid, string pathSid) - { - PathCustomerProfileSid = pathCustomerProfileSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique string that identifies the resource. + /// The unique string of a policy + public CreateCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid, string policySid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PolicySid = policySid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// + public class ReadCustomerProfilesEvaluationsOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathCustomerProfileSid { get; } + + /// + /// Construct a new ReadCustomerProfilesEvaluationsOptions + /// + /// The unique string that identifies the resource. + public ReadCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Evaluation Instance. + /// + public class FetchCustomerProfilesEvaluationsOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathCustomerProfileSid { get; } + /// + /// The unique string that identifies the Evaluation resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCustomerProfilesEvaluationsOptions + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + public FetchCustomerProfilesEvaluationsOptions(string pathCustomerProfileSid, string pathSid) + { + PathCustomerProfileSid = pathCustomerProfileSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsResource.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsResource.cs index 3d0caf2d4..474fb0ceb 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfiles/CustomerProfilesEvaluationsResource.cs @@ -17,369 +17,369 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1.CustomerProfiles -{ - - public class CustomerProfilesEvaluationsResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Compliant = new StatusEnum("compliant"); - public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); - } - - private static Request BuildCreateRequest(CreateCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Evaluation - /// - /// Create CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static CustomerProfilesEvaluationsResource Create(CreateCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Evaluation - /// - /// Create CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Evaluation - /// - /// The unique string that identifies the resource. - /// The unique string of a policy - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static CustomerProfilesEvaluationsResource Create(string pathCustomerProfileSid, - string policySid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, policySid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Evaluation - /// - /// The unique string that identifies the resource. - /// The unique string of a policy - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, - string policySid, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, policySid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Evaluations associated to the customer_profile resource. - /// - /// Read CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static ResourceSet Read(ReadCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the customer_profile resource. - /// - /// Read CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Evaluations associated to the customer_profile resource. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static ResourceSet Read(string pathCustomerProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesEvaluationsOptions(pathCustomerProfileSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the customer_profile resource. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesEvaluationsOptions(pathCustomerProfileSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static CustomerProfilesEvaluationsResource Fetch(FetchCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch CustomerProfilesEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// A single instance of CustomerProfilesEvaluations - public static CustomerProfilesEvaluationsResource Fetch(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfilesEvaluations - public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CustomerProfilesEvaluationsResource object - /// - /// Raw JSON string - /// CustomerProfilesEvaluationsResource object represented by the provided JSON - public static CustomerProfilesEvaluationsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Evaluation resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a policy - /// - [JsonProperty("policy_sid")] - public string PolicySid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("customer_profile_sid")] - public string CustomerProfileSid { get; private set; } - /// - /// The compliance status of the Evaluation resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CustomerProfilesEvaluationsResource.StatusEnum Status { get; private set; } - /// - /// The results of the Evaluation resource - /// - [JsonProperty("results")] - public List Results { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CustomerProfilesEvaluationsResource() - { - - } - } +{ + + public class CustomerProfilesEvaluationsResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Compliant = new StatusEnum("compliant"); + public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); + } + + private static Request BuildCreateRequest(CreateCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Evaluation + /// + /// Create CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static CustomerProfilesEvaluationsResource Create(CreateCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Evaluation + /// + /// Create CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Evaluation + /// + /// The unique string that identifies the resource. + /// The unique string of a policy + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static CustomerProfilesEvaluationsResource Create(string pathCustomerProfileSid, + string policySid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, policySid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Evaluation + /// + /// The unique string that identifies the resource. + /// The unique string of a policy + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task CreateAsync(string pathCustomerProfileSid, + string policySid, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, policySid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// + /// Read CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static ResourceSet Read(ReadCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// + /// Read CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static ResourceSet Read(string pathCustomerProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesEvaluationsOptions(pathCustomerProfileSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the customer_profile resource. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task> ReadAsync(string pathCustomerProfileSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesEvaluationsOptions(pathCustomerProfileSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchCustomerProfilesEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathCustomerProfileSid + "/Evaluations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static CustomerProfilesEvaluationsResource Fetch(FetchCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch CustomerProfilesEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// A single instance of CustomerProfilesEvaluations + public static CustomerProfilesEvaluationsResource Fetch(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfilesEvaluations + public static async System.Threading.Tasks.Task FetchAsync(string pathCustomerProfileSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesEvaluationsOptions(pathCustomerProfileSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CustomerProfilesEvaluationsResource object + /// + /// Raw JSON string + /// CustomerProfilesEvaluationsResource object represented by the provided JSON + public static CustomerProfilesEvaluationsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Evaluation resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a policy + /// + [JsonProperty("policy_sid")] + public string PolicySid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("customer_profile_sid")] + public string CustomerProfileSid { get; private set; } + /// + /// The compliance status of the Evaluation resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CustomerProfilesEvaluationsResource.StatusEnum Status { get; private set; } + /// + /// The results of the Evaluation resource + /// + [JsonProperty("results")] + public List Results { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CustomerProfilesEvaluationsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfilesOptions.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfilesOptions.cs index 73ea4ac3d..b636f3bc6 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfilesOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfilesOptions.cs @@ -9,242 +9,242 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Create a new Customer-Profile. + /// + public class CreateCustomerProfilesOptions : IOptions + { /// - /// Create a new Customer-Profile. - /// - public class CreateCustomerProfilesOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The email address - /// - public string Email { get; } - /// - /// The unique string of a policy. - /// - public string PolicySid { get; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - - /// - /// Construct a new CreateCustomerProfilesOptions - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - public CreateCustomerProfilesOptions(string friendlyName, string email, string policySid) - { - FriendlyName = friendlyName; - Email = email; - PolicySid = policySid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - public class ReadCustomerProfilesOptions : ReadOptions - { - /// - /// The verification status of the Customer-Profile resource - /// - public CustomerProfilesResource.StatusEnum Status { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The unique string of a policy. - /// - public string PolicySid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The email address + /// + public string Email { get; } /// - /// Fetch a specific Customer-Profile instance. + /// The unique string of a policy. /// - public class FetchCustomerProfilesOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCustomerProfilesOptions - /// - /// The unique string that identifies the resource. - public FetchCustomerProfilesOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PolicySid { get; } /// - /// Updates a Customer-Profile in an account. - /// - public class UpdateCustomerProfilesOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - /// - /// The verification status of the Customer-Profile resource - /// - public CustomerProfilesResource.StatusEnum Status { get; set; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The email address - /// - public string Email { get; set; } - - /// - /// Construct a new UpdateCustomerProfilesOptions - /// - /// The unique string that identifies the resource. - public UpdateCustomerProfilesOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - return p; - } - } - + /// The URL we call to inform your application of status changes. + /// + public Uri StatusCallback { get; set; } + /// - /// Delete a specific Customer-Profile. + /// Construct a new CreateCustomerProfilesOptions /// - public class DeleteCustomerProfilesOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCustomerProfilesOptions - /// - /// The unique string that identifies the resource. - public DeleteCustomerProfilesOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + public CreateCustomerProfilesOptions(string friendlyName, string email, string policySid) + { + FriendlyName = friendlyName; + Email = email; + PolicySid = policySid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + return p; + } + } + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + public class ReadCustomerProfilesOptions : ReadOptions + { + /// + /// The verification status of the Customer-Profile resource + /// + public CustomerProfilesResource.StatusEnum Status { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The unique string of a policy. + /// + public string PolicySid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Customer-Profile instance. + /// + public class FetchCustomerProfilesOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchCustomerProfilesOptions + /// + /// The unique string that identifies the resource. + public FetchCustomerProfilesOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Updates a Customer-Profile in an account. + /// + public class UpdateCustomerProfilesOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + /// + /// The verification status of the Customer-Profile resource + /// + public CustomerProfilesResource.StatusEnum Status { get; set; } + /// + /// The URL we call to inform your application of status changes. + /// + public Uri StatusCallback { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The email address + /// + public string Email { get; set; } + + /// + /// Construct a new UpdateCustomerProfilesOptions + /// + /// The unique string that identifies the resource. + public UpdateCustomerProfilesOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + return p; + } + } + + /// + /// Delete a specific Customer-Profile. + /// + public class DeleteCustomerProfilesOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCustomerProfilesOptions + /// + /// The unique string that identifies the resource. + public DeleteCustomerProfilesOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/CustomerProfilesResource.cs b/src/Twilio/Rest/Trusthub/V1/CustomerProfilesResource.cs index e3fd5c7a6..ad99c3c0c 100644 --- a/src/Twilio/Rest/Trusthub/V1/CustomerProfilesResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/CustomerProfilesResource.cs @@ -17,563 +17,563 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1 -{ - - public class CustomerProfilesResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum InReview = new StatusEnum("in-review"); - public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); - public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); - } - - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateCustomerProfilesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Customer-Profile. - /// - /// Create CustomerProfiles parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Create(CreateCustomerProfilesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Customer-Profile. - /// - /// Create CustomerProfiles parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Customer-Profile. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - /// The URL we call to inform your application of status changes. - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Create(string friendlyName, - string email, - string policySid, - Uri statusCallback = null, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesOptions(friendlyName, email, policySid){StatusCallback = statusCallback}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Customer-Profile. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - /// The URL we call to inform your application of status changes. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string email, - string policySid, - Uri statusCallback = null, - ITwilioRestClient client = null) - { - var options = new CreateCustomerProfilesOptions(friendlyName, email, policySid){StatusCallback = statusCallback}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCustomerProfilesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// Read CustomerProfiles parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static ResourceSet Read(ReadCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// Read CustomerProfiles parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// The verification status of the Customer-Profile resource - /// The string that you assigned to describe the resource - /// The unique string of a policy. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static ResourceSet Read(CustomerProfilesResource.StatusEnum status = null, - string friendlyName = null, - string policySid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesOptions(){Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// The verification status of the Customer-Profile resource - /// The string that you assigned to describe the resource - /// The unique string of a policy. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task> ReadAsync(CustomerProfilesResource.StatusEnum status = null, - string friendlyName = null, - string policySid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCustomerProfilesOptions(){Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchCustomerProfilesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Customer-Profile instance. - /// - /// Fetch CustomerProfiles parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Fetch(FetchCustomerProfilesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Customer-Profile instance. - /// - /// Fetch CustomerProfiles parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Customer-Profile instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Customer-Profile instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCustomerProfilesOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCustomerProfilesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a Customer-Profile in an account. - /// - /// Update CustomerProfiles parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Update(UpdateCustomerProfilesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a Customer-Profile in an account. - /// - /// Update CustomerProfiles parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a Customer-Profile in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Customer-Profile resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static CustomerProfilesResource Update(string pathSid, - CustomerProfilesResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateCustomerProfilesOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a Customer-Profile in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Customer-Profile resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - CustomerProfilesResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateCustomerProfilesOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCustomerProfilesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/CustomerProfiles/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Customer-Profile. - /// - /// Delete CustomerProfiles parameters - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static bool Delete(DeleteCustomerProfilesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Customer-Profile. - /// - /// Delete CustomerProfiles parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Customer-Profile. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of CustomerProfiles - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Customer-Profile. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CustomerProfiles - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCustomerProfilesOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CustomerProfilesResource object - /// - /// Raw JSON string - /// CustomerProfilesResource object represented by the provided JSON - public static CustomerProfilesResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a policy. - /// - [JsonProperty("policy_sid")] - public string PolicySid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The verification status of the Customer-Profile resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CustomerProfilesResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource will be valid until. - /// - [JsonProperty("valid_until")] - public DateTime? ValidUntil { get; private set; } - /// - /// The email address - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The URL we call to inform your application of status changes. - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Customer-Profile resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Assigned Items of the Customer-Profile resource - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private CustomerProfilesResource() - { - - } - } +{ + + public class CustomerProfilesResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum InReview = new StatusEnum("in-review"); + public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); + public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); + } + + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateCustomerProfilesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Customer-Profile. + /// + /// Create CustomerProfiles parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Create(CreateCustomerProfilesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Customer-Profile. + /// + /// Create CustomerProfiles parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task CreateAsync(CreateCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Customer-Profile. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + /// The URL we call to inform your application of status changes. + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Create(string friendlyName, + string email, + string policySid, + Uri statusCallback = null, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesOptions(friendlyName, email, policySid) { StatusCallback = statusCallback }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Customer-Profile. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + /// The URL we call to inform your application of status changes. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string email, + string policySid, + Uri statusCallback = null, + ITwilioRestClient client = null) + { + var options = new CreateCustomerProfilesOptions(friendlyName, email, policySid) { StatusCallback = statusCallback }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCustomerProfilesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// Read CustomerProfiles parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static ResourceSet Read(ReadCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// Read CustomerProfiles parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task> ReadAsync(ReadCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// The verification status of the Customer-Profile resource + /// The string that you assigned to describe the resource + /// The unique string of a policy. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static ResourceSet Read(CustomerProfilesResource.StatusEnum status = null, + string friendlyName = null, + string policySid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesOptions() { Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// The verification status of the Customer-Profile resource + /// The string that you assigned to describe the resource + /// The unique string of a policy. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task> ReadAsync(CustomerProfilesResource.StatusEnum status = null, + string friendlyName = null, + string policySid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCustomerProfilesOptions() { Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchCustomerProfilesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Customer-Profile instance. + /// + /// Fetch CustomerProfiles parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Fetch(FetchCustomerProfilesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Customer-Profile instance. + /// + /// Fetch CustomerProfiles parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task FetchAsync(FetchCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Customer-Profile instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Customer-Profile instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCustomerProfilesOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCustomerProfilesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a Customer-Profile in an account. + /// + /// Update CustomerProfiles parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Update(UpdateCustomerProfilesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a Customer-Profile in an account. + /// + /// Update CustomerProfiles parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a Customer-Profile in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Customer-Profile resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static CustomerProfilesResource Update(string pathSid, + CustomerProfilesResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateCustomerProfilesOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a Customer-Profile in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Customer-Profile resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + CustomerProfilesResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateCustomerProfilesOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCustomerProfilesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/CustomerProfiles/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Customer-Profile. + /// + /// Delete CustomerProfiles parameters + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static bool Delete(DeleteCustomerProfilesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Customer-Profile. + /// + /// Delete CustomerProfiles parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCustomerProfilesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Customer-Profile. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of CustomerProfiles + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Customer-Profile. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CustomerProfiles + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCustomerProfilesOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CustomerProfilesResource object + /// + /// Raw JSON string + /// CustomerProfilesResource object represented by the provided JSON + public static CustomerProfilesResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a policy. + /// + [JsonProperty("policy_sid")] + public string PolicySid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The verification status of the Customer-Profile resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CustomerProfilesResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource will be valid until. + /// + [JsonProperty("valid_until")] + public DateTime? ValidUntil { get; private set; } + /// + /// The email address + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The URL we call to inform your application of status changes. + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Customer-Profile resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Assigned Items of the Customer-Profile resource + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private CustomerProfilesResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/EndUserOptions.cs b/src/Twilio/Rest/Trusthub/V1/EndUserOptions.cs index 7e163170b..452acb3c1 100644 --- a/src/Twilio/Rest/Trusthub/V1/EndUserOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/EndUserOptions.cs @@ -9,185 +9,185 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Create a new End User. + /// + public class CreateEndUserOptions : IOptions + { /// - /// Create a new End User. - /// - public class CreateEndUserOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The type of end user of the Bundle resource - /// - public string Type { get; } - /// - /// The set of parameters that compose the End User resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new CreateEndUserOptions - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - public CreateEndUserOptions(string friendlyName, string type) - { - FriendlyName = friendlyName; - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all End User for an account. - /// - public class ReadEndUserOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of end user of the Bundle resource + /// + public string Type { get; } /// - /// Fetch specific End User Instance. + /// The set of parameters that compose the End User resource /// - public class FetchEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEndUserOptions - /// - /// The unique string that identifies the resource - public FetchEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public object Attributes { get; set; } + /// - /// Update an existing End User. - /// - public class UpdateEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The set of parameters that compose the End User resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new UpdateEndUserOptions - /// - /// The unique string that identifies the resource - public UpdateEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// Construct a new CreateEndUserOptions + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + public CreateEndUserOptions(string friendlyName, string type) + { + FriendlyName = friendlyName; + Type = type; + } + /// - /// Delete a specific End User. + /// Generate the necessary parameters /// - public class DeleteEndUserOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteEndUserOptions - /// - /// The unique string that identifies the resource - public DeleteEndUserOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Retrieve a list of all End User for an account. + /// + public class ReadEndUserOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific End User Instance. + /// + public class FetchEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchEndUserOptions + /// + /// The unique string that identifies the resource + public FetchEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an existing End User. + /// + public class UpdateEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The set of parameters that compose the End User resource + /// + public object Attributes { get; set; } + + /// + /// Construct a new UpdateEndUserOptions + /// + /// The unique string that identifies the resource + public UpdateEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Delete a specific End User. + /// + public class DeleteEndUserOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteEndUserOptions + /// + /// The unique string that identifies the resource + public DeleteEndUserOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/EndUserResource.cs b/src/Twilio/Rest/Trusthub/V1/EndUserResource.cs index df0280141..40a48101d 100644 --- a/src/Twilio/Rest/Trusthub/V1/EndUserResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/EndUserResource.cs @@ -16,487 +16,487 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1 -{ - - public class EndUserResource : Resource - { - private static Request BuildCreateRequest(CreateEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/EndUsers", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new End User. - /// - /// Create EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Create(CreateEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new End User. - /// - /// Create EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task CreateAsync(CreateEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new End User. - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Create(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateEndUserOptions(friendlyName, type){Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new End User. - /// - /// The string that you assigned to describe the resource - /// The type of end user of the Bundle resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateEndUserOptions(friendlyName, type){Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/EndUsers", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all End User for an account. - /// - /// Read EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static ResourceSet Read(ReadEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End User for an account. - /// - /// Read EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all End User for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of EndUser - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End User for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/EndUsers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific End User Instance. - /// - /// Fetch EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Fetch(FetchEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific End User Instance. - /// - /// Fetch EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific End User Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEndUserOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific End User Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEndUserOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/EndUsers/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing End User. - /// - /// Update EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Update(UpdateEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing End User. - /// - /// Update EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task UpdateAsync(UpdateEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing End User. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static EndUserResource Update(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateEndUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing End User. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the End User resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateEndUserOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteEndUserOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/EndUsers/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific End User. - /// - /// Delete EndUser parameters - /// Client to make requests to Twilio - /// A single instance of EndUser - public static bool Delete(DeleteEndUserOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific End User. - /// - /// Delete EndUser parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task DeleteAsync(DeleteEndUserOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific End User. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of EndUser - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEndUserOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific End User. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUser - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteEndUserOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EndUserResource object - /// - /// Raw JSON string - /// EndUserResource object represented by the provided JSON - public static EndUserResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The type of end user of the Bundle resource - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The set of parameters that compose the End Users resource - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the End User resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EndUserResource() - { - - } - } +{ + + public class EndUserResource : Resource + { + private static Request BuildCreateRequest(CreateEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/EndUsers", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new End User. + /// + /// Create EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Create(CreateEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new End User. + /// + /// Create EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task CreateAsync(CreateEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new End User. + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Create(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateEndUserOptions(friendlyName, type) { Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new End User. + /// + /// The string that you assigned to describe the resource + /// The type of end user of the Bundle resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateEndUserOptions(friendlyName, type) { Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/EndUsers", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all End User for an account. + /// + /// Read EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static ResourceSet Read(ReadEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End User for an account. + /// + /// Read EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all End User for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of EndUser + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End User for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/EndUsers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific End User Instance. + /// + /// Fetch EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Fetch(FetchEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific End User Instance. + /// + /// Fetch EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific End User Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEndUserOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific End User Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEndUserOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/EndUsers/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing End User. + /// + /// Update EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Update(UpdateEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing End User. + /// + /// Update EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task UpdateAsync(UpdateEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing End User. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static EndUserResource Update(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateEndUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing End User. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the End User resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateEndUserOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteEndUserOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/EndUsers/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific End User. + /// + /// Delete EndUser parameters + /// Client to make requests to Twilio + /// A single instance of EndUser + public static bool Delete(DeleteEndUserOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific End User. + /// + /// Delete EndUser parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task DeleteAsync(DeleteEndUserOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific End User. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of EndUser + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEndUserOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific End User. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUser + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteEndUserOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EndUserResource object + /// + /// Raw JSON string + /// EndUserResource object represented by the provided JSON + public static EndUserResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The type of end user of the Bundle resource + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The set of parameters that compose the End Users resource + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the End User resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EndUserResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/EndUserTypeOptions.cs b/src/Twilio/Rest/Trusthub/V1/EndUserTypeOptions.cs index 82619f561..b05a9cc6c 100644 --- a/src/Twilio/Rest/Trusthub/V1/EndUserTypeOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/EndUserTypeOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Retrieve a list of all End-User Types. + /// + public class ReadEndUserTypeOptions : ReadOptions + { /// - /// Retrieve a list of all End-User Types. + /// Generate the necessary parameters /// - public class ReadEndUserTypeOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific End-User Type Instance. + /// + public class FetchEndUserTypeOptions : IOptions + { /// - /// Fetch a specific End-User Type Instance. + /// The unique string that identifies the End-User Type resource /// - public class FetchEndUserTypeOptions : IOptions - { - /// - /// The unique string that identifies the End-User Type resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchEndUserTypeOptions - /// - /// The unique string that identifies the End-User Type resource - public FetchEndUserTypeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchEndUserTypeOptions + /// + /// The unique string that identifies the End-User Type resource + public FetchEndUserTypeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/EndUserTypeResource.cs b/src/Twilio/Rest/Trusthub/V1/EndUserTypeResource.cs index 0167710a5..9c0e0d413 100644 --- a/src/Twilio/Rest/Trusthub/V1/EndUserTypeResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/EndUserTypeResource.cs @@ -16,254 +16,254 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1 -{ - - public class EndUserTypeResource : Resource - { - private static Request BuildReadRequest(ReadEndUserTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/EndUserTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all End-User Types. - /// - /// Read EndUserType parameters - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static ResourceSet Read(ReadEndUserTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("end_user_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End-User Types. - /// - /// Read EndUserType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("end_user_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all End-User Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserTypeOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all End-User Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEndUserTypeOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("end_user_types", response.Content); - } - - private static Request BuildFetchRequest(FetchEndUserTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/EndUserTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific End-User Type Instance. - /// - /// Fetch EndUserType parameters - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static EndUserTypeResource Fetch(FetchEndUserTypeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific End-User Type Instance. - /// - /// Fetch EndUserType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific End-User Type Instance. - /// - /// The unique string that identifies the End-User Type resource - /// Client to make requests to Twilio - /// A single instance of EndUserType - public static EndUserTypeResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchEndUserTypeOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific End-User Type Instance. - /// - /// The unique string that identifies the End-User Type resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of EndUserType - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchEndUserTypeOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a EndUserTypeResource object - /// - /// Raw JSON string - /// EndUserTypeResource object represented by the provided JSON - public static EndUserTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the End-User Type resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the End-User Type resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// A machine-readable description of the End-User Type resource - /// - [JsonProperty("machine_name")] - public string MachineName { get; private set; } - /// - /// The required information for creating an End-User. - /// - [JsonProperty("fields")] - public List Fields { get; private set; } - /// - /// The absolute URL of the End-User Type resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private EndUserTypeResource() - { - - } - } +{ + + public class EndUserTypeResource : Resource + { + private static Request BuildReadRequest(ReadEndUserTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/EndUserTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all End-User Types. + /// + /// Read EndUserType parameters + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static ResourceSet Read(ReadEndUserTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("end_user_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End-User Types. + /// + /// Read EndUserType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task> ReadAsync(ReadEndUserTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("end_user_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all End-User Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserTypeOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all End-User Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEndUserTypeOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("end_user_types", response.Content); + } + + private static Request BuildFetchRequest(FetchEndUserTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/EndUserTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific End-User Type Instance. + /// + /// Fetch EndUserType parameters + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static EndUserTypeResource Fetch(FetchEndUserTypeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific End-User Type Instance. + /// + /// Fetch EndUserType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task FetchAsync(FetchEndUserTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific End-User Type Instance. + /// + /// The unique string that identifies the End-User Type resource + /// Client to make requests to Twilio + /// A single instance of EndUserType + public static EndUserTypeResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchEndUserTypeOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific End-User Type Instance. + /// + /// The unique string that identifies the End-User Type resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of EndUserType + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchEndUserTypeOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a EndUserTypeResource object + /// + /// Raw JSON string + /// EndUserTypeResource object represented by the provided JSON + public static EndUserTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the End-User Type resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the End-User Type resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// A machine-readable description of the End-User Type resource + /// + [JsonProperty("machine_name")] + public string MachineName { get; private set; } + /// + /// The required information for creating an End-User. + /// + [JsonProperty("fields")] + public List Fields { get; private set; } + /// + /// The absolute URL of the End-User Type resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private EndUserTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/PoliciesOptions.cs b/src/Twilio/Rest/Trusthub/V1/PoliciesOptions.cs index b60c74537..0088f3d94 100644 --- a/src/Twilio/Rest/Trusthub/V1/PoliciesOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/PoliciesOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Retrieve a list of all Policys. + /// + public class ReadPoliciesOptions : ReadOptions + { /// - /// Retrieve a list of all Policys. + /// Generate the necessary parameters /// - public class ReadPoliciesOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Policy Instance. + /// + public class FetchPoliciesOptions : IOptions + { /// - /// Fetch specific Policy Instance. + /// The unique string that identifies the Policy resource /// - public class FetchPoliciesOptions : IOptions - { - /// - /// The unique string that identifies the Policy resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPoliciesOptions - /// - /// The unique string that identifies the Policy resource - public FetchPoliciesOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchPoliciesOptions + /// + /// The unique string that identifies the Policy resource + public FetchPoliciesOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/PoliciesResource.cs b/src/Twilio/Rest/Trusthub/V1/PoliciesResource.cs index 3a8e05849..972d8d75b 100644 --- a/src/Twilio/Rest/Trusthub/V1/PoliciesResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/PoliciesResource.cs @@ -17,262 +17,262 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1 -{ - - public class PoliciesResource : Resource - { - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildReadRequest(ReadPoliciesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/Policies", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Policys. - /// - /// Read Policies parameters - /// Client to make requests to Twilio - /// A single instance of Policies - public static ResourceSet Read(ReadPoliciesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Policys. - /// - /// Read Policies parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Policies - public static async System.Threading.Tasks.Task> ReadAsync(ReadPoliciesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Policys. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Policies - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPoliciesOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Policys. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Policies - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPoliciesOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchPoliciesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/Policies/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Policy Instance. - /// - /// Fetch Policies parameters - /// Client to make requests to Twilio - /// A single instance of Policies - public static PoliciesResource Fetch(FetchPoliciesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Policy Instance. - /// - /// Fetch Policies parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Policies - public static async System.Threading.Tasks.Task FetchAsync(FetchPoliciesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Policy Instance. - /// - /// The unique string that identifies the Policy resource - /// Client to make requests to Twilio - /// A single instance of Policies - public static PoliciesResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchPoliciesOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Policy Instance. - /// - /// The unique string that identifies the Policy resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Policies - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPoliciesOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a PoliciesResource object - /// - /// Raw JSON string - /// PoliciesResource object represented by the provided JSON - public static PoliciesResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Policy resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the Policy resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The sid of a Policy object that dictates requirements - /// - [JsonProperty("requirements")] - public object Requirements { get; private set; } - /// - /// The absolute URL of the Policy resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private PoliciesResource() - { - - } - } +{ + + public class PoliciesResource : Resource + { + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildReadRequest(ReadPoliciesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/Policies", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Policys. + /// + /// Read Policies parameters + /// Client to make requests to Twilio + /// A single instance of Policies + public static ResourceSet Read(ReadPoliciesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Policys. + /// + /// Read Policies parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Policies + public static async System.Threading.Tasks.Task> ReadAsync(ReadPoliciesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Policys. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Policies + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPoliciesOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Policys. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Policies + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPoliciesOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchPoliciesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/Policies/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Policy Instance. + /// + /// Fetch Policies parameters + /// Client to make requests to Twilio + /// A single instance of Policies + public static PoliciesResource Fetch(FetchPoliciesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Policy Instance. + /// + /// Fetch Policies parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Policies + public static async System.Threading.Tasks.Task FetchAsync(FetchPoliciesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Policy Instance. + /// + /// The unique string that identifies the Policy resource + /// Client to make requests to Twilio + /// A single instance of Policies + public static PoliciesResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchPoliciesOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Policy Instance. + /// + /// The unique string that identifies the Policy resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Policies + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPoliciesOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a PoliciesResource object + /// + /// Raw JSON string + /// PoliciesResource object represented by the provided JSON + public static PoliciesResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Policy resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the Policy resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The sid of a Policy object that dictates requirements + /// + [JsonProperty("requirements")] + public object Requirements { get; private set; } + /// + /// The absolute URL of the Policy resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private PoliciesResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentOptions.cs b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentOptions.cs index 8f059b9ef..fd158dcff 100644 --- a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentOptions.cs @@ -9,185 +9,185 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Create a new Supporting Document. + /// + public class CreateSupportingDocumentOptions : IOptions + { /// - /// Create a new Supporting Document. - /// - public class CreateSupportingDocumentOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The type of the Supporting Document - /// - public string Type { get; } - /// - /// The set of parameters that compose the Supporting Documents resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new CreateSupportingDocumentOptions - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - public CreateSupportingDocumentOptions(string friendlyName, string type) - { - FriendlyName = friendlyName; - Type = type; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all Supporting Document for an account. - /// - public class ReadSupportingDocumentOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of the Supporting Document + /// + public string Type { get; } /// - /// Fetch specific Supporting Document Instance. + /// The set of parameters that compose the Supporting Documents resource /// - public class FetchSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public FetchSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public object Attributes { get; set; } + /// - /// Update an existing Supporting Document. - /// - public class UpdateSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The set of parameters that compose the Supporting Document resource - /// - public object Attributes { get; set; } - - /// - /// Construct a new UpdateSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public UpdateSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Attributes != null) - { - p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); - } - - return p; - } - } - + /// Construct a new CreateSupportingDocumentOptions + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + public CreateSupportingDocumentOptions(string friendlyName, string type) + { + FriendlyName = friendlyName; + Type = type; + } + /// - /// Delete a specific Supporting Document. + /// Generate the necessary parameters /// - public class DeleteSupportingDocumentOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSupportingDocumentOptions - /// - /// The unique string that identifies the resource - public DeleteSupportingDocumentOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + public class ReadSupportingDocumentOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Supporting Document Instance. + /// + public class FetchSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public FetchSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update an existing Supporting Document. + /// + public class UpdateSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The set of parameters that compose the Supporting Document resource + /// + public object Attributes { get; set; } + + /// + /// Construct a new UpdateSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public UpdateSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Attributes != null) + { + p.Add(new KeyValuePair("Attributes", Serializers.JsonObject(Attributes))); + } + + return p; + } + } + + /// + /// Delete a specific Supporting Document. + /// + public class DeleteSupportingDocumentOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSupportingDocumentOptions + /// + /// The unique string that identifies the resource + public DeleteSupportingDocumentOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentResource.cs b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentResource.cs index e4138ab6a..92f6f487d 100644 --- a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentResource.cs @@ -17,521 +17,521 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1 -{ - - public class SupportingDocumentResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum Rejected = new StatusEnum("rejected"); - public static readonly StatusEnum Approved = new StatusEnum("approved"); - public static readonly StatusEnum Expired = new StatusEnum("expired"); - public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); - } - - private static Request BuildCreateRequest(CreateSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/SupportingDocuments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Supporting Document. - /// - /// Create SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Create(CreateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Supporting Document. - /// - /// Create SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task CreateAsync(CreateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Supporting Document. - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - /// The set of parameters that compose the Supporting Documents resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Create(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateSupportingDocumentOptions(friendlyName, type){Attributes = attributes}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Supporting Document. - /// - /// The string that you assigned to describe the resource - /// The type of the Supporting Document - /// The set of parameters that compose the Supporting Documents resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string type, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new CreateSupportingDocumentOptions(friendlyName, type){Attributes = attributes}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/SupportingDocuments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Read SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static ResourceSet Read(ReadSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Read SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/SupportingDocuments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Supporting Document Instance. - /// - /// Fetch SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Fetch(FetchSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Supporting Document Instance. - /// - /// Fetch SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Supporting Document Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Supporting Document Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/SupportingDocuments/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update an existing Supporting Document. - /// - /// Update SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Update(UpdateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update an existing Supporting Document. - /// - /// Update SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update an existing Supporting Document. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the Supporting Document resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static SupportingDocumentResource Update(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateSupportingDocumentOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update an existing Supporting Document. - /// - /// The unique string that identifies the resource - /// The string that you assigned to describe the resource - /// The set of parameters that compose the Supporting Document resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - object attributes = null, - ITwilioRestClient client = null) - { - var options = new UpdateSupportingDocumentOptions(pathSid){FriendlyName = friendlyName, Attributes = attributes}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSupportingDocumentOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/SupportingDocuments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Supporting Document. - /// - /// Delete SupportingDocument parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static bool Delete(DeleteSupportingDocumentOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Supporting Document. - /// - /// Delete SupportingDocument parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSupportingDocumentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Supporting Document. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocument - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSupportingDocumentOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Supporting Document. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocument - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSupportingDocumentOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SupportingDocumentResource object - /// - /// Raw JSON string - /// SupportingDocumentResource object represented by the provided JSON - public static SupportingDocumentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The image type of the file - /// - [JsonProperty("mime_type")] - public string MimeType { get; private set; } - /// - /// The verification status of the Supporting Document resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SupportingDocumentResource.StatusEnum Status { get; private set; } - /// - /// The type of the Supporting Document - /// - [JsonProperty("type")] - public string Type { get; private set; } - /// - /// The set of parameters that compose the Supporting Documents resource - /// - [JsonProperty("attributes")] - public object Attributes { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Supporting Document resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SupportingDocumentResource() - { - - } - } +{ + + public class SupportingDocumentResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum Rejected = new StatusEnum("rejected"); + public static readonly StatusEnum Approved = new StatusEnum("approved"); + public static readonly StatusEnum Expired = new StatusEnum("expired"); + public static readonly StatusEnum ProvisionallyApproved = new StatusEnum("provisionally-approved"); + } + + private static Request BuildCreateRequest(CreateSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/SupportingDocuments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Supporting Document. + /// + /// Create SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Create(CreateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Supporting Document. + /// + /// Create SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task CreateAsync(CreateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Supporting Document. + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + /// The set of parameters that compose the Supporting Documents resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Create(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateSupportingDocumentOptions(friendlyName, type) { Attributes = attributes }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Supporting Document. + /// + /// The string that you assigned to describe the resource + /// The type of the Supporting Document + /// The set of parameters that compose the Supporting Documents resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string type, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new CreateSupportingDocumentOptions(friendlyName, type) { Attributes = attributes }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/SupportingDocuments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Read SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static ResourceSet Read(ReadSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Read SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/SupportingDocuments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Supporting Document Instance. + /// + /// Fetch SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Fetch(FetchSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Supporting Document Instance. + /// + /// Fetch SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Supporting Document Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Supporting Document Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/SupportingDocuments/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update an existing Supporting Document. + /// + /// Update SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Update(UpdateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update an existing Supporting Document. + /// + /// Update SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update an existing Supporting Document. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the Supporting Document resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static SupportingDocumentResource Update(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateSupportingDocumentOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update an existing Supporting Document. + /// + /// The unique string that identifies the resource + /// The string that you assigned to describe the resource + /// The set of parameters that compose the Supporting Document resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + object attributes = null, + ITwilioRestClient client = null) + { + var options = new UpdateSupportingDocumentOptions(pathSid) { FriendlyName = friendlyName, Attributes = attributes }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSupportingDocumentOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/SupportingDocuments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Supporting Document. + /// + /// Delete SupportingDocument parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static bool Delete(DeleteSupportingDocumentOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Supporting Document. + /// + /// Delete SupportingDocument parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSupportingDocumentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Supporting Document. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocument + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSupportingDocumentOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Supporting Document. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocument + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSupportingDocumentOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SupportingDocumentResource object + /// + /// Raw JSON string + /// SupportingDocumentResource object represented by the provided JSON + public static SupportingDocumentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The image type of the file + /// + [JsonProperty("mime_type")] + public string MimeType { get; private set; } + /// + /// The verification status of the Supporting Document resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SupportingDocumentResource.StatusEnum Status { get; private set; } + /// + /// The type of the Supporting Document + /// + [JsonProperty("type")] + public string Type { get; private set; } + /// + /// The set of parameters that compose the Supporting Documents resource + /// + [JsonProperty("attributes")] + public object Attributes { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Supporting Document resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SupportingDocumentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeOptions.cs b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeOptions.cs index 32ac06975..8ee5d73b6 100644 --- a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeOptions.cs @@ -9,55 +9,55 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Retrieve a list of all Supporting Document Types. + /// + public class ReadSupportingDocumentTypeOptions : ReadOptions + { /// - /// Retrieve a list of all Supporting Document Types. + /// Generate the necessary parameters /// - public class ReadSupportingDocumentTypeOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + public class FetchSupportingDocumentTypeOptions : IOptions + { /// - /// Fetch a specific Supporting Document Type Instance. + /// The unique string that identifies the Supporting Document Type resource /// - public class FetchSupportingDocumentTypeOptions : IOptions - { - /// - /// The unique string that identifies the Supporting Document Type resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSupportingDocumentTypeOptions - /// - /// The unique string that identifies the Supporting Document Type resource - public FetchSupportingDocumentTypeOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchSupportingDocumentTypeOptions + /// + /// The unique string that identifies the Supporting Document Type resource + public FetchSupportingDocumentTypeOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeResource.cs b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeResource.cs index ee8488f05..781a5b254 100644 --- a/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/SupportingDocumentTypeResource.cs @@ -16,258 +16,258 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1 -{ - - public class SupportingDocumentTypeResource : Resource - { - private static Request BuildReadRequest(ReadSupportingDocumentTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/SupportingDocumentTypes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Read SupportingDocumentType parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static ResourceSet Read(ReadSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("supporting_document_types", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Read SupportingDocumentType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("supporting_document_types", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentTypeOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Supporting Document Types. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSupportingDocumentTypeOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("supporting_document_types", response.Content); - } - - private static Request BuildFetchRequest(FetchSupportingDocumentTypeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/SupportingDocumentTypes/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// Fetch SupportingDocumentType parameters - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static SupportingDocumentTypeResource Fetch(FetchSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// Fetch SupportingDocumentType parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentTypeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// The unique string that identifies the Supporting Document Type resource - /// Client to make requests to Twilio - /// A single instance of SupportingDocumentType - public static SupportingDocumentTypeResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentTypeOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Supporting Document Type Instance. - /// - /// The unique string that identifies the Supporting Document Type resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SupportingDocumentType - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSupportingDocumentTypeOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SupportingDocumentTypeResource object - /// - /// Raw JSON string - /// SupportingDocumentTypeResource object represented by the provided JSON - public static SupportingDocumentTypeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Supporting Document Type resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// A human-readable description of the Supporting Document Type resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The machine-readable description of the Supporting Document Type resource - /// - [JsonProperty("machine_name")] - public string MachineName { get; private set; } - /// - /// The required information for creating a Supporting Document - /// - [JsonProperty("fields")] - public List Fields { get; private set; } - /// - /// The absolute URL of the Supporting Document Type resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SupportingDocumentTypeResource() - { - - } - } +{ + + public class SupportingDocumentTypeResource : Resource + { + private static Request BuildReadRequest(ReadSupportingDocumentTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/SupportingDocumentTypes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Read SupportingDocumentType parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static ResourceSet Read(ReadSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("supporting_document_types", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Read SupportingDocumentType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task> ReadAsync(ReadSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("supporting_document_types", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentTypeOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Supporting Document Types. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSupportingDocumentTypeOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("supporting_document_types", response.Content); + } + + private static Request BuildFetchRequest(FetchSupportingDocumentTypeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/SupportingDocumentTypes/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// Fetch SupportingDocumentType parameters + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static SupportingDocumentTypeResource Fetch(FetchSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// Fetch SupportingDocumentType parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task FetchAsync(FetchSupportingDocumentTypeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// The unique string that identifies the Supporting Document Type resource + /// Client to make requests to Twilio + /// A single instance of SupportingDocumentType + public static SupportingDocumentTypeResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentTypeOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Supporting Document Type Instance. + /// + /// The unique string that identifies the Supporting Document Type resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SupportingDocumentType + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSupportingDocumentTypeOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SupportingDocumentTypeResource object + /// + /// Raw JSON string + /// SupportingDocumentTypeResource object represented by the provided JSON + public static SupportingDocumentTypeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Supporting Document Type resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// A human-readable description of the Supporting Document Type resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The machine-readable description of the Supporting Document Type resource + /// + [JsonProperty("machine_name")] + public string MachineName { get; private set; } + /// + /// The required information for creating a Supporting Document + /// + [JsonProperty("fields")] + public List Fields { get; private set; } + /// + /// The absolute URL of the Supporting Document Type resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SupportingDocumentTypeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentOptions.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentOptions.cs index f72b835cc..9c6e008ca 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentOptions.cs @@ -9,181 +9,181 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - +{ + + /// + /// Create a new Assigned Item. + /// + public class CreateTrustProductsChannelEndpointAssignmentOptions : IOptions + { /// - /// Create a new Assigned Item. - /// - public class CreateTrustProductsChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The type of channel endpoint - /// - public string ChannelEndpointType { get; } - /// - /// The sid of an channel endpoint - /// - public string ChannelEndpointSid { get; } - - /// - /// Construct a new CreateTrustProductsChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - public CreateTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, - string channelEndpointType, - string channelEndpointSid) - { - PathTrustProductSid = pathTrustProductSid; - ChannelEndpointType = channelEndpointType; - ChannelEndpointSid = channelEndpointSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ChannelEndpointType != null) - { - p.Add(new KeyValuePair("ChannelEndpointType", ChannelEndpointType)); - } - - if (ChannelEndpointSid != null) - { - p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); - } - - return p; - } - } - + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } /// - /// Retrieve a list of all Assigned Items for an account. - /// - public class ReadTrustProductsChannelEndpointAssignmentOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The sid of an channel endpoint - /// - public string ChannelEndpointSid { get; set; } - /// - /// comma separated list of channel endpoint sids - /// - public string ChannelEndpointSids { get; set; } - - /// - /// Construct a new ReadTrustProductsChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - public ReadTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid) - { - PathTrustProductSid = pathTrustProductSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (ChannelEndpointSid != null) - { - p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); - } - - if (ChannelEndpointSids != null) - { - p.Add(new KeyValuePair("ChannelEndpointSids", ChannelEndpointSids)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The type of channel endpoint + /// + public string ChannelEndpointType { get; } /// - /// Fetch specific Assigned Item Instance. - /// - public class FetchTrustProductsChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTrustProductsChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public FetchTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, string pathSid) - { - PathTrustProductSid = pathTrustProductSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The sid of an channel endpoint + /// + public string ChannelEndpointSid { get; } + /// - /// Remove an Assignment Item Instance. - /// - public class DeleteTrustProductsChannelEndpointAssignmentOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTrustProductsChannelEndpointAssignmentOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public DeleteTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, string pathSid) - { - PathTrustProductSid = pathTrustProductSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateTrustProductsChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + public CreateTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, + string channelEndpointType, + string channelEndpointSid) + { + PathTrustProductSid = pathTrustProductSid; + ChannelEndpointType = channelEndpointType; + ChannelEndpointSid = channelEndpointSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (ChannelEndpointType != null) + { + p.Add(new KeyValuePair("ChannelEndpointType", ChannelEndpointType)); + } + + if (ChannelEndpointSid != null) + { + p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + public class ReadTrustProductsChannelEndpointAssignmentOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + /// + /// The sid of an channel endpoint + /// + public string ChannelEndpointSid { get; set; } + /// + /// comma separated list of channel endpoint sids + /// + public string ChannelEndpointSids { get; set; } + + /// + /// Construct a new ReadTrustProductsChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + public ReadTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid) + { + PathTrustProductSid = pathTrustProductSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (ChannelEndpointSid != null) + { + p.Add(new KeyValuePair("ChannelEndpointSid", ChannelEndpointSid.ToString())); + } + + if (ChannelEndpointSids != null) + { + p.Add(new KeyValuePair("ChannelEndpointSids", ChannelEndpointSids)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Assigned Item Instance. + /// + public class FetchTrustProductsChannelEndpointAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchTrustProductsChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public FetchTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, string pathSid) + { + PathTrustProductSid = pathTrustProductSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an Assignment Item Instance. + /// + public class DeleteTrustProductsChannelEndpointAssignmentOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTrustProductsChannelEndpointAssignmentOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public DeleteTrustProductsChannelEndpointAssignmentOptions(string pathTrustProductSid, string pathSid) + { + PathTrustProductSid = pathTrustProductSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentResource.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentResource.cs index 24e5293a8..8ea9f4dd8 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsChannelEndpointAssignmentResource.cs @@ -16,438 +16,438 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - - public class TrustProductsChannelEndpointAssignmentResource : Resource - { - private static Request BuildCreateRequest(CreateTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Assigned Item. - /// - /// Create TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static TrustProductsChannelEndpointAssignmentResource Create(CreateTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// Create TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static TrustProductsChannelEndpointAssignmentResource Create(string pathTrustProductSid, - string channelEndpointType, - string channelEndpointSid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, channelEndpointType, channelEndpointSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The type of channel endpoint - /// The sid of an channel endpoint - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, - string channelEndpointType, - string channelEndpointSid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, channelEndpointType, channelEndpointSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static ResourceSet Read(ReadTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// The sid of an channel endpoint - /// comma separated list of channel endpoint sids - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static ResourceSet Read(string pathTrustProductSid, - string channelEndpointSid = null, - string channelEndpointSids = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid){ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// The sid of an channel endpoint - /// comma separated list of channel endpoint sids - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, - string channelEndpointSid = null, - string channelEndpointSids = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid){ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, - ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static TrustProductsChannelEndpointAssignmentResource Fetch(FetchTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static TrustProductsChannelEndpointAssignmentResource Fetch(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Assignment Item Instance. - /// - /// Delete TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static bool Delete(DeleteTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// Delete TrustProductsChannelEndpointAssignment parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsChannelEndpointAssignmentOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of TrustProductsChannelEndpointAssignment - public static bool Delete(string pathTrustProductSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TrustProductsChannelEndpointAssignmentResource object - /// - /// Raw JSON string - /// TrustProductsChannelEndpointAssignmentResource object represented by the provided JSON - public static TrustProductsChannelEndpointAssignmentResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the CustomerProfile resource. - /// - [JsonProperty("trust_product_sid")] - public string TrustProductSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The type of channel endpoint - /// - [JsonProperty("channel_endpoint_type")] - public string ChannelEndpointType { get; private set; } - /// - /// The sid of an channel endpoint - /// - [JsonProperty("channel_endpoint_sid")] - public string ChannelEndpointSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Identity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TrustProductsChannelEndpointAssignmentResource() - { - - } - } +{ + + public class TrustProductsChannelEndpointAssignmentResource : Resource + { + private static Request BuildCreateRequest(CreateTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Assigned Item. + /// + /// Create TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static TrustProductsChannelEndpointAssignmentResource Create(CreateTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// Create TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static TrustProductsChannelEndpointAssignmentResource Create(string pathTrustProductSid, + string channelEndpointType, + string channelEndpointSid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, channelEndpointType, channelEndpointSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The type of channel endpoint + /// The sid of an channel endpoint + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, + string channelEndpointType, + string channelEndpointSid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, channelEndpointType, channelEndpointSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static ResourceSet Read(ReadTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// The sid of an channel endpoint + /// comma separated list of channel endpoint sids + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static ResourceSet Read(string pathTrustProductSid, + string channelEndpointSid = null, + string channelEndpointSids = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid) { ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// The sid of an channel endpoint + /// comma separated list of channel endpoint sids + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, + string channelEndpointSid = null, + string channelEndpointSids = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid) { ChannelEndpointSid = channelEndpointSid, ChannelEndpointSids = channelEndpointSids, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, + ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static TrustProductsChannelEndpointAssignmentResource Fetch(FetchTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static TrustProductsChannelEndpointAssignmentResource Fetch(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/ChannelEndpointAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Assignment Item Instance. + /// + /// Delete TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static bool Delete(DeleteTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// Delete TrustProductsChannelEndpointAssignment parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsChannelEndpointAssignmentOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of TrustProductsChannelEndpointAssignment + public static bool Delete(string pathTrustProductSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsChannelEndpointAssignment + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsChannelEndpointAssignmentOptions(pathTrustProductSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TrustProductsChannelEndpointAssignmentResource object + /// + /// Raw JSON string + /// TrustProductsChannelEndpointAssignmentResource object represented by the provided JSON + public static TrustProductsChannelEndpointAssignmentResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the CustomerProfile resource. + /// + [JsonProperty("trust_product_sid")] + public string TrustProductSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The type of channel endpoint + /// + [JsonProperty("channel_endpoint_type")] + public string ChannelEndpointType { get; private set; } + /// + /// The sid of an channel endpoint + /// + [JsonProperty("channel_endpoint_sid")] + public string ChannelEndpointSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Identity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TrustProductsChannelEndpointAssignmentResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsOptions.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsOptions.cs index 26467ff03..09c921f68 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsOptions.cs @@ -9,150 +9,150 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - +{ + + /// + /// Create a new Assigned Item. + /// + public class CreateTrustProductsEntityAssignmentsOptions : IOptions + { /// - /// Create a new Assigned Item. + /// The unique string that identifies the resource. /// - public class CreateTrustProductsEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The sid of an object bag - /// - public string ObjectSid { get; } - - /// - /// Construct a new CreateTrustProductsEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - public CreateTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string objectSid) - { - PathTrustProductSid = pathTrustProductSid; - ObjectSid = objectSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (ObjectSid != null) - { - p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); - } - - return p; - } - } - + public string PathTrustProductSid { get; } /// - /// Retrieve a list of all Assigned Items for an account. + /// The sid of an object bag /// - public class ReadTrustProductsEntityAssignmentsOptions : ReadOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - - /// - /// Construct a new ReadTrustProductsEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - public ReadTrustProductsEntityAssignmentsOptions(string pathTrustProductSid) - { - PathTrustProductSid = pathTrustProductSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string ObjectSid { get; } + /// - /// Fetch specific Assigned Item Instance. + /// Construct a new CreateTrustProductsEntityAssignmentsOptions /// - public class FetchTrustProductsEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTrustProductsEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public FetchTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string pathSid) - { - PathTrustProductSid = pathTrustProductSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The unique string that identifies the resource. + /// The sid of an object bag + public CreateTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string objectSid) + { + PathTrustProductSid = pathTrustProductSid; + ObjectSid = objectSid; + } + /// - /// Remove an Assignment Item Instance. + /// Generate the necessary parameters /// - public class DeleteTrustProductsEntityAssignmentsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathTrustProductSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTrustProductsEntityAssignmentsOptions - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - public DeleteTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string pathSid) - { - PathTrustProductSid = pathTrustProductSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (ObjectSid != null) + { + p.Add(new KeyValuePair("ObjectSid", ObjectSid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + public class ReadTrustProductsEntityAssignmentsOptions : ReadOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + + /// + /// Construct a new ReadTrustProductsEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + public ReadTrustProductsEntityAssignmentsOptions(string pathTrustProductSid) + { + PathTrustProductSid = pathTrustProductSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Assigned Item Instance. + /// + public class FetchTrustProductsEntityAssignmentsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchTrustProductsEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public FetchTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string pathSid) + { + PathTrustProductSid = pathTrustProductSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Remove an Assignment Item Instance. + /// + public class DeleteTrustProductsEntityAssignmentsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathTrustProductSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTrustProductsEntityAssignmentsOptions + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + public DeleteTrustProductsEntityAssignmentsOptions(string pathTrustProductSid, string pathSid) + { + PathTrustProductSid = pathTrustProductSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsResource.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsResource.cs index 48682bfeb..4c8c5a5db 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEntityAssignmentsResource.cs @@ -16,418 +16,418 @@ using Twilio.Http; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - - public class TrustProductsEntityAssignmentsResource : Resource - { - private static Request BuildCreateRequest(CreateTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Assigned Item. - /// - /// Create TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static TrustProductsEntityAssignmentsResource Create(CreateTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// Create TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static TrustProductsEntityAssignmentsResource Create(string pathTrustProductSid, - string objectSid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsEntityAssignmentsOptions(pathTrustProductSid, objectSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Assigned Item. - /// - /// The unique string that identifies the resource. - /// The sid of an object bag - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, - string objectSid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsEntityAssignmentsOptions(pathTrustProductSid, objectSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTrustProductsEntityAssignmentsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static ResourceSet Read(ReadTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// Read TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static ResourceSet Read(string pathTrustProductSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsEntityAssignmentsOptions(pathTrustProductSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Assigned Items for an account. - /// - /// The unique string that identifies the resource. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsEntityAssignmentsOptions(pathTrustProductSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static TrustProductsEntityAssignmentsResource Fetch(FetchTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// Fetch TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static TrustProductsEntityAssignmentsResource Fetch(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Assigned Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Remove an Assignment Item Instance. - /// - /// Delete TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static bool Delete(DeleteTrustProductsEntityAssignmentsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// Delete TrustProductsEntityAssignments parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsEntityAssignmentsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of TrustProductsEntityAssignments - public static bool Delete(string pathTrustProductSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Remove an Assignment Item Instance. - /// - /// The unique string that identifies the resource. - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEntityAssignments - public static async System.Threading.Tasks.Task DeleteAsync(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TrustProductsEntityAssignmentsResource object - /// - /// Raw JSON string - /// TrustProductsEntityAssignmentsResource object represented by the provided JSON - public static TrustProductsEntityAssignmentsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies the TrustProduct resource. - /// - [JsonProperty("trust_product_sid")] - public string TrustProductSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The sid of an object bag - /// - [JsonProperty("object_sid")] - public string ObjectSid { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The absolute URL of the Identity resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TrustProductsEntityAssignmentsResource() - { - - } - } +{ + + public class TrustProductsEntityAssignmentsResource : Resource + { + private static Request BuildCreateRequest(CreateTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Assigned Item. + /// + /// Create TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static TrustProductsEntityAssignmentsResource Create(CreateTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// Create TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static TrustProductsEntityAssignmentsResource Create(string pathTrustProductSid, + string objectSid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsEntityAssignmentsOptions(pathTrustProductSid, objectSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Assigned Item. + /// + /// The unique string that identifies the resource. + /// The sid of an object bag + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, + string objectSid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsEntityAssignmentsOptions(pathTrustProductSid, objectSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTrustProductsEntityAssignmentsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static ResourceSet Read(ReadTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// Read TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static ResourceSet Read(string pathTrustProductSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsEntityAssignmentsOptions(pathTrustProductSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Assigned Items for an account. + /// + /// The unique string that identifies the resource. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsEntityAssignmentsOptions(pathTrustProductSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static TrustProductsEntityAssignmentsResource Fetch(FetchTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// Fetch TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static TrustProductsEntityAssignmentsResource Fetch(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Assigned Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/EntityAssignments/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Remove an Assignment Item Instance. + /// + /// Delete TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static bool Delete(DeleteTrustProductsEntityAssignmentsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// Delete TrustProductsEntityAssignments parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsEntityAssignmentsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of TrustProductsEntityAssignments + public static bool Delete(string pathTrustProductSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Remove an Assignment Item Instance. + /// + /// The unique string that identifies the resource. + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEntityAssignments + public static async System.Threading.Tasks.Task DeleteAsync(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsEntityAssignmentsOptions(pathTrustProductSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TrustProductsEntityAssignmentsResource object + /// + /// Raw JSON string + /// TrustProductsEntityAssignmentsResource object represented by the provided JSON + public static TrustProductsEntityAssignmentsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies the TrustProduct resource. + /// + [JsonProperty("trust_product_sid")] + public string TrustProductSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The sid of an object bag + /// + [JsonProperty("object_sid")] + public string ObjectSid { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The absolute URL of the Identity resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TrustProductsEntityAssignmentsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsOptions.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsOptions.cs index 5eebccebe..aa042ca61 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsOptions.cs @@ -9,115 +9,115 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - +{ + + /// + /// Create a new Evaluation + /// + public class CreateTrustProductsEvaluationsOptions : IOptions + { /// - /// Create a new Evaluation + /// The unique string that identifies the resource /// - public class CreateTrustProductsEvaluationsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathTrustProductSid { get; } - /// - /// The unique string of a policy - /// - public string PolicySid { get; } - - /// - /// Construct a new CreateTrustProductsEvaluationsOptions - /// - /// The unique string that identifies the resource - /// The unique string of a policy - public CreateTrustProductsEvaluationsOptions(string pathTrustProductSid, string policySid) - { - PathTrustProductSid = pathTrustProductSid; - PolicySid = policySid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - return p; - } - } - + public string PathTrustProductSid { get; } /// - /// Retrieve a list of Evaluations associated to the trust_product resource. + /// The unique string of a policy /// - public class ReadTrustProductsEvaluationsOptions : ReadOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathTrustProductSid { get; } - - /// - /// Construct a new ReadTrustProductsEvaluationsOptions - /// - /// The unique string that identifies the resource - public ReadTrustProductsEvaluationsOptions(string pathTrustProductSid) - { - PathTrustProductSid = pathTrustProductSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PolicySid { get; } + /// - /// Fetch specific Evaluation Instance. + /// Construct a new CreateTrustProductsEvaluationsOptions /// - public class FetchTrustProductsEvaluationsOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathTrustProductSid { get; } - /// - /// The unique string that identifies the Evaluation resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTrustProductsEvaluationsOptions - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - public FetchTrustProductsEvaluationsOptions(string pathTrustProductSid, string pathSid) - { - PathTrustProductSid = pathTrustProductSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The unique string that identifies the resource + /// The unique string of a policy + public CreateTrustProductsEvaluationsOptions(string pathTrustProductSid, string policySid) + { + PathTrustProductSid = pathTrustProductSid; + PolicySid = policySid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + return p; + } + } + + /// + /// Retrieve a list of Evaluations associated to the trust_product resource. + /// + public class ReadTrustProductsEvaluationsOptions : ReadOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathTrustProductSid { get; } + + /// + /// Construct a new ReadTrustProductsEvaluationsOptions + /// + /// The unique string that identifies the resource + public ReadTrustProductsEvaluationsOptions(string pathTrustProductSid) + { + PathTrustProductSid = pathTrustProductSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Evaluation Instance. + /// + public class FetchTrustProductsEvaluationsOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathTrustProductSid { get; } + /// + /// The unique string that identifies the Evaluation resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchTrustProductsEvaluationsOptions + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + public FetchTrustProductsEvaluationsOptions(string pathTrustProductSid, string pathSid) + { + PathTrustProductSid = pathTrustProductSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsResource.cs b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsResource.cs index 0660cdbc6..9d470396f 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProducts/TrustProductsEvaluationsResource.cs @@ -17,369 +17,369 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1.TrustProducts -{ - - public class TrustProductsEvaluationsResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Compliant = new StatusEnum("compliant"); - public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); - } - - private static Request BuildCreateRequest(CreateTrustProductsEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Evaluation - /// - /// Create TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static TrustProductsEvaluationsResource Create(CreateTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Evaluation - /// - /// Create TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Evaluation - /// - /// The unique string that identifies the resource - /// The unique string of a policy - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static TrustProductsEvaluationsResource Create(string pathTrustProductSid, - string policySid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsEvaluationsOptions(pathTrustProductSid, policySid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Evaluation - /// - /// The unique string that identifies the resource - /// The unique string of a policy - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, - string policySid, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsEvaluationsOptions(pathTrustProductSid, policySid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTrustProductsEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Evaluations associated to the trust_product resource. - /// - /// Read TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static ResourceSet Read(ReadTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the trust_product resource. - /// - /// Read TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Evaluations associated to the trust_product resource. - /// - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static ResourceSet Read(string pathTrustProductSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsEvaluationsOptions(pathTrustProductSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Evaluations associated to the trust_product resource. - /// - /// The unique string that identifies the resource - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsEvaluationsOptions(pathTrustProductSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchTrustProductsEvaluationsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static TrustProductsEvaluationsResource Fetch(FetchTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// Fetch TrustProductsEvaluations parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsEvaluationsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// A single instance of TrustProductsEvaluations - public static TrustProductsEvaluationsResource Fetch(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsEvaluationsOptions(pathTrustProductSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Evaluation Instance. - /// - /// The unique string that identifies the resource - /// The unique string that identifies the Evaluation resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProductsEvaluations - public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsEvaluationsOptions(pathTrustProductSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TrustProductsEvaluationsResource object - /// - /// Raw JSON string - /// TrustProductsEvaluationsResource object represented by the provided JSON - public static TrustProductsEvaluationsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Evaluation resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a policy - /// - [JsonProperty("policy_sid")] - public string PolicySid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("trust_product_sid")] - public string TrustProductSid { get; private set; } - /// - /// The compliance status of the Evaluation resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public TrustProductsEvaluationsResource.StatusEnum Status { get; private set; } - /// - /// The results of the Evaluation resource - /// - [JsonProperty("results")] - public List Results { get; private set; } - /// - /// The date_created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private TrustProductsEvaluationsResource() - { - - } - } +{ + + public class TrustProductsEvaluationsResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Compliant = new StatusEnum("compliant"); + public static readonly StatusEnum Noncompliant = new StatusEnum("noncompliant"); + } + + private static Request BuildCreateRequest(CreateTrustProductsEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Evaluation + /// + /// Create TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static TrustProductsEvaluationsResource Create(CreateTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Evaluation + /// + /// Create TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Evaluation + /// + /// The unique string that identifies the resource + /// The unique string of a policy + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static TrustProductsEvaluationsResource Create(string pathTrustProductSid, + string policySid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsEvaluationsOptions(pathTrustProductSid, policySid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Evaluation + /// + /// The unique string that identifies the resource + /// The unique string of a policy + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task CreateAsync(string pathTrustProductSid, + string policySid, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsEvaluationsOptions(pathTrustProductSid, policySid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTrustProductsEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Evaluations associated to the trust_product resource. + /// + /// Read TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static ResourceSet Read(ReadTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the trust_product resource. + /// + /// Read TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Evaluations associated to the trust_product resource. + /// + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static ResourceSet Read(string pathTrustProductSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsEvaluationsOptions(pathTrustProductSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Evaluations associated to the trust_product resource. + /// + /// The unique string that identifies the resource + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task> ReadAsync(string pathTrustProductSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsEvaluationsOptions(pathTrustProductSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchTrustProductsEvaluationsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathTrustProductSid + "/Evaluations/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static TrustProductsEvaluationsResource Fetch(FetchTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// Fetch TrustProductsEvaluations parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsEvaluationsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// A single instance of TrustProductsEvaluations + public static TrustProductsEvaluationsResource Fetch(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsEvaluationsOptions(pathTrustProductSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Evaluation Instance. + /// + /// The unique string that identifies the resource + /// The unique string that identifies the Evaluation resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProductsEvaluations + public static async System.Threading.Tasks.Task FetchAsync(string pathTrustProductSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsEvaluationsOptions(pathTrustProductSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TrustProductsEvaluationsResource object + /// + /// Raw JSON string + /// TrustProductsEvaluationsResource object represented by the provided JSON + public static TrustProductsEvaluationsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Evaluation resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a policy + /// + [JsonProperty("policy_sid")] + public string PolicySid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("trust_product_sid")] + public string TrustProductSid { get; private set; } + /// + /// The compliance status of the Evaluation resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public TrustProductsEvaluationsResource.StatusEnum Status { get; private set; } + /// + /// The results of the Evaluation resource + /// + [JsonProperty("results")] + public List Results { get; private set; } + /// + /// The date_created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private TrustProductsEvaluationsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProductsOptions.cs b/src/Twilio/Rest/Trusthub/V1/TrustProductsOptions.cs index caaa9c72b..c50390ffd 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProductsOptions.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProductsOptions.cs @@ -9,242 +9,242 @@ using Twilio.Converters; namespace Twilio.Rest.Trusthub.V1 -{ - +{ + + /// + /// Create a new Customer-Profile. + /// + public class CreateTrustProductsOptions : IOptions + { /// - /// Create a new Customer-Profile. - /// - public class CreateTrustProductsOptions : IOptions - { - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; } - /// - /// The email address - /// - public string Email { get; } - /// - /// The unique string of a policy. - /// - public string PolicySid { get; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - - /// - /// Construct a new CreateTrustProductsOptions - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - public CreateTrustProductsOptions(string friendlyName, string email, string policySid) - { - FriendlyName = friendlyName; - Email = email; - PolicySid = policySid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - return p; - } - } - + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; } /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - public class ReadTrustProductsOptions : ReadOptions - { - /// - /// The verification status of the Customer-Profile resource - /// - public TrustProductsResource.StatusEnum Status { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The unique string of a policy. - /// - public string PolicySid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PolicySid != null) - { - p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The email address + /// + public string Email { get; } /// - /// Fetch a specific Customer-Profile instance. + /// The unique string of a policy. /// - public class FetchTrustProductsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchTrustProductsOptions - /// - /// The unique string that identifies the resource. - public FetchTrustProductsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PolicySid { get; } /// - /// Updates a Customer-Profile in an account. - /// - public class UpdateTrustProductsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - /// - /// The verification status of the Customer-Profile resource - /// - public TrustProductsResource.StatusEnum Status { get; set; } - /// - /// The URL we call to inform your application of status changes. - /// - public Uri StatusCallback { get; set; } - /// - /// The string that you assigned to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The email address - /// - public string Email { get; set; } - - /// - /// Construct a new UpdateTrustProductsOptions - /// - /// The unique string that identifies the resource. - public UpdateTrustProductsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Email != null) - { - p.Add(new KeyValuePair("Email", Email)); - } - - return p; - } - } - + /// The URL we call to inform your application of status changes. + /// + public Uri StatusCallback { get; set; } + /// - /// Delete a specific Customer-Profile. + /// Construct a new CreateTrustProductsOptions /// - public class DeleteTrustProductsOptions : IOptions - { - /// - /// The unique string that identifies the resource. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteTrustProductsOptions - /// - /// The unique string that identifies the resource. - public DeleteTrustProductsOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + public CreateTrustProductsOptions(string friendlyName, string email, string policySid) + { + FriendlyName = friendlyName; + Email = email; + PolicySid = policySid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + return p; + } + } + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + public class ReadTrustProductsOptions : ReadOptions + { + /// + /// The verification status of the Customer-Profile resource + /// + public TrustProductsResource.StatusEnum Status { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The unique string of a policy. + /// + public string PolicySid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PolicySid != null) + { + p.Add(new KeyValuePair("PolicySid", PolicySid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Customer-Profile instance. + /// + public class FetchTrustProductsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchTrustProductsOptions + /// + /// The unique string that identifies the resource. + public FetchTrustProductsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Updates a Customer-Profile in an account. + /// + public class UpdateTrustProductsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + /// + /// The verification status of the Customer-Profile resource + /// + public TrustProductsResource.StatusEnum Status { get; set; } + /// + /// The URL we call to inform your application of status changes. + /// + public Uri StatusCallback { get; set; } + /// + /// The string that you assigned to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The email address + /// + public string Email { get; set; } + + /// + /// Construct a new UpdateTrustProductsOptions + /// + /// The unique string that identifies the resource. + public UpdateTrustProductsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Email != null) + { + p.Add(new KeyValuePair("Email", Email)); + } + + return p; + } + } + + /// + /// Delete a specific Customer-Profile. + /// + public class DeleteTrustProductsOptions : IOptions + { + /// + /// The unique string that identifies the resource. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteTrustProductsOptions + /// + /// The unique string that identifies the resource. + public DeleteTrustProductsOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Trusthub/V1/TrustProductsResource.cs b/src/Twilio/Rest/Trusthub/V1/TrustProductsResource.cs index 227b8879a..903845914 100644 --- a/src/Twilio/Rest/Trusthub/V1/TrustProductsResource.cs +++ b/src/Twilio/Rest/Trusthub/V1/TrustProductsResource.cs @@ -17,562 +17,562 @@ using Twilio.Types; namespace Twilio.Rest.Trusthub.V1 -{ - - public class TrustProductsResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Draft = new StatusEnum("draft"); - public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); - public static readonly StatusEnum InReview = new StatusEnum("in-review"); - public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); - public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); - } - - public sealed class EndUserTypeEnum : StringEnum - { - private EndUserTypeEnum(string value) : base(value) {} - public EndUserTypeEnum() {} - public static implicit operator EndUserTypeEnum(string value) - { - return new EndUserTypeEnum(value); - } - - public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); - public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); - } - - private static Request BuildCreateRequest(CreateTrustProductsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/TrustProducts", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Customer-Profile. - /// - /// Create TrustProducts parameters - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Create(CreateTrustProductsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Customer-Profile. - /// - /// Create TrustProducts parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Customer-Profile. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - /// The URL we call to inform your application of status changes. - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Create(string friendlyName, - string email, - string policySid, - Uri statusCallback = null, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsOptions(friendlyName, email, policySid){StatusCallback = statusCallback}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Customer-Profile. - /// - /// The string that you assigned to describe the resource - /// The email address - /// The unique string of a policy. - /// The URL we call to inform your application of status changes. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string email, - string policySid, - Uri statusCallback = null, - ITwilioRestClient client = null) - { - var options = new CreateTrustProductsOptions(friendlyName, email, policySid){StatusCallback = statusCallback}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadTrustProductsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// Read TrustProducts parameters - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static ResourceSet Read(ReadTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// Read TrustProducts parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("results", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// The verification status of the Customer-Profile resource - /// The string that you assigned to describe the resource - /// The unique string of a policy. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static ResourceSet Read(TrustProductsResource.StatusEnum status = null, - string friendlyName = null, - string policySid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsOptions(){Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Customer-Profiles for an account. - /// - /// The verification status of the Customer-Profile resource - /// The string that you assigned to describe the resource - /// The unique string of a policy. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task> ReadAsync(TrustProductsResource.StatusEnum status = null, - string friendlyName = null, - string policySid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTrustProductsOptions(){Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Trusthub) - ); - - var response = client.Request(request); - return Page.FromJson("results", response.Content); - } - - private static Request BuildFetchRequest(FetchTrustProductsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Customer-Profile instance. - /// - /// Fetch TrustProducts parameters - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Fetch(FetchTrustProductsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Customer-Profile instance. - /// - /// Fetch TrustProducts parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Customer-Profile instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchTrustProductsOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Customer-Profile instance. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchTrustProductsOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateTrustProductsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates a Customer-Profile in an account. - /// - /// Update TrustProducts parameters - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Update(UpdateTrustProductsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates a Customer-Profile in an account. - /// - /// Update TrustProducts parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task UpdateAsync(UpdateTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates a Customer-Profile in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Customer-Profile resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static TrustProductsResource Update(string pathSid, - TrustProductsResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateTrustProductsOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates a Customer-Profile in an account. - /// - /// The unique string that identifies the resource. - /// The verification status of the Customer-Profile resource - /// The URL we call to inform your application of status changes. - /// The string that you assigned to describe the resource - /// The email address - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - TrustProductsResource.StatusEnum status = null, - Uri statusCallback = null, - string friendlyName = null, - string email = null, - ITwilioRestClient client = null) - { - var options = new UpdateTrustProductsOptions(pathSid){Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteTrustProductsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Trusthub, - "/v1/TrustProducts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Customer-Profile. - /// - /// Delete TrustProducts parameters - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static bool Delete(DeleteTrustProductsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Customer-Profile. - /// - /// Delete TrustProducts parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Customer-Profile. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// A single instance of TrustProducts - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Customer-Profile. - /// - /// The unique string that identifies the resource. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of TrustProducts - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteTrustProductsOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a TrustProductsResource object - /// - /// Raw JSON string - /// TrustProductsResource object represented by the provided JSON - public static TrustProductsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string of a policy. - /// - [JsonProperty("policy_sid")] - public string PolicySid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The verification status of the Customer-Profile resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public TrustProductsResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource will be valid until. - /// - [JsonProperty("valid_until")] - public DateTime? ValidUntil { get; private set; } - /// - /// The email address - /// - [JsonProperty("email")] - public string Email { get; private set; } - /// - /// The URL we call to inform your application of status changes. - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Customer-Profile resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of the Assigned Items of the Customer-Profile resource - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private TrustProductsResource() - { - - } - } +{ + + public class TrustProductsResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Draft = new StatusEnum("draft"); + public static readonly StatusEnum PendingReview = new StatusEnum("pending-review"); + public static readonly StatusEnum InReview = new StatusEnum("in-review"); + public static readonly StatusEnum TwilioRejected = new StatusEnum("twilio-rejected"); + public static readonly StatusEnum TwilioApproved = new StatusEnum("twilio-approved"); + } + + public sealed class EndUserTypeEnum : StringEnum + { + private EndUserTypeEnum(string value) : base(value) { } + public EndUserTypeEnum() { } + public static implicit operator EndUserTypeEnum(string value) + { + return new EndUserTypeEnum(value); + } + + public static readonly EndUserTypeEnum Individual = new EndUserTypeEnum("individual"); + public static readonly EndUserTypeEnum Business = new EndUserTypeEnum("business"); + } + + private static Request BuildCreateRequest(CreateTrustProductsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/TrustProducts", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Customer-Profile. + /// + /// Create TrustProducts parameters + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Create(CreateTrustProductsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Customer-Profile. + /// + /// Create TrustProducts parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task CreateAsync(CreateTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Customer-Profile. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + /// The URL we call to inform your application of status changes. + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Create(string friendlyName, + string email, + string policySid, + Uri statusCallback = null, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsOptions(friendlyName, email, policySid) { StatusCallback = statusCallback }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Customer-Profile. + /// + /// The string that you assigned to describe the resource + /// The email address + /// The unique string of a policy. + /// The URL we call to inform your application of status changes. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string email, + string policySid, + Uri statusCallback = null, + ITwilioRestClient client = null) + { + var options = new CreateTrustProductsOptions(friendlyName, email, policySid) { StatusCallback = statusCallback }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadTrustProductsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// Read TrustProducts parameters + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static ResourceSet Read(ReadTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// Read TrustProducts parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task> ReadAsync(ReadTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("results", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// The verification status of the Customer-Profile resource + /// The string that you assigned to describe the resource + /// The unique string of a policy. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static ResourceSet Read(TrustProductsResource.StatusEnum status = null, + string friendlyName = null, + string policySid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsOptions() { Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Customer-Profiles for an account. + /// + /// The verification status of the Customer-Profile resource + /// The string that you assigned to describe the resource + /// The unique string of a policy. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task> ReadAsync(TrustProductsResource.StatusEnum status = null, + string friendlyName = null, + string policySid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTrustProductsOptions() { Status = status, FriendlyName = friendlyName, PolicySid = policySid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Trusthub) + ); + + var response = client.Request(request); + return Page.FromJson("results", response.Content); + } + + private static Request BuildFetchRequest(FetchTrustProductsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Customer-Profile instance. + /// + /// Fetch TrustProducts parameters + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Fetch(FetchTrustProductsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Customer-Profile instance. + /// + /// Fetch TrustProducts parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task FetchAsync(FetchTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Customer-Profile instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchTrustProductsOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Customer-Profile instance. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchTrustProductsOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateTrustProductsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates a Customer-Profile in an account. + /// + /// Update TrustProducts parameters + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Update(UpdateTrustProductsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates a Customer-Profile in an account. + /// + /// Update TrustProducts parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task UpdateAsync(UpdateTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates a Customer-Profile in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Customer-Profile resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static TrustProductsResource Update(string pathSid, + TrustProductsResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateTrustProductsOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates a Customer-Profile in an account. + /// + /// The unique string that identifies the resource. + /// The verification status of the Customer-Profile resource + /// The URL we call to inform your application of status changes. + /// The string that you assigned to describe the resource + /// The email address + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + TrustProductsResource.StatusEnum status = null, + Uri statusCallback = null, + string friendlyName = null, + string email = null, + ITwilioRestClient client = null) + { + var options = new UpdateTrustProductsOptions(pathSid) { Status = status, StatusCallback = statusCallback, FriendlyName = friendlyName, Email = email }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteTrustProductsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Trusthub, + "/v1/TrustProducts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Customer-Profile. + /// + /// Delete TrustProducts parameters + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static bool Delete(DeleteTrustProductsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Customer-Profile. + /// + /// Delete TrustProducts parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task DeleteAsync(DeleteTrustProductsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Customer-Profile. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// A single instance of TrustProducts + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Customer-Profile. + /// + /// The unique string that identifies the resource. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of TrustProducts + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteTrustProductsOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a TrustProductsResource object + /// + /// Raw JSON string + /// TrustProductsResource object represented by the provided JSON + public static TrustProductsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string of a policy. + /// + [JsonProperty("policy_sid")] + public string PolicySid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The verification status of the Customer-Profile resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public TrustProductsResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource will be valid until. + /// + [JsonProperty("valid_until")] + public DateTime? ValidUntil { get; private set; } + /// + /// The email address + /// + [JsonProperty("email")] + public string Email { get; private set; } + /// + /// The URL we call to inform your application of status changes. + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Customer-Profile resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of the Assigned Items of the Customer-Profile resource + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private TrustProductsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/FormOptions.cs b/src/Twilio/Rest/Verify/V2/FormOptions.cs index b264e45a8..3c4263a01 100644 --- a/src/Twilio/Rest/Verify/V2/FormOptions.cs +++ b/src/Twilio/Rest/Verify/V2/FormOptions.cs @@ -9,37 +9,37 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch the forms for a specific Form Type. + /// + public class FetchFormOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch the forms for a specific Form Type. + /// The Type of this Form /// - public class FetchFormOptions : IOptions - { - /// - /// The Type of this Form - /// - public FormResource.FormTypesEnum PathFormType { get; } - - /// - /// Construct a new FetchFormOptions - /// - /// The Type of this Form - public FetchFormOptions(FormResource.FormTypesEnum pathFormType) - { - PathFormType = pathFormType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public FormResource.FormTypesEnum PathFormType { get; } + + /// + /// Construct a new FetchFormOptions + /// + /// The Type of this Form + public FetchFormOptions(FormResource.FormTypesEnum pathFormType) + { + PathFormType = pathFormType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/FormResource.cs b/src/Twilio/Rest/Verify/V2/FormResource.cs index 30ff97dc7..d6656cd80 100644 --- a/src/Twilio/Rest/Verify/V2/FormResource.cs +++ b/src/Twilio/Rest/Verify/V2/FormResource.cs @@ -19,133 +19,133 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2 -{ - - public class FormResource : Resource - { - public sealed class FormTypesEnum : StringEnum - { - private FormTypesEnum(string value) : base(value) {} - public FormTypesEnum() {} - public static implicit operator FormTypesEnum(string value) - { - return new FormTypesEnum(value); - } - - public static readonly FormTypesEnum FormPush = new FormTypesEnum("form-push"); - } - - private static Request BuildFetchRequest(FetchFormOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Forms/" + options.PathFormType + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the forms for a specific Form Type. - /// - /// Fetch Form parameters - /// Client to make requests to Twilio - /// A single instance of Form - public static FormResource Fetch(FetchFormOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch the forms for a specific Form Type. - /// - /// Fetch Form parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Form - public static async System.Threading.Tasks.Task FetchAsync(FetchFormOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch the forms for a specific Form Type. - /// - /// The Type of this Form - /// Client to make requests to Twilio - /// A single instance of Form - public static FormResource Fetch(FormResource.FormTypesEnum pathFormType, ITwilioRestClient client = null) - { - var options = new FetchFormOptions(pathFormType); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch the forms for a specific Form Type. - /// - /// The Type of this Form - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Form - public static async System.Threading.Tasks.Task FetchAsync(FormResource.FormTypesEnum pathFormType, - ITwilioRestClient client = null) - { - var options = new FetchFormOptions(pathFormType); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FormResource object - /// - /// Raw JSON string - /// FormResource object represented by the provided JSON - public static FormResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The Type of this Form - /// - [JsonProperty("form_type")] - [JsonConverter(typeof(StringEnumConverter))] - public FormResource.FormTypesEnum FormType { get; private set; } - /// - /// Object that contains the available forms for this type. - /// - [JsonProperty("forms")] - public object Forms { get; private set; } - /// - /// Additional information for the available forms for this type. - /// - [JsonProperty("form_meta")] - public object FormMeta { get; private set; } - /// - /// The URL to access the forms for this type. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FormResource() - { - - } - } +{ + + public class FormResource : Resource + { + public sealed class FormTypesEnum : StringEnum + { + private FormTypesEnum(string value) : base(value) { } + public FormTypesEnum() { } + public static implicit operator FormTypesEnum(string value) + { + return new FormTypesEnum(value); + } + + public static readonly FormTypesEnum FormPush = new FormTypesEnum("form-push"); + } + + private static Request BuildFetchRequest(FetchFormOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Forms/" + options.PathFormType + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the forms for a specific Form Type. + /// + /// Fetch Form parameters + /// Client to make requests to Twilio + /// A single instance of Form + public static FormResource Fetch(FetchFormOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch the forms for a specific Form Type. + /// + /// Fetch Form parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Form + public static async System.Threading.Tasks.Task FetchAsync(FetchFormOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch the forms for a specific Form Type. + /// + /// The Type of this Form + /// Client to make requests to Twilio + /// A single instance of Form + public static FormResource Fetch(FormResource.FormTypesEnum pathFormType, ITwilioRestClient client = null) + { + var options = new FetchFormOptions(pathFormType); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch the forms for a specific Form Type. + /// + /// The Type of this Form + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Form + public static async System.Threading.Tasks.Task FetchAsync(FormResource.FormTypesEnum pathFormType, + ITwilioRestClient client = null) + { + var options = new FetchFormOptions(pathFormType); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FormResource object + /// + /// Raw JSON string + /// FormResource object represented by the provided JSON + public static FormResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The Type of this Form + /// + [JsonProperty("form_type")] + [JsonConverter(typeof(StringEnumConverter))] + public FormResource.FormTypesEnum FormType { get; private set; } + /// + /// Object that contains the available forms for this type. + /// + [JsonProperty("forms")] + public object Forms { get; private set; } + /// + /// Additional information for the available forms for this type. + /// + [JsonProperty("form_meta")] + public object FormMeta { get; private set; } + /// + /// The URL to access the forms for this type. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FormResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/AccessTokenOptions.cs b/src/Twilio/Rest/Verify/V2/Service/AccessTokenOptions.cs index 84605022f..72af690d3 100644 --- a/src/Twilio/Rest/Verify/V2/Service/AccessTokenOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/AccessTokenOptions.cs @@ -9,70 +9,70 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new enrollment Access Token for the Entity + /// + public class CreateAccessTokenOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new enrollment Access Token for the Entity + /// Service Sid. /// - public class CreateAccessTokenOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string Identity { get; } - /// - /// The Type of this Factor - /// - public AccessTokenResource.FactorTypesEnum FactorType { get; } - /// - /// The factor friendly name - /// - public string FactorFriendlyName { get; set; } - - /// - /// Construct a new CreateAccessTokenOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The Type of this Factor - public CreateAccessTokenOptions(string pathServiceSid, - string identity, - AccessTokenResource.FactorTypesEnum factorType) - { - PathServiceSid = pathServiceSid; - Identity = identity; - FactorType = factorType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (FactorType != null) - { - p.Add(new KeyValuePair("FactorType", FactorType.ToString())); - } - - if (FactorFriendlyName != null) - { - p.Add(new KeyValuePair("FactorFriendlyName", FactorFriendlyName)); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string Identity { get; } + /// + /// The Type of this Factor + /// + public AccessTokenResource.FactorTypesEnum FactorType { get; } + /// + /// The factor friendly name + /// + public string FactorFriendlyName { get; set; } + + /// + /// Construct a new CreateAccessTokenOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The Type of this Factor + public CreateAccessTokenOptions(string pathServiceSid, + string identity, + AccessTokenResource.FactorTypesEnum factorType) + { + PathServiceSid = pathServiceSid; + Identity = identity; + FactorType = factorType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (FactorType != null) + { + p.Add(new KeyValuePair("FactorType", FactorType.ToString())); + } + + if (FactorFriendlyName != null) + { + p.Add(new KeyValuePair("FactorFriendlyName", FactorFriendlyName)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/AccessTokenResource.cs b/src/Twilio/Rest/Verify/V2/Service/AccessTokenResource.cs index 22543f666..8408c21d9 100644 --- a/src/Twilio/Rest/Verify/V2/Service/AccessTokenResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/AccessTokenResource.cs @@ -19,130 +19,130 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service -{ - - public class AccessTokenResource : Resource - { - public sealed class FactorTypesEnum : StringEnum - { - private FactorTypesEnum(string value) : base(value) {} - public FactorTypesEnum() {} - public static implicit operator FactorTypesEnum(string value) - { - return new FactorTypesEnum(value); - } - - public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); - } - - private static Request BuildCreateRequest(CreateAccessTokenOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/AccessTokens", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new enrollment Access Token for the Entity - /// - /// Create AccessToken parameters - /// Client to make requests to Twilio - /// A single instance of AccessToken - public static AccessTokenResource Create(CreateAccessTokenOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new enrollment Access Token for the Entity - /// - /// Create AccessToken parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AccessToken - public static async System.Threading.Tasks.Task CreateAsync(CreateAccessTokenOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new enrollment Access Token for the Entity - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The Type of this Factor - /// The factor friendly name - /// Client to make requests to Twilio - /// A single instance of AccessToken - public static AccessTokenResource Create(string pathServiceSid, - string identity, - AccessTokenResource.FactorTypesEnum factorType, - string factorFriendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateAccessTokenOptions(pathServiceSid, identity, factorType){FactorFriendlyName = factorFriendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new enrollment Access Token for the Entity - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The Type of this Factor - /// The factor friendly name - /// Client to make requests to Twilio - /// Task that resolves to A single instance of AccessToken - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - AccessTokenResource.FactorTypesEnum factorType, - string factorFriendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateAccessTokenOptions(pathServiceSid, identity, factorType){FactorFriendlyName = factorFriendlyName}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a AccessTokenResource object - /// - /// Raw JSON string - /// AccessTokenResource object represented by the provided JSON - public static AccessTokenResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// Generated access token. - /// - [JsonProperty("token")] - public string Token { get; private set; } - - private AccessTokenResource() - { - - } - } +{ + + public class AccessTokenResource : Resource + { + public sealed class FactorTypesEnum : StringEnum + { + private FactorTypesEnum(string value) : base(value) { } + public FactorTypesEnum() { } + public static implicit operator FactorTypesEnum(string value) + { + return new FactorTypesEnum(value); + } + + public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); + } + + private static Request BuildCreateRequest(CreateAccessTokenOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/AccessTokens", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new enrollment Access Token for the Entity + /// + /// Create AccessToken parameters + /// Client to make requests to Twilio + /// A single instance of AccessToken + public static AccessTokenResource Create(CreateAccessTokenOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new enrollment Access Token for the Entity + /// + /// Create AccessToken parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AccessToken + public static async System.Threading.Tasks.Task CreateAsync(CreateAccessTokenOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new enrollment Access Token for the Entity + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The Type of this Factor + /// The factor friendly name + /// Client to make requests to Twilio + /// A single instance of AccessToken + public static AccessTokenResource Create(string pathServiceSid, + string identity, + AccessTokenResource.FactorTypesEnum factorType, + string factorFriendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateAccessTokenOptions(pathServiceSid, identity, factorType) { FactorFriendlyName = factorFriendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new enrollment Access Token for the Entity + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The Type of this Factor + /// The factor friendly name + /// Client to make requests to Twilio + /// Task that resolves to A single instance of AccessToken + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + AccessTokenResource.FactorTypesEnum factorType, + string factorFriendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateAccessTokenOptions(pathServiceSid, identity, factorType) { FactorFriendlyName = factorFriendlyName }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a AccessTokenResource object + /// + /// Raw JSON string + /// AccessTokenResource object represented by the provided JSON + public static AccessTokenResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// Generated access token. + /// + [JsonProperty("token")] + public string Token { get; private set; } + + private AccessTokenResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationOptions.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationOptions.cs index cc0ada55e..9e3912704 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationOptions.cs @@ -9,58 +9,58 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service.Entity.Challenge -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Notification for the corresponding Challenge + /// + public class CreateNotificationOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Notification for the corresponding Challenge + /// Service Sid. /// - public class CreateNotificationOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// Challenge Sid. - /// - public string PathChallengeSid { get; } - /// - /// How long, in seconds, the notification is valid. - /// - public int? Ttl { get; set; } - - /// - /// Construct a new CreateNotificationOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Challenge Sid. - public CreateNotificationOptions(string pathServiceSid, string pathIdentity, string pathChallengeSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathChallengeSid = pathChallengeSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Ttl != null) - { - p.Add(new KeyValuePair("Ttl", Ttl.ToString())); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// Challenge Sid. + /// + public string PathChallengeSid { get; } + /// + /// How long, in seconds, the notification is valid. + /// + public int? Ttl { get; set; } + + /// + /// Construct a new CreateNotificationOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Challenge Sid. + public CreateNotificationOptions(string pathServiceSid, string pathIdentity, string pathChallengeSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathChallengeSid = pathChallengeSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Ttl != null) + { + p.Add(new KeyValuePair("Ttl", Ttl.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationResource.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationResource.cs index c13488ec0..4062f2a64 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/Challenge/NotificationResource.cs @@ -18,158 +18,158 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2.Service.Entity.Challenge -{ - - public class NotificationResource : Resource - { - private static Request BuildCreateRequest(CreateNotificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathChallengeSid + "/Notifications", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Notification for the corresponding Challenge - /// - /// Create Notification parameters - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Create(CreateNotificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Notification for the corresponding Challenge - /// - /// Create Notification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task CreateAsync(CreateNotificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Notification for the corresponding Challenge - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Challenge Sid. - /// How long, in seconds, the notification is valid. - /// Client to make requests to Twilio - /// A single instance of Notification - public static NotificationResource Create(string pathServiceSid, - string pathIdentity, - string pathChallengeSid, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateNotificationOptions(pathServiceSid, pathIdentity, pathChallengeSid){Ttl = ttl}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Notification for the corresponding Challenge - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Challenge Sid. - /// How long, in seconds, the notification is valid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Notification - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathIdentity, - string pathChallengeSid, - int? ttl = null, - ITwilioRestClient client = null) - { - var options = new CreateNotificationOptions(pathServiceSid, pathIdentity, pathChallengeSid){Ttl = ttl}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NotificationResource object - /// - /// Raw JSON string - /// NotificationResource object represented by the provided JSON - public static NotificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Notification. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Entity Sid. - /// - [JsonProperty("entity_sid")] - public string EntitySid { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Challenge Sid. - /// - [JsonProperty("challenge_sid")] - public string ChallengeSid { get; private set; } - /// - /// The priority of the notification. - /// - [JsonProperty("priority")] - public string Priority { get; private set; } - /// - /// How long, in seconds, the notification is valid. - /// - [JsonProperty("ttl")] - public int? Ttl { get; private set; } - /// - /// The date this Notification was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - - private NotificationResource() - { - - } - } +{ + + public class NotificationResource : Resource + { + private static Request BuildCreateRequest(CreateNotificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathChallengeSid + "/Notifications", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Notification for the corresponding Challenge + /// + /// Create Notification parameters + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Create(CreateNotificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Notification for the corresponding Challenge + /// + /// Create Notification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task CreateAsync(CreateNotificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Notification for the corresponding Challenge + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Challenge Sid. + /// How long, in seconds, the notification is valid. + /// Client to make requests to Twilio + /// A single instance of Notification + public static NotificationResource Create(string pathServiceSid, + string pathIdentity, + string pathChallengeSid, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateNotificationOptions(pathServiceSid, pathIdentity, pathChallengeSid) { Ttl = ttl }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Notification for the corresponding Challenge + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Challenge Sid. + /// How long, in seconds, the notification is valid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Notification + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathIdentity, + string pathChallengeSid, + int? ttl = null, + ITwilioRestClient client = null) + { + var options = new CreateNotificationOptions(pathServiceSid, pathIdentity, pathChallengeSid) { Ttl = ttl }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NotificationResource object + /// + /// Raw JSON string + /// NotificationResource object represented by the provided JSON + public static NotificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Notification. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Entity Sid. + /// + [JsonProperty("entity_sid")] + public string EntitySid { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Challenge Sid. + /// + [JsonProperty("challenge_sid")] + public string ChallengeSid { get; private set; } + /// + /// The priority of the notification. + /// + [JsonProperty("priority")] + public string Priority { get; private set; } + /// + /// How long, in seconds, the notification is valid. + /// + [JsonProperty("ttl")] + public int? Ttl { get; private set; } + /// + /// The date this Notification was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + private NotificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeOptions.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeOptions.cs index ae0982531..376aa37ff 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeOptions.cs @@ -10,264 +10,264 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Challenge for the Factor + /// + public class CreateChallengeOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Challenge for the Factor + /// Service Sid. /// - public class CreateChallengeOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// Factor Sid. - /// - public string FactorSid { get; } - /// - /// The date-time when this Challenge expires - /// - public DateTime? ExpirationDate { get; set; } - /// - /// Shown to the user when the push notification arrives - /// - public string DetailsMessage { get; set; } - /// - /// A list of objects that describe the Fields included in the Challenge - /// - public List DetailsFields { get; set; } - /// - /// Hidden details provided to contextualize the Challenge - /// - public object HiddenDetails { get; set; } - /// - /// Optional payload to verify the Challenge - /// - public string AuthPayload { get; set; } - - /// - /// Construct a new CreateChallengeOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Factor Sid. - public CreateChallengeOptions(string pathServiceSid, string pathIdentity, string factorSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - FactorSid = factorSid; - DetailsFields = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FactorSid != null) - { - p.Add(new KeyValuePair("FactorSid", FactorSid.ToString())); - } - - if (ExpirationDate != null) - { - p.Add(new KeyValuePair("ExpirationDate", Serializers.DateTimeIso8601(ExpirationDate))); - } - - if (DetailsMessage != null) - { - p.Add(new KeyValuePair("Details.Message", DetailsMessage)); - } - - if (DetailsFields != null) - { - p.AddRange(DetailsFields.Select(prop => new KeyValuePair("Details.Fields", Serializers.JsonObject(prop)))); - } - - if (HiddenDetails != null) - { - p.Add(new KeyValuePair("HiddenDetails", Serializers.JsonObject(HiddenDetails))); - } - - if (AuthPayload != null) - { - p.Add(new KeyValuePair("AuthPayload", AuthPayload)); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Challenge. + /// Unique external identifier of the Entity /// - public class FetchChallengeOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// A string that uniquely identifies this Challenge. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchChallengeOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - public FetchChallengeOptions(string pathServiceSid, string pathIdentity, string pathSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathIdentity { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Challenges for a Factor. + /// Factor Sid. /// - public class ReadChallengeOptions : ReadOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// Factor Sid. - /// - public string FactorSid { get; set; } - /// - /// The Status of theChallenges to fetch - /// - public ChallengeResource.ChallengeStatusesEnum Status { get; set; } - /// - /// The sort order of the Challenges list - /// - public ChallengeResource.ListOrdersEnum Order { get; set; } - - /// - /// Construct a new ReadChallengeOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - public ReadChallengeOptions(string pathServiceSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FactorSid != null) - { - p.Add(new KeyValuePair("FactorSid", FactorSid.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Order != null) - { - p.Add(new KeyValuePair("Order", Order.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string FactorSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Verify a specific Challenge. + /// The date-time when this Challenge expires /// - public class UpdateChallengeOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// A string that uniquely identifies this Challenge. - /// - public string PathSid { get; } - /// - /// Optional payload to verify the Challenge - /// - public string AuthPayload { get; set; } - - /// - /// Construct a new UpdateChallengeOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - public UpdateChallengeOptions(string pathServiceSid, string pathIdentity, string pathSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AuthPayload != null) - { - p.Add(new KeyValuePair("AuthPayload", AuthPayload)); - } - - return p; - } - } + public DateTime? ExpirationDate { get; set; } + /// + /// Shown to the user when the push notification arrives + /// + public string DetailsMessage { get; set; } + /// + /// A list of objects that describe the Fields included in the Challenge + /// + public List DetailsFields { get; set; } + /// + /// Hidden details provided to contextualize the Challenge + /// + public object HiddenDetails { get; set; } + /// + /// Optional payload to verify the Challenge + /// + public string AuthPayload { get; set; } + + /// + /// Construct a new CreateChallengeOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Factor Sid. + public CreateChallengeOptions(string pathServiceSid, string pathIdentity, string factorSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + FactorSid = factorSid; + DetailsFields = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FactorSid != null) + { + p.Add(new KeyValuePair("FactorSid", FactorSid.ToString())); + } + + if (ExpirationDate != null) + { + p.Add(new KeyValuePair("ExpirationDate", Serializers.DateTimeIso8601(ExpirationDate))); + } + + if (DetailsMessage != null) + { + p.Add(new KeyValuePair("Details.Message", DetailsMessage)); + } + + if (DetailsFields != null) + { + p.AddRange(DetailsFields.Select(prop => new KeyValuePair("Details.Fields", Serializers.JsonObject(prop)))); + } + + if (HiddenDetails != null) + { + p.Add(new KeyValuePair("HiddenDetails", Serializers.JsonObject(HiddenDetails))); + } + + if (AuthPayload != null) + { + p.Add(new KeyValuePair("AuthPayload", AuthPayload)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Challenge. + /// + public class FetchChallengeOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// A string that uniquely identifies this Challenge. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchChallengeOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + public FetchChallengeOptions(string pathServiceSid, string pathIdentity, string pathSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Challenges for a Factor. + /// + public class ReadChallengeOptions : ReadOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// Factor Sid. + /// + public string FactorSid { get; set; } + /// + /// The Status of theChallenges to fetch + /// + public ChallengeResource.ChallengeStatusesEnum Status { get; set; } + /// + /// The sort order of the Challenges list + /// + public ChallengeResource.ListOrdersEnum Order { get; set; } + + /// + /// Construct a new ReadChallengeOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + public ReadChallengeOptions(string pathServiceSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FactorSid != null) + { + p.Add(new KeyValuePair("FactorSid", FactorSid.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Order != null) + { + p.Add(new KeyValuePair("Order", Order.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Verify a specific Challenge. + /// + public class UpdateChallengeOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// A string that uniquely identifies this Challenge. + /// + public string PathSid { get; } + /// + /// Optional payload to verify the Challenge + /// + public string AuthPayload { get; set; } + + /// + /// Construct a new UpdateChallengeOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + public UpdateChallengeOptions(string pathServiceSid, string pathIdentity, string pathSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AuthPayload != null) + { + p.Add(new KeyValuePair("AuthPayload", AuthPayload)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeResource.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeResource.cs index 564b8daf4..df9671e37 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/ChallengeResource.cs @@ -19,577 +19,577 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - - public class ChallengeResource : Resource - { - public sealed class ChallengeStatusesEnum : StringEnum - { - private ChallengeStatusesEnum(string value) : base(value) {} - public ChallengeStatusesEnum() {} - public static implicit operator ChallengeStatusesEnum(string value) - { - return new ChallengeStatusesEnum(value); - } - - public static readonly ChallengeStatusesEnum Pending = new ChallengeStatusesEnum("pending"); - public static readonly ChallengeStatusesEnum Expired = new ChallengeStatusesEnum("expired"); - public static readonly ChallengeStatusesEnum Approved = new ChallengeStatusesEnum("approved"); - public static readonly ChallengeStatusesEnum Denied = new ChallengeStatusesEnum("denied"); - } - - public sealed class ChallengeReasonsEnum : StringEnum - { - private ChallengeReasonsEnum(string value) : base(value) {} - public ChallengeReasonsEnum() {} - public static implicit operator ChallengeReasonsEnum(string value) - { - return new ChallengeReasonsEnum(value); - } - - public static readonly ChallengeReasonsEnum None = new ChallengeReasonsEnum("none"); - public static readonly ChallengeReasonsEnum NotNeeded = new ChallengeReasonsEnum("not_needed"); - public static readonly ChallengeReasonsEnum NotRequested = new ChallengeReasonsEnum("not_requested"); - } - - public sealed class FactorTypesEnum : StringEnum - { - private FactorTypesEnum(string value) : base(value) {} - public FactorTypesEnum() {} - public static implicit operator FactorTypesEnum(string value) - { - return new FactorTypesEnum(value); - } - - public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); - public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); - } - - public sealed class ListOrdersEnum : StringEnum - { - private ListOrdersEnum(string value) : base(value) {} - public ListOrdersEnum() {} - public static implicit operator ListOrdersEnum(string value) - { - return new ListOrdersEnum(value); - } - - public static readonly ListOrdersEnum Asc = new ListOrdersEnum("asc"); - public static readonly ListOrdersEnum Desc = new ListOrdersEnum("desc"); - } - - private static Request BuildCreateRequest(CreateChallengeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Challenge for the Factor - /// - /// Create Challenge parameters - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Create(CreateChallengeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Challenge for the Factor - /// - /// Create Challenge parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task CreateAsync(CreateChallengeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Challenge for the Factor - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Factor Sid. - /// The date-time when this Challenge expires - /// Shown to the user when the push notification arrives - /// A list of objects that describe the Fields included in the Challenge - /// Hidden details provided to contextualize the Challenge - /// Optional payload to verify the Challenge - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Create(string pathServiceSid, - string pathIdentity, - string factorSid, - DateTime? expirationDate = null, - string detailsMessage = null, - List detailsFields = null, - object hiddenDetails = null, - string authPayload = null, - ITwilioRestClient client = null) - { - var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid){ExpirationDate = expirationDate, DetailsMessage = detailsMessage, DetailsFields = detailsFields, HiddenDetails = hiddenDetails, AuthPayload = authPayload}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Challenge for the Factor - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Factor Sid. - /// The date-time when this Challenge expires - /// Shown to the user when the push notification arrives - /// A list of objects that describe the Fields included in the Challenge - /// Hidden details provided to contextualize the Challenge - /// Optional payload to verify the Challenge - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathIdentity, - string factorSid, - DateTime? expirationDate = null, - string detailsMessage = null, - List detailsFields = null, - object hiddenDetails = null, - string authPayload = null, - ITwilioRestClient client = null) - { - var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid){ExpirationDate = expirationDate, DetailsMessage = detailsMessage, DetailsFields = detailsFields, HiddenDetails = hiddenDetails, AuthPayload = authPayload}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchChallengeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Challenge. - /// - /// Fetch Challenge parameters - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Fetch(FetchChallengeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Challenge. - /// - /// Fetch Challenge parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task FetchAsync(FetchChallengeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Challenge. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Fetch(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChallengeOptions(pathServiceSid, pathIdentity, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Challenge. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchChallengeOptions(pathServiceSid, pathIdentity, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadChallengeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Challenges for a Factor. - /// - /// Read Challenge parameters - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ResourceSet Read(ReadChallengeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("challenges", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Challenges for a Factor. - /// - /// Read Challenge parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task> ReadAsync(ReadChallengeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("challenges", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Challenges for a Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Factor Sid. - /// The Status of theChallenges to fetch - /// The sort order of the Challenges list - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ResourceSet Read(string pathServiceSid, - string pathIdentity, - string factorSid = null, - ChallengeResource.ChallengeStatusesEnum status = null, - ChallengeResource.ListOrdersEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChallengeOptions(pathServiceSid, pathIdentity){FactorSid = factorSid, Status = status, Order = order, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Challenges for a Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Factor Sid. - /// The Status of theChallenges to fetch - /// The sort order of the Challenges list - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathIdentity, - string factorSid = null, - ChallengeResource.ChallengeStatusesEnum status = null, - ChallengeResource.ListOrdersEnum order = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadChallengeOptions(pathServiceSid, pathIdentity){FactorSid = factorSid, Status = status, Order = order, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("challenges", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("challenges", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("challenges", response.Content); - } - - private static Request BuildUpdateRequest(UpdateChallengeOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Verify a specific Challenge. - /// - /// Update Challenge parameters - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Update(UpdateChallengeOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Verify a specific Challenge. - /// - /// Update Challenge parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task UpdateAsync(UpdateChallengeOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Verify a specific Challenge. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - /// Optional payload to verify the Challenge - /// Client to make requests to Twilio - /// A single instance of Challenge - public static ChallengeResource Update(string pathServiceSid, - string pathIdentity, - string pathSid, - string authPayload = null, - ITwilioRestClient client = null) - { - var options = new UpdateChallengeOptions(pathServiceSid, pathIdentity, pathSid){AuthPayload = authPayload}; - return Update(options, client); - } - - #if !NET35 - /// - /// Verify a specific Challenge. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Challenge. - /// Optional payload to verify the Challenge - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Challenge - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathIdentity, - string pathSid, - string authPayload = null, - ITwilioRestClient client = null) - { - var options = new UpdateChallengeOptions(pathServiceSid, pathIdentity, pathSid){AuthPayload = authPayload}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ChallengeResource object - /// - /// Raw JSON string - /// ChallengeResource object represented by the provided JSON - public static ChallengeResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Challenge. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Entity Sid. - /// - [JsonProperty("entity_sid")] - public string EntitySid { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Factor Sid. - /// - [JsonProperty("factor_sid")] - public string FactorSid { get; private set; } - /// - /// The date this Challenge was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Challenge was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The date this Challenge was responded - /// - [JsonProperty("date_responded")] - public DateTime? DateResponded { get; private set; } - /// - /// The date-time when this Challenge expires - /// - [JsonProperty("expiration_date")] - public DateTime? ExpirationDate { get; private set; } - /// - /// The Status of this Challenge - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ChallengeResource.ChallengeStatusesEnum Status { get; private set; } - /// - /// The Reason of this Challenge `status` - /// - [JsonProperty("responded_reason")] - [JsonConverter(typeof(StringEnumConverter))] - public ChallengeResource.ChallengeReasonsEnum RespondedReason { get; private set; } - /// - /// Details about the Challenge. - /// - [JsonProperty("details")] - public object Details { get; private set; } - /// - /// Hidden details about the Challenge - /// - [JsonProperty("hidden_details")] - public object HiddenDetails { get; private set; } - /// - /// The Factor Type of this Challenge - /// - [JsonProperty("factor_type")] - [JsonConverter(typeof(StringEnumConverter))] - public ChallengeResource.FactorTypesEnum FactorType { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ChallengeResource() - { - - } - } +{ + + public class ChallengeResource : Resource + { + public sealed class ChallengeStatusesEnum : StringEnum + { + private ChallengeStatusesEnum(string value) : base(value) { } + public ChallengeStatusesEnum() { } + public static implicit operator ChallengeStatusesEnum(string value) + { + return new ChallengeStatusesEnum(value); + } + + public static readonly ChallengeStatusesEnum Pending = new ChallengeStatusesEnum("pending"); + public static readonly ChallengeStatusesEnum Expired = new ChallengeStatusesEnum("expired"); + public static readonly ChallengeStatusesEnum Approved = new ChallengeStatusesEnum("approved"); + public static readonly ChallengeStatusesEnum Denied = new ChallengeStatusesEnum("denied"); + } + + public sealed class ChallengeReasonsEnum : StringEnum + { + private ChallengeReasonsEnum(string value) : base(value) { } + public ChallengeReasonsEnum() { } + public static implicit operator ChallengeReasonsEnum(string value) + { + return new ChallengeReasonsEnum(value); + } + + public static readonly ChallengeReasonsEnum None = new ChallengeReasonsEnum("none"); + public static readonly ChallengeReasonsEnum NotNeeded = new ChallengeReasonsEnum("not_needed"); + public static readonly ChallengeReasonsEnum NotRequested = new ChallengeReasonsEnum("not_requested"); + } + + public sealed class FactorTypesEnum : StringEnum + { + private FactorTypesEnum(string value) : base(value) { } + public FactorTypesEnum() { } + public static implicit operator FactorTypesEnum(string value) + { + return new FactorTypesEnum(value); + } + + public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); + public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); + } + + public sealed class ListOrdersEnum : StringEnum + { + private ListOrdersEnum(string value) : base(value) { } + public ListOrdersEnum() { } + public static implicit operator ListOrdersEnum(string value) + { + return new ListOrdersEnum(value); + } + + public static readonly ListOrdersEnum Asc = new ListOrdersEnum("asc"); + public static readonly ListOrdersEnum Desc = new ListOrdersEnum("desc"); + } + + private static Request BuildCreateRequest(CreateChallengeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Challenge for the Factor + /// + /// Create Challenge parameters + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Create(CreateChallengeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Challenge for the Factor + /// + /// Create Challenge parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task CreateAsync(CreateChallengeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Challenge for the Factor + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Factor Sid. + /// The date-time when this Challenge expires + /// Shown to the user when the push notification arrives + /// A list of objects that describe the Fields included in the Challenge + /// Hidden details provided to contextualize the Challenge + /// Optional payload to verify the Challenge + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Create(string pathServiceSid, + string pathIdentity, + string factorSid, + DateTime? expirationDate = null, + string detailsMessage = null, + List detailsFields = null, + object hiddenDetails = null, + string authPayload = null, + ITwilioRestClient client = null) + { + var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid) { ExpirationDate = expirationDate, DetailsMessage = detailsMessage, DetailsFields = detailsFields, HiddenDetails = hiddenDetails, AuthPayload = authPayload }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Challenge for the Factor + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Factor Sid. + /// The date-time when this Challenge expires + /// Shown to the user when the push notification arrives + /// A list of objects that describe the Fields included in the Challenge + /// Hidden details provided to contextualize the Challenge + /// Optional payload to verify the Challenge + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathIdentity, + string factorSid, + DateTime? expirationDate = null, + string detailsMessage = null, + List detailsFields = null, + object hiddenDetails = null, + string authPayload = null, + ITwilioRestClient client = null) + { + var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid) { ExpirationDate = expirationDate, DetailsMessage = detailsMessage, DetailsFields = detailsFields, HiddenDetails = hiddenDetails, AuthPayload = authPayload }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchChallengeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Challenge. + /// + /// Fetch Challenge parameters + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Fetch(FetchChallengeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Challenge. + /// + /// Fetch Challenge parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task FetchAsync(FetchChallengeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Challenge. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Fetch(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChallengeOptions(pathServiceSid, pathIdentity, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Challenge. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchChallengeOptions(pathServiceSid, pathIdentity, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadChallengeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Challenges for a Factor. + /// + /// Read Challenge parameters + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ResourceSet Read(ReadChallengeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("challenges", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Challenges for a Factor. + /// + /// Read Challenge parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task> ReadAsync(ReadChallengeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("challenges", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Challenges for a Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Factor Sid. + /// The Status of theChallenges to fetch + /// The sort order of the Challenges list + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ResourceSet Read(string pathServiceSid, + string pathIdentity, + string factorSid = null, + ChallengeResource.ChallengeStatusesEnum status = null, + ChallengeResource.ListOrdersEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChallengeOptions(pathServiceSid, pathIdentity) { FactorSid = factorSid, Status = status, Order = order, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Challenges for a Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Factor Sid. + /// The Status of theChallenges to fetch + /// The sort order of the Challenges list + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathIdentity, + string factorSid = null, + ChallengeResource.ChallengeStatusesEnum status = null, + ChallengeResource.ListOrdersEnum order = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadChallengeOptions(pathServiceSid, pathIdentity) { FactorSid = factorSid, Status = status, Order = order, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("challenges", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("challenges", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("challenges", response.Content); + } + + private static Request BuildUpdateRequest(UpdateChallengeOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Verify a specific Challenge. + /// + /// Update Challenge parameters + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Update(UpdateChallengeOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Verify a specific Challenge. + /// + /// Update Challenge parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task UpdateAsync(UpdateChallengeOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Verify a specific Challenge. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + /// Optional payload to verify the Challenge + /// Client to make requests to Twilio + /// A single instance of Challenge + public static ChallengeResource Update(string pathServiceSid, + string pathIdentity, + string pathSid, + string authPayload = null, + ITwilioRestClient client = null) + { + var options = new UpdateChallengeOptions(pathServiceSid, pathIdentity, pathSid) { AuthPayload = authPayload }; + return Update(options, client); + } + +#if !NET35 + /// + /// Verify a specific Challenge. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Challenge. + /// Optional payload to verify the Challenge + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Challenge + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathIdentity, + string pathSid, + string authPayload = null, + ITwilioRestClient client = null) + { + var options = new UpdateChallengeOptions(pathServiceSid, pathIdentity, pathSid) { AuthPayload = authPayload }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ChallengeResource object + /// + /// Raw JSON string + /// ChallengeResource object represented by the provided JSON + public static ChallengeResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Challenge. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Entity Sid. + /// + [JsonProperty("entity_sid")] + public string EntitySid { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Factor Sid. + /// + [JsonProperty("factor_sid")] + public string FactorSid { get; private set; } + /// + /// The date this Challenge was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Challenge was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The date this Challenge was responded + /// + [JsonProperty("date_responded")] + public DateTime? DateResponded { get; private set; } + /// + /// The date-time when this Challenge expires + /// + [JsonProperty("expiration_date")] + public DateTime? ExpirationDate { get; private set; } + /// + /// The Status of this Challenge + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ChallengeResource.ChallengeStatusesEnum Status { get; private set; } + /// + /// The Reason of this Challenge `status` + /// + [JsonProperty("responded_reason")] + [JsonConverter(typeof(StringEnumConverter))] + public ChallengeResource.ChallengeReasonsEnum RespondedReason { get; private set; } + /// + /// Details about the Challenge. + /// + [JsonProperty("details")] + public object Details { get; private set; } + /// + /// Hidden details about the Challenge + /// + [JsonProperty("hidden_details")] + public object HiddenDetails { get; private set; } + /// + /// The Factor Type of this Challenge + /// + [JsonProperty("factor_type")] + [JsonConverter(typeof(StringEnumConverter))] + public ChallengeResource.FactorTypesEnum FactorType { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ChallengeResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/FactorOptions.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/FactorOptions.cs index 26cddf213..94339a420 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/FactorOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/FactorOptions.cs @@ -9,258 +9,258 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Factor. + /// + public class DeleteFactorOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Factor. + /// Service Sid. /// - public class DeleteFactorOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// A string that uniquely identifies this Factor. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteFactorOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - public DeleteFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Factor. + /// Unique external identifier of the Entity /// - public class FetchFactorOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// A string that uniquely identifies this Factor. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchFactorOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - public FetchFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathIdentity { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Factors for an Entity. + /// A string that uniquely identifies this Factor. /// - public class ReadFactorOptions : ReadOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - - /// - /// Construct a new ReadFactorOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - public ReadFactorOptions(string pathServiceSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// Construct a new DeleteFactorOptions /// - public class UpdateFactorOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// A string that uniquely identifies this Factor. - /// - public string PathSid { get; } - /// - /// Optional payload to verify the Factor for the first time - /// - public string AuthPayload { get; set; } - /// - /// The friendly name of this Factor - /// - public string FriendlyName { get; set; } - /// - /// For APN, the device token. For FCM, the registration token - /// - public string ConfigNotificationToken { get; set; } - /// - /// The Verify Push SDK version used to configure the factor - /// - public string ConfigSdkVersion { get; set; } - /// - /// How often, in seconds, are TOTP codes generated - /// - public int? ConfigTimeStep { get; set; } - /// - /// The number of past and future time-steps valid at a given time - /// - public int? ConfigSkew { get; set; } - /// - /// Number of digits for generated TOTP codes - /// - public int? ConfigCodeLength { get; set; } - /// - /// The algorithm used to derive the TOTP codes - /// - public FactorResource.TotpAlgorithmsEnum ConfigAlg { get; set; } - /// - /// The transport technology used to generate the Notification Token - /// - public string ConfigNotificationPlatform { get; set; } - - /// - /// Construct a new UpdateFactorOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - public UpdateFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (AuthPayload != null) - { - p.Add(new KeyValuePair("AuthPayload", AuthPayload)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (ConfigNotificationToken != null) - { - p.Add(new KeyValuePair("Config.NotificationToken", ConfigNotificationToken)); - } - - if (ConfigSdkVersion != null) - { - p.Add(new KeyValuePair("Config.SdkVersion", ConfigSdkVersion)); - } - - if (ConfigTimeStep != null) - { - p.Add(new KeyValuePair("Config.TimeStep", ConfigTimeStep.ToString())); - } - - if (ConfigSkew != null) - { - p.Add(new KeyValuePair("Config.Skew", ConfigSkew.ToString())); - } - - if (ConfigCodeLength != null) - { - p.Add(new KeyValuePair("Config.CodeLength", ConfigCodeLength.ToString())); - } - - if (ConfigAlg != null) - { - p.Add(new KeyValuePair("Config.Alg", ConfigAlg.ToString())); - } - - if (ConfigNotificationPlatform != null) - { - p.Add(new KeyValuePair("Config.NotificationPlatform", ConfigNotificationPlatform)); - } - - return p; - } - } + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + public DeleteFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Factor. + /// + public class FetchFactorOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// A string that uniquely identifies this Factor. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchFactorOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + public FetchFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Factors for an Entity. + /// + public class ReadFactorOptions : ReadOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + + /// + /// Construct a new ReadFactorOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + public ReadFactorOptions(string pathServiceSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// + public class UpdateFactorOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// A string that uniquely identifies this Factor. + /// + public string PathSid { get; } + /// + /// Optional payload to verify the Factor for the first time + /// + public string AuthPayload { get; set; } + /// + /// The friendly name of this Factor + /// + public string FriendlyName { get; set; } + /// + /// For APN, the device token. For FCM, the registration token + /// + public string ConfigNotificationToken { get; set; } + /// + /// The Verify Push SDK version used to configure the factor + /// + public string ConfigSdkVersion { get; set; } + /// + /// How often, in seconds, are TOTP codes generated + /// + public int? ConfigTimeStep { get; set; } + /// + /// The number of past and future time-steps valid at a given time + /// + public int? ConfigSkew { get; set; } + /// + /// Number of digits for generated TOTP codes + /// + public int? ConfigCodeLength { get; set; } + /// + /// The algorithm used to derive the TOTP codes + /// + public FactorResource.TotpAlgorithmsEnum ConfigAlg { get; set; } + /// + /// The transport technology used to generate the Notification Token + /// + public string ConfigNotificationPlatform { get; set; } + + /// + /// Construct a new UpdateFactorOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + public UpdateFactorOptions(string pathServiceSid, string pathIdentity, string pathSid) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (AuthPayload != null) + { + p.Add(new KeyValuePair("AuthPayload", AuthPayload)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (ConfigNotificationToken != null) + { + p.Add(new KeyValuePair("Config.NotificationToken", ConfigNotificationToken)); + } + + if (ConfigSdkVersion != null) + { + p.Add(new KeyValuePair("Config.SdkVersion", ConfigSdkVersion)); + } + + if (ConfigTimeStep != null) + { + p.Add(new KeyValuePair("Config.TimeStep", ConfigTimeStep.ToString())); + } + + if (ConfigSkew != null) + { + p.Add(new KeyValuePair("Config.Skew", ConfigSkew.ToString())); + } + + if (ConfigCodeLength != null) + { + p.Add(new KeyValuePair("Config.CodeLength", ConfigCodeLength.ToString())); + } + + if (ConfigAlg != null) + { + p.Add(new KeyValuePair("Config.Alg", ConfigAlg.ToString())); + } + + if (ConfigNotificationPlatform != null) + { + p.Add(new KeyValuePair("Config.NotificationPlatform", ConfigNotificationPlatform)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/FactorResource.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/FactorResource.cs index 038dd6e45..096b992c2 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/FactorResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/FactorResource.cs @@ -19,550 +19,550 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - - public class FactorResource : Resource - { - public sealed class FactorStatusesEnum : StringEnum - { - private FactorStatusesEnum(string value) : base(value) {} - public FactorStatusesEnum() {} - public static implicit operator FactorStatusesEnum(string value) - { - return new FactorStatusesEnum(value); - } - - public static readonly FactorStatusesEnum Unverified = new FactorStatusesEnum("unverified"); - public static readonly FactorStatusesEnum Verified = new FactorStatusesEnum("verified"); - } - - public sealed class FactorTypesEnum : StringEnum - { - private FactorTypesEnum(string value) : base(value) {} - public FactorTypesEnum() {} - public static implicit operator FactorTypesEnum(string value) - { - return new FactorTypesEnum(value); - } - - public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); - public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); - } - - public sealed class NotificationPlatformsEnum : StringEnum - { - private NotificationPlatformsEnum(string value) : base(value) {} - public NotificationPlatformsEnum() {} - public static implicit operator NotificationPlatformsEnum(string value) - { - return new NotificationPlatformsEnum(value); - } - - public static readonly NotificationPlatformsEnum Apn = new NotificationPlatformsEnum("apn"); - public static readonly NotificationPlatformsEnum Fcm = new NotificationPlatformsEnum("fcm"); - public static readonly NotificationPlatformsEnum None = new NotificationPlatformsEnum("none"); - } - - public sealed class TotpAlgorithmsEnum : StringEnum - { - private TotpAlgorithmsEnum(string value) : base(value) {} - public TotpAlgorithmsEnum() {} - public static implicit operator TotpAlgorithmsEnum(string value) - { - return new TotpAlgorithmsEnum(value); - } - - public static readonly TotpAlgorithmsEnum Sha1 = new TotpAlgorithmsEnum("sha1"); - public static readonly TotpAlgorithmsEnum Sha256 = new TotpAlgorithmsEnum("sha256"); - public static readonly TotpAlgorithmsEnum Sha512 = new TotpAlgorithmsEnum("sha512"); - } - - private static Request BuildDeleteRequest(DeleteFactorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Factor. - /// - /// Delete Factor parameters - /// Client to make requests to Twilio - /// A single instance of Factor - public static bool Delete(DeleteFactorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Factor. - /// - /// Delete Factor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task DeleteAsync(DeleteFactorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Client to make requests to Twilio - /// A single instance of Factor - public static bool Delete(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFactorOptions(pathServiceSid, pathIdentity, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteFactorOptions(pathServiceSid, pathIdentity, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchFactorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Factor. - /// - /// Fetch Factor parameters - /// Client to make requests to Twilio - /// A single instance of Factor - public static FactorResource Fetch(FetchFactorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Factor. - /// - /// Fetch Factor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task FetchAsync(FetchFactorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Client to make requests to Twilio - /// A single instance of Factor - public static FactorResource Fetch(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFactorOptions(pathServiceSid, pathIdentity, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Factor. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathIdentity, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchFactorOptions(pathServiceSid, pathIdentity, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadFactorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Factors for an Entity. - /// - /// Read Factor parameters - /// Client to make requests to Twilio - /// A single instance of Factor - public static ResourceSet Read(ReadFactorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("factors", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Factors for an Entity. - /// - /// Read Factor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task> ReadAsync(ReadFactorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("factors", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Factors for an Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Factor - public static ResourceSet Read(string pathServiceSid, - string pathIdentity, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFactorOptions(pathServiceSid, pathIdentity){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Factors for an Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathIdentity, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadFactorOptions(pathServiceSid, pathIdentity){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("factors", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("factors", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("factors", response.Content); - } - - private static Request BuildUpdateRequest(UpdateFactorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. - /// - /// Update Factor parameters - /// Client to make requests to Twilio - /// A single instance of Factor - public static FactorResource Update(UpdateFactorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. - /// - /// Update Factor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task UpdateAsync(UpdateFactorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Optional payload to verify the Factor for the first time - /// The friendly name of this Factor - /// For APN, the device token. For FCM, the registration token - /// The Verify Push SDK version used to configure the factor - /// How often, in seconds, are TOTP codes generated - /// The number of past and future time-steps valid at a given time - /// Number of digits for generated TOTP codes - /// The algorithm used to derive the TOTP codes - /// The transport technology used to generate the Notification Token - /// Client to make requests to Twilio - /// A single instance of Factor - public static FactorResource Update(string pathServiceSid, - string pathIdentity, - string pathSid, - string authPayload = null, - string friendlyName = null, - string configNotificationToken = null, - string configSdkVersion = null, - int? configTimeStep = null, - int? configSkew = null, - int? configCodeLength = null, - FactorResource.TotpAlgorithmsEnum configAlg = null, - string configNotificationPlatform = null, - ITwilioRestClient client = null) - { - var options = new UpdateFactorOptions(pathServiceSid, pathIdentity, pathSid){AuthPayload = authPayload, FriendlyName = friendlyName, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg, ConfigNotificationPlatform = configNotificationPlatform}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// A string that uniquely identifies this Factor. - /// Optional payload to verify the Factor for the first time - /// The friendly name of this Factor - /// For APN, the device token. For FCM, the registration token - /// The Verify Push SDK version used to configure the factor - /// How often, in seconds, are TOTP codes generated - /// The number of past and future time-steps valid at a given time - /// Number of digits for generated TOTP codes - /// The algorithm used to derive the TOTP codes - /// The transport technology used to generate the Notification Token - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Factor - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathIdentity, - string pathSid, - string authPayload = null, - string friendlyName = null, - string configNotificationToken = null, - string configSdkVersion = null, - int? configTimeStep = null, - int? configSkew = null, - int? configCodeLength = null, - FactorResource.TotpAlgorithmsEnum configAlg = null, - string configNotificationPlatform = null, - ITwilioRestClient client = null) - { - var options = new UpdateFactorOptions(pathServiceSid, pathIdentity, pathSid){AuthPayload = authPayload, FriendlyName = friendlyName, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg, ConfigNotificationPlatform = configNotificationPlatform}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a FactorResource object - /// - /// Raw JSON string - /// FactorResource object represented by the provided JSON - public static FactorResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Factor. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Entity Sid. - /// - [JsonProperty("entity_sid")] - public string EntitySid { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The date this Factor was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Factor was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A human readable description of this resource. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The Status of this Factor - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public FactorResource.FactorStatusesEnum Status { get; private set; } - /// - /// The Type of this Factor - /// - [JsonProperty("factor_type")] - [JsonConverter(typeof(StringEnumConverter))] - public FactorResource.FactorTypesEnum FactorType { get; private set; } - /// - /// Configurations for a `factor_type`. - /// - [JsonProperty("config")] - public object Config { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private FactorResource() - { - - } - } +{ + + public class FactorResource : Resource + { + public sealed class FactorStatusesEnum : StringEnum + { + private FactorStatusesEnum(string value) : base(value) { } + public FactorStatusesEnum() { } + public static implicit operator FactorStatusesEnum(string value) + { + return new FactorStatusesEnum(value); + } + + public static readonly FactorStatusesEnum Unverified = new FactorStatusesEnum("unverified"); + public static readonly FactorStatusesEnum Verified = new FactorStatusesEnum("verified"); + } + + public sealed class FactorTypesEnum : StringEnum + { + private FactorTypesEnum(string value) : base(value) { } + public FactorTypesEnum() { } + public static implicit operator FactorTypesEnum(string value) + { + return new FactorTypesEnum(value); + } + + public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); + public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); + } + + public sealed class NotificationPlatformsEnum : StringEnum + { + private NotificationPlatformsEnum(string value) : base(value) { } + public NotificationPlatformsEnum() { } + public static implicit operator NotificationPlatformsEnum(string value) + { + return new NotificationPlatformsEnum(value); + } + + public static readonly NotificationPlatformsEnum Apn = new NotificationPlatformsEnum("apn"); + public static readonly NotificationPlatformsEnum Fcm = new NotificationPlatformsEnum("fcm"); + public static readonly NotificationPlatformsEnum None = new NotificationPlatformsEnum("none"); + } + + public sealed class TotpAlgorithmsEnum : StringEnum + { + private TotpAlgorithmsEnum(string value) : base(value) { } + public TotpAlgorithmsEnum() { } + public static implicit operator TotpAlgorithmsEnum(string value) + { + return new TotpAlgorithmsEnum(value); + } + + public static readonly TotpAlgorithmsEnum Sha1 = new TotpAlgorithmsEnum("sha1"); + public static readonly TotpAlgorithmsEnum Sha256 = new TotpAlgorithmsEnum("sha256"); + public static readonly TotpAlgorithmsEnum Sha512 = new TotpAlgorithmsEnum("sha512"); + } + + private static Request BuildDeleteRequest(DeleteFactorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Factor. + /// + /// Delete Factor parameters + /// Client to make requests to Twilio + /// A single instance of Factor + public static bool Delete(DeleteFactorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Factor. + /// + /// Delete Factor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task DeleteAsync(DeleteFactorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Client to make requests to Twilio + /// A single instance of Factor + public static bool Delete(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFactorOptions(pathServiceSid, pathIdentity, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteFactorOptions(pathServiceSid, pathIdentity, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchFactorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Factor. + /// + /// Fetch Factor parameters + /// Client to make requests to Twilio + /// A single instance of Factor + public static FactorResource Fetch(FetchFactorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Factor. + /// + /// Fetch Factor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task FetchAsync(FetchFactorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Client to make requests to Twilio + /// A single instance of Factor + public static FactorResource Fetch(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFactorOptions(pathServiceSid, pathIdentity, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Factor. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathIdentity, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchFactorOptions(pathServiceSid, pathIdentity, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadFactorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Factors for an Entity. + /// + /// Read Factor parameters + /// Client to make requests to Twilio + /// A single instance of Factor + public static ResourceSet Read(ReadFactorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("factors", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Factors for an Entity. + /// + /// Read Factor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task> ReadAsync(ReadFactorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("factors", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Factors for an Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Factor + public static ResourceSet Read(string pathServiceSid, + string pathIdentity, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFactorOptions(pathServiceSid, pathIdentity) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Factors for an Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathIdentity, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadFactorOptions(pathServiceSid, pathIdentity) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("factors", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("factors", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("factors", response.Content); + } + + private static Request BuildUpdateRequest(UpdateFactorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// + /// Update Factor parameters + /// Client to make requests to Twilio + /// A single instance of Factor + public static FactorResource Update(UpdateFactorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// + /// Update Factor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task UpdateAsync(UpdateFactorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Optional payload to verify the Factor for the first time + /// The friendly name of this Factor + /// For APN, the device token. For FCM, the registration token + /// The Verify Push SDK version used to configure the factor + /// How often, in seconds, are TOTP codes generated + /// The number of past and future time-steps valid at a given time + /// Number of digits for generated TOTP codes + /// The algorithm used to derive the TOTP codes + /// The transport technology used to generate the Notification Token + /// Client to make requests to Twilio + /// A single instance of Factor + public static FactorResource Update(string pathServiceSid, + string pathIdentity, + string pathSid, + string authPayload = null, + string friendlyName = null, + string configNotificationToken = null, + string configSdkVersion = null, + int? configTimeStep = null, + int? configSkew = null, + int? configCodeLength = null, + FactorResource.TotpAlgorithmsEnum configAlg = null, + string configNotificationPlatform = null, + ITwilioRestClient client = null) + { + var options = new UpdateFactorOptions(pathServiceSid, pathIdentity, pathSid) { AuthPayload = authPayload, FriendlyName = friendlyName, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg, ConfigNotificationPlatform = configNotificationPlatform }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Factor. This endpoint can be used to Verify a Factor if passed an `AuthPayload` param. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// A string that uniquely identifies this Factor. + /// Optional payload to verify the Factor for the first time + /// The friendly name of this Factor + /// For APN, the device token. For FCM, the registration token + /// The Verify Push SDK version used to configure the factor + /// How often, in seconds, are TOTP codes generated + /// The number of past and future time-steps valid at a given time + /// Number of digits for generated TOTP codes + /// The algorithm used to derive the TOTP codes + /// The transport technology used to generate the Notification Token + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Factor + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathIdentity, + string pathSid, + string authPayload = null, + string friendlyName = null, + string configNotificationToken = null, + string configSdkVersion = null, + int? configTimeStep = null, + int? configSkew = null, + int? configCodeLength = null, + FactorResource.TotpAlgorithmsEnum configAlg = null, + string configNotificationPlatform = null, + ITwilioRestClient client = null) + { + var options = new UpdateFactorOptions(pathServiceSid, pathIdentity, pathSid) { AuthPayload = authPayload, FriendlyName = friendlyName, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg, ConfigNotificationPlatform = configNotificationPlatform }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a FactorResource object + /// + /// Raw JSON string + /// FactorResource object represented by the provided JSON + public static FactorResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Factor. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Entity Sid. + /// + [JsonProperty("entity_sid")] + public string EntitySid { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The date this Factor was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Factor was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A human readable description of this resource. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The Status of this Factor + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public FactorResource.FactorStatusesEnum Status { get; private set; } + /// + /// The Type of this Factor + /// + [JsonProperty("factor_type")] + [JsonConverter(typeof(StringEnumConverter))] + public FactorResource.FactorTypesEnum FactorType { get; private set; } + /// + /// Configurations for a `factor_type`. + /// + [JsonProperty("config")] + public object Config { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private FactorResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorOptions.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorOptions.cs index 66e046f87..5c6f6026e 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorOptions.cs @@ -9,167 +9,167 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Factor for the Entity + /// + public class CreateNewFactorOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Factor for the Entity - /// - public class CreateNewFactorOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - /// - /// The friendly name of this Factor - /// - public string FriendlyName { get; } - /// - /// The Type of this Factor - /// - public NewFactorResource.FactorTypesEnum FactorType { get; } - /// - /// The algorithm used when `factor_type` is `push` - /// - public string BindingAlg { get; set; } - /// - /// The public key encoded in Base64 - /// - public string BindingPublicKey { get; set; } - /// - /// The ID that uniquely identifies your app in the Google or Apple store - /// - public string ConfigAppId { get; set; } - /// - /// The transport technology used to generate the Notification Token - /// - public NewFactorResource.NotificationPlatformsEnum ConfigNotificationPlatform { get; set; } - /// - /// For APN, the device token. For FCM, the registration token - /// - public string ConfigNotificationToken { get; set; } - /// - /// The Verify Push SDK version used to configure the factor - /// - public string ConfigSdkVersion { get; set; } - /// - /// The shared secret in Base32 - /// - public string BindingSecret { get; set; } - /// - /// How often, in seconds, are TOTP codes generated - /// - public int? ConfigTimeStep { get; set; } - /// - /// The number of past and future time-steps valid at a given time - /// - public int? ConfigSkew { get; set; } - /// - /// Number of digits for generated TOTP codes - /// - public int? ConfigCodeLength { get; set; } - /// - /// The algorithm used to derive the TOTP codes - /// - public NewFactorResource.TotpAlgorithmsEnum ConfigAlg { get; set; } - - /// - /// Construct a new CreateNewFactorOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The friendly name of this Factor - /// The Type of this Factor - public CreateNewFactorOptions(string pathServiceSid, - string pathIdentity, - string friendlyName, - NewFactorResource.FactorTypesEnum factorType) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - FriendlyName = friendlyName; - FactorType = factorType; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (FactorType != null) - { - p.Add(new KeyValuePair("FactorType", FactorType.ToString())); - } - - if (BindingAlg != null) - { - p.Add(new KeyValuePair("Binding.Alg", BindingAlg)); - } - - if (BindingPublicKey != null) - { - p.Add(new KeyValuePair("Binding.PublicKey", BindingPublicKey.ToString())); - } - - if (ConfigAppId != null) - { - p.Add(new KeyValuePair("Config.AppId", ConfigAppId)); - } - - if (ConfigNotificationPlatform != null) - { - p.Add(new KeyValuePair("Config.NotificationPlatform", ConfigNotificationPlatform.ToString())); - } - - if (ConfigNotificationToken != null) - { - p.Add(new KeyValuePair("Config.NotificationToken", ConfigNotificationToken)); - } - - if (ConfigSdkVersion != null) - { - p.Add(new KeyValuePair("Config.SdkVersion", ConfigSdkVersion)); - } - - if (BindingSecret != null) - { - p.Add(new KeyValuePair("Binding.Secret", BindingSecret)); - } - - if (ConfigTimeStep != null) - { - p.Add(new KeyValuePair("Config.TimeStep", ConfigTimeStep.ToString())); - } - - if (ConfigSkew != null) - { - p.Add(new KeyValuePair("Config.Skew", ConfigSkew.ToString())); - } - - if (ConfigCodeLength != null) - { - p.Add(new KeyValuePair("Config.CodeLength", ConfigCodeLength.ToString())); - } - - if (ConfigAlg != null) - { - p.Add(new KeyValuePair("Config.Alg", ConfigAlg.ToString())); - } - - return p; - } - } + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + /// + /// The friendly name of this Factor + /// + public string FriendlyName { get; } + /// + /// The Type of this Factor + /// + public NewFactorResource.FactorTypesEnum FactorType { get; } + /// + /// The algorithm used when `factor_type` is `push` + /// + public string BindingAlg { get; set; } + /// + /// The public key encoded in Base64 + /// + public string BindingPublicKey { get; set; } + /// + /// The ID that uniquely identifies your app in the Google or Apple store + /// + public string ConfigAppId { get; set; } + /// + /// The transport technology used to generate the Notification Token + /// + public NewFactorResource.NotificationPlatformsEnum ConfigNotificationPlatform { get; set; } + /// + /// For APN, the device token. For FCM, the registration token + /// + public string ConfigNotificationToken { get; set; } + /// + /// The Verify Push SDK version used to configure the factor + /// + public string ConfigSdkVersion { get; set; } + /// + /// The shared secret in Base32 + /// + public string BindingSecret { get; set; } + /// + /// How often, in seconds, are TOTP codes generated + /// + public int? ConfigTimeStep { get; set; } + /// + /// The number of past and future time-steps valid at a given time + /// + public int? ConfigSkew { get; set; } + /// + /// Number of digits for generated TOTP codes + /// + public int? ConfigCodeLength { get; set; } + /// + /// The algorithm used to derive the TOTP codes + /// + public NewFactorResource.TotpAlgorithmsEnum ConfigAlg { get; set; } + + /// + /// Construct a new CreateNewFactorOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The friendly name of this Factor + /// The Type of this Factor + public CreateNewFactorOptions(string pathServiceSid, + string pathIdentity, + string friendlyName, + NewFactorResource.FactorTypesEnum factorType) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + FriendlyName = friendlyName; + FactorType = factorType; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (FactorType != null) + { + p.Add(new KeyValuePair("FactorType", FactorType.ToString())); + } + + if (BindingAlg != null) + { + p.Add(new KeyValuePair("Binding.Alg", BindingAlg)); + } + + if (BindingPublicKey != null) + { + p.Add(new KeyValuePair("Binding.PublicKey", BindingPublicKey.ToString())); + } + + if (ConfigAppId != null) + { + p.Add(new KeyValuePair("Config.AppId", ConfigAppId)); + } + + if (ConfigNotificationPlatform != null) + { + p.Add(new KeyValuePair("Config.NotificationPlatform", ConfigNotificationPlatform.ToString())); + } + + if (ConfigNotificationToken != null) + { + p.Add(new KeyValuePair("Config.NotificationToken", ConfigNotificationToken)); + } + + if (ConfigSdkVersion != null) + { + p.Add(new KeyValuePair("Config.SdkVersion", ConfigSdkVersion)); + } + + if (BindingSecret != null) + { + p.Add(new KeyValuePair("Binding.Secret", BindingSecret)); + } + + if (ConfigTimeStep != null) + { + p.Add(new KeyValuePair("Config.TimeStep", ConfigTimeStep.ToString())); + } + + if (ConfigSkew != null) + { + p.Add(new KeyValuePair("Config.Skew", ConfigSkew.ToString())); + } + + if (ConfigCodeLength != null) + { + p.Add(new KeyValuePair("Config.CodeLength", ConfigCodeLength.ToString())); + } + + if (ConfigAlg != null) + { + p.Add(new KeyValuePair("Config.Alg", ConfigAlg.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorResource.cs b/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorResource.cs index a71833403..61b1312e7 100644 --- a/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/Entity/NewFactorResource.cs @@ -19,278 +19,278 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service.Entity -{ - - public class NewFactorResource : Resource - { - public sealed class FactorStatusesEnum : StringEnum - { - private FactorStatusesEnum(string value) : base(value) {} - public FactorStatusesEnum() {} - public static implicit operator FactorStatusesEnum(string value) - { - return new FactorStatusesEnum(value); - } - - public static readonly FactorStatusesEnum Unverified = new FactorStatusesEnum("unverified"); - public static readonly FactorStatusesEnum Verified = new FactorStatusesEnum("verified"); - } - - public sealed class FactorTypesEnum : StringEnum - { - private FactorTypesEnum(string value) : base(value) {} - public FactorTypesEnum() {} - public static implicit operator FactorTypesEnum(string value) - { - return new FactorTypesEnum(value); - } - - public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); - public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); - } - - public sealed class NotificationPlatformsEnum : StringEnum - { - private NotificationPlatformsEnum(string value) : base(value) {} - public NotificationPlatformsEnum() {} - public static implicit operator NotificationPlatformsEnum(string value) - { - return new NotificationPlatformsEnum(value); - } - - public static readonly NotificationPlatformsEnum Apn = new NotificationPlatformsEnum("apn"); - public static readonly NotificationPlatformsEnum Fcm = new NotificationPlatformsEnum("fcm"); - public static readonly NotificationPlatformsEnum None = new NotificationPlatformsEnum("none"); - } - - public sealed class TotpAlgorithmsEnum : StringEnum - { - private TotpAlgorithmsEnum(string value) : base(value) {} - public TotpAlgorithmsEnum() {} - public static implicit operator TotpAlgorithmsEnum(string value) - { - return new TotpAlgorithmsEnum(value); - } - - public static readonly TotpAlgorithmsEnum Sha1 = new TotpAlgorithmsEnum("sha1"); - public static readonly TotpAlgorithmsEnum Sha256 = new TotpAlgorithmsEnum("sha256"); - public static readonly TotpAlgorithmsEnum Sha512 = new TotpAlgorithmsEnum("sha512"); - } - - private static Request BuildCreateRequest(CreateNewFactorOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Factor for the Entity - /// - /// Create NewFactor parameters - /// Client to make requests to Twilio - /// A single instance of NewFactor - public static NewFactorResource Create(CreateNewFactorOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Factor for the Entity - /// - /// Create NewFactor parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewFactor - public static async System.Threading.Tasks.Task CreateAsync(CreateNewFactorOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Factor for the Entity - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The friendly name of this Factor - /// The Type of this Factor - /// The algorithm used when `factor_type` is `push` - /// The public key encoded in Base64 - /// The ID that uniquely identifies your app in the Google or Apple store - /// The transport technology used to generate the Notification Token - /// For APN, the device token. For FCM, the registration token - /// The Verify Push SDK version used to configure the factor - /// The shared secret in Base32 - /// How often, in seconds, are TOTP codes generated - /// The number of past and future time-steps valid at a given time - /// Number of digits for generated TOTP codes - /// The algorithm used to derive the TOTP codes - /// Client to make requests to Twilio - /// A single instance of NewFactor - public static NewFactorResource Create(string pathServiceSid, - string pathIdentity, - string friendlyName, - NewFactorResource.FactorTypesEnum factorType, - string bindingAlg = null, - string bindingPublicKey = null, - string configAppId = null, - NewFactorResource.NotificationPlatformsEnum configNotificationPlatform = null, - string configNotificationToken = null, - string configSdkVersion = null, - string bindingSecret = null, - int? configTimeStep = null, - int? configSkew = null, - int? configCodeLength = null, - NewFactorResource.TotpAlgorithmsEnum configAlg = null, - ITwilioRestClient client = null) - { - var options = new CreateNewFactorOptions(pathServiceSid, pathIdentity, friendlyName, factorType){BindingAlg = bindingAlg, BindingPublicKey = bindingPublicKey, ConfigAppId = configAppId, ConfigNotificationPlatform = configNotificationPlatform, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, BindingSecret = bindingSecret, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Factor for the Entity - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// The friendly name of this Factor - /// The Type of this Factor - /// The algorithm used when `factor_type` is `push` - /// The public key encoded in Base64 - /// The ID that uniquely identifies your app in the Google or Apple store - /// The transport technology used to generate the Notification Token - /// For APN, the device token. For FCM, the registration token - /// The Verify Push SDK version used to configure the factor - /// The shared secret in Base32 - /// How often, in seconds, are TOTP codes generated - /// The number of past and future time-steps valid at a given time - /// Number of digits for generated TOTP codes - /// The algorithm used to derive the TOTP codes - /// Client to make requests to Twilio - /// Task that resolves to A single instance of NewFactor - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathIdentity, - string friendlyName, - NewFactorResource.FactorTypesEnum factorType, - string bindingAlg = null, - string bindingPublicKey = null, - string configAppId = null, - NewFactorResource.NotificationPlatformsEnum configNotificationPlatform = null, - string configNotificationToken = null, - string configSdkVersion = null, - string bindingSecret = null, - int? configTimeStep = null, - int? configSkew = null, - int? configCodeLength = null, - NewFactorResource.TotpAlgorithmsEnum configAlg = null, - ITwilioRestClient client = null) - { - var options = new CreateNewFactorOptions(pathServiceSid, pathIdentity, friendlyName, factorType){BindingAlg = bindingAlg, BindingPublicKey = bindingPublicKey, ConfigAppId = configAppId, ConfigNotificationPlatform = configNotificationPlatform, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, BindingSecret = bindingSecret, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a NewFactorResource object - /// - /// Raw JSON string - /// NewFactorResource object represented by the provided JSON - public static NewFactorResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Factor. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// Entity Sid. - /// - [JsonProperty("entity_sid")] - public string EntitySid { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("binding")] - public object Binding { get; private set; } - /// - /// The date this Factor was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Factor was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// A human readable description of this resource. - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The Status of this Factor - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public NewFactorResource.FactorStatusesEnum Status { get; private set; } - /// - /// The Type of this Factor - /// - [JsonProperty("factor_type")] - [JsonConverter(typeof(StringEnumConverter))] - public NewFactorResource.FactorTypesEnum FactorType { get; private set; } - /// - /// Binding for a `factor_type`. - /// - [JsonProperty("config")] - public object Config { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private NewFactorResource() - { - - } - } +{ + + public class NewFactorResource : Resource + { + public sealed class FactorStatusesEnum : StringEnum + { + private FactorStatusesEnum(string value) : base(value) { } + public FactorStatusesEnum() { } + public static implicit operator FactorStatusesEnum(string value) + { + return new FactorStatusesEnum(value); + } + + public static readonly FactorStatusesEnum Unverified = new FactorStatusesEnum("unverified"); + public static readonly FactorStatusesEnum Verified = new FactorStatusesEnum("verified"); + } + + public sealed class FactorTypesEnum : StringEnum + { + private FactorTypesEnum(string value) : base(value) { } + public FactorTypesEnum() { } + public static implicit operator FactorTypesEnum(string value) + { + return new FactorTypesEnum(value); + } + + public static readonly FactorTypesEnum Push = new FactorTypesEnum("push"); + public static readonly FactorTypesEnum Totp = new FactorTypesEnum("totp"); + } + + public sealed class NotificationPlatformsEnum : StringEnum + { + private NotificationPlatformsEnum(string value) : base(value) { } + public NotificationPlatformsEnum() { } + public static implicit operator NotificationPlatformsEnum(string value) + { + return new NotificationPlatformsEnum(value); + } + + public static readonly NotificationPlatformsEnum Apn = new NotificationPlatformsEnum("apn"); + public static readonly NotificationPlatformsEnum Fcm = new NotificationPlatformsEnum("fcm"); + public static readonly NotificationPlatformsEnum None = new NotificationPlatformsEnum("none"); + } + + public sealed class TotpAlgorithmsEnum : StringEnum + { + private TotpAlgorithmsEnum(string value) : base(value) { } + public TotpAlgorithmsEnum() { } + public static implicit operator TotpAlgorithmsEnum(string value) + { + return new TotpAlgorithmsEnum(value); + } + + public static readonly TotpAlgorithmsEnum Sha1 = new TotpAlgorithmsEnum("sha1"); + public static readonly TotpAlgorithmsEnum Sha256 = new TotpAlgorithmsEnum("sha256"); + public static readonly TotpAlgorithmsEnum Sha512 = new TotpAlgorithmsEnum("sha512"); + } + + private static Request BuildCreateRequest(CreateNewFactorOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Factor for the Entity + /// + /// Create NewFactor parameters + /// Client to make requests to Twilio + /// A single instance of NewFactor + public static NewFactorResource Create(CreateNewFactorOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Factor for the Entity + /// + /// Create NewFactor parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewFactor + public static async System.Threading.Tasks.Task CreateAsync(CreateNewFactorOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Factor for the Entity + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The friendly name of this Factor + /// The Type of this Factor + /// The algorithm used when `factor_type` is `push` + /// The public key encoded in Base64 + /// The ID that uniquely identifies your app in the Google or Apple store + /// The transport technology used to generate the Notification Token + /// For APN, the device token. For FCM, the registration token + /// The Verify Push SDK version used to configure the factor + /// The shared secret in Base32 + /// How often, in seconds, are TOTP codes generated + /// The number of past and future time-steps valid at a given time + /// Number of digits for generated TOTP codes + /// The algorithm used to derive the TOTP codes + /// Client to make requests to Twilio + /// A single instance of NewFactor + public static NewFactorResource Create(string pathServiceSid, + string pathIdentity, + string friendlyName, + NewFactorResource.FactorTypesEnum factorType, + string bindingAlg = null, + string bindingPublicKey = null, + string configAppId = null, + NewFactorResource.NotificationPlatformsEnum configNotificationPlatform = null, + string configNotificationToken = null, + string configSdkVersion = null, + string bindingSecret = null, + int? configTimeStep = null, + int? configSkew = null, + int? configCodeLength = null, + NewFactorResource.TotpAlgorithmsEnum configAlg = null, + ITwilioRestClient client = null) + { + var options = new CreateNewFactorOptions(pathServiceSid, pathIdentity, friendlyName, factorType) { BindingAlg = bindingAlg, BindingPublicKey = bindingPublicKey, ConfigAppId = configAppId, ConfigNotificationPlatform = configNotificationPlatform, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, BindingSecret = bindingSecret, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Factor for the Entity + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// The friendly name of this Factor + /// The Type of this Factor + /// The algorithm used when `factor_type` is `push` + /// The public key encoded in Base64 + /// The ID that uniquely identifies your app in the Google or Apple store + /// The transport technology used to generate the Notification Token + /// For APN, the device token. For FCM, the registration token + /// The Verify Push SDK version used to configure the factor + /// The shared secret in Base32 + /// How often, in seconds, are TOTP codes generated + /// The number of past and future time-steps valid at a given time + /// Number of digits for generated TOTP codes + /// The algorithm used to derive the TOTP codes + /// Client to make requests to Twilio + /// Task that resolves to A single instance of NewFactor + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathIdentity, + string friendlyName, + NewFactorResource.FactorTypesEnum factorType, + string bindingAlg = null, + string bindingPublicKey = null, + string configAppId = null, + NewFactorResource.NotificationPlatformsEnum configNotificationPlatform = null, + string configNotificationToken = null, + string configSdkVersion = null, + string bindingSecret = null, + int? configTimeStep = null, + int? configSkew = null, + int? configCodeLength = null, + NewFactorResource.TotpAlgorithmsEnum configAlg = null, + ITwilioRestClient client = null) + { + var options = new CreateNewFactorOptions(pathServiceSid, pathIdentity, friendlyName, factorType) { BindingAlg = bindingAlg, BindingPublicKey = bindingPublicKey, ConfigAppId = configAppId, ConfigNotificationPlatform = configNotificationPlatform, ConfigNotificationToken = configNotificationToken, ConfigSdkVersion = configSdkVersion, BindingSecret = bindingSecret, ConfigTimeStep = configTimeStep, ConfigSkew = configSkew, ConfigCodeLength = configCodeLength, ConfigAlg = configAlg }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a NewFactorResource object + /// + /// Raw JSON string + /// NewFactorResource object represented by the provided JSON + public static NewFactorResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Factor. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// Entity Sid. + /// + [JsonProperty("entity_sid")] + public string EntitySid { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("binding")] + public object Binding { get; private set; } + /// + /// The date this Factor was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Factor was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// A human readable description of this resource. + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The Status of this Factor + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public NewFactorResource.FactorStatusesEnum Status { get; private set; } + /// + /// The Type of this Factor + /// + [JsonProperty("factor_type")] + [JsonConverter(typeof(StringEnumConverter))] + public NewFactorResource.FactorTypesEnum FactorType { get; private set; } + /// + /// Binding for a `factor_type`. + /// + [JsonProperty("config")] + public object Config { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private NewFactorResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/EntityOptions.cs b/src/Twilio/Rest/Verify/V2/Service/EntityOptions.cs index dfbe35bab..764ed4e7c 100644 --- a/src/Twilio/Rest/Verify/V2/Service/EntityOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/EntityOptions.cs @@ -9,158 +9,158 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Entity for the Service + /// + public class CreateEntityOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Entity for the Service + /// Service Sid. /// - public class CreateEntityOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string Identity { get; } - - /// - /// Construct a new CreateEntityOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - public CreateEntityOptions(string pathServiceSid, string identity) - { - PathServiceSid = pathServiceSid; - Identity = identity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Entity. + /// Unique external identifier of the Entity /// - public class DeleteEntityOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - - /// - /// Construct a new DeleteEntityOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - public DeleteEntityOptions(string pathServiceSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string Identity { get; } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Entity. + /// Construct a new CreateEntityOptions /// - public class FetchEntityOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// Unique external identifier of the Entity - /// - public string PathIdentity { get; } - - /// - /// Construct a new FetchEntityOptions - /// - /// Service Sid. - /// Unique external identifier of the Entity - public FetchEntityOptions(string pathServiceSid, string pathIdentity) - { - PathServiceSid = pathServiceSid; - PathIdentity = pathIdentity; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Service Sid. + /// Unique external identifier of the Entity + public CreateEntityOptions(string pathServiceSid, string identity) + { + PathServiceSid = pathServiceSid; + Identity = identity; + } + /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Entities for a Service. + /// Generate the necessary parameters /// - public class ReadEntityOptions : ReadOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadEntityOptions - /// - /// Service Sid. - public ReadEntityOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Entity. + /// + public class DeleteEntityOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + + /// + /// Construct a new DeleteEntityOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + public DeleteEntityOptions(string pathServiceSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Entity. + /// + public class FetchEntityOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// Unique external identifier of the Entity + /// + public string PathIdentity { get; } + + /// + /// Construct a new FetchEntityOptions + /// + /// Service Sid. + /// Unique external identifier of the Entity + public FetchEntityOptions(string pathServiceSid, string pathIdentity) + { + PathServiceSid = pathServiceSid; + PathIdentity = pathIdentity; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Entities for a Service. + /// + public class ReadEntityOptions : ReadOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadEntityOptions + /// + /// Service Sid. + public ReadEntityOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/EntityResource.cs b/src/Twilio/Rest/Verify/V2/Service/EntityResource.cs index 6d031f449..cfbc41655 100644 --- a/src/Twilio/Rest/Verify/V2/Service/EntityResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/EntityResource.cs @@ -18,416 +18,416 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2.Service -{ - - public class EntityResource : Resource - { - private static Request BuildCreateRequest(CreateEntityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Entity for the Service - /// - /// Create Entity parameters - /// Client to make requests to Twilio - /// A single instance of Entity - public static EntityResource Create(CreateEntityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Entity for the Service - /// - /// Create Entity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task CreateAsync(CreateEntityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Entity for the Service - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// A single instance of Entity - public static EntityResource Create(string pathServiceSid, string identity, ITwilioRestClient client = null) - { - var options = new CreateEntityOptions(pathServiceSid, identity); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Entity for the Service - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string identity, - ITwilioRestClient client = null) - { - var options = new CreateEntityOptions(pathServiceSid, identity); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteEntityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Entity. - /// - /// Delete Entity parameters - /// Client to make requests to Twilio - /// A single instance of Entity - public static bool Delete(DeleteEntityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Entity. - /// - /// Delete Entity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task DeleteAsync(DeleteEntityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// A single instance of Entity - public static bool Delete(string pathServiceSid, string pathIdentity, ITwilioRestClient client = null) - { - var options = new DeleteEntityOptions(pathServiceSid, pathIdentity); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new DeleteEntityOptions(pathServiceSid, pathIdentity); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchEntityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Entity. - /// - /// Fetch Entity parameters - /// Client to make requests to Twilio - /// A single instance of Entity - public static EntityResource Fetch(FetchEntityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Entity. - /// - /// Fetch Entity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task FetchAsync(FetchEntityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// A single instance of Entity - public static EntityResource Fetch(string pathServiceSid, string pathIdentity, ITwilioRestClient client = null) - { - var options = new FetchEntityOptions(pathServiceSid, pathIdentity); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Entity. - /// - /// Service Sid. - /// Unique external identifier of the Entity - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathIdentity, - ITwilioRestClient client = null) - { - var options = new FetchEntityOptions(pathServiceSid, pathIdentity); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadEntityOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Entities", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Entities for a Service. - /// - /// Read Entity parameters - /// Client to make requests to Twilio - /// A single instance of Entity - public static ResourceSet Read(ReadEntityOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("entities", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Entities for a Service. - /// - /// Read Entity parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task> ReadAsync(ReadEntityOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("entities", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Entities for a Service. - /// - /// Service Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Entity - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEntityOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Entities for a Service. - /// - /// Service Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Entity - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadEntityOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("entities", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("entities", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("entities", response.Content); - } - - /// - /// Converts a JSON string into a EntityResource object - /// - /// Raw JSON string - /// EntityResource object represented by the provided JSON - public static EntityResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Entity. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Unique external identifier of the Entity - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// Account Sid. - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The date this Entity was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Entity was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// Nested resource URLs. - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private EntityResource() - { - - } - } +{ + + public class EntityResource : Resource + { + private static Request BuildCreateRequest(CreateEntityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Entity for the Service + /// + /// Create Entity parameters + /// Client to make requests to Twilio + /// A single instance of Entity + public static EntityResource Create(CreateEntityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Entity for the Service + /// + /// Create Entity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task CreateAsync(CreateEntityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Entity for the Service + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// A single instance of Entity + public static EntityResource Create(string pathServiceSid, string identity, ITwilioRestClient client = null) + { + var options = new CreateEntityOptions(pathServiceSid, identity); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Entity for the Service + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string identity, + ITwilioRestClient client = null) + { + var options = new CreateEntityOptions(pathServiceSid, identity); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteEntityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Entity. + /// + /// Delete Entity parameters + /// Client to make requests to Twilio + /// A single instance of Entity + public static bool Delete(DeleteEntityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Entity. + /// + /// Delete Entity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task DeleteAsync(DeleteEntityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// A single instance of Entity + public static bool Delete(string pathServiceSid, string pathIdentity, ITwilioRestClient client = null) + { + var options = new DeleteEntityOptions(pathServiceSid, pathIdentity); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new DeleteEntityOptions(pathServiceSid, pathIdentity); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchEntityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Entity. + /// + /// Fetch Entity parameters + /// Client to make requests to Twilio + /// A single instance of Entity + public static EntityResource Fetch(FetchEntityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Entity. + /// + /// Fetch Entity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task FetchAsync(FetchEntityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// A single instance of Entity + public static EntityResource Fetch(string pathServiceSid, string pathIdentity, ITwilioRestClient client = null) + { + var options = new FetchEntityOptions(pathServiceSid, pathIdentity); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Entity. + /// + /// Service Sid. + /// Unique external identifier of the Entity + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathIdentity, + ITwilioRestClient client = null) + { + var options = new FetchEntityOptions(pathServiceSid, pathIdentity); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadEntityOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Entities", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Entities for a Service. + /// + /// Read Entity parameters + /// Client to make requests to Twilio + /// A single instance of Entity + public static ResourceSet Read(ReadEntityOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("entities", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Entities for a Service. + /// + /// Read Entity parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task> ReadAsync(ReadEntityOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("entities", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Entities for a Service. + /// + /// Service Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Entity + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEntityOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Entities for a Service. + /// + /// Service Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Entity + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadEntityOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("entities", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("entities", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("entities", response.Content); + } + + /// + /// Converts a JSON string into a EntityResource object + /// + /// Raw JSON string + /// EntityResource object represented by the provided JSON + public static EntityResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Entity. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Unique external identifier of the Entity + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// Account Sid. + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The date this Entity was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Entity was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// Nested resource URLs. + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private EntityResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationOptions.cs b/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationOptions.cs index d2ae2a070..39fcbfdf3 100644 --- a/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationOptions.cs @@ -9,207 +9,207 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// Create a new MessagingConfiguration for a service. + /// + public class CreateMessagingConfigurationOptions : IOptions + { /// - /// Create a new MessagingConfiguration for a service. - /// - public class CreateMessagingConfigurationOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The ISO-3166-1 country code of the country or `all`. - /// - public string Country { get; } - /// - /// The SID of the Messaging Service used for this configuration. - /// - public string MessagingServiceSid { get; } - - /// - /// Construct a new CreateMessagingConfigurationOptions - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - public CreateMessagingConfigurationOptions(string pathServiceSid, string country, string messagingServiceSid) - { - PathServiceSid = pathServiceSid; - Country = country; - MessagingServiceSid = messagingServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Country != null) - { - p.Add(new KeyValuePair("Country", Country)); - } - - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - return p; - } - } - + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } /// - /// Update a specific MessagingConfiguration - /// - public class UpdateMessagingConfigurationOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The ISO-3166-1 country code of the country or `all`. - /// - public string PathCountry { get; } - /// - /// The SID of the Messaging Service used for this configuration. - /// - public string MessagingServiceSid { get; } - - /// - /// Construct a new UpdateMessagingConfigurationOptions - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - public UpdateMessagingConfigurationOptions(string pathServiceSid, string pathCountry, string messagingServiceSid) - { - PathServiceSid = pathServiceSid; - PathCountry = pathCountry; - MessagingServiceSid = messagingServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (MessagingServiceSid != null) - { - p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); - } - - return p; - } - } - + /// The ISO-3166-1 country code of the country or `all`. + /// + public string Country { get; } /// - /// Fetch a specific MessagingConfiguration. - /// - public class FetchMessagingConfigurationOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The ISO-3166-1 country code of the country or `all`. - /// - public string PathCountry { get; } - - /// - /// Construct a new FetchMessagingConfigurationOptions - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - public FetchMessagingConfigurationOptions(string pathServiceSid, string pathCountry) - { - PathServiceSid = pathServiceSid; - PathCountry = pathCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the Messaging Service used for this configuration. + /// + public string MessagingServiceSid { get; } + /// - /// Retrieve a list of all Messaging Configurations for a Service. + /// Construct a new CreateMessagingConfigurationOptions /// - public class ReadMessagingConfigurationOptions : ReadOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadMessagingConfigurationOptions - /// - /// The SID of the Service that the resource is associated with - public ReadMessagingConfigurationOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + public CreateMessagingConfigurationOptions(string pathServiceSid, string country, string messagingServiceSid) + { + PathServiceSid = pathServiceSid; + Country = country; + MessagingServiceSid = messagingServiceSid; + } + /// - /// Delete a specific MessagingConfiguration. - /// - public class DeleteMessagingConfigurationOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The ISO-3166-1 country code of the country or `all`. - /// - public string PathCountry { get; } - - /// - /// Construct a new DeleteMessagingConfigurationOptions - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - public DeleteMessagingConfigurationOptions(string pathServiceSid, string pathCountry) - { - PathServiceSid = pathServiceSid; - PathCountry = pathCountry; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Country != null) + { + p.Add(new KeyValuePair("Country", Country)); + } + + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + return p; + } + } + + /// + /// Update a specific MessagingConfiguration + /// + public class UpdateMessagingConfigurationOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The ISO-3166-1 country code of the country or `all`. + /// + public string PathCountry { get; } + /// + /// The SID of the Messaging Service used for this configuration. + /// + public string MessagingServiceSid { get; } + + /// + /// Construct a new UpdateMessagingConfigurationOptions + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + public UpdateMessagingConfigurationOptions(string pathServiceSid, string pathCountry, string messagingServiceSid) + { + PathServiceSid = pathServiceSid; + PathCountry = pathCountry; + MessagingServiceSid = messagingServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (MessagingServiceSid != null) + { + p.Add(new KeyValuePair("MessagingServiceSid", MessagingServiceSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific MessagingConfiguration. + /// + public class FetchMessagingConfigurationOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The ISO-3166-1 country code of the country or `all`. + /// + public string PathCountry { get; } + + /// + /// Construct a new FetchMessagingConfigurationOptions + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + public FetchMessagingConfigurationOptions(string pathServiceSid, string pathCountry) + { + PathServiceSid = pathServiceSid; + PathCountry = pathCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Messaging Configurations for a Service. + /// + public class ReadMessagingConfigurationOptions : ReadOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadMessagingConfigurationOptions + /// + /// The SID of the Service that the resource is associated with + public ReadMessagingConfigurationOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a specific MessagingConfiguration. + /// + public class DeleteMessagingConfigurationOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The ISO-3166-1 country code of the country or `all`. + /// + public string PathCountry { get; } + + /// + /// Construct a new DeleteMessagingConfigurationOptions + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + public DeleteMessagingConfigurationOptions(string pathServiceSid, string pathCountry) + { + PathServiceSid = pathServiceSid; + PathCountry = pathCountry; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationResource.cs b/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationResource.cs index e3ef9e2ad..0f024fc25 100644 --- a/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/MessagingConfigurationResource.cs @@ -16,501 +16,501 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2.Service -{ - - public class MessagingConfigurationResource : Resource - { - private static Request BuildCreateRequest(CreateMessagingConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new MessagingConfiguration for a service. - /// - /// Create MessagingConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Create(CreateMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new MessagingConfiguration for a service. - /// - /// Create MessagingConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task CreateAsync(CreateMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new MessagingConfiguration for a service. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Create(string pathServiceSid, - string country, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new CreateMessagingConfigurationOptions(pathServiceSid, country, messagingServiceSid); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new MessagingConfiguration for a service. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string country, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new CreateMessagingConfigurationOptions(pathServiceSid, country, messagingServiceSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateMessagingConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific MessagingConfiguration - /// - /// Update MessagingConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Update(UpdateMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific MessagingConfiguration - /// - /// Update MessagingConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific MessagingConfiguration - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Update(string pathServiceSid, - string pathCountry, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new UpdateMessagingConfigurationOptions(pathServiceSid, pathCountry, messagingServiceSid); - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific MessagingConfiguration - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// The SID of the Messaging Service used for this configuration. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathCountry, - string messagingServiceSid, - ITwilioRestClient client = null) - { - var options = new UpdateMessagingConfigurationOptions(pathServiceSid, pathCountry, messagingServiceSid); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchMessagingConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific MessagingConfiguration. - /// - /// Fetch MessagingConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Fetch(FetchMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific MessagingConfiguration. - /// - /// Fetch MessagingConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task FetchAsync(FetchMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific MessagingConfiguration. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static MessagingConfigurationResource Fetch(string pathServiceSid, - string pathCountry, - ITwilioRestClient client = null) - { - var options = new FetchMessagingConfigurationOptions(pathServiceSid, pathCountry); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific MessagingConfiguration. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathCountry, - ITwilioRestClient client = null) - { - var options = new FetchMessagingConfigurationOptions(pathServiceSid, pathCountry); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadMessagingConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Messaging Configurations for a Service. - /// - /// Read MessagingConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static ResourceSet Read(ReadMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("messaging_configurations", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Messaging Configurations for a Service. - /// - /// Read MessagingConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task> ReadAsync(ReadMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("messaging_configurations", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Messaging Configurations for a Service. - /// - /// The SID of the Service that the resource is associated with - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessagingConfigurationOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Messaging Configurations for a Service. - /// - /// The SID of the Service that the resource is associated with - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadMessagingConfigurationOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("messaging_configurations", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("messaging_configurations", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("messaging_configurations", response.Content); - } - - private static Request BuildDeleteRequest(DeleteMessagingConfigurationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific MessagingConfiguration. - /// - /// Delete MessagingConfiguration parameters - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static bool Delete(DeleteMessagingConfigurationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific MessagingConfiguration. - /// - /// Delete MessagingConfiguration parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessagingConfigurationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific MessagingConfiguration. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// Client to make requests to Twilio - /// A single instance of MessagingConfiguration - public static bool Delete(string pathServiceSid, string pathCountry, ITwilioRestClient client = null) - { - var options = new DeleteMessagingConfigurationOptions(pathServiceSid, pathCountry); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific MessagingConfiguration. - /// - /// The SID of the Service that the resource is associated with - /// The ISO-3166-1 country code of the country or `all`. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of MessagingConfiguration - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathCountry, - ITwilioRestClient client = null) - { - var options = new DeleteMessagingConfigurationOptions(pathServiceSid, pathCountry); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a MessagingConfigurationResource object - /// - /// Raw JSON string - /// MessagingConfigurationResource object represented by the provided JSON - public static MessagingConfigurationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The ISO-3166-1 country code of the country or `all`. - /// - [JsonProperty("country")] - public string Country { get; private set; } - /// - /// The SID of the Messaging Service used for this configuration. - /// - [JsonProperty("messaging_service_sid")] - public string MessagingServiceSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private MessagingConfigurationResource() - { - - } - } +{ + + public class MessagingConfigurationResource : Resource + { + private static Request BuildCreateRequest(CreateMessagingConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new MessagingConfiguration for a service. + /// + /// Create MessagingConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Create(CreateMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new MessagingConfiguration for a service. + /// + /// Create MessagingConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task CreateAsync(CreateMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new MessagingConfiguration for a service. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Create(string pathServiceSid, + string country, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new CreateMessagingConfigurationOptions(pathServiceSid, country, messagingServiceSid); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new MessagingConfiguration for a service. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string country, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new CreateMessagingConfigurationOptions(pathServiceSid, country, messagingServiceSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateMessagingConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific MessagingConfiguration + /// + /// Update MessagingConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Update(UpdateMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific MessagingConfiguration + /// + /// Update MessagingConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(UpdateMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific MessagingConfiguration + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Update(string pathServiceSid, + string pathCountry, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new UpdateMessagingConfigurationOptions(pathServiceSid, pathCountry, messagingServiceSid); + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific MessagingConfiguration + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// The SID of the Messaging Service used for this configuration. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathCountry, + string messagingServiceSid, + ITwilioRestClient client = null) + { + var options = new UpdateMessagingConfigurationOptions(pathServiceSid, pathCountry, messagingServiceSid); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchMessagingConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific MessagingConfiguration. + /// + /// Fetch MessagingConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Fetch(FetchMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific MessagingConfiguration. + /// + /// Fetch MessagingConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task FetchAsync(FetchMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific MessagingConfiguration. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static MessagingConfigurationResource Fetch(string pathServiceSid, + string pathCountry, + ITwilioRestClient client = null) + { + var options = new FetchMessagingConfigurationOptions(pathServiceSid, pathCountry); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific MessagingConfiguration. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathCountry, + ITwilioRestClient client = null) + { + var options = new FetchMessagingConfigurationOptions(pathServiceSid, pathCountry); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadMessagingConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Messaging Configurations for a Service. + /// + /// Read MessagingConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static ResourceSet Read(ReadMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("messaging_configurations", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Messaging Configurations for a Service. + /// + /// Read MessagingConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task> ReadAsync(ReadMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("messaging_configurations", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Messaging Configurations for a Service. + /// + /// The SID of the Service that the resource is associated with + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessagingConfigurationOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Messaging Configurations for a Service. + /// + /// The SID of the Service that the resource is associated with + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadMessagingConfigurationOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("messaging_configurations", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("messaging_configurations", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("messaging_configurations", response.Content); + } + + private static Request BuildDeleteRequest(DeleteMessagingConfigurationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/MessagingConfigurations/" + options.PathCountry + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific MessagingConfiguration. + /// + /// Delete MessagingConfiguration parameters + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static bool Delete(DeleteMessagingConfigurationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific MessagingConfiguration. + /// + /// Delete MessagingConfiguration parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task DeleteAsync(DeleteMessagingConfigurationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific MessagingConfiguration. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// Client to make requests to Twilio + /// A single instance of MessagingConfiguration + public static bool Delete(string pathServiceSid, string pathCountry, ITwilioRestClient client = null) + { + var options = new DeleteMessagingConfigurationOptions(pathServiceSid, pathCountry); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific MessagingConfiguration. + /// + /// The SID of the Service that the resource is associated with + /// The ISO-3166-1 country code of the country or `all`. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of MessagingConfiguration + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathCountry, + ITwilioRestClient client = null) + { + var options = new DeleteMessagingConfigurationOptions(pathServiceSid, pathCountry); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a MessagingConfigurationResource object + /// + /// Raw JSON string + /// MessagingConfigurationResource object represented by the provided JSON + public static MessagingConfigurationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The ISO-3166-1 country code of the country or `all`. + /// + [JsonProperty("country")] + public string Country { get; private set; } + /// + /// The SID of the Messaging Service used for this configuration. + /// + [JsonProperty("messaging_service_sid")] + public string MessagingServiceSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private MessagingConfigurationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketOptions.cs b/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketOptions.cs index c04633610..09ccc843d 100644 --- a/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketOptions.cs @@ -9,244 +9,244 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service.RateLimit -{ - +{ + + /// + /// Create a new Bucket for a Rate Limit + /// + public class CreateBucketOptions : IOptions + { /// - /// Create a new Bucket for a Rate Limit - /// - public class CreateBucketOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// Rate Limit Sid. - /// - public string PathRateLimitSid { get; } - /// - /// Max number of requests. - /// - public int? Max { get; } - /// - /// Number of seconds that the rate limit will be enforced over. - /// - public int? Interval { get; } - - /// - /// Construct a new CreateBucketOptions - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// Max number of requests. - /// Number of seconds that the rate limit will be enforced over. - public CreateBucketOptions(string pathServiceSid, string pathRateLimitSid, int? max, int? interval) - { - PathServiceSid = pathServiceSid; - PathRateLimitSid = pathRateLimitSid; - Max = max; - Interval = interval; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Max != null) - { - p.Add(new KeyValuePair("Max", Max.ToString())); - } - - if (Interval != null) - { - p.Add(new KeyValuePair("Interval", Interval.ToString())); - } - - return p; - } - } - + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } /// - /// Update a specific Bucket. - /// - public class UpdateBucketOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// Rate Limit Sid. - /// - public string PathRateLimitSid { get; } - /// - /// A string that uniquely identifies this Bucket. - /// - public string PathSid { get; } - /// - /// Max number of requests. - /// - public int? Max { get; set; } - /// - /// Number of seconds that the rate limit will be enforced over. - /// - public int? Interval { get; set; } - - /// - /// Construct a new UpdateBucketOptions - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - public UpdateBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathRateLimitSid = pathRateLimitSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Max != null) - { - p.Add(new KeyValuePair("Max", Max.ToString())); - } - - if (Interval != null) - { - p.Add(new KeyValuePair("Interval", Interval.ToString())); - } - - return p; - } - } - + /// Rate Limit Sid. + /// + public string PathRateLimitSid { get; } /// - /// Fetch a specific Bucket. - /// - public class FetchBucketOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// Rate Limit Sid. - /// - public string PathRateLimitSid { get; } - /// - /// A string that uniquely identifies this Bucket. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchBucketOptions - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - public FetchBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathRateLimitSid = pathRateLimitSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Max number of requests. + /// + public int? Max { get; } /// - /// Retrieve a list of all Buckets for a Rate Limit. - /// - public class ReadBucketOptions : ReadOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// Rate Limit Sid. - /// - public string PathRateLimitSid { get; } - - /// - /// Construct a new ReadBucketOptions - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - public ReadBucketOptions(string pathServiceSid, string pathRateLimitSid) - { - PathServiceSid = pathServiceSid; - PathRateLimitSid = pathRateLimitSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Number of seconds that the rate limit will be enforced over. + /// + public int? Interval { get; } + /// - /// Delete a specific Bucket. - /// - public class DeleteBucketOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// Rate Limit Sid. - /// - public string PathRateLimitSid { get; } - /// - /// A string that uniquely identifies this Bucket. - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteBucketOptions - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - public DeleteBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathRateLimitSid = pathRateLimitSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Construct a new CreateBucketOptions + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// Max number of requests. + /// Number of seconds that the rate limit will be enforced over. + public CreateBucketOptions(string pathServiceSid, string pathRateLimitSid, int? max, int? interval) + { + PathServiceSid = pathServiceSid; + PathRateLimitSid = pathRateLimitSid; + Max = max; + Interval = interval; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Max != null) + { + p.Add(new KeyValuePair("Max", Max.ToString())); + } + + if (Interval != null) + { + p.Add(new KeyValuePair("Interval", Interval.ToString())); + } + + return p; + } + } + + /// + /// Update a specific Bucket. + /// + public class UpdateBucketOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// Rate Limit Sid. + /// + public string PathRateLimitSid { get; } + /// + /// A string that uniquely identifies this Bucket. + /// + public string PathSid { get; } + /// + /// Max number of requests. + /// + public int? Max { get; set; } + /// + /// Number of seconds that the rate limit will be enforced over. + /// + public int? Interval { get; set; } + + /// + /// Construct a new UpdateBucketOptions + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + public UpdateBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathRateLimitSid = pathRateLimitSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Max != null) + { + p.Add(new KeyValuePair("Max", Max.ToString())); + } + + if (Interval != null) + { + p.Add(new KeyValuePair("Interval", Interval.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Bucket. + /// + public class FetchBucketOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// Rate Limit Sid. + /// + public string PathRateLimitSid { get; } + /// + /// A string that uniquely identifies this Bucket. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchBucketOptions + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + public FetchBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathRateLimitSid = pathRateLimitSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Buckets for a Rate Limit. + /// + public class ReadBucketOptions : ReadOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// Rate Limit Sid. + /// + public string PathRateLimitSid { get; } + + /// + /// Construct a new ReadBucketOptions + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + public ReadBucketOptions(string pathServiceSid, string pathRateLimitSid) + { + PathServiceSid = pathServiceSid; + PathRateLimitSid = pathRateLimitSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a specific Bucket. + /// + public class DeleteBucketOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// Rate Limit Sid. + /// + public string PathRateLimitSid { get; } + /// + /// A string that uniquely identifies this Bucket. + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteBucketOptions + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + public DeleteBucketOptions(string pathServiceSid, string pathRateLimitSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathRateLimitSid = pathRateLimitSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketResource.cs b/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketResource.cs index 8889305f4..397c83d9b 100644 --- a/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/RateLimit/BucketResource.cs @@ -16,531 +16,531 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2.Service.RateLimit -{ - - public class BucketResource : Resource - { - private static Request BuildCreateRequest(CreateBucketOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Bucket for a Rate Limit - /// - /// Create Bucket parameters - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Create(CreateBucketOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Bucket for a Rate Limit - /// - /// Create Bucket parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task CreateAsync(CreateBucketOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Bucket for a Rate Limit - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// Max number of requests. - /// Number of seconds that the rate limit will be enforced over. - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Create(string pathServiceSid, - string pathRateLimitSid, - int? max, - int? interval, - ITwilioRestClient client = null) - { - var options = new CreateBucketOptions(pathServiceSid, pathRateLimitSid, max, interval); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Bucket for a Rate Limit - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// Max number of requests. - /// Number of seconds that the rate limit will be enforced over. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string pathRateLimitSid, - int? max, - int? interval, - ITwilioRestClient client = null) - { - var options = new CreateBucketOptions(pathServiceSid, pathRateLimitSid, max, interval); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateBucketOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Bucket. - /// - /// Update Bucket parameters - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Update(UpdateBucketOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Bucket. - /// - /// Update Bucket parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task UpdateAsync(UpdateBucketOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Max number of requests. - /// Number of seconds that the rate limit will be enforced over. - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Update(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - int? max = null, - int? interval = null, - ITwilioRestClient client = null) - { - var options = new UpdateBucketOptions(pathServiceSid, pathRateLimitSid, pathSid){Max = max, Interval = interval}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Max number of requests. - /// Number of seconds that the rate limit will be enforced over. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - int? max = null, - int? interval = null, - ITwilioRestClient client = null) - { - var options = new UpdateBucketOptions(pathServiceSid, pathRateLimitSid, pathSid){Max = max, Interval = interval}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchBucketOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Bucket. - /// - /// Fetch Bucket parameters - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Fetch(FetchBucketOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Bucket. - /// - /// Fetch Bucket parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task FetchAsync(FetchBucketOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Client to make requests to Twilio - /// A single instance of Bucket - public static BucketResource Fetch(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadBucketOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Buckets for a Rate Limit. - /// - /// Read Bucket parameters - /// Client to make requests to Twilio - /// A single instance of Bucket - public static ResourceSet Read(ReadBucketOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("buckets", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Buckets for a Rate Limit. - /// - /// Read Bucket parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task> ReadAsync(ReadBucketOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("buckets", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Buckets for a Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Bucket - public static ResourceSet Read(string pathServiceSid, - string pathRateLimitSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBucketOptions(pathServiceSid, pathRateLimitSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Buckets for a Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - string pathRateLimitSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadBucketOptions(pathServiceSid, pathRateLimitSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("buckets", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("buckets", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("buckets", response.Content); - } - - private static Request BuildDeleteRequest(DeleteBucketOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Bucket. - /// - /// Delete Bucket parameters - /// Client to make requests to Twilio - /// A single instance of Bucket - public static bool Delete(DeleteBucketOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Bucket. - /// - /// Delete Bucket parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task DeleteAsync(DeleteBucketOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Client to make requests to Twilio - /// A single instance of Bucket - public static bool Delete(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Bucket. - /// - /// The SID of the Service that the resource is associated with - /// Rate Limit Sid. - /// A string that uniquely identifies this Bucket. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Bucket - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathRateLimitSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BucketResource object - /// - /// Raw JSON string - /// BucketResource object represented by the provided JSON - public static BucketResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Bucket. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Rate Limit Sid. - /// - [JsonProperty("rate_limit_sid")] - public string RateLimitSid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Max number of requests. - /// - [JsonProperty("max")] - public int? Max { get; private set; } - /// - /// Number of seconds that the rate limit will be enforced over. - /// - [JsonProperty("interval")] - public int? Interval { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private BucketResource() - { - - } - } +{ + + public class BucketResource : Resource + { + private static Request BuildCreateRequest(CreateBucketOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Bucket for a Rate Limit + /// + /// Create Bucket parameters + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Create(CreateBucketOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Bucket for a Rate Limit + /// + /// Create Bucket parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task CreateAsync(CreateBucketOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Bucket for a Rate Limit + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// Max number of requests. + /// Number of seconds that the rate limit will be enforced over. + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Create(string pathServiceSid, + string pathRateLimitSid, + int? max, + int? interval, + ITwilioRestClient client = null) + { + var options = new CreateBucketOptions(pathServiceSid, pathRateLimitSid, max, interval); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Bucket for a Rate Limit + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// Max number of requests. + /// Number of seconds that the rate limit will be enforced over. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string pathRateLimitSid, + int? max, + int? interval, + ITwilioRestClient client = null) + { + var options = new CreateBucketOptions(pathServiceSid, pathRateLimitSid, max, interval); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateBucketOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Bucket. + /// + /// Update Bucket parameters + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Update(UpdateBucketOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Bucket. + /// + /// Update Bucket parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task UpdateAsync(UpdateBucketOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Max number of requests. + /// Number of seconds that the rate limit will be enforced over. + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Update(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + int? max = null, + int? interval = null, + ITwilioRestClient client = null) + { + var options = new UpdateBucketOptions(pathServiceSid, pathRateLimitSid, pathSid) { Max = max, Interval = interval }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Max number of requests. + /// Number of seconds that the rate limit will be enforced over. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + int? max = null, + int? interval = null, + ITwilioRestClient client = null) + { + var options = new UpdateBucketOptions(pathServiceSid, pathRateLimitSid, pathSid) { Max = max, Interval = interval }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchBucketOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Bucket. + /// + /// Fetch Bucket parameters + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Fetch(FetchBucketOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Bucket. + /// + /// Fetch Bucket parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task FetchAsync(FetchBucketOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Client to make requests to Twilio + /// A single instance of Bucket + public static BucketResource Fetch(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadBucketOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Buckets for a Rate Limit. + /// + /// Read Bucket parameters + /// Client to make requests to Twilio + /// A single instance of Bucket + public static ResourceSet Read(ReadBucketOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("buckets", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Buckets for a Rate Limit. + /// + /// Read Bucket parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task> ReadAsync(ReadBucketOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("buckets", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Buckets for a Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Bucket + public static ResourceSet Read(string pathServiceSid, + string pathRateLimitSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBucketOptions(pathServiceSid, pathRateLimitSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Buckets for a Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + string pathRateLimitSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadBucketOptions(pathServiceSid, pathRateLimitSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("buckets", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("buckets", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("buckets", response.Content); + } + + private static Request BuildDeleteRequest(DeleteBucketOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathRateLimitSid + "/Buckets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Bucket. + /// + /// Delete Bucket parameters + /// Client to make requests to Twilio + /// A single instance of Bucket + public static bool Delete(DeleteBucketOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Bucket. + /// + /// Delete Bucket parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task DeleteAsync(DeleteBucketOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Client to make requests to Twilio + /// A single instance of Bucket + public static bool Delete(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Bucket. + /// + /// The SID of the Service that the resource is associated with + /// Rate Limit Sid. + /// A string that uniquely identifies this Bucket. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Bucket + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathRateLimitSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteBucketOptions(pathServiceSid, pathRateLimitSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BucketResource object + /// + /// Raw JSON string + /// BucketResource object represented by the provided JSON + public static BucketResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Bucket. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Rate Limit Sid. + /// + [JsonProperty("rate_limit_sid")] + public string RateLimitSid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Max number of requests. + /// + [JsonProperty("max")] + public int? Max { get; private set; } + /// + /// Number of seconds that the rate limit will be enforced over. + /// + [JsonProperty("interval")] + public int? Interval { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private BucketResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/RateLimitOptions.cs b/src/Twilio/Rest/Verify/V2/Service/RateLimitOptions.cs index d1c841849..7ffb59513 100644 --- a/src/Twilio/Rest/Verify/V2/Service/RateLimitOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/RateLimitOptions.cs @@ -9,203 +9,203 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// Create a new Rate Limit for a Service + /// + public class CreateRateLimitOptions : IOptions + { /// - /// Create a new Rate Limit for a Service - /// - public class CreateRateLimitOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// A unique, developer assigned name of this Rate Limit. - /// - public string UniqueName { get; } - /// - /// Description of this Rate Limit - /// - public string Description { get; set; } - - /// - /// Construct a new CreateRateLimitOptions - /// - /// The SID of the Service that the resource is associated with - /// A unique, developer assigned name of this Rate Limit. - public CreateRateLimitOptions(string pathServiceSid, string uniqueName) - { - PathServiceSid = pathServiceSid; - UniqueName = uniqueName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - return p; - } - } - + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } /// - /// Update a specific Rate Limit. - /// - public class UpdateRateLimitOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// Description of this Rate Limit - /// - public string Description { get; set; } - - /// - /// Construct a new UpdateRateLimitOptions - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - public UpdateRateLimitOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Description != null) - { - p.Add(new KeyValuePair("Description", Description)); - } - - return p; - } - } - + /// A unique, developer assigned name of this Rate Limit. + /// + public string UniqueName { get; } /// - /// Fetch a specific Rate Limit. - /// - public class FetchRateLimitOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRateLimitOptions - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - public FetchRateLimitOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// Description of this Rate Limit + /// + public string Description { get; set; } + /// - /// Retrieve a list of all Rate Limits for a service. + /// Construct a new CreateRateLimitOptions /// - public class ReadRateLimitOptions : ReadOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadRateLimitOptions - /// - /// The SID of the Service that the resource is associated with - public ReadRateLimitOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID of the Service that the resource is associated with + /// A unique, developer assigned name of this Rate Limit. + public CreateRateLimitOptions(string pathServiceSid, string uniqueName) + { + PathServiceSid = pathServiceSid; + UniqueName = uniqueName; + } + /// - /// Delete a specific Rate Limit. - /// - public class DeleteRateLimitOptions : IOptions - { - /// - /// The SID of the Service that the resource is associated with - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRateLimitOptions - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - public DeleteRateLimitOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + return p; + } + } + + /// + /// Update a specific Rate Limit. + /// + public class UpdateRateLimitOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// Description of this Rate Limit + /// + public string Description { get; set; } + + /// + /// Construct a new UpdateRateLimitOptions + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + public UpdateRateLimitOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Description != null) + { + p.Add(new KeyValuePair("Description", Description)); + } + + return p; + } + } + + /// + /// Fetch a specific Rate Limit. + /// + public class FetchRateLimitOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchRateLimitOptions + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + public FetchRateLimitOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Rate Limits for a service. + /// + public class ReadRateLimitOptions : ReadOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadRateLimitOptions + /// + /// The SID of the Service that the resource is associated with + public ReadRateLimitOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a specific Rate Limit. + /// + public class DeleteRateLimitOptions : IOptions + { + /// + /// The SID of the Service that the resource is associated with + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRateLimitOptions + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + public DeleteRateLimitOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/RateLimitResource.cs b/src/Twilio/Rest/Verify/V2/Service/RateLimitResource.cs index 127090682..d896e8872 100644 --- a/src/Twilio/Rest/Verify/V2/Service/RateLimitResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/RateLimitResource.cs @@ -16,503 +16,503 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2.Service -{ - - public class RateLimitResource : Resource - { - private static Request BuildCreateRequest(CreateRateLimitOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Rate Limit for a Service - /// - /// Create RateLimit parameters - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Create(CreateRateLimitOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Rate Limit for a Service - /// - /// Create RateLimit parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task CreateAsync(CreateRateLimitOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Rate Limit for a Service - /// - /// The SID of the Service that the resource is associated with - /// A unique, developer assigned name of this Rate Limit. - /// Description of this Rate Limit - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Create(string pathServiceSid, - string uniqueName, - string description = null, - ITwilioRestClient client = null) - { - var options = new CreateRateLimitOptions(pathServiceSid, uniqueName){Description = description}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Rate Limit for a Service - /// - /// The SID of the Service that the resource is associated with - /// A unique, developer assigned name of this Rate Limit. - /// Description of this Rate Limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string uniqueName, - string description = null, - ITwilioRestClient client = null) - { - var options = new CreateRateLimitOptions(pathServiceSid, uniqueName){Description = description}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRateLimitOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Rate Limit. - /// - /// Update RateLimit parameters - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Update(UpdateRateLimitOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Rate Limit. - /// - /// Update RateLimit parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRateLimitOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Description of this Rate Limit - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Update(string pathServiceSid, - string pathSid, - string description = null, - ITwilioRestClient client = null) - { - var options = new UpdateRateLimitOptions(pathServiceSid, pathSid){Description = description}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Description of this Rate Limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string description = null, - ITwilioRestClient client = null) - { - var options = new UpdateRateLimitOptions(pathServiceSid, pathSid){Description = description}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchRateLimitOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Rate Limit. - /// - /// Fetch RateLimit parameters - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Fetch(FetchRateLimitOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Rate Limit. - /// - /// Fetch RateLimit parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task FetchAsync(FetchRateLimitOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static RateLimitResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRateLimitOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRateLimitOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRateLimitOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Rate Limits for a service. - /// - /// Read RateLimit parameters - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static ResourceSet Read(ReadRateLimitOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_limits", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Rate Limits for a service. - /// - /// Read RateLimit parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task> ReadAsync(ReadRateLimitOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_limits", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Rate Limits for a service. - /// - /// The SID of the Service that the resource is associated with - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRateLimitOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Rate Limits for a service. - /// - /// The SID of the Service that the resource is associated with - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRateLimitOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("rate_limits", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("rate_limits", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("rate_limits", response.Content); - } - - private static Request BuildDeleteRequest(DeleteRateLimitOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Rate Limit. - /// - /// Delete RateLimit parameters - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static bool Delete(DeleteRateLimitOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Rate Limit. - /// - /// Delete RateLimit parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRateLimitOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of RateLimit - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRateLimitOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Rate Limit. - /// - /// The SID of the Service that the resource is associated with - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RateLimit - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRateLimitOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RateLimitResource object - /// - /// Raw JSON string - /// RateLimitResource object represented by the provided JSON - public static RateLimitResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Rate Limit. - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A unique, developer assigned name of this Rate Limit. - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// Description of this Rate Limit - /// - [JsonProperty("description")] - public string Description { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The URL of this resource. - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private RateLimitResource() - { - - } - } +{ + + public class RateLimitResource : Resource + { + private static Request BuildCreateRequest(CreateRateLimitOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Rate Limit for a Service + /// + /// Create RateLimit parameters + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Create(CreateRateLimitOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Rate Limit for a Service + /// + /// Create RateLimit parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task CreateAsync(CreateRateLimitOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Rate Limit for a Service + /// + /// The SID of the Service that the resource is associated with + /// A unique, developer assigned name of this Rate Limit. + /// Description of this Rate Limit + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Create(string pathServiceSid, + string uniqueName, + string description = null, + ITwilioRestClient client = null) + { + var options = new CreateRateLimitOptions(pathServiceSid, uniqueName) { Description = description }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Rate Limit for a Service + /// + /// The SID of the Service that the resource is associated with + /// A unique, developer assigned name of this Rate Limit. + /// Description of this Rate Limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string uniqueName, + string description = null, + ITwilioRestClient client = null) + { + var options = new CreateRateLimitOptions(pathServiceSid, uniqueName) { Description = description }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRateLimitOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Rate Limit. + /// + /// Update RateLimit parameters + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Update(UpdateRateLimitOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Rate Limit. + /// + /// Update RateLimit parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRateLimitOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Description of this Rate Limit + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Update(string pathServiceSid, + string pathSid, + string description = null, + ITwilioRestClient client = null) + { + var options = new UpdateRateLimitOptions(pathServiceSid, pathSid) { Description = description }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Description of this Rate Limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string description = null, + ITwilioRestClient client = null) + { + var options = new UpdateRateLimitOptions(pathServiceSid, pathSid) { Description = description }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchRateLimitOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Rate Limit. + /// + /// Fetch RateLimit parameters + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Fetch(FetchRateLimitOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Rate Limit. + /// + /// Fetch RateLimit parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task FetchAsync(FetchRateLimitOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static RateLimitResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRateLimitOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRateLimitOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRateLimitOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Rate Limits for a service. + /// + /// Read RateLimit parameters + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static ResourceSet Read(ReadRateLimitOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_limits", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Rate Limits for a service. + /// + /// Read RateLimit parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task> ReadAsync(ReadRateLimitOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_limits", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Rate Limits for a service. + /// + /// The SID of the Service that the resource is associated with + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRateLimitOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Rate Limits for a service. + /// + /// The SID of the Service that the resource is associated with + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRateLimitOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("rate_limits", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("rate_limits", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("rate_limits", response.Content); + } + + private static Request BuildDeleteRequest(DeleteRateLimitOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/RateLimits/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Rate Limit. + /// + /// Delete RateLimit parameters + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static bool Delete(DeleteRateLimitOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Rate Limit. + /// + /// Delete RateLimit parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRateLimitOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of RateLimit + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRateLimitOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Rate Limit. + /// + /// The SID of the Service that the resource is associated with + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RateLimit + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRateLimitOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RateLimitResource object + /// + /// Raw JSON string + /// RateLimitResource object represented by the provided JSON + public static RateLimitResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Rate Limit. + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A unique, developer assigned name of this Rate Limit. + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// Description of this Rate Limit + /// + [JsonProperty("description")] + public string Description { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The URL of this resource. + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private RateLimitResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/VerificationCheckOptions.cs b/src/Twilio/Rest/Verify/V2/Service/VerificationCheckOptions.cs index 638736b0b..b108fbc6e 100644 --- a/src/Twilio/Rest/Verify/V2/Service/VerificationCheckOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/VerificationCheckOptions.cs @@ -9,82 +9,82 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// challenge a specific Verification Check. + /// + public class CreateVerificationCheckOptions : IOptions + { /// - /// challenge a specific Verification Check. + /// The SID of the verification Service to create the resource under /// - public class CreateVerificationCheckOptions : IOptions - { - /// - /// The SID of the verification Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The verification string - /// - public string Code { get; } - /// - /// The phone number or email to verify - /// - public string To { get; set; } - /// - /// A SID that uniquely identifies the Verification Check - /// - public string VerificationSid { get; set; } - /// - /// The amount of the associated PSD2 compliant transaction. - /// - public string Amount { get; set; } - /// - /// The payee of the associated PSD2 compliant transaction - /// - public string Payee { get; set; } - - /// - /// Construct a new CreateVerificationCheckOptions - /// - /// The SID of the verification Service to create the resource under - /// The verification string - public CreateVerificationCheckOptions(string pathServiceSid, string code) - { - PathServiceSid = pathServiceSid; - Code = code; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Code != null) - { - p.Add(new KeyValuePair("Code", Code)); - } - - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (VerificationSid != null) - { - p.Add(new KeyValuePair("VerificationSid", VerificationSid.ToString())); - } - - if (Amount != null) - { - p.Add(new KeyValuePair("Amount", Amount)); - } - - if (Payee != null) - { - p.Add(new KeyValuePair("Payee", Payee)); - } - - return p; - } - } + public string PathServiceSid { get; } + /// + /// The verification string + /// + public string Code { get; } + /// + /// The phone number or email to verify + /// + public string To { get; set; } + /// + /// A SID that uniquely identifies the Verification Check + /// + public string VerificationSid { get; set; } + /// + /// The amount of the associated PSD2 compliant transaction. + /// + public string Amount { get; set; } + /// + /// The payee of the associated PSD2 compliant transaction + /// + public string Payee { get; set; } + + /// + /// Construct a new CreateVerificationCheckOptions + /// + /// The SID of the verification Service to create the resource under + /// The verification string + public CreateVerificationCheckOptions(string pathServiceSid, string code) + { + PathServiceSid = pathServiceSid; + Code = code; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Code != null) + { + p.Add(new KeyValuePair("Code", Code)); + } + + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (VerificationSid != null) + { + p.Add(new KeyValuePair("VerificationSid", VerificationSid.ToString())); + } + + if (Amount != null) + { + p.Add(new KeyValuePair("Amount", Amount)); + } + + if (Payee != null) + { + p.Add(new KeyValuePair("Payee", Payee)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/VerificationCheckResource.cs b/src/Twilio/Rest/Verify/V2/Service/VerificationCheckResource.cs index f50418612..273bea4af 100644 --- a/src/Twilio/Rest/Verify/V2/Service/VerificationCheckResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/VerificationCheckResource.cs @@ -17,193 +17,193 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service -{ - - public class VerificationCheckResource : Resource - { - public sealed class ChannelEnum : StringEnum - { - private ChannelEnum(string value) : base(value) {} - public ChannelEnum() {} - public static implicit operator ChannelEnum(string value) - { - return new ChannelEnum(value); - } - - public static readonly ChannelEnum Sms = new ChannelEnum("sms"); - public static readonly ChannelEnum Call = new ChannelEnum("call"); - public static readonly ChannelEnum Email = new ChannelEnum("email"); - public static readonly ChannelEnum Whatsapp = new ChannelEnum("whatsapp"); - } - - private static Request BuildCreateRequest(CreateVerificationCheckOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/VerificationCheck", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// challenge a specific Verification Check. - /// - /// Create VerificationCheck parameters - /// Client to make requests to Twilio - /// A single instance of VerificationCheck - public static VerificationCheckResource Create(CreateVerificationCheckOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// challenge a specific Verification Check. - /// - /// Create VerificationCheck parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationCheck - public static async System.Threading.Tasks.Task CreateAsync(CreateVerificationCheckOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// challenge a specific Verification Check. - /// - /// The SID of the verification Service to create the resource under - /// The verification string - /// The phone number or email to verify - /// A SID that uniquely identifies the Verification Check - /// The amount of the associated PSD2 compliant transaction. - /// The payee of the associated PSD2 compliant transaction - /// Client to make requests to Twilio - /// A single instance of VerificationCheck - public static VerificationCheckResource Create(string pathServiceSid, - string code, - string to = null, - string verificationSid = null, - string amount = null, - string payee = null, - ITwilioRestClient client = null) - { - var options = new CreateVerificationCheckOptions(pathServiceSid, code){To = to, VerificationSid = verificationSid, Amount = amount, Payee = payee}; - return Create(options, client); - } - - #if !NET35 - /// - /// challenge a specific Verification Check. - /// - /// The SID of the verification Service to create the resource under - /// The verification string - /// The phone number or email to verify - /// A SID that uniquely identifies the Verification Check - /// The amount of the associated PSD2 compliant transaction. - /// The payee of the associated PSD2 compliant transaction - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationCheck - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string code, - string to = null, - string verificationSid = null, - string amount = null, - string payee = null, - ITwilioRestClient client = null) - { - var options = new CreateVerificationCheckOptions(pathServiceSid, code){To = to, VerificationSid = verificationSid, Amount = amount, Payee = payee}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a VerificationCheckResource object - /// - /// Raw JSON string - /// VerificationCheckResource object represented by the provided JSON - public static VerificationCheckResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The phone number or email being verified - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The verification method to use - /// - [JsonProperty("channel")] - [JsonConverter(typeof(StringEnumConverter))] - public VerificationCheckResource.ChannelEnum Channel { get; private set; } - /// - /// The status of the verification resource - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// Whether the verification was successful - /// - [JsonProperty("valid")] - public bool? Valid { get; private set; } - /// - /// The amount of the associated PSD2 compliant transaction. - /// - [JsonProperty("amount")] - public string Amount { get; private set; } - /// - /// The payee of the associated PSD2 compliant transaction - /// - [JsonProperty("payee")] - public string Payee { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Verification Check resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Verification Check resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private VerificationCheckResource() - { - - } - } +{ + + public class VerificationCheckResource : Resource + { + public sealed class ChannelEnum : StringEnum + { + private ChannelEnum(string value) : base(value) { } + public ChannelEnum() { } + public static implicit operator ChannelEnum(string value) + { + return new ChannelEnum(value); + } + + public static readonly ChannelEnum Sms = new ChannelEnum("sms"); + public static readonly ChannelEnum Call = new ChannelEnum("call"); + public static readonly ChannelEnum Email = new ChannelEnum("email"); + public static readonly ChannelEnum Whatsapp = new ChannelEnum("whatsapp"); + } + + private static Request BuildCreateRequest(CreateVerificationCheckOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/VerificationCheck", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// challenge a specific Verification Check. + /// + /// Create VerificationCheck parameters + /// Client to make requests to Twilio + /// A single instance of VerificationCheck + public static VerificationCheckResource Create(CreateVerificationCheckOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// challenge a specific Verification Check. + /// + /// Create VerificationCheck parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationCheck + public static async System.Threading.Tasks.Task CreateAsync(CreateVerificationCheckOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// challenge a specific Verification Check. + /// + /// The SID of the verification Service to create the resource under + /// The verification string + /// The phone number or email to verify + /// A SID that uniquely identifies the Verification Check + /// The amount of the associated PSD2 compliant transaction. + /// The payee of the associated PSD2 compliant transaction + /// Client to make requests to Twilio + /// A single instance of VerificationCheck + public static VerificationCheckResource Create(string pathServiceSid, + string code, + string to = null, + string verificationSid = null, + string amount = null, + string payee = null, + ITwilioRestClient client = null) + { + var options = new CreateVerificationCheckOptions(pathServiceSid, code) { To = to, VerificationSid = verificationSid, Amount = amount, Payee = payee }; + return Create(options, client); + } + +#if !NET35 + /// + /// challenge a specific Verification Check. + /// + /// The SID of the verification Service to create the resource under + /// The verification string + /// The phone number or email to verify + /// A SID that uniquely identifies the Verification Check + /// The amount of the associated PSD2 compliant transaction. + /// The payee of the associated PSD2 compliant transaction + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationCheck + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string code, + string to = null, + string verificationSid = null, + string amount = null, + string payee = null, + ITwilioRestClient client = null) + { + var options = new CreateVerificationCheckOptions(pathServiceSid, code) { To = to, VerificationSid = verificationSid, Amount = amount, Payee = payee }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a VerificationCheckResource object + /// + /// Raw JSON string + /// VerificationCheckResource object represented by the provided JSON + public static VerificationCheckResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The phone number or email being verified + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The verification method to use + /// + [JsonProperty("channel")] + [JsonConverter(typeof(StringEnumConverter))] + public VerificationCheckResource.ChannelEnum Channel { get; private set; } + /// + /// The status of the verification resource + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// Whether the verification was successful + /// + [JsonProperty("valid")] + public bool? Valid { get; private set; } + /// + /// The amount of the associated PSD2 compliant transaction. + /// + [JsonProperty("amount")] + public string Amount { get; private set; } + /// + /// The payee of the associated PSD2 compliant transaction + /// + [JsonProperty("payee")] + public string Payee { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Verification Check resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Verification Check resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private VerificationCheckResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/VerificationOptions.cs b/src/Twilio/Rest/Verify/V2/Service/VerificationOptions.cs index 1c01b10e7..b316a2137 100644 --- a/src/Twilio/Rest/Verify/V2/Service/VerificationOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/VerificationOptions.cs @@ -9,246 +9,246 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// Create a new Verification using a Service + /// + public class CreateVerificationOptions : IOptions + { /// - /// Create a new Verification using a Service - /// - public class CreateVerificationOptions : IOptions - { - /// - /// The SID of the verification Service to create the resource under - /// - public string PathServiceSid { get; } - /// - /// The phone number or email to verify - /// - public string To { get; } - /// - /// The verification method to use - /// - public string Channel { get; } - /// - /// A custom user defined friendly name - /// - public string CustomFriendlyName { get; set; } - /// - /// The text of a custom message to use for the verification - /// - public string CustomMessage { get; set; } - /// - /// The digits to send after a phone call is answered - /// - public string SendDigits { get; set; } - /// - /// The locale to use for the verification SMS, WhatsApp or call - /// - public string Locale { get; set; } - /// - /// A pre-generated code - /// - public string CustomCode { get; set; } - /// - /// The amount of the associated PSD2 compliant transaction. - /// - public string Amount { get; set; } - /// - /// The payee of the associated PSD2 compliant transaction - /// - public string Payee { get; set; } - /// - /// The custom key-value pairs of Programmable Rate Limits. - /// - public object RateLimits { get; set; } - /// - /// Channel specific configuration in json format. - /// - public object ChannelConfiguration { get; set; } - /// - /// Your App Hash to be appended at the end of an SMS. - /// - public string AppHash { get; set; } - /// - /// The verification template SMS messages. - /// - public string TemplateSid { get; set; } - /// - /// The values of the special variables declared on the message template. - /// - public string TemplateCustomSubstitutions { get; set; } - - /// - /// Construct a new CreateVerificationOptions - /// - /// The SID of the verification Service to create the resource under - /// The phone number or email to verify - /// The verification method to use - public CreateVerificationOptions(string pathServiceSid, string to, string channel) - { - PathServiceSid = pathServiceSid; - To = to; - Channel = channel; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (To != null) - { - p.Add(new KeyValuePair("To", To)); - } - - if (Channel != null) - { - p.Add(new KeyValuePair("Channel", Channel)); - } - - if (CustomFriendlyName != null) - { - p.Add(new KeyValuePair("CustomFriendlyName", CustomFriendlyName)); - } - - if (CustomMessage != null) - { - p.Add(new KeyValuePair("CustomMessage", CustomMessage)); - } - - if (SendDigits != null) - { - p.Add(new KeyValuePair("SendDigits", SendDigits)); - } - - if (Locale != null) - { - p.Add(new KeyValuePair("Locale", Locale)); - } - - if (CustomCode != null) - { - p.Add(new KeyValuePair("CustomCode", CustomCode)); - } - - if (Amount != null) - { - p.Add(new KeyValuePair("Amount", Amount)); - } - - if (Payee != null) - { - p.Add(new KeyValuePair("Payee", Payee)); - } - - if (RateLimits != null) - { - p.Add(new KeyValuePair("RateLimits", Serializers.JsonObject(RateLimits))); - } - - if (ChannelConfiguration != null) - { - p.Add(new KeyValuePair("ChannelConfiguration", Serializers.JsonObject(ChannelConfiguration))); - } - - if (AppHash != null) - { - p.Add(new KeyValuePair("AppHash", AppHash)); - } - - if (TemplateSid != null) - { - p.Add(new KeyValuePair("TemplateSid", TemplateSid.ToString())); - } - - if (TemplateCustomSubstitutions != null) - { - p.Add(new KeyValuePair("TemplateCustomSubstitutions", TemplateCustomSubstitutions)); - } - - return p; - } - } - + /// The SID of the verification Service to create the resource under + /// + public string PathServiceSid { get; } /// - /// Update a Verification status - /// - public class UpdateVerificationOptions : IOptions - { - /// - /// The SID of the verification Service to update the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The new status of the resource - /// - public VerificationResource.StatusEnum Status { get; } - - /// - /// Construct a new UpdateVerificationOptions - /// - /// The SID of the verification Service to update the resource from - /// The unique string that identifies the resource - /// The new status of the resource - public UpdateVerificationOptions(string pathServiceSid, string pathSid, VerificationResource.StatusEnum status) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } - + /// The phone number or email to verify + /// + public string To { get; } /// - /// Fetch a specific Verification - /// - public class FetchVerificationOptions : IOptions - { - /// - /// The SID of the verification Service to fetch the resource from - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchVerificationOptions - /// - /// The SID of the verification Service to fetch the resource from - /// The unique string that identifies the resource - public FetchVerificationOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The verification method to use + /// + public string Channel { get; } + /// + /// A custom user defined friendly name + /// + public string CustomFriendlyName { get; set; } + /// + /// The text of a custom message to use for the verification + /// + public string CustomMessage { get; set; } + /// + /// The digits to send after a phone call is answered + /// + public string SendDigits { get; set; } + /// + /// The locale to use for the verification SMS, WhatsApp or call + /// + public string Locale { get; set; } + /// + /// A pre-generated code + /// + public string CustomCode { get; set; } + /// + /// The amount of the associated PSD2 compliant transaction. + /// + public string Amount { get; set; } + /// + /// The payee of the associated PSD2 compliant transaction + /// + public string Payee { get; set; } + /// + /// The custom key-value pairs of Programmable Rate Limits. + /// + public object RateLimits { get; set; } + /// + /// Channel specific configuration in json format. + /// + public object ChannelConfiguration { get; set; } + /// + /// Your App Hash to be appended at the end of an SMS. + /// + public string AppHash { get; set; } + /// + /// The verification template SMS messages. + /// + public string TemplateSid { get; set; } + /// + /// The values of the special variables declared on the message template. + /// + public string TemplateCustomSubstitutions { get; set; } + + /// + /// Construct a new CreateVerificationOptions + /// + /// The SID of the verification Service to create the resource under + /// The phone number or email to verify + /// The verification method to use + public CreateVerificationOptions(string pathServiceSid, string to, string channel) + { + PathServiceSid = pathServiceSid; + To = to; + Channel = channel; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (To != null) + { + p.Add(new KeyValuePair("To", To)); + } + + if (Channel != null) + { + p.Add(new KeyValuePair("Channel", Channel)); + } + + if (CustomFriendlyName != null) + { + p.Add(new KeyValuePair("CustomFriendlyName", CustomFriendlyName)); + } + + if (CustomMessage != null) + { + p.Add(new KeyValuePair("CustomMessage", CustomMessage)); + } + + if (SendDigits != null) + { + p.Add(new KeyValuePair("SendDigits", SendDigits)); + } + + if (Locale != null) + { + p.Add(new KeyValuePair("Locale", Locale)); + } + + if (CustomCode != null) + { + p.Add(new KeyValuePair("CustomCode", CustomCode)); + } + + if (Amount != null) + { + p.Add(new KeyValuePair("Amount", Amount)); + } + + if (Payee != null) + { + p.Add(new KeyValuePair("Payee", Payee)); + } + + if (RateLimits != null) + { + p.Add(new KeyValuePair("RateLimits", Serializers.JsonObject(RateLimits))); + } + + if (ChannelConfiguration != null) + { + p.Add(new KeyValuePair("ChannelConfiguration", Serializers.JsonObject(ChannelConfiguration))); + } + + if (AppHash != null) + { + p.Add(new KeyValuePair("AppHash", AppHash)); + } + + if (TemplateSid != null) + { + p.Add(new KeyValuePair("TemplateSid", TemplateSid.ToString())); + } + + if (TemplateCustomSubstitutions != null) + { + p.Add(new KeyValuePair("TemplateCustomSubstitutions", TemplateCustomSubstitutions)); + } + + return p; + } + } + + /// + /// Update a Verification status + /// + public class UpdateVerificationOptions : IOptions + { + /// + /// The SID of the verification Service to update the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The new status of the resource + /// + public VerificationResource.StatusEnum Status { get; } + + /// + /// Construct a new UpdateVerificationOptions + /// + /// The SID of the verification Service to update the resource from + /// The unique string that identifies the resource + /// The new status of the resource + public UpdateVerificationOptions(string pathServiceSid, string pathSid, VerificationResource.StatusEnum status) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific Verification + /// + public class FetchVerificationOptions : IOptions + { + /// + /// The SID of the verification Service to fetch the resource from + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchVerificationOptions + /// + /// The SID of the verification Service to fetch the resource from + /// The unique string that identifies the resource + public FetchVerificationOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/VerificationResource.cs b/src/Twilio/Rest/Verify/V2/Service/VerificationResource.cs index 8df563861..ea1d4e4d7 100644 --- a/src/Twilio/Rest/Verify/V2/Service/VerificationResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/VerificationResource.cs @@ -17,404 +17,404 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service -{ - - public class VerificationResource : Resource - { - public sealed class ChannelEnum : StringEnum - { - private ChannelEnum(string value) : base(value) {} - public ChannelEnum() {} - public static implicit operator ChannelEnum(string value) - { - return new ChannelEnum(value); - } - - public static readonly ChannelEnum Sms = new ChannelEnum("sms"); - public static readonly ChannelEnum Call = new ChannelEnum("call"); - public static readonly ChannelEnum Email = new ChannelEnum("email"); - public static readonly ChannelEnum Whatsapp = new ChannelEnum("whatsapp"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Approved = new StatusEnum("approved"); - } - - private static Request BuildCreateRequest(CreateVerificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Verifications", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Verification using a Service - /// - /// Create Verification parameters - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Create(CreateVerificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Verification using a Service - /// - /// Create Verification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task CreateAsync(CreateVerificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Verification using a Service - /// - /// The SID of the verification Service to create the resource under - /// The phone number or email to verify - /// The verification method to use - /// A custom user defined friendly name - /// The text of a custom message to use for the verification - /// The digits to send after a phone call is answered - /// The locale to use for the verification SMS, WhatsApp or call - /// A pre-generated code - /// The amount of the associated PSD2 compliant transaction. - /// The payee of the associated PSD2 compliant transaction - /// The custom key-value pairs of Programmable Rate Limits. - /// Channel specific configuration in json format. - /// Your App Hash to be appended at the end of an SMS. - /// The verification template SMS messages. - /// The values of the special variables declared on the message template. - /// - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Create(string pathServiceSid, - string to, - string channel, - string customFriendlyName = null, - string customMessage = null, - string sendDigits = null, - string locale = null, - string customCode = null, - string amount = null, - string payee = null, - object rateLimits = null, - object channelConfiguration = null, - string appHash = null, - string templateSid = null, - string templateCustomSubstitutions = null, - ITwilioRestClient client = null) - { - var options = new CreateVerificationOptions(pathServiceSid, to, channel){CustomFriendlyName = customFriendlyName, CustomMessage = customMessage, SendDigits = sendDigits, Locale = locale, CustomCode = customCode, Amount = amount, Payee = payee, RateLimits = rateLimits, ChannelConfiguration = channelConfiguration, AppHash = appHash, TemplateSid = templateSid, TemplateCustomSubstitutions = templateCustomSubstitutions}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Verification using a Service - /// - /// The SID of the verification Service to create the resource under - /// The phone number or email to verify - /// The verification method to use - /// A custom user defined friendly name - /// The text of a custom message to use for the verification - /// The digits to send after a phone call is answered - /// The locale to use for the verification SMS, WhatsApp or call - /// A pre-generated code - /// The amount of the associated PSD2 compliant transaction. - /// The payee of the associated PSD2 compliant transaction - /// The custom key-value pairs of Programmable Rate Limits. - /// Channel specific configuration in json format. - /// Your App Hash to be appended at the end of an SMS. - /// The verification template SMS messages. - /// The values of the special variables declared on the message template. - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string to, - string channel, - string customFriendlyName = null, - string customMessage = null, - string sendDigits = null, - string locale = null, - string customCode = null, - string amount = null, - string payee = null, - object rateLimits = null, - object channelConfiguration = null, - string appHash = null, - string templateSid = null, - string templateCustomSubstitutions = null, - ITwilioRestClient client = null) - { - var options = new CreateVerificationOptions(pathServiceSid, to, channel){CustomFriendlyName = customFriendlyName, CustomMessage = customMessage, SendDigits = sendDigits, Locale = locale, CustomCode = customCode, Amount = amount, Payee = payee, RateLimits = rateLimits, ChannelConfiguration = channelConfiguration, AppHash = appHash, TemplateSid = templateSid, TemplateCustomSubstitutions = templateCustomSubstitutions}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateVerificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Verifications/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a Verification status - /// - /// Update Verification parameters - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Update(UpdateVerificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a Verification status - /// - /// Update Verification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task UpdateAsync(UpdateVerificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a Verification status - /// - /// The SID of the verification Service to update the resource from - /// The unique string that identifies the resource - /// The new status of the resource - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Update(string pathServiceSid, - string pathSid, - VerificationResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateVerificationOptions(pathServiceSid, pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// Update a Verification status - /// - /// The SID of the verification Service to update the resource from - /// The unique string that identifies the resource - /// The new status of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - VerificationResource.StatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateVerificationOptions(pathServiceSid, pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchVerificationOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Verifications/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Verification - /// - /// Fetch Verification parameters - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Fetch(FetchVerificationOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Verification - /// - /// Fetch Verification parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task FetchAsync(FetchVerificationOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Verification - /// - /// The SID of the verification Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Verification - public static VerificationResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchVerificationOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Verification - /// - /// The SID of the verification Service to fetch the resource from - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Verification - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchVerificationOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a VerificationResource object - /// - /// Raw JSON string - /// VerificationResource object represented by the provided JSON - public static VerificationResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Service that the resource is associated with - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The phone number or email being verified - /// - [JsonProperty("to")] - public string To { get; private set; } - /// - /// The verification method used. - /// - [JsonProperty("channel")] - [JsonConverter(typeof(StringEnumConverter))] - public VerificationResource.ChannelEnum Channel { get; private set; } - /// - /// The status of the verification resource - /// - [JsonProperty("status")] - public string Status { get; private set; } - /// - /// Whether the verification was successful - /// - [JsonProperty("valid")] - public bool? Valid { get; private set; } - /// - /// Information about the phone number being verified - /// - [JsonProperty("lookup")] - public object Lookup { get; private set; } - /// - /// The amount of the associated PSD2 compliant transaction. - /// - [JsonProperty("amount")] - public string Amount { get; private set; } - /// - /// The payee of the associated PSD2 compliant transaction - /// - [JsonProperty("payee")] - public string Payee { get; private set; } - /// - /// An array of verification attempt objects. - /// - [JsonProperty("send_code_attempts")] - public List SendCodeAttempts { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Verification resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private VerificationResource() - { - - } - } +{ + + public class VerificationResource : Resource + { + public sealed class ChannelEnum : StringEnum + { + private ChannelEnum(string value) : base(value) { } + public ChannelEnum() { } + public static implicit operator ChannelEnum(string value) + { + return new ChannelEnum(value); + } + + public static readonly ChannelEnum Sms = new ChannelEnum("sms"); + public static readonly ChannelEnum Call = new ChannelEnum("call"); + public static readonly ChannelEnum Email = new ChannelEnum("email"); + public static readonly ChannelEnum Whatsapp = new ChannelEnum("whatsapp"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Approved = new StatusEnum("approved"); + } + + private static Request BuildCreateRequest(CreateVerificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Verifications", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Verification using a Service + /// + /// Create Verification parameters + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Create(CreateVerificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Verification using a Service + /// + /// Create Verification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task CreateAsync(CreateVerificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Verification using a Service + /// + /// The SID of the verification Service to create the resource under + /// The phone number or email to verify + /// The verification method to use + /// A custom user defined friendly name + /// The text of a custom message to use for the verification + /// The digits to send after a phone call is answered + /// The locale to use for the verification SMS, WhatsApp or call + /// A pre-generated code + /// The amount of the associated PSD2 compliant transaction. + /// The payee of the associated PSD2 compliant transaction + /// The custom key-value pairs of Programmable Rate Limits. + /// Channel specific configuration in json format. + /// Your App Hash to be appended at the end of an SMS. + /// The verification template SMS messages. + /// The values of the special variables declared on the message template. + /// + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Create(string pathServiceSid, + string to, + string channel, + string customFriendlyName = null, + string customMessage = null, + string sendDigits = null, + string locale = null, + string customCode = null, + string amount = null, + string payee = null, + object rateLimits = null, + object channelConfiguration = null, + string appHash = null, + string templateSid = null, + string templateCustomSubstitutions = null, + ITwilioRestClient client = null) + { + var options = new CreateVerificationOptions(pathServiceSid, to, channel) { CustomFriendlyName = customFriendlyName, CustomMessage = customMessage, SendDigits = sendDigits, Locale = locale, CustomCode = customCode, Amount = amount, Payee = payee, RateLimits = rateLimits, ChannelConfiguration = channelConfiguration, AppHash = appHash, TemplateSid = templateSid, TemplateCustomSubstitutions = templateCustomSubstitutions }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Verification using a Service + /// + /// The SID of the verification Service to create the resource under + /// The phone number or email to verify + /// The verification method to use + /// A custom user defined friendly name + /// The text of a custom message to use for the verification + /// The digits to send after a phone call is answered + /// The locale to use for the verification SMS, WhatsApp or call + /// A pre-generated code + /// The amount of the associated PSD2 compliant transaction. + /// The payee of the associated PSD2 compliant transaction + /// The custom key-value pairs of Programmable Rate Limits. + /// Channel specific configuration in json format. + /// Your App Hash to be appended at the end of an SMS. + /// The verification template SMS messages. + /// The values of the special variables declared on the message template. + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string to, + string channel, + string customFriendlyName = null, + string customMessage = null, + string sendDigits = null, + string locale = null, + string customCode = null, + string amount = null, + string payee = null, + object rateLimits = null, + object channelConfiguration = null, + string appHash = null, + string templateSid = null, + string templateCustomSubstitutions = null, + ITwilioRestClient client = null) + { + var options = new CreateVerificationOptions(pathServiceSid, to, channel) { CustomFriendlyName = customFriendlyName, CustomMessage = customMessage, SendDigits = sendDigits, Locale = locale, CustomCode = customCode, Amount = amount, Payee = payee, RateLimits = rateLimits, ChannelConfiguration = channelConfiguration, AppHash = appHash, TemplateSid = templateSid, TemplateCustomSubstitutions = templateCustomSubstitutions }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateVerificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Verifications/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a Verification status + /// + /// Update Verification parameters + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Update(UpdateVerificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a Verification status + /// + /// Update Verification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task UpdateAsync(UpdateVerificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a Verification status + /// + /// The SID of the verification Service to update the resource from + /// The unique string that identifies the resource + /// The new status of the resource + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Update(string pathServiceSid, + string pathSid, + VerificationResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateVerificationOptions(pathServiceSid, pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// Update a Verification status + /// + /// The SID of the verification Service to update the resource from + /// The unique string that identifies the resource + /// The new status of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + VerificationResource.StatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateVerificationOptions(pathServiceSid, pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchVerificationOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Verifications/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Verification + /// + /// Fetch Verification parameters + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Fetch(FetchVerificationOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Verification + /// + /// Fetch Verification parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task FetchAsync(FetchVerificationOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Verification + /// + /// The SID of the verification Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Verification + public static VerificationResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchVerificationOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Verification + /// + /// The SID of the verification Service to fetch the resource from + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Verification + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchVerificationOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a VerificationResource object + /// + /// Raw JSON string + /// VerificationResource object represented by the provided JSON + public static VerificationResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Service that the resource is associated with + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The phone number or email being verified + /// + [JsonProperty("to")] + public string To { get; private set; } + /// + /// The verification method used. + /// + [JsonProperty("channel")] + [JsonConverter(typeof(StringEnumConverter))] + public VerificationResource.ChannelEnum Channel { get; private set; } + /// + /// The status of the verification resource + /// + [JsonProperty("status")] + public string Status { get; private set; } + /// + /// Whether the verification was successful + /// + [JsonProperty("valid")] + public bool? Valid { get; private set; } + /// + /// Information about the phone number being verified + /// + [JsonProperty("lookup")] + public object Lookup { get; private set; } + /// + /// The amount of the associated PSD2 compliant transaction. + /// + [JsonProperty("amount")] + public string Amount { get; private set; } + /// + /// The payee of the associated PSD2 compliant transaction + /// + [JsonProperty("payee")] + public string Payee { get; private set; } + /// + /// An array of verification attempt objects. + /// + [JsonProperty("send_code_attempts")] + public List SendCodeAttempts { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Verification resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private VerificationResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/WebhookOptions.cs b/src/Twilio/Rest/Verify/V2/Service/WebhookOptions.cs index d351b5381..6d6d09ac6 100644 --- a/src/Twilio/Rest/Verify/V2/Service/WebhookOptions.cs +++ b/src/Twilio/Rest/Verify/V2/Service/WebhookOptions.cs @@ -10,281 +10,281 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2.Service -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Create a new Webhook for the Service + /// + public class CreateWebhookOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Create a new Webhook for the Service + /// Service Sid. /// - public class CreateWebhookOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// The string that you assigned to describe the webhook - /// - public string FriendlyName { get; } - /// - /// The array of events that this Webhook is subscribed to. - /// - public List EventTypes { get; } - /// - /// The URL associated with this Webhook. - /// - public string WebhookUrl { get; } - /// - /// The webhook status - /// - public WebhookResource.StatusEnum Status { get; set; } - /// - /// The webhook version - /// - public WebhookResource.VersionEnum Version { get; set; } - - /// - /// Construct a new CreateWebhookOptions - /// - /// Service Sid. - /// The string that you assigned to describe the webhook - /// The array of events that this Webhook is subscribed to. - /// The URL associated with this Webhook. - public CreateWebhookOptions(string pathServiceSid, string friendlyName, List eventTypes, string webhookUrl) - { - PathServiceSid = pathServiceSid; - FriendlyName = friendlyName; - EventTypes = eventTypes; - WebhookUrl = webhookUrl; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (EventTypes != null) - { - p.AddRange(EventTypes.Select(prop => new KeyValuePair("EventTypes", prop))); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Version != null) - { - p.Add(new KeyValuePair("Version", Version.ToString())); - } - - return p; - } - } - + public string PathServiceSid { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// UpdateWebhookOptions + /// The string that you assigned to describe the webhook /// - public class UpdateWebhookOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The string that you assigned to describe the webhook - /// - public string FriendlyName { get; set; } - /// - /// The array of events that this Webhook is subscribed to. - /// - public List EventTypes { get; set; } - /// - /// The URL associated with this Webhook. - /// - public string WebhookUrl { get; set; } - /// - /// The webhook status - /// - public WebhookResource.StatusEnum Status { get; set; } - /// - /// The webhook version - /// - public WebhookResource.VersionEnum Version { get; set; } - - /// - /// Construct a new UpdateWebhookOptions - /// - /// Service Sid. - /// The unique string that identifies the resource - public UpdateWebhookOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - EventTypes = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (EventTypes != null) - { - p.AddRange(EventTypes.Select(prop => new KeyValuePair("EventTypes", prop))); - } - - if (WebhookUrl != null) - { - p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Version != null) - { - p.Add(new KeyValuePair("Version", Version.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete a specific Webhook. + /// The array of events that this Webhook is subscribed to. /// - public class DeleteWebhookOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteWebhookOptions - /// - /// Service Sid. - /// The unique string that identifies the resource to delete - public DeleteWebhookOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List EventTypes { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Fetch a specific Webhook. + /// The URL associated with this Webhook. /// - public class FetchWebhookOptions : IOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - /// - /// The unique string that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchWebhookOptions - /// - /// Service Sid. - /// The unique string that identifies the resource to fetch - public FetchWebhookOptions(string pathServiceSid, string pathSid) - { - PathServiceSid = pathServiceSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string WebhookUrl { get; } /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Retrieve a list of all Webhooks for a Service. + /// The webhook status /// - public class ReadWebhookOptions : ReadOptions - { - /// - /// Service Sid. - /// - public string PathServiceSid { get; } - - /// - /// Construct a new ReadWebhookOptions - /// - /// Service Sid. - public ReadWebhookOptions(string pathServiceSid) - { - PathServiceSid = pathServiceSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public WebhookResource.StatusEnum Status { get; set; } + /// + /// The webhook version + /// + public WebhookResource.VersionEnum Version { get; set; } + + /// + /// Construct a new CreateWebhookOptions + /// + /// Service Sid. + /// The string that you assigned to describe the webhook + /// The array of events that this Webhook is subscribed to. + /// The URL associated with this Webhook. + public CreateWebhookOptions(string pathServiceSid, string friendlyName, List eventTypes, string webhookUrl) + { + PathServiceSid = pathServiceSid; + FriendlyName = friendlyName; + EventTypes = eventTypes; + WebhookUrl = webhookUrl; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (EventTypes != null) + { + p.AddRange(EventTypes.Select(prop => new KeyValuePair("EventTypes", prop))); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Version != null) + { + p.Add(new KeyValuePair("Version", Version.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// UpdateWebhookOptions + /// + public class UpdateWebhookOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The string that you assigned to describe the webhook + /// + public string FriendlyName { get; set; } + /// + /// The array of events that this Webhook is subscribed to. + /// + public List EventTypes { get; set; } + /// + /// The URL associated with this Webhook. + /// + public string WebhookUrl { get; set; } + /// + /// The webhook status + /// + public WebhookResource.StatusEnum Status { get; set; } + /// + /// The webhook version + /// + public WebhookResource.VersionEnum Version { get; set; } + + /// + /// Construct a new UpdateWebhookOptions + /// + /// Service Sid. + /// The unique string that identifies the resource + public UpdateWebhookOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + EventTypes = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (EventTypes != null) + { + p.AddRange(EventTypes.Select(prop => new KeyValuePair("EventTypes", prop))); + } + + if (WebhookUrl != null) + { + p.Add(new KeyValuePair("WebhookUrl", WebhookUrl)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Version != null) + { + p.Add(new KeyValuePair("Version", Version.ToString())); + } + + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete a specific Webhook. + /// + public class DeleteWebhookOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteWebhookOptions + /// + /// Service Sid. + /// The unique string that identifies the resource to delete + public DeleteWebhookOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Fetch a specific Webhook. + /// + public class FetchWebhookOptions : IOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + /// + /// The unique string that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchWebhookOptions + /// + /// Service Sid. + /// The unique string that identifies the resource to fetch + public FetchWebhookOptions(string pathServiceSid, string pathSid) + { + PathServiceSid = pathServiceSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Retrieve a list of all Webhooks for a Service. + /// + public class ReadWebhookOptions : ReadOptions + { + /// + /// Service Sid. + /// + public string PathServiceSid { get; } + + /// + /// Construct a new ReadWebhookOptions + /// + /// Service Sid. + public ReadWebhookOptions(string pathServiceSid) + { + PathServiceSid = pathServiceSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/Service/WebhookResource.cs b/src/Twilio/Rest/Verify/V2/Service/WebhookResource.cs index 5ace87ab8..d10ea90db 100644 --- a/src/Twilio/Rest/Verify/V2/Service/WebhookResource.cs +++ b/src/Twilio/Rest/Verify/V2/Service/WebhookResource.cs @@ -19,588 +19,588 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2.Service -{ - - public class WebhookResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Enabled = new StatusEnum("enabled"); - public static readonly StatusEnum Disabled = new StatusEnum("disabled"); - } - - public sealed class VersionEnum : StringEnum - { - private VersionEnum(string value) : base(value) {} - public VersionEnum() {} - public static implicit operator VersionEnum(string value) - { - return new VersionEnum(value); - } - - public static readonly VersionEnum V1 = new VersionEnum("v1"); - public static readonly VersionEnum V2 = new VersionEnum("v2"); - } - - public sealed class MethodsEnum : StringEnum - { - private MethodsEnum(string value) : base(value) {} - public MethodsEnum() {} - public static implicit operator MethodsEnum(string value) - { - return new MethodsEnum(value); - } - - public static readonly MethodsEnum Get = new MethodsEnum("GET"); - public static readonly MethodsEnum Post = new MethodsEnum("POST"); - } - - private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Webhooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Webhook for the Service - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Webhook for the Service - /// - /// Create Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Webhook for the Service - /// - /// Service Sid. - /// The string that you assigned to describe the webhook - /// The array of events that this Webhook is subscribed to. - /// The URL associated with this Webhook. - /// The webhook status - /// The webhook version - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Create(string pathServiceSid, - string friendlyName, - List eventTypes, - string webhookUrl, - WebhookResource.StatusEnum status = null, - WebhookResource.VersionEnum version = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, friendlyName, eventTypes, webhookUrl){Status = status, Version = version}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Webhook for the Service - /// - /// Service Sid. - /// The string that you assigned to describe the webhook - /// The array of events that this Webhook is subscribed to. - /// The URL associated with this Webhook. - /// The webhook status - /// The webhook version - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, - string friendlyName, - List eventTypes, - string webhookUrl, - WebhookResource.StatusEnum status = null, - WebhookResource.VersionEnum version = null, - ITwilioRestClient client = null) - { - var options = new CreateWebhookOptions(pathServiceSid, friendlyName, eventTypes, webhookUrl){Status = status, Version = version}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// Service Sid. - /// The unique string that identifies the resource - /// The string that you assigned to describe the webhook - /// The array of events that this Webhook is subscribed to. - /// The URL associated with this Webhook. - /// The webhook status - /// The webhook version - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Update(string pathServiceSid, - string pathSid, - string friendlyName = null, - List eventTypes = null, - string webhookUrl = null, - WebhookResource.StatusEnum status = null, - WebhookResource.VersionEnum version = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, EventTypes = eventTypes, WebhookUrl = webhookUrl, Status = status, Version = version}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// Service Sid. - /// The unique string that identifies the resource - /// The string that you assigned to describe the webhook - /// The array of events that this Webhook is subscribed to. - /// The URL associated with this Webhook. - /// The webhook status - /// The webhook version - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, - string pathSid, - string friendlyName = null, - List eventTypes = null, - string webhookUrl = null, - WebhookResource.StatusEnum status = null, - WebhookResource.VersionEnum version = null, - ITwilioRestClient client = null) - { - var options = new UpdateWebhookOptions(pathServiceSid, pathSid){FriendlyName = friendlyName, EventTypes = eventTypes, WebhookUrl = webhookUrl, Status = status, Version = version}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Webhook. - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Webhook. - /// - /// Delete Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Webhook. - /// - /// Service Sid. - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Webhook - public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Webhook. - /// - /// Service Sid. - /// The unique string that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteWebhookOptions(pathServiceSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific Webhook. - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific Webhook. - /// - /// Fetch Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific Webhook. - /// - /// Service Sid. - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Webhook - public static WebhookResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific Webhook. - /// - /// Service Sid. - /// The unique string that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchWebhookOptions(pathServiceSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathServiceSid + "/Webhooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Webhooks for a Service. - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Webhooks for a Service. - /// - /// Read Webhook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("webhooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Webhooks for a Service. - /// - /// Service Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Webhook - public static ResourceSet Read(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Webhooks for a Service. - /// - /// Service Sid. - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Webhook - public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadWebhookOptions(pathServiceSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("webhooks", response.Content); - } - - /// - /// Converts a JSON string into a WebhookResource object - /// - /// Raw JSON string - /// WebhookResource object represented by the provided JSON - public static WebhookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Service Sid. - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the webhook - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The array of events that this Webhook is subscribed to. - /// - [JsonProperty("event_types")] - public List EventTypes { get; private set; } - /// - /// The webhook status - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.StatusEnum Status { get; private set; } - /// - /// The webhook version - /// - [JsonProperty("version")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.VersionEnum Version { get; private set; } - /// - /// The URL associated with this Webhook. - /// - [JsonProperty("webhook_url")] - public Uri WebhookUrl { get; private set; } - /// - /// The method used when calling the webhook's URL. - /// - [JsonProperty("webhook_method")] - [JsonConverter(typeof(StringEnumConverter))] - public WebhookResource.MethodsEnum WebhookMethod { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the Webhook resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private WebhookResource() - { - - } - } +{ + + public class WebhookResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Enabled = new StatusEnum("enabled"); + public static readonly StatusEnum Disabled = new StatusEnum("disabled"); + } + + public sealed class VersionEnum : StringEnum + { + private VersionEnum(string value) : base(value) { } + public VersionEnum() { } + public static implicit operator VersionEnum(string value) + { + return new VersionEnum(value); + } + + public static readonly VersionEnum V1 = new VersionEnum("v1"); + public static readonly VersionEnum V2 = new VersionEnum("v2"); + } + + public sealed class MethodsEnum : StringEnum + { + private MethodsEnum(string value) : base(value) { } + public MethodsEnum() { } + public static implicit operator MethodsEnum(string value) + { + return new MethodsEnum(value); + } + + public static readonly MethodsEnum Get = new MethodsEnum("GET"); + public static readonly MethodsEnum Post = new MethodsEnum("POST"); + } + + private static Request BuildCreateRequest(CreateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Webhooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Webhook for the Service + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(CreateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Webhook for the Service + /// + /// Create Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(CreateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Webhook for the Service + /// + /// Service Sid. + /// The string that you assigned to describe the webhook + /// The array of events that this Webhook is subscribed to. + /// The URL associated with this Webhook. + /// The webhook status + /// The webhook version + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Create(string pathServiceSid, + string friendlyName, + List eventTypes, + string webhookUrl, + WebhookResource.StatusEnum status = null, + WebhookResource.VersionEnum version = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, friendlyName, eventTypes, webhookUrl) { Status = status, Version = version }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Webhook for the Service + /// + /// Service Sid. + /// The string that you assigned to describe the webhook + /// The array of events that this Webhook is subscribed to. + /// The URL associated with this Webhook. + /// The webhook status + /// The webhook version + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task CreateAsync(string pathServiceSid, + string friendlyName, + List eventTypes, + string webhookUrl, + WebhookResource.StatusEnum status = null, + WebhookResource.VersionEnum version = null, + ITwilioRestClient client = null) + { + var options = new CreateWebhookOptions(pathServiceSid, friendlyName, eventTypes, webhookUrl) { Status = status, Version = version }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(UpdateWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// Service Sid. + /// The unique string that identifies the resource + /// The string that you assigned to describe the webhook + /// The array of events that this Webhook is subscribed to. + /// The URL associated with this Webhook. + /// The webhook status + /// The webhook version + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Update(string pathServiceSid, + string pathSid, + string friendlyName = null, + List eventTypes = null, + string webhookUrl = null, + WebhookResource.StatusEnum status = null, + WebhookResource.VersionEnum version = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, EventTypes = eventTypes, WebhookUrl = webhookUrl, Status = status, Version = version }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// Service Sid. + /// The unique string that identifies the resource + /// The string that you assigned to describe the webhook + /// The array of events that this Webhook is subscribed to. + /// The URL associated with this Webhook. + /// The webhook status + /// The webhook version + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task UpdateAsync(string pathServiceSid, + string pathSid, + string friendlyName = null, + List eventTypes = null, + string webhookUrl = null, + WebhookResource.StatusEnum status = null, + WebhookResource.VersionEnum version = null, + ITwilioRestClient client = null) + { + var options = new UpdateWebhookOptions(pathServiceSid, pathSid) { FriendlyName = friendlyName, EventTypes = eventTypes, WebhookUrl = webhookUrl, Status = status, Version = version }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Webhook. + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(DeleteWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Webhook. + /// + /// Delete Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Webhook. + /// + /// Service Sid. + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Webhook + public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Webhook. + /// + /// Service Sid. + /// The unique string that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task DeleteAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteWebhookOptions(pathServiceSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Webhooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific Webhook. + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(FetchWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific Webhook. + /// + /// Fetch Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(FetchWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific Webhook. + /// + /// Service Sid. + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Webhook + public static WebhookResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific Webhook. + /// + /// Service Sid. + /// The unique string that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task FetchAsync(string pathServiceSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchWebhookOptions(pathServiceSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadWebhookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathServiceSid + "/Webhooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Webhooks for a Service. + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(ReadWebhookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Webhooks for a Service. + /// + /// Read Webhook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(ReadWebhookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("webhooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Webhooks for a Service. + /// + /// Service Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Webhook + public static ResourceSet Read(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Webhooks for a Service. + /// + /// Service Sid. + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Webhook + public static async System.Threading.Tasks.Task> ReadAsync(string pathServiceSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadWebhookOptions(pathServiceSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("webhooks", response.Content); + } + + /// + /// Converts a JSON string into a WebhookResource object + /// + /// Raw JSON string + /// WebhookResource object represented by the provided JSON + public static WebhookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Service Sid. + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the webhook + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The array of events that this Webhook is subscribed to. + /// + [JsonProperty("event_types")] + public List EventTypes { get; private set; } + /// + /// The webhook status + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.StatusEnum Status { get; private set; } + /// + /// The webhook version + /// + [JsonProperty("version")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.VersionEnum Version { get; private set; } + /// + /// The URL associated with this Webhook. + /// + [JsonProperty("webhook_url")] + public Uri WebhookUrl { get; private set; } + /// + /// The method used when calling the webhook's URL. + /// + [JsonProperty("webhook_method")] + [JsonConverter(typeof(StringEnumConverter))] + public WebhookResource.MethodsEnum WebhookMethod { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the Webhook resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private WebhookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/ServiceOptions.cs b/src/Twilio/Rest/Verify/V2/ServiceOptions.cs index e39fe1dd0..e8b82f515 100644 --- a/src/Twilio/Rest/Verify/V2/ServiceOptions.cs +++ b/src/Twilio/Rest/Verify/V2/ServiceOptions.cs @@ -9,444 +9,444 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2 -{ - +{ + + /// + /// Create a new Verification Service. + /// + public class CreateServiceOptions : IOptions + { /// - /// Create a new Verification Service. - /// - public class CreateServiceOptions : IOptions - { - /// - /// A string to describe the verification service - /// - public string FriendlyName { get; } - /// - /// The length of the verification code to generate - /// - public int? CodeLength { get; set; } - /// - /// Whether to perform a lookup with each verification - /// - public bool? LookupEnabled { get; set; } - /// - /// Whether to skip sending SMS verifications to landlines - /// - public bool? SkipSmsToLandlines { get; set; } - /// - /// Whether to ask the user to press a number before delivering the verify code in a phone call - /// - public bool? DtmfInputRequired { get; set; } - /// - /// The name of an alternative text-to-speech service to use in phone calls - /// - public string TtsName { get; set; } - /// - /// Whether to pass PSD2 transaction parameters when starting a verification - /// - public bool? Psd2Enabled { get; set; } - /// - /// Whether to add a security warning at the end of an SMS. - /// - public bool? DoNotShareWarningEnabled { get; set; } - /// - /// Whether to allow sending verifications with a custom code. - /// - public bool? CustomCodeEnabled { get; set; } - /// - /// Optional. Include the date in the Challenge's reponse. Default: true - /// - public bool? PushIncludeDate { get; set; } - /// - /// Optional. Set APN Credential for this service. - /// - public string PushApnCredentialSid { get; set; } - /// - /// Optional. Set FCM Credential for this service. - /// - public string PushFcmCredentialSid { get; set; } - /// - /// Optional. Set TOTP Issuer for this service. - /// - public string TotpIssuer { get; set; } - /// - /// Optional. How often, in seconds, are TOTP codes generated - /// - public int? TotpTimeStep { get; set; } - /// - /// Optional. Number of digits for generated TOTP codes - /// - public int? TotpCodeLength { get; set; } - /// - /// Optional. The number of past and future time-steps valid at a given time - /// - public int? TotpSkew { get; set; } - /// - /// The verification template SMS messages. - /// - public string DefaultTemplateSid { get; set; } - - /// - /// Construct a new CreateServiceOptions - /// - /// A string to describe the verification service - public CreateServiceOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CodeLength != null) - { - p.Add(new KeyValuePair("CodeLength", CodeLength.ToString())); - } - - if (LookupEnabled != null) - { - p.Add(new KeyValuePair("LookupEnabled", LookupEnabled.Value.ToString().ToLower())); - } - - if (SkipSmsToLandlines != null) - { - p.Add(new KeyValuePair("SkipSmsToLandlines", SkipSmsToLandlines.Value.ToString().ToLower())); - } - - if (DtmfInputRequired != null) - { - p.Add(new KeyValuePair("DtmfInputRequired", DtmfInputRequired.Value.ToString().ToLower())); - } - - if (TtsName != null) - { - p.Add(new KeyValuePair("TtsName", TtsName)); - } - - if (Psd2Enabled != null) - { - p.Add(new KeyValuePair("Psd2Enabled", Psd2Enabled.Value.ToString().ToLower())); - } - - if (DoNotShareWarningEnabled != null) - { - p.Add(new KeyValuePair("DoNotShareWarningEnabled", DoNotShareWarningEnabled.Value.ToString().ToLower())); - } - - if (CustomCodeEnabled != null) - { - p.Add(new KeyValuePair("CustomCodeEnabled", CustomCodeEnabled.Value.ToString().ToLower())); - } - - if (PushIncludeDate != null) - { - p.Add(new KeyValuePair("Push.IncludeDate", PushIncludeDate.Value.ToString().ToLower())); - } - - if (PushApnCredentialSid != null) - { - p.Add(new KeyValuePair("Push.ApnCredentialSid", PushApnCredentialSid.ToString())); - } - - if (PushFcmCredentialSid != null) - { - p.Add(new KeyValuePair("Push.FcmCredentialSid", PushFcmCredentialSid.ToString())); - } - - if (TotpIssuer != null) - { - p.Add(new KeyValuePair("Totp.Issuer", TotpIssuer)); - } - - if (TotpTimeStep != null) - { - p.Add(new KeyValuePair("Totp.TimeStep", TotpTimeStep.ToString())); - } - - if (TotpCodeLength != null) - { - p.Add(new KeyValuePair("Totp.CodeLength", TotpCodeLength.ToString())); - } - - if (TotpSkew != null) - { - p.Add(new KeyValuePair("Totp.Skew", TotpSkew.ToString())); - } - - if (DefaultTemplateSid != null) - { - p.Add(new KeyValuePair("DefaultTemplateSid", DefaultTemplateSid.ToString())); - } - - return p; - } - } - + /// A string to describe the verification service + /// + public string FriendlyName { get; } /// - /// Fetch specific Verification Service Instance. + /// The length of the verification code to generate /// - public class FetchServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchServiceOptions - /// - /// The unique string that identifies the resource - public FetchServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public int? CodeLength { get; set; } /// - /// Delete a specific Verification Service Instance. + /// Whether to perform a lookup with each verification /// - public class DeleteServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteServiceOptions - /// - /// The unique string that identifies the resource - public DeleteServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public bool? LookupEnabled { get; set; } /// - /// Retrieve a list of all Verification Services for an account. - /// - public class ReadServiceOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Whether to skip sending SMS verifications to landlines + /// + public bool? SkipSmsToLandlines { get; set; } /// - /// Update a specific Verification Service. - /// - public class UpdateServiceOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the verification service - /// - public string FriendlyName { get; set; } - /// - /// The length of the verification code to generate - /// - public int? CodeLength { get; set; } - /// - /// Whether to perform a lookup with each verification - /// - public bool? LookupEnabled { get; set; } - /// - /// Whether to skip sending SMS verifications to landlines - /// - public bool? SkipSmsToLandlines { get; set; } - /// - /// Whether to ask the user to press a number before delivering the verify code in a phone call - /// - public bool? DtmfInputRequired { get; set; } - /// - /// The name of an alternative text-to-speech service to use in phone calls - /// - public string TtsName { get; set; } - /// - /// Whether to pass PSD2 transaction parameters when starting a verification - /// - public bool? Psd2Enabled { get; set; } - /// - /// Whether to add a privacy warning at the end of an SMS. - /// - public bool? DoNotShareWarningEnabled { get; set; } - /// - /// Whether to allow sending verifications with a custom code. - /// - public bool? CustomCodeEnabled { get; set; } - /// - /// Optional. Include the date in the Challenge's reponse. Default: true - /// - public bool? PushIncludeDate { get; set; } - /// - /// Optional. Set APN Credential for this service. - /// - public string PushApnCredentialSid { get; set; } - /// - /// Optional. Set FCM Credential for this service. - /// - public string PushFcmCredentialSid { get; set; } - /// - /// Optional. Set TOTP Issuer for this service. - /// - public string TotpIssuer { get; set; } - /// - /// Optional. How often, in seconds, are TOTP codes generated - /// - public int? TotpTimeStep { get; set; } - /// - /// Optional. Number of digits for generated TOTP codes - /// - public int? TotpCodeLength { get; set; } - /// - /// Optional. The number of past and future time-steps valid at a given time - /// - public int? TotpSkew { get; set; } - /// - /// The verification template SMS messages. - /// - public string DefaultTemplateSid { get; set; } - - /// - /// Construct a new UpdateServiceOptions - /// - /// The unique string that identifies the resource - public UpdateServiceOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CodeLength != null) - { - p.Add(new KeyValuePair("CodeLength", CodeLength.ToString())); - } - - if (LookupEnabled != null) - { - p.Add(new KeyValuePair("LookupEnabled", LookupEnabled.Value.ToString().ToLower())); - } - - if (SkipSmsToLandlines != null) - { - p.Add(new KeyValuePair("SkipSmsToLandlines", SkipSmsToLandlines.Value.ToString().ToLower())); - } - - if (DtmfInputRequired != null) - { - p.Add(new KeyValuePair("DtmfInputRequired", DtmfInputRequired.Value.ToString().ToLower())); - } - - if (TtsName != null) - { - p.Add(new KeyValuePair("TtsName", TtsName)); - } - - if (Psd2Enabled != null) - { - p.Add(new KeyValuePair("Psd2Enabled", Psd2Enabled.Value.ToString().ToLower())); - } - - if (DoNotShareWarningEnabled != null) - { - p.Add(new KeyValuePair("DoNotShareWarningEnabled", DoNotShareWarningEnabled.Value.ToString().ToLower())); - } - - if (CustomCodeEnabled != null) - { - p.Add(new KeyValuePair("CustomCodeEnabled", CustomCodeEnabled.Value.ToString().ToLower())); - } - - if (PushIncludeDate != null) - { - p.Add(new KeyValuePair("Push.IncludeDate", PushIncludeDate.Value.ToString().ToLower())); - } - - if (PushApnCredentialSid != null) - { - p.Add(new KeyValuePair("Push.ApnCredentialSid", PushApnCredentialSid.ToString())); - } - - if (PushFcmCredentialSid != null) - { - p.Add(new KeyValuePair("Push.FcmCredentialSid", PushFcmCredentialSid.ToString())); - } - - if (TotpIssuer != null) - { - p.Add(new KeyValuePair("Totp.Issuer", TotpIssuer)); - } - - if (TotpTimeStep != null) - { - p.Add(new KeyValuePair("Totp.TimeStep", TotpTimeStep.ToString())); - } - - if (TotpCodeLength != null) - { - p.Add(new KeyValuePair("Totp.CodeLength", TotpCodeLength.ToString())); - } - - if (TotpSkew != null) - { - p.Add(new KeyValuePair("Totp.Skew", TotpSkew.ToString())); - } - - if (DefaultTemplateSid != null) - { - p.Add(new KeyValuePair("DefaultTemplateSid", DefaultTemplateSid.ToString())); - } - - return p; - } - } + /// Whether to ask the user to press a number before delivering the verify code in a phone call + /// + public bool? DtmfInputRequired { get; set; } + /// + /// The name of an alternative text-to-speech service to use in phone calls + /// + public string TtsName { get; set; } + /// + /// Whether to pass PSD2 transaction parameters when starting a verification + /// + public bool? Psd2Enabled { get; set; } + /// + /// Whether to add a security warning at the end of an SMS. + /// + public bool? DoNotShareWarningEnabled { get; set; } + /// + /// Whether to allow sending verifications with a custom code. + /// + public bool? CustomCodeEnabled { get; set; } + /// + /// Optional. Include the date in the Challenge's reponse. Default: true + /// + public bool? PushIncludeDate { get; set; } + /// + /// Optional. Set APN Credential for this service. + /// + public string PushApnCredentialSid { get; set; } + /// + /// Optional. Set FCM Credential for this service. + /// + public string PushFcmCredentialSid { get; set; } + /// + /// Optional. Set TOTP Issuer for this service. + /// + public string TotpIssuer { get; set; } + /// + /// Optional. How often, in seconds, are TOTP codes generated + /// + public int? TotpTimeStep { get; set; } + /// + /// Optional. Number of digits for generated TOTP codes + /// + public int? TotpCodeLength { get; set; } + /// + /// Optional. The number of past and future time-steps valid at a given time + /// + public int? TotpSkew { get; set; } + /// + /// The verification template SMS messages. + /// + public string DefaultTemplateSid { get; set; } + + /// + /// Construct a new CreateServiceOptions + /// + /// A string to describe the verification service + public CreateServiceOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CodeLength != null) + { + p.Add(new KeyValuePair("CodeLength", CodeLength.ToString())); + } + + if (LookupEnabled != null) + { + p.Add(new KeyValuePair("LookupEnabled", LookupEnabled.Value.ToString().ToLower())); + } + + if (SkipSmsToLandlines != null) + { + p.Add(new KeyValuePair("SkipSmsToLandlines", SkipSmsToLandlines.Value.ToString().ToLower())); + } + + if (DtmfInputRequired != null) + { + p.Add(new KeyValuePair("DtmfInputRequired", DtmfInputRequired.Value.ToString().ToLower())); + } + + if (TtsName != null) + { + p.Add(new KeyValuePair("TtsName", TtsName)); + } + + if (Psd2Enabled != null) + { + p.Add(new KeyValuePair("Psd2Enabled", Psd2Enabled.Value.ToString().ToLower())); + } + + if (DoNotShareWarningEnabled != null) + { + p.Add(new KeyValuePair("DoNotShareWarningEnabled", DoNotShareWarningEnabled.Value.ToString().ToLower())); + } + + if (CustomCodeEnabled != null) + { + p.Add(new KeyValuePair("CustomCodeEnabled", CustomCodeEnabled.Value.ToString().ToLower())); + } + + if (PushIncludeDate != null) + { + p.Add(new KeyValuePair("Push.IncludeDate", PushIncludeDate.Value.ToString().ToLower())); + } + + if (PushApnCredentialSid != null) + { + p.Add(new KeyValuePair("Push.ApnCredentialSid", PushApnCredentialSid.ToString())); + } + + if (PushFcmCredentialSid != null) + { + p.Add(new KeyValuePair("Push.FcmCredentialSid", PushFcmCredentialSid.ToString())); + } + + if (TotpIssuer != null) + { + p.Add(new KeyValuePair("Totp.Issuer", TotpIssuer)); + } + + if (TotpTimeStep != null) + { + p.Add(new KeyValuePair("Totp.TimeStep", TotpTimeStep.ToString())); + } + + if (TotpCodeLength != null) + { + p.Add(new KeyValuePair("Totp.CodeLength", TotpCodeLength.ToString())); + } + + if (TotpSkew != null) + { + p.Add(new KeyValuePair("Totp.Skew", TotpSkew.ToString())); + } + + if (DefaultTemplateSid != null) + { + p.Add(new KeyValuePair("DefaultTemplateSid", DefaultTemplateSid.ToString())); + } + + return p; + } + } + + /// + /// Fetch specific Verification Service Instance. + /// + public class FetchServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchServiceOptions + /// + /// The unique string that identifies the resource + public FetchServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Delete a specific Verification Service Instance. + /// + public class DeleteServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteServiceOptions + /// + /// The unique string that identifies the resource + public DeleteServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of all Verification Services for an account. + /// + public class ReadServiceOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Update a specific Verification Service. + /// + public class UpdateServiceOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the verification service + /// + public string FriendlyName { get; set; } + /// + /// The length of the verification code to generate + /// + public int? CodeLength { get; set; } + /// + /// Whether to perform a lookup with each verification + /// + public bool? LookupEnabled { get; set; } + /// + /// Whether to skip sending SMS verifications to landlines + /// + public bool? SkipSmsToLandlines { get; set; } + /// + /// Whether to ask the user to press a number before delivering the verify code in a phone call + /// + public bool? DtmfInputRequired { get; set; } + /// + /// The name of an alternative text-to-speech service to use in phone calls + /// + public string TtsName { get; set; } + /// + /// Whether to pass PSD2 transaction parameters when starting a verification + /// + public bool? Psd2Enabled { get; set; } + /// + /// Whether to add a privacy warning at the end of an SMS. + /// + public bool? DoNotShareWarningEnabled { get; set; } + /// + /// Whether to allow sending verifications with a custom code. + /// + public bool? CustomCodeEnabled { get; set; } + /// + /// Optional. Include the date in the Challenge's reponse. Default: true + /// + public bool? PushIncludeDate { get; set; } + /// + /// Optional. Set APN Credential for this service. + /// + public string PushApnCredentialSid { get; set; } + /// + /// Optional. Set FCM Credential for this service. + /// + public string PushFcmCredentialSid { get; set; } + /// + /// Optional. Set TOTP Issuer for this service. + /// + public string TotpIssuer { get; set; } + /// + /// Optional. How often, in seconds, are TOTP codes generated + /// + public int? TotpTimeStep { get; set; } + /// + /// Optional. Number of digits for generated TOTP codes + /// + public int? TotpCodeLength { get; set; } + /// + /// Optional. The number of past and future time-steps valid at a given time + /// + public int? TotpSkew { get; set; } + /// + /// The verification template SMS messages. + /// + public string DefaultTemplateSid { get; set; } + + /// + /// Construct a new UpdateServiceOptions + /// + /// The unique string that identifies the resource + public UpdateServiceOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CodeLength != null) + { + p.Add(new KeyValuePair("CodeLength", CodeLength.ToString())); + } + + if (LookupEnabled != null) + { + p.Add(new KeyValuePair("LookupEnabled", LookupEnabled.Value.ToString().ToLower())); + } + + if (SkipSmsToLandlines != null) + { + p.Add(new KeyValuePair("SkipSmsToLandlines", SkipSmsToLandlines.Value.ToString().ToLower())); + } + + if (DtmfInputRequired != null) + { + p.Add(new KeyValuePair("DtmfInputRequired", DtmfInputRequired.Value.ToString().ToLower())); + } + + if (TtsName != null) + { + p.Add(new KeyValuePair("TtsName", TtsName)); + } + + if (Psd2Enabled != null) + { + p.Add(new KeyValuePair("Psd2Enabled", Psd2Enabled.Value.ToString().ToLower())); + } + + if (DoNotShareWarningEnabled != null) + { + p.Add(new KeyValuePair("DoNotShareWarningEnabled", DoNotShareWarningEnabled.Value.ToString().ToLower())); + } + + if (CustomCodeEnabled != null) + { + p.Add(new KeyValuePair("CustomCodeEnabled", CustomCodeEnabled.Value.ToString().ToLower())); + } + + if (PushIncludeDate != null) + { + p.Add(new KeyValuePair("Push.IncludeDate", PushIncludeDate.Value.ToString().ToLower())); + } + + if (PushApnCredentialSid != null) + { + p.Add(new KeyValuePair("Push.ApnCredentialSid", PushApnCredentialSid.ToString())); + } + + if (PushFcmCredentialSid != null) + { + p.Add(new KeyValuePair("Push.FcmCredentialSid", PushFcmCredentialSid.ToString())); + } + + if (TotpIssuer != null) + { + p.Add(new KeyValuePair("Totp.Issuer", TotpIssuer)); + } + + if (TotpTimeStep != null) + { + p.Add(new KeyValuePair("Totp.TimeStep", TotpTimeStep.ToString())); + } + + if (TotpCodeLength != null) + { + p.Add(new KeyValuePair("Totp.CodeLength", TotpCodeLength.ToString())); + } + + if (TotpSkew != null) + { + p.Add(new KeyValuePair("Totp.Skew", TotpSkew.ToString())); + } + + if (DefaultTemplateSid != null) + { + p.Add(new KeyValuePair("DefaultTemplateSid", DefaultTemplateSid.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/ServiceResource.cs b/src/Twilio/Rest/Verify/V2/ServiceResource.cs index 299e46777..839d7c8c9 100644 --- a/src/Twilio/Rest/Verify/V2/ServiceResource.cs +++ b/src/Twilio/Rest/Verify/V2/ServiceResource.cs @@ -16,657 +16,657 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2 -{ - - public class ServiceResource : Resource - { - private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a new Verification Service. - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a new Verification Service. - /// - /// Create Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a new Verification Service. - /// - /// A string to describe the verification service - /// The length of the verification code to generate - /// Whether to perform a lookup with each verification - /// Whether to skip sending SMS verifications to landlines - /// Whether to ask the user to press a number before delivering the verify code in a - /// phone call - /// The name of an alternative text-to-speech service to use in phone calls - /// Whether to pass PSD2 transaction parameters when starting a verification - /// Whether to add a security warning at the end of an SMS. - /// Whether to allow sending verifications with a custom code. - /// Optional. Include the date in the Challenge's reponse. Default: true - /// Optional. Set APN Credential for this service. - /// Optional. Set FCM Credential for this service. - /// Optional. Set TOTP Issuer for this service. - /// Optional. How often, in seconds, are TOTP codes generated - /// Optional. Number of digits for generated TOTP codes - /// Optional. The number of past and future time-steps valid at a given time - /// The verification template SMS messages. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Create(string friendlyName, - int? codeLength = null, - bool? lookupEnabled = null, - bool? skipSmsToLandlines = null, - bool? dtmfInputRequired = null, - string ttsName = null, - bool? psd2Enabled = null, - bool? doNotShareWarningEnabled = null, - bool? customCodeEnabled = null, - bool? pushIncludeDate = null, - string pushApnCredentialSid = null, - string pushFcmCredentialSid = null, - string totpIssuer = null, - int? totpTimeStep = null, - int? totpCodeLength = null, - int? totpSkew = null, - string defaultTemplateSid = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName){CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// Create a new Verification Service. - /// - /// A string to describe the verification service - /// The length of the verification code to generate - /// Whether to perform a lookup with each verification - /// Whether to skip sending SMS verifications to landlines - /// Whether to ask the user to press a number before delivering the verify code in a - /// phone call - /// The name of an alternative text-to-speech service to use in phone calls - /// Whether to pass PSD2 transaction parameters when starting a verification - /// Whether to add a security warning at the end of an SMS. - /// Whether to allow sending verifications with a custom code. - /// Optional. Include the date in the Challenge's reponse. Default: true - /// Optional. Set APN Credential for this service. - /// Optional. Set FCM Credential for this service. - /// Optional. Set TOTP Issuer for this service. - /// Optional. How often, in seconds, are TOTP codes generated - /// Optional. Number of digits for generated TOTP codes - /// Optional. The number of past and future time-steps valid at a given time - /// The verification template SMS messages. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - int? codeLength = null, - bool? lookupEnabled = null, - bool? skipSmsToLandlines = null, - bool? dtmfInputRequired = null, - string ttsName = null, - bool? psd2Enabled = null, - bool? doNotShareWarningEnabled = null, - bool? customCodeEnabled = null, - bool? pushIncludeDate = null, - string pushApnCredentialSid = null, - string pushFcmCredentialSid = null, - string totpIssuer = null, - int? totpTimeStep = null, - int? totpCodeLength = null, - int? totpSkew = null, - string defaultTemplateSid = null, - ITwilioRestClient client = null) - { - var options = new CreateServiceOptions(friendlyName){CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch specific Verification Service Instance. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch specific Verification Service Instance. - /// - /// Fetch Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch specific Verification Service Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch specific Verification Service Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchServiceOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Verify, - "/v2/Services/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a specific Verification Service Instance. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a specific Verification Service Instance. - /// - /// Delete Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a specific Verification Service Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of Service - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a specific Verification Service Instance. - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteServiceOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Services", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of all Verification Services for an account. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Verification Services for an account. - /// - /// Read Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("services", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of all Verification Services for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Service - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of all Verification Services for an account. - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadServiceOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("services", response.Content); - } - - private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Verify, - "/v2/Services/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update a specific Verification Service. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update a specific Verification Service. - /// - /// Update Service parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update a specific Verification Service. - /// - /// The unique string that identifies the resource - /// A string to describe the verification service - /// The length of the verification code to generate - /// Whether to perform a lookup with each verification - /// Whether to skip sending SMS verifications to landlines - /// Whether to ask the user to press a number before delivering the verify code in a - /// phone call - /// The name of an alternative text-to-speech service to use in phone calls - /// Whether to pass PSD2 transaction parameters when starting a verification - /// Whether to add a privacy warning at the end of an SMS. - /// Whether to allow sending verifications with a custom code. - /// Optional. Include the date in the Challenge's reponse. Default: true - /// Optional. Set APN Credential for this service. - /// Optional. Set FCM Credential for this service. - /// Optional. Set TOTP Issuer for this service. - /// Optional. How often, in seconds, are TOTP codes generated - /// Optional. Number of digits for generated TOTP codes - /// Optional. The number of past and future time-steps valid at a given time - /// The verification template SMS messages. - /// Client to make requests to Twilio - /// A single instance of Service - public static ServiceResource Update(string pathSid, - string friendlyName = null, - int? codeLength = null, - bool? lookupEnabled = null, - bool? skipSmsToLandlines = null, - bool? dtmfInputRequired = null, - string ttsName = null, - bool? psd2Enabled = null, - bool? doNotShareWarningEnabled = null, - bool? customCodeEnabled = null, - bool? pushIncludeDate = null, - string pushApnCredentialSid = null, - string pushFcmCredentialSid = null, - string totpIssuer = null, - int? totpTimeStep = null, - int? totpCodeLength = null, - int? totpSkew = null, - string defaultTemplateSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update a specific Verification Service. - /// - /// The unique string that identifies the resource - /// A string to describe the verification service - /// The length of the verification code to generate - /// Whether to perform a lookup with each verification - /// Whether to skip sending SMS verifications to landlines - /// Whether to ask the user to press a number before delivering the verify code in a - /// phone call - /// The name of an alternative text-to-speech service to use in phone calls - /// Whether to pass PSD2 transaction parameters when starting a verification - /// Whether to add a privacy warning at the end of an SMS. - /// Whether to allow sending verifications with a custom code. - /// Optional. Include the date in the Challenge's reponse. Default: true - /// Optional. Set APN Credential for this service. - /// Optional. Set FCM Credential for this service. - /// Optional. Set TOTP Issuer for this service. - /// Optional. How often, in seconds, are TOTP codes generated - /// Optional. Number of digits for generated TOTP codes - /// Optional. The number of past and future time-steps valid at a given time - /// The verification template SMS messages. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Service - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - int? codeLength = null, - bool? lookupEnabled = null, - bool? skipSmsToLandlines = null, - bool? dtmfInputRequired = null, - string ttsName = null, - bool? psd2Enabled = null, - bool? doNotShareWarningEnabled = null, - bool? customCodeEnabled = null, - bool? pushIncludeDate = null, - string pushApnCredentialSid = null, - string pushFcmCredentialSid = null, - string totpIssuer = null, - int? totpTimeStep = null, - int? totpCodeLength = null, - int? totpSkew = null, - string defaultTemplateSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateServiceOptions(pathSid){FriendlyName = friendlyName, CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ServiceResource object - /// - /// Raw JSON string - /// ServiceResource object represented by the provided JSON - public static ServiceResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the verification service - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The length of the verification code - /// - [JsonProperty("code_length")] - public int? CodeLength { get; private set; } - /// - /// Whether to perform a lookup with each verification - /// - [JsonProperty("lookup_enabled")] - public bool? LookupEnabled { get; private set; } - /// - /// Whether to pass PSD2 transaction parameters when starting a verification - /// - [JsonProperty("psd2_enabled")] - public bool? Psd2Enabled { get; private set; } - /// - /// Whether to skip sending SMS verifications to landlines - /// - [JsonProperty("skip_sms_to_landlines")] - public bool? SkipSmsToLandlines { get; private set; } - /// - /// Whether to ask the user to press a number before delivering the verify code in a phone call - /// - [JsonProperty("dtmf_input_required")] - public bool? DtmfInputRequired { get; private set; } - /// - /// The name of an alternative text-to-speech service to use in phone calls - /// - [JsonProperty("tts_name")] - public string TtsName { get; private set; } - /// - /// Whether to add a security warning at the end of an SMS. - /// - [JsonProperty("do_not_share_warning_enabled")] - public bool? DoNotShareWarningEnabled { get; private set; } - /// - /// Whether to allow sending verifications with a custom code. - /// - [JsonProperty("custom_code_enabled")] - public bool? CustomCodeEnabled { get; private set; } - /// - /// The service level configuration of factor push type. - /// - [JsonProperty("push")] - public object Push { get; private set; } - /// - /// The service level configuration of factor TOTP type. - /// - [JsonProperty("totp")] - public object Totp { get; private set; } - /// - /// The default_template_sid - /// - [JsonProperty("default_template_sid")] - public string DefaultTemplateSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ServiceResource() - { - - } - } +{ + + public class ServiceResource : Resource + { + private static Request BuildCreateRequest(CreateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a new Verification Service. + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(CreateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a new Verification Service. + /// + /// Create Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(CreateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a new Verification Service. + /// + /// A string to describe the verification service + /// The length of the verification code to generate + /// Whether to perform a lookup with each verification + /// Whether to skip sending SMS verifications to landlines + /// Whether to ask the user to press a number before delivering the verify code in a + /// phone call + /// The name of an alternative text-to-speech service to use in phone calls + /// Whether to pass PSD2 transaction parameters when starting a verification + /// Whether to add a security warning at the end of an SMS. + /// Whether to allow sending verifications with a custom code. + /// Optional. Include the date in the Challenge's reponse. Default: true + /// Optional. Set APN Credential for this service. + /// Optional. Set FCM Credential for this service. + /// Optional. Set TOTP Issuer for this service. + /// Optional. How often, in seconds, are TOTP codes generated + /// Optional. Number of digits for generated TOTP codes + /// Optional. The number of past and future time-steps valid at a given time + /// The verification template SMS messages. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Create(string friendlyName, + int? codeLength = null, + bool? lookupEnabled = null, + bool? skipSmsToLandlines = null, + bool? dtmfInputRequired = null, + string ttsName = null, + bool? psd2Enabled = null, + bool? doNotShareWarningEnabled = null, + bool? customCodeEnabled = null, + bool? pushIncludeDate = null, + string pushApnCredentialSid = null, + string pushFcmCredentialSid = null, + string totpIssuer = null, + int? totpTimeStep = null, + int? totpCodeLength = null, + int? totpSkew = null, + string defaultTemplateSid = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName) { CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// Create a new Verification Service. + /// + /// A string to describe the verification service + /// The length of the verification code to generate + /// Whether to perform a lookup with each verification + /// Whether to skip sending SMS verifications to landlines + /// Whether to ask the user to press a number before delivering the verify code in a + /// phone call + /// The name of an alternative text-to-speech service to use in phone calls + /// Whether to pass PSD2 transaction parameters when starting a verification + /// Whether to add a security warning at the end of an SMS. + /// Whether to allow sending verifications with a custom code. + /// Optional. Include the date in the Challenge's reponse. Default: true + /// Optional. Set APN Credential for this service. + /// Optional. Set FCM Credential for this service. + /// Optional. Set TOTP Issuer for this service. + /// Optional. How often, in seconds, are TOTP codes generated + /// Optional. Number of digits for generated TOTP codes + /// Optional. The number of past and future time-steps valid at a given time + /// The verification template SMS messages. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + int? codeLength = null, + bool? lookupEnabled = null, + bool? skipSmsToLandlines = null, + bool? dtmfInputRequired = null, + string ttsName = null, + bool? psd2Enabled = null, + bool? doNotShareWarningEnabled = null, + bool? customCodeEnabled = null, + bool? pushIncludeDate = null, + string pushApnCredentialSid = null, + string pushFcmCredentialSid = null, + string totpIssuer = null, + int? totpTimeStep = null, + int? totpCodeLength = null, + int? totpSkew = null, + string defaultTemplateSid = null, + ITwilioRestClient client = null) + { + var options = new CreateServiceOptions(friendlyName) { CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch specific Verification Service Instance. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(FetchServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch specific Verification Service Instance. + /// + /// Fetch Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(FetchServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch specific Verification Service Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch specific Verification Service Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchServiceOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Verify, + "/v2/Services/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a specific Verification Service Instance. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(DeleteServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a specific Verification Service Instance. + /// + /// Delete Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(DeleteServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a specific Verification Service Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of Service + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a specific Verification Service Instance. + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteServiceOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Services", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of all Verification Services for an account. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(ReadServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Verification Services for an account. + /// + /// Read Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(ReadServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("services", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of all Verification Services for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Service + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of all Verification Services for an account. + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadServiceOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("services", response.Content); + } + + private static Request BuildUpdateRequest(UpdateServiceOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Verify, + "/v2/Services/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update a specific Verification Service. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(UpdateServiceOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update a specific Verification Service. + /// + /// Update Service parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(UpdateServiceOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update a specific Verification Service. + /// + /// The unique string that identifies the resource + /// A string to describe the verification service + /// The length of the verification code to generate + /// Whether to perform a lookup with each verification + /// Whether to skip sending SMS verifications to landlines + /// Whether to ask the user to press a number before delivering the verify code in a + /// phone call + /// The name of an alternative text-to-speech service to use in phone calls + /// Whether to pass PSD2 transaction parameters when starting a verification + /// Whether to add a privacy warning at the end of an SMS. + /// Whether to allow sending verifications with a custom code. + /// Optional. Include the date in the Challenge's reponse. Default: true + /// Optional. Set APN Credential for this service. + /// Optional. Set FCM Credential for this service. + /// Optional. Set TOTP Issuer for this service. + /// Optional. How often, in seconds, are TOTP codes generated + /// Optional. Number of digits for generated TOTP codes + /// Optional. The number of past and future time-steps valid at a given time + /// The verification template SMS messages. + /// Client to make requests to Twilio + /// A single instance of Service + public static ServiceResource Update(string pathSid, + string friendlyName = null, + int? codeLength = null, + bool? lookupEnabled = null, + bool? skipSmsToLandlines = null, + bool? dtmfInputRequired = null, + string ttsName = null, + bool? psd2Enabled = null, + bool? doNotShareWarningEnabled = null, + bool? customCodeEnabled = null, + bool? pushIncludeDate = null, + string pushApnCredentialSid = null, + string pushFcmCredentialSid = null, + string totpIssuer = null, + int? totpTimeStep = null, + int? totpCodeLength = null, + int? totpSkew = null, + string defaultTemplateSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update a specific Verification Service. + /// + /// The unique string that identifies the resource + /// A string to describe the verification service + /// The length of the verification code to generate + /// Whether to perform a lookup with each verification + /// Whether to skip sending SMS verifications to landlines + /// Whether to ask the user to press a number before delivering the verify code in a + /// phone call + /// The name of an alternative text-to-speech service to use in phone calls + /// Whether to pass PSD2 transaction parameters when starting a verification + /// Whether to add a privacy warning at the end of an SMS. + /// Whether to allow sending verifications with a custom code. + /// Optional. Include the date in the Challenge's reponse. Default: true + /// Optional. Set APN Credential for this service. + /// Optional. Set FCM Credential for this service. + /// Optional. Set TOTP Issuer for this service. + /// Optional. How often, in seconds, are TOTP codes generated + /// Optional. Number of digits for generated TOTP codes + /// Optional. The number of past and future time-steps valid at a given time + /// The verification template SMS messages. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Service + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + int? codeLength = null, + bool? lookupEnabled = null, + bool? skipSmsToLandlines = null, + bool? dtmfInputRequired = null, + string ttsName = null, + bool? psd2Enabled = null, + bool? doNotShareWarningEnabled = null, + bool? customCodeEnabled = null, + bool? pushIncludeDate = null, + string pushApnCredentialSid = null, + string pushFcmCredentialSid = null, + string totpIssuer = null, + int? totpTimeStep = null, + int? totpCodeLength = null, + int? totpSkew = null, + string defaultTemplateSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateServiceOptions(pathSid) { FriendlyName = friendlyName, CodeLength = codeLength, LookupEnabled = lookupEnabled, SkipSmsToLandlines = skipSmsToLandlines, DtmfInputRequired = dtmfInputRequired, TtsName = ttsName, Psd2Enabled = psd2Enabled, DoNotShareWarningEnabled = doNotShareWarningEnabled, CustomCodeEnabled = customCodeEnabled, PushIncludeDate = pushIncludeDate, PushApnCredentialSid = pushApnCredentialSid, PushFcmCredentialSid = pushFcmCredentialSid, TotpIssuer = totpIssuer, TotpTimeStep = totpTimeStep, TotpCodeLength = totpCodeLength, TotpSkew = totpSkew, DefaultTemplateSid = defaultTemplateSid }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ServiceResource object + /// + /// Raw JSON string + /// ServiceResource object represented by the provided JSON + public static ServiceResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the verification service + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The length of the verification code + /// + [JsonProperty("code_length")] + public int? CodeLength { get; private set; } + /// + /// Whether to perform a lookup with each verification + /// + [JsonProperty("lookup_enabled")] + public bool? LookupEnabled { get; private set; } + /// + /// Whether to pass PSD2 transaction parameters when starting a verification + /// + [JsonProperty("psd2_enabled")] + public bool? Psd2Enabled { get; private set; } + /// + /// Whether to skip sending SMS verifications to landlines + /// + [JsonProperty("skip_sms_to_landlines")] + public bool? SkipSmsToLandlines { get; private set; } + /// + /// Whether to ask the user to press a number before delivering the verify code in a phone call + /// + [JsonProperty("dtmf_input_required")] + public bool? DtmfInputRequired { get; private set; } + /// + /// The name of an alternative text-to-speech service to use in phone calls + /// + [JsonProperty("tts_name")] + public string TtsName { get; private set; } + /// + /// Whether to add a security warning at the end of an SMS. + /// + [JsonProperty("do_not_share_warning_enabled")] + public bool? DoNotShareWarningEnabled { get; private set; } + /// + /// Whether to allow sending verifications with a custom code. + /// + [JsonProperty("custom_code_enabled")] + public bool? CustomCodeEnabled { get; private set; } + /// + /// The service level configuration of factor push type. + /// + [JsonProperty("push")] + public object Push { get; private set; } + /// + /// The service level configuration of factor TOTP type. + /// + [JsonProperty("totp")] + public object Totp { get; private set; } + /// + /// The default_template_sid + /// + [JsonProperty("default_template_sid")] + public string DefaultTemplateSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ServiceResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/TemplateOptions.cs b/src/Twilio/Rest/Verify/V2/TemplateOptions.cs index 04b1939bc..7bfcfd0a2 100644 --- a/src/Twilio/Rest/Verify/V2/TemplateOptions.cs +++ b/src/Twilio/Rest/Verify/V2/TemplateOptions.cs @@ -9,36 +9,36 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2 -{ - +{ + + /// + /// List all the available templates for a given Account. + /// + public class ReadTemplateOptions : ReadOptions + { /// - /// List all the available templates for a given Account. + /// Filter templates using friendly name /// - public class ReadTemplateOptions : ReadOptions - { - /// - /// Filter templates using friendly name - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/TemplateResource.cs b/src/Twilio/Rest/Verify/V2/TemplateResource.cs index 1cc6f5e6d..47552cfe3 100644 --- a/src/Twilio/Rest/Verify/V2/TemplateResource.cs +++ b/src/Twilio/Rest/Verify/V2/TemplateResource.cs @@ -16,186 +16,186 @@ using Twilio.Http; namespace Twilio.Rest.Verify.V2 -{ - - public class TemplateResource : Resource - { - private static Request BuildReadRequest(ReadTemplateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Templates", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List all the available templates for a given Account. - /// - /// Read Template parameters - /// Client to make requests to Twilio - /// A single instance of Template - public static ResourceSet Read(ReadTemplateOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("templates", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List all the available templates for a given Account. - /// - /// Read Template parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Template - public static async System.Threading.Tasks.Task> ReadAsync(ReadTemplateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("templates", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List all the available templates for a given Account. - /// - /// Filter templates using friendly name - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Template - public static ResourceSet Read(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTemplateOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List all the available templates for a given Account. - /// - /// Filter templates using friendly name - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Template - public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadTemplateOptions(){FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("templates", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("templates", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("templates", response.Content); - } - - /// - /// Converts a JSON string into a TemplateResource object - /// - /// Raw JSON string - /// TemplateResource object represented by the provided JSON - public static TemplateResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Template - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// A string to describe the verification template - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Ojbect with the template translations. - /// - [JsonProperty("translations")] - public object Translations { get; private set; } - - private TemplateResource() - { - - } - } +{ + + public class TemplateResource : Resource + { + private static Request BuildReadRequest(ReadTemplateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Templates", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List all the available templates for a given Account. + /// + /// Read Template parameters + /// Client to make requests to Twilio + /// A single instance of Template + public static ResourceSet Read(ReadTemplateOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("templates", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List all the available templates for a given Account. + /// + /// Read Template parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Template + public static async System.Threading.Tasks.Task> ReadAsync(ReadTemplateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("templates", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List all the available templates for a given Account. + /// + /// Filter templates using friendly name + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Template + public static ResourceSet Read(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTemplateOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List all the available templates for a given Account. + /// + /// Filter templates using friendly name + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Template + public static async System.Threading.Tasks.Task> ReadAsync(string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadTemplateOptions() { FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("templates", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("templates", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("templates", response.Content); + } + + /// + /// Converts a JSON string into a TemplateResource object + /// + /// Raw JSON string + /// TemplateResource object represented by the provided JSON + public static TemplateResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Template + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// A string to describe the verification template + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Ojbect with the template translations. + /// + [JsonProperty("translations")] + public object Translations { get; private set; } + + private TemplateResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/VerificationAttemptOptions.cs b/src/Twilio/Rest/Verify/V2/VerificationAttemptOptions.cs index 47a85ab1f..5c88311a0 100644 --- a/src/Twilio/Rest/Verify/V2/VerificationAttemptOptions.cs +++ b/src/Twilio/Rest/Verify/V2/VerificationAttemptOptions.cs @@ -9,83 +9,83 @@ using Twilio.Converters; namespace Twilio.Rest.Verify.V2 -{ - +{ + + /// + /// List all the verification attempts for a given Account. + /// + public class ReadVerificationAttemptOptions : ReadOptions + { /// - /// List all the verification attempts for a given Account. + /// Filter verification attempts after this date /// - public class ReadVerificationAttemptOptions : ReadOptions - { - /// - /// Filter verification attempts after this date - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Filter verification attempts befor this date - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Destination of a verification - /// - public string ChannelDataTo { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (ChannelDataTo != null) - { - p.Add(new KeyValuePair("ChannelData.To", ChannelDataTo)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public DateTime? DateCreatedAfter { get; set; } /// - /// Fetch a specific verification attempt. + /// Filter verification attempts befor this date /// - public class FetchVerificationAttemptOptions : IOptions - { - /// - /// Verification Attempt Sid. - /// - public string PathSid { get; } - - /// - /// Construct a new FetchVerificationAttemptOptions - /// - /// Verification Attempt Sid. - public FetchVerificationAttemptOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public DateTime? DateCreatedBefore { get; set; } + /// + /// Destination of a verification + /// + public string ChannelDataTo { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (ChannelDataTo != null) + { + p.Add(new KeyValuePair("ChannelData.To", ChannelDataTo)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Fetch a specific verification attempt. + /// + public class FetchVerificationAttemptOptions : IOptions + { + /// + /// Verification Attempt Sid. + /// + public string PathSid { get; } + + /// + /// Construct a new FetchVerificationAttemptOptions + /// + /// Verification Attempt Sid. + public FetchVerificationAttemptOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Verify/V2/VerificationAttemptResource.cs b/src/Twilio/Rest/Verify/V2/VerificationAttemptResource.cs index 7ea34a669..7be1ad5b2 100644 --- a/src/Twilio/Rest/Verify/V2/VerificationAttemptResource.cs +++ b/src/Twilio/Rest/Verify/V2/VerificationAttemptResource.cs @@ -17,320 +17,320 @@ using Twilio.Types; namespace Twilio.Rest.Verify.V2 -{ - - public class VerificationAttemptResource : Resource - { - public sealed class ChannelsEnum : StringEnum - { - private ChannelsEnum(string value) : base(value) {} - public ChannelsEnum() {} - public static implicit operator ChannelsEnum(string value) - { - return new ChannelsEnum(value); - } - - public static readonly ChannelsEnum Sms = new ChannelsEnum("sms"); - public static readonly ChannelsEnum Call = new ChannelsEnum("call"); - public static readonly ChannelsEnum Email = new ChannelsEnum("email"); - public static readonly ChannelsEnum Whatsapp = new ChannelsEnum("whatsapp"); - } - - public sealed class ConversionStatusEnum : StringEnum - { - private ConversionStatusEnum(string value) : base(value) {} - public ConversionStatusEnum() {} - public static implicit operator ConversionStatusEnum(string value) - { - return new ConversionStatusEnum(value); - } - - public static readonly ConversionStatusEnum Converted = new ConversionStatusEnum("converted"); - public static readonly ConversionStatusEnum Unconverted = new ConversionStatusEnum("unconverted"); - } - - private static Request BuildReadRequest(ReadVerificationAttemptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Attempts", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List all the verification attempts for a given Account. - /// - /// Read VerificationAttempt parameters - /// Client to make requests to Twilio - /// A single instance of VerificationAttempt - public static ResourceSet Read(ReadVerificationAttemptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("attempts", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List all the verification attempts for a given Account. - /// - /// Read VerificationAttempt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationAttempt - public static async System.Threading.Tasks.Task> ReadAsync(ReadVerificationAttemptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("attempts", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List all the verification attempts for a given Account. - /// - /// Filter verification attempts after this date - /// Filter verification attempts befor this date - /// Destination of a verification - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of VerificationAttempt - public static ResourceSet Read(DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string channelDataTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVerificationAttemptOptions(){DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, ChannelDataTo = channelDataTo, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List all the verification attempts for a given Account. - /// - /// Filter verification attempts after this date - /// Filter verification attempts befor this date - /// Destination of a verification - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationAttempt - public static async System.Threading.Tasks.Task> ReadAsync(DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string channelDataTo = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadVerificationAttemptOptions(){DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, ChannelDataTo = channelDataTo, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("attempts", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("attempts", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Verify) - ); - - var response = client.Request(request); - return Page.FromJson("attempts", response.Content); - } - - private static Request BuildFetchRequest(FetchVerificationAttemptOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Verify, - "/v2/Attempts/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a specific verification attempt. - /// - /// Fetch VerificationAttempt parameters - /// Client to make requests to Twilio - /// A single instance of VerificationAttempt - public static VerificationAttemptResource Fetch(FetchVerificationAttemptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a specific verification attempt. - /// - /// Fetch VerificationAttempt parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationAttempt - public static async System.Threading.Tasks.Task FetchAsync(FetchVerificationAttemptOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a specific verification attempt. - /// - /// Verification Attempt Sid. - /// Client to make requests to Twilio - /// A single instance of VerificationAttempt - public static VerificationAttemptResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchVerificationAttemptOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a specific verification attempt. - /// - /// Verification Attempt Sid. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of VerificationAttempt - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchVerificationAttemptOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a VerificationAttemptResource object - /// - /// Raw JSON string - /// VerificationAttemptResource object represented by the provided JSON - public static VerificationAttemptResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A string that uniquely identifies this Verification Attempt - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// Account Sid - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The service_sid - /// - [JsonProperty("service_sid")] - public string ServiceSid { get; private set; } - /// - /// The date this Attempt was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date this Attempt was updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Status of a conversion - /// - [JsonProperty("conversion_status")] - [JsonConverter(typeof(StringEnumConverter))] - public VerificationAttemptResource.ConversionStatusEnum ConversionStatus { get; private set; } - /// - /// Channel used for the attempt - /// - [JsonProperty("channel")] - [JsonConverter(typeof(StringEnumConverter))] - public VerificationAttemptResource.ChannelsEnum Channel { get; private set; } - /// - /// Object with the channel information for an attempt - /// - [JsonProperty("channel_data")] - public object ChannelData { get; private set; } - /// - /// The url - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private VerificationAttemptResource() - { - - } - } +{ + + public class VerificationAttemptResource : Resource + { + public sealed class ChannelsEnum : StringEnum + { + private ChannelsEnum(string value) : base(value) { } + public ChannelsEnum() { } + public static implicit operator ChannelsEnum(string value) + { + return new ChannelsEnum(value); + } + + public static readonly ChannelsEnum Sms = new ChannelsEnum("sms"); + public static readonly ChannelsEnum Call = new ChannelsEnum("call"); + public static readonly ChannelsEnum Email = new ChannelsEnum("email"); + public static readonly ChannelsEnum Whatsapp = new ChannelsEnum("whatsapp"); + } + + public sealed class ConversionStatusEnum : StringEnum + { + private ConversionStatusEnum(string value) : base(value) { } + public ConversionStatusEnum() { } + public static implicit operator ConversionStatusEnum(string value) + { + return new ConversionStatusEnum(value); + } + + public static readonly ConversionStatusEnum Converted = new ConversionStatusEnum("converted"); + public static readonly ConversionStatusEnum Unconverted = new ConversionStatusEnum("unconverted"); + } + + private static Request BuildReadRequest(ReadVerificationAttemptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Attempts", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List all the verification attempts for a given Account. + /// + /// Read VerificationAttempt parameters + /// Client to make requests to Twilio + /// A single instance of VerificationAttempt + public static ResourceSet Read(ReadVerificationAttemptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("attempts", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List all the verification attempts for a given Account. + /// + /// Read VerificationAttempt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationAttempt + public static async System.Threading.Tasks.Task> ReadAsync(ReadVerificationAttemptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("attempts", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List all the verification attempts for a given Account. + /// + /// Filter verification attempts after this date + /// Filter verification attempts befor this date + /// Destination of a verification + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of VerificationAttempt + public static ResourceSet Read(DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string channelDataTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVerificationAttemptOptions() { DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, ChannelDataTo = channelDataTo, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List all the verification attempts for a given Account. + /// + /// Filter verification attempts after this date + /// Filter verification attempts befor this date + /// Destination of a verification + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationAttempt + public static async System.Threading.Tasks.Task> ReadAsync(DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string channelDataTo = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadVerificationAttemptOptions() { DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, ChannelDataTo = channelDataTo, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("attempts", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("attempts", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Verify) + ); + + var response = client.Request(request); + return Page.FromJson("attempts", response.Content); + } + + private static Request BuildFetchRequest(FetchVerificationAttemptOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Verify, + "/v2/Attempts/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a specific verification attempt. + /// + /// Fetch VerificationAttempt parameters + /// Client to make requests to Twilio + /// A single instance of VerificationAttempt + public static VerificationAttemptResource Fetch(FetchVerificationAttemptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a specific verification attempt. + /// + /// Fetch VerificationAttempt parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationAttempt + public static async System.Threading.Tasks.Task FetchAsync(FetchVerificationAttemptOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a specific verification attempt. + /// + /// Verification Attempt Sid. + /// Client to make requests to Twilio + /// A single instance of VerificationAttempt + public static VerificationAttemptResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchVerificationAttemptOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a specific verification attempt. + /// + /// Verification Attempt Sid. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of VerificationAttempt + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchVerificationAttemptOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a VerificationAttemptResource object + /// + /// Raw JSON string + /// VerificationAttemptResource object represented by the provided JSON + public static VerificationAttemptResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A string that uniquely identifies this Verification Attempt + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// Account Sid + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The service_sid + /// + [JsonProperty("service_sid")] + public string ServiceSid { get; private set; } + /// + /// The date this Attempt was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date this Attempt was updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Status of a conversion + /// + [JsonProperty("conversion_status")] + [JsonConverter(typeof(StringEnumConverter))] + public VerificationAttemptResource.ConversionStatusEnum ConversionStatus { get; private set; } + /// + /// Channel used for the attempt + /// + [JsonProperty("channel")] + [JsonConverter(typeof(StringEnumConverter))] + public VerificationAttemptResource.ChannelsEnum Channel { get; private set; } + /// + /// Object with the channel information for an attempt + /// + [JsonProperty("channel_data")] + public object ChannelData { get; private set; } + /// + /// The url + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private VerificationAttemptResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionHookOptions.cs b/src/Twilio/Rest/Video/V1/CompositionHookOptions.cs index be8a45551..3d83d971d 100644 --- a/src/Twilio/Rest/Video/V1/CompositionHookOptions.cs +++ b/src/Twilio/Rest/Video/V1/CompositionHookOptions.cs @@ -10,361 +10,361 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// + public class FetchCompositionHookOptions : IOptions + { /// - /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// The SID that identifies the resource to fetch /// - public class FetchCompositionHookOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCompositionHookOptions - /// - /// The SID that identifies the resource to fetch - public FetchCompositionHookOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// List of all Recording CompositionHook resources. - /// - public class ReadCompositionHookOptions : ReadOptions - { - /// - /// Read only CompositionHook resources with an enabled value that matches this parameter - /// - public bool? Enabled { get; set; } - /// - /// Read only CompositionHook resources created on or after this ISO 8601 datetime with time zone - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only CompositionHook resources created before this ISO 8601 datetime with time zone - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Read only CompositionHook resources with friendly names that match this string - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchCompositionHookOptions + /// + /// The SID that identifies the resource to fetch + public FetchCompositionHookOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// Generate the necessary parameters /// - public class DeleteCompositionHookOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCompositionHookOptions - /// - /// The SID that identifies the resource to delete - public DeleteCompositionHookOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// List of all Recording CompositionHook resources. + /// + public class ReadCompositionHookOptions : ReadOptions + { /// - /// CreateCompositionHookOptions - /// - public class CreateCompositionHookOptions : IOptions - { - /// - /// A unique string to describe the resource - /// - public string FriendlyName { get; } - /// - /// Whether the composition hook is active - /// - public bool? Enabled { get; set; } - /// - /// An object that describes the video layout of the composition hook - /// - public object VideoLayout { get; set; } - /// - /// An array of track names from the same group room to merge - /// - public List AudioSources { get; set; } - /// - /// An array of track names to exclude - /// - public List AudioSourcesExcluded { get; set; } - /// - /// A string that describes the rows (width) and columns (height) of the generated composed video in pixels - /// - public string Resolution { get; set; } - /// - /// The container format of the media files used by the compositions created by the composition hook - /// - public CompositionHookResource.FormatEnum Format { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook - /// - public bool? Trim { get; set; } - - /// - /// Construct a new CreateCompositionHookOptions - /// - /// A unique string to describe the resource - public CreateCompositionHookOptions(string friendlyName) - { - FriendlyName = friendlyName; - AudioSources = new List(); - AudioSourcesExcluded = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (VideoLayout != null) - { - p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); - } - - if (AudioSources != null) - { - p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); - } - - if (AudioSourcesExcluded != null) - { - p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); - } - - if (Resolution != null) - { - p.Add(new KeyValuePair("Resolution", Resolution)); - } - - if (Format != null) - { - p.Add(new KeyValuePair("Format", Format.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Read only CompositionHook resources with an enabled value that matches this parameter + /// + public bool? Enabled { get; set; } /// - /// UpdateCompositionHookOptions - /// - public class UpdateCompositionHookOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// A unique string to describe the resource - /// - public string FriendlyName { get; } - /// - /// Whether the composition hook is active - /// - public bool? Enabled { get; set; } - /// - /// A JSON object that describes the video layout of the composition hook - /// - public object VideoLayout { get; set; } - /// - /// An array of track names from the same group room to merge - /// - public List AudioSources { get; set; } - /// - /// An array of track names to exclude - /// - public List AudioSourcesExcluded { get; set; } - /// - /// Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook - /// - public bool? Trim { get; set; } - /// - /// The container format of the media files used by the compositions created by the composition hook - /// - public CompositionHookResource.FormatEnum Format { get; set; } - /// - /// A string that describes the columns (width) and rows (height) of the generated composed video in pixels - /// - public string Resolution { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Construct a new UpdateCompositionHookOptions - /// - /// The SID that identifies the resource to update - /// A unique string to describe the resource - public UpdateCompositionHookOptions(string pathSid, string friendlyName) - { - PathSid = pathSid; - FriendlyName = friendlyName; - AudioSources = new List(); - AudioSourcesExcluded = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - if (VideoLayout != null) - { - p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); - } - - if (AudioSources != null) - { - p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); - } - - if (AudioSourcesExcluded != null) - { - p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); - } - - if (Format != null) - { - p.Add(new KeyValuePair("Format", Format.ToString())); - } - - if (Resolution != null) - { - p.Add(new KeyValuePair("Resolution", Resolution)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - return p; - } - } + /// Read only CompositionHook resources created on or after this ISO 8601 datetime with time zone + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only CompositionHook resources created before this ISO 8601 datetime with time zone + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// Read only CompositionHook resources with friendly names that match this string + /// + public string FriendlyName { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// + public class DeleteCompositionHookOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCompositionHookOptions + /// + /// The SID that identifies the resource to delete + public DeleteCompositionHookOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateCompositionHookOptions + /// + public class CreateCompositionHookOptions : IOptions + { + /// + /// A unique string to describe the resource + /// + public string FriendlyName { get; } + /// + /// Whether the composition hook is active + /// + public bool? Enabled { get; set; } + /// + /// An object that describes the video layout of the composition hook + /// + public object VideoLayout { get; set; } + /// + /// An array of track names from the same group room to merge + /// + public List AudioSources { get; set; } + /// + /// An array of track names to exclude + /// + public List AudioSourcesExcluded { get; set; } + /// + /// A string that describes the rows (width) and columns (height) of the generated composed video in pixels + /// + public string Resolution { get; set; } + /// + /// The container format of the media files used by the compositions created by the composition hook + /// + public CompositionHookResource.FormatEnum Format { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook + /// + public bool? Trim { get; set; } + + /// + /// Construct a new CreateCompositionHookOptions + /// + /// A unique string to describe the resource + public CreateCompositionHookOptions(string friendlyName) + { + FriendlyName = friendlyName; + AudioSources = new List(); + AudioSourcesExcluded = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (VideoLayout != null) + { + p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); + } + + if (AudioSources != null) + { + p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); + } + + if (AudioSourcesExcluded != null) + { + p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); + } + + if (Resolution != null) + { + p.Add(new KeyValuePair("Resolution", Resolution)); + } + + if (Format != null) + { + p.Add(new KeyValuePair("Format", Format.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// UpdateCompositionHookOptions + /// + public class UpdateCompositionHookOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// A unique string to describe the resource + /// + public string FriendlyName { get; } + /// + /// Whether the composition hook is active + /// + public bool? Enabled { get; set; } + /// + /// A JSON object that describes the video layout of the composition hook + /// + public object VideoLayout { get; set; } + /// + /// An array of track names from the same group room to merge + /// + public List AudioSources { get; set; } + /// + /// An array of track names to exclude + /// + public List AudioSourcesExcluded { get; set; } + /// + /// Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook + /// + public bool? Trim { get; set; } + /// + /// The container format of the media files used by the compositions created by the composition hook + /// + public CompositionHookResource.FormatEnum Format { get; set; } + /// + /// A string that describes the columns (width) and rows (height) of the generated composed video in pixels + /// + public string Resolution { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Construct a new UpdateCompositionHookOptions + /// + /// The SID that identifies the resource to update + /// A unique string to describe the resource + public UpdateCompositionHookOptions(string pathSid, string friendlyName) + { + PathSid = pathSid; + FriendlyName = friendlyName; + AudioSources = new List(); + AudioSourcesExcluded = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + if (VideoLayout != null) + { + p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); + } + + if (AudioSources != null) + { + p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); + } + + if (AudioSourcesExcluded != null) + { + p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); + } + + if (Format != null) + { + p.Add(new KeyValuePair("Format", Format.ToString())); + } + + if (Resolution != null) + { + p.Add(new KeyValuePair("Resolution", Resolution)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionHookResource.cs b/src/Twilio/Rest/Video/V1/CompositionHookResource.cs index 439181b4f..ba4b0fd0d 100644 --- a/src/Twilio/Rest/Video/V1/CompositionHookResource.cs +++ b/src/Twilio/Rest/Video/V1/CompositionHookResource.cs @@ -17,633 +17,633 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1 -{ - - public class CompositionHookResource : Resource - { - public sealed class FormatEnum : StringEnum - { - private FormatEnum(string value) : base(value) {} - public FormatEnum() {} - public static implicit operator FormatEnum(string value) - { - return new FormatEnum(value); - } - - public static readonly FormatEnum Mp4 = new FormatEnum("mp4"); - public static readonly FormatEnum Webm = new FormatEnum("webm"); - } - - private static Request BuildFetchRequest(FetchCompositionHookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/CompositionHooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single CompositionHook resource identified by a CompositionHook SID. - /// - /// Fetch CompositionHook parameters - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Fetch(FetchCompositionHookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single CompositionHook resource identified by a CompositionHook SID. - /// - /// Fetch CompositionHook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single CompositionHook resource identified by a CompositionHook SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCompositionHookOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single CompositionHook resource identified by a CompositionHook SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCompositionHookOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCompositionHookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/CompositionHooks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List of all Recording CompositionHook resources. - /// - /// Read CompositionHook parameters - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static ResourceSet Read(ReadCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("composition_hooks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List of all Recording CompositionHook resources. - /// - /// Read CompositionHook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task> ReadAsync(ReadCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("composition_hooks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List of all Recording CompositionHook resources. - /// - /// Read only CompositionHook resources with an enabled value that matches this parameter - /// - /// Read only CompositionHook resources created on or after this ISO 8601 datetime with - /// time zone - /// Read only CompositionHook resources created before this ISO 8601 datetime with - /// time zone - /// Read only CompositionHook resources with friendly names that match this string - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static ResourceSet Read(bool? enabled = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCompositionHookOptions(){Enabled = enabled, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List of all Recording CompositionHook resources. - /// - /// Read only CompositionHook resources with an enabled value that matches this parameter - /// - /// Read only CompositionHook resources created on or after this ISO 8601 datetime with - /// time zone - /// Read only CompositionHook resources created before this ISO 8601 datetime with - /// time zone - /// Read only CompositionHook resources with friendly names that match this string - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task> ReadAsync(bool? enabled = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string friendlyName = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCompositionHookOptions(){Enabled = enabled, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("composition_hooks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("composition_hooks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("composition_hooks", response.Content); - } - - private static Request BuildDeleteRequest(DeleteCompositionHookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Video, - "/v1/CompositionHooks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. - /// - /// Delete CompositionHook parameters - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static bool Delete(DeleteCompositionHookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. - /// - /// Delete CompositionHook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCompositionHookOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCompositionHookOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateCompositionHookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/CompositionHooks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create CompositionHook parameters - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Create(CreateCompositionHookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create CompositionHook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A unique string to describe the resource - /// Whether the composition hook is active - /// An object that describes the video layout of the composition hook - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// A string that describes the rows (width) and columns (height) of the generated composed - /// video in pixels - /// The container format of the media files used by the compositions created by the composition - /// hook - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Whether to clip the intervals where there is no active media in the Compositions triggered by - /// the composition hook - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Create(string friendlyName, - bool? enabled = null, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - string resolution = null, - CompositionHookResource.FormatEnum format = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? trim = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionHookOptions(friendlyName){Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A unique string to describe the resource - /// Whether the composition hook is active - /// An object that describes the video layout of the composition hook - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// A string that describes the rows (width) and columns (height) of the generated composed - /// video in pixels - /// The container format of the media files used by the compositions created by the composition - /// hook - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Whether to clip the intervals where there is no active media in the Compositions triggered by - /// the composition hook - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - bool? enabled = null, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - string resolution = null, - CompositionHookResource.FormatEnum format = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? trim = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionHookOptions(friendlyName){Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateCompositionHookOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/CompositionHooks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update CompositionHook parameters - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Update(UpdateCompositionHookOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update CompositionHook parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task UpdateAsync(UpdateCompositionHookOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// A unique string to describe the resource - /// Whether the composition hook is active - /// A JSON object that describes the video layout of the composition hook - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// Whether to clip the intervals where there is no active media in the Compositions triggered by - /// the composition hook - /// The container format of the media files used by the compositions created by the composition - /// hook - /// A string that describes the columns (width) and rows (height) of the generated composed - /// video in pixels - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Client to make requests to Twilio - /// A single instance of CompositionHook - public static CompositionHookResource Update(string pathSid, - string friendlyName, - bool? enabled = null, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - bool? trim = null, - CompositionHookResource.FormatEnum format = null, - string resolution = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateCompositionHookOptions(pathSid, friendlyName){Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Trim = trim, Format = format, Resolution = resolution, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// A unique string to describe the resource - /// Whether the composition hook is active - /// A JSON object that describes the video layout of the composition hook - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// Whether to clip the intervals where there is no active media in the Compositions triggered by - /// the composition hook - /// The container format of the media files used by the compositions created by the composition - /// hook - /// A string that describes the columns (width) and rows (height) of the generated composed - /// video in pixels - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionHook - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName, - bool? enabled = null, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - bool? trim = null, - CompositionHookResource.FormatEnum format = null, - string resolution = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - ITwilioRestClient client = null) - { - var options = new UpdateCompositionHookOptions(pathSid, friendlyName){Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Trim = trim, Format = format, Resolution = resolution, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CompositionHookResource object - /// - /// Raw JSON string - /// CompositionHookResource object represented by the provided JSON - public static CompositionHookResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Whether the CompositionHook is active - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The array of track names to include in the compositions created by the composition hook - /// - [JsonProperty("audio_sources")] - public List AudioSources { get; private set; } - /// - /// The array of track names to exclude from the compositions created by the composition hook - /// - [JsonProperty("audio_sources_excluded")] - public List AudioSourcesExcluded { get; private set; } - /// - /// A JSON object that describes the video layout of the Composition - /// - [JsonProperty("video_layout")] - public object VideoLayout { get; private set; } - /// - /// The dimensions of the video image in pixels expressed as columns (width) and rows (height) - /// - [JsonProperty("resolution")] - public string Resolution { get; private set; } - /// - /// Whether intervals with no media are clipped - /// - [JsonProperty("trim")] - public bool? Trim { get; private set; } - /// - /// The container format of the media files used by the compositions created by the composition hook - /// - [JsonProperty("format")] - [JsonConverter(typeof(StringEnumConverter))] - public CompositionHookResource.FormatEnum Format { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we should use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CompositionHookResource() - { - - } - } +{ + + public class CompositionHookResource : Resource + { + public sealed class FormatEnum : StringEnum + { + private FormatEnum(string value) : base(value) { } + public FormatEnum() { } + public static implicit operator FormatEnum(string value) + { + return new FormatEnum(value); + } + + public static readonly FormatEnum Mp4 = new FormatEnum("mp4"); + public static readonly FormatEnum Webm = new FormatEnum("webm"); + } + + private static Request BuildFetchRequest(FetchCompositionHookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/CompositionHooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// + /// Fetch CompositionHook parameters + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Fetch(FetchCompositionHookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// + /// Fetch CompositionHook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCompositionHookOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single CompositionHook resource identified by a CompositionHook SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCompositionHookOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCompositionHookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/CompositionHooks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List of all Recording CompositionHook resources. + /// + /// Read CompositionHook parameters + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static ResourceSet Read(ReadCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("composition_hooks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List of all Recording CompositionHook resources. + /// + /// Read CompositionHook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task> ReadAsync(ReadCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("composition_hooks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List of all Recording CompositionHook resources. + /// + /// Read only CompositionHook resources with an enabled value that matches this parameter + /// + /// Read only CompositionHook resources created on or after this ISO 8601 datetime with + /// time zone + /// Read only CompositionHook resources created before this ISO 8601 datetime with + /// time zone + /// Read only CompositionHook resources with friendly names that match this string + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static ResourceSet Read(bool? enabled = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCompositionHookOptions() { Enabled = enabled, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List of all Recording CompositionHook resources. + /// + /// Read only CompositionHook resources with an enabled value that matches this parameter + /// + /// Read only CompositionHook resources created on or after this ISO 8601 datetime with + /// time zone + /// Read only CompositionHook resources created before this ISO 8601 datetime with + /// time zone + /// Read only CompositionHook resources with friendly names that match this string + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task> ReadAsync(bool? enabled = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string friendlyName = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCompositionHookOptions() { Enabled = enabled, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, FriendlyName = friendlyName, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("composition_hooks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("composition_hooks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("composition_hooks", response.Content); + } + + private static Request BuildDeleteRequest(DeleteCompositionHookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Video, + "/v1/CompositionHooks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// + /// Delete CompositionHook parameters + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static bool Delete(DeleteCompositionHookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// + /// Delete CompositionHook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCompositionHookOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Recording CompositionHook resource identified by a `CompositionHook SID`. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCompositionHookOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateCompositionHookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/CompositionHooks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create CompositionHook parameters + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Create(CreateCompositionHookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create CompositionHook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A unique string to describe the resource + /// Whether the composition hook is active + /// An object that describes the video layout of the composition hook + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// A string that describes the rows (width) and columns (height) of the generated composed + /// video in pixels + /// The container format of the media files used by the compositions created by the composition + /// hook + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Whether to clip the intervals where there is no active media in the Compositions triggered by + /// the composition hook + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Create(string friendlyName, + bool? enabled = null, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + string resolution = null, + CompositionHookResource.FormatEnum format = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? trim = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionHookOptions(friendlyName) { Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A unique string to describe the resource + /// Whether the composition hook is active + /// An object that describes the video layout of the composition hook + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// A string that describes the rows (width) and columns (height) of the generated composed + /// video in pixels + /// The container format of the media files used by the compositions created by the composition + /// hook + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Whether to clip the intervals where there is no active media in the Compositions triggered by + /// the composition hook + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + bool? enabled = null, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + string resolution = null, + CompositionHookResource.FormatEnum format = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? trim = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionHookOptions(friendlyName) { Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateCompositionHookOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/CompositionHooks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update CompositionHook parameters + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Update(UpdateCompositionHookOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update CompositionHook parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task UpdateAsync(UpdateCompositionHookOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// A unique string to describe the resource + /// Whether the composition hook is active + /// A JSON object that describes the video layout of the composition hook + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// Whether to clip the intervals where there is no active media in the Compositions triggered by + /// the composition hook + /// The container format of the media files used by the compositions created by the composition + /// hook + /// A string that describes the columns (width) and rows (height) of the generated composed + /// video in pixels + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Client to make requests to Twilio + /// A single instance of CompositionHook + public static CompositionHookResource Update(string pathSid, + string friendlyName, + bool? enabled = null, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + bool? trim = null, + CompositionHookResource.FormatEnum format = null, + string resolution = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateCompositionHookOptions(pathSid, friendlyName) { Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Trim = trim, Format = format, Resolution = resolution, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// A unique string to describe the resource + /// Whether the composition hook is active + /// A JSON object that describes the video layout of the composition hook + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// Whether to clip the intervals where there is no active media in the Compositions triggered by + /// the composition hook + /// The container format of the media files used by the compositions created by the composition + /// hook + /// A string that describes the columns (width) and rows (height) of the generated composed + /// video in pixels + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionHook + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName, + bool? enabled = null, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + bool? trim = null, + CompositionHookResource.FormatEnum format = null, + string resolution = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + ITwilioRestClient client = null) + { + var options = new UpdateCompositionHookOptions(pathSid, friendlyName) { Enabled = enabled, VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Trim = trim, Format = format, Resolution = resolution, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CompositionHookResource object + /// + /// Raw JSON string + /// CompositionHookResource object represented by the provided JSON + public static CompositionHookResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Whether the CompositionHook is active + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The array of track names to include in the compositions created by the composition hook + /// + [JsonProperty("audio_sources")] + public List AudioSources { get; private set; } + /// + /// The array of track names to exclude from the compositions created by the composition hook + /// + [JsonProperty("audio_sources_excluded")] + public List AudioSourcesExcluded { get; private set; } + /// + /// A JSON object that describes the video layout of the Composition + /// + [JsonProperty("video_layout")] + public object VideoLayout { get; private set; } + /// + /// The dimensions of the video image in pixels expressed as columns (width) and rows (height) + /// + [JsonProperty("resolution")] + public string Resolution { get; private set; } + /// + /// Whether intervals with no media are clipped + /// + [JsonProperty("trim")] + public bool? Trim { get; private set; } + /// + /// The container format of the media files used by the compositions created by the composition hook + /// + [JsonProperty("format")] + [JsonConverter(typeof(StringEnumConverter))] + public CompositionHookResource.FormatEnum Format { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we should use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CompositionHookResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionOptions.cs b/src/Twilio/Rest/Video/V1/CompositionOptions.cs index f5a6e6474..537c2ab5e 100644 --- a/src/Twilio/Rest/Video/V1/CompositionOptions.cs +++ b/src/Twilio/Rest/Video/V1/CompositionOptions.cs @@ -10,229 +10,229 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// Returns a single Composition resource identified by a Composition SID. + /// + public class FetchCompositionOptions : IOptions + { /// - /// Returns a single Composition resource identified by a Composition SID. + /// The SID that identifies the resource to fetch /// - public class FetchCompositionOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCompositionOptions - /// - /// The SID that identifies the resource to fetch - public FetchCompositionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// List of all Recording compositions. - /// - public class ReadCompositionOptions : ReadOptions - { - /// - /// Read only Composition resources with this status - /// - public CompositionResource.StatusEnum Status { get; set; } - /// - /// Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only Composition resources created before this ISO 8601 date-time with time zone - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Read only Composition resources with this Room SID - /// - public string RoomSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (RoomSid != null) - { - p.Add(new KeyValuePair("RoomSid", RoomSid.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchCompositionOptions + /// + /// The SID that identifies the resource to fetch + public FetchCompositionOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Delete a Recording Composition resource identified by a Composition SID. + /// Generate the necessary parameters /// - public class DeleteCompositionOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCompositionOptions - /// - /// The SID that identifies the resource to delete - public DeleteCompositionOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// List of all Recording compositions. + /// + public class ReadCompositionOptions : ReadOptions + { /// - /// CreateCompositionOptions - /// - public class CreateCompositionOptions : IOptions - { - /// - /// The SID of the Group Room with the media tracks to be used as composition sources - /// - public string RoomSid { get; } - /// - /// An object that describes the video layout of the composition - /// - public object VideoLayout { get; set; } - /// - /// An array of track names from the same group room to merge - /// - public List AudioSources { get; set; } - /// - /// An array of track names to exclude - /// - public List AudioSourcesExcluded { get; set; } - /// - /// A string that describes the columns (width) and rows (height) of the generated composed video in pixels - /// - public string Resolution { get; set; } - /// - /// The container format of the composition's media files - /// - public CompositionResource.FormatEnum Format { get; set; } - /// - /// The URL we should call to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether to clip the intervals where there is no active media in the composition - /// - public bool? Trim { get; set; } - - /// - /// Construct a new CreateCompositionOptions - /// - /// The SID of the Group Room with the media tracks to be used as composition sources - public CreateCompositionOptions(string roomSid) - { - RoomSid = roomSid; - AudioSources = new List(); - AudioSourcesExcluded = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (RoomSid != null) - { - p.Add(new KeyValuePair("RoomSid", RoomSid.ToString())); - } - - if (VideoLayout != null) - { - p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); - } - - if (AudioSources != null) - { - p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); - } - - if (AudioSourcesExcluded != null) - { - p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); - } - - if (Resolution != null) - { - p.Add(new KeyValuePair("Resolution", Resolution)); - } - - if (Format != null) - { - p.Add(new KeyValuePair("Format", Format.ToString())); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (Trim != null) - { - p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); - } - - return p; - } - } + /// Read only Composition resources with this status + /// + public CompositionResource.StatusEnum Status { get; set; } + /// + /// Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only Composition resources created before this ISO 8601 date-time with time zone + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// Read only Composition resources with this Room SID + /// + public string RoomSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (RoomSid != null) + { + p.Add(new KeyValuePair("RoomSid", RoomSid.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a Recording Composition resource identified by a Composition SID. + /// + public class DeleteCompositionOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCompositionOptions + /// + /// The SID that identifies the resource to delete + public DeleteCompositionOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateCompositionOptions + /// + public class CreateCompositionOptions : IOptions + { + /// + /// The SID of the Group Room with the media tracks to be used as composition sources + /// + public string RoomSid { get; } + /// + /// An object that describes the video layout of the composition + /// + public object VideoLayout { get; set; } + /// + /// An array of track names from the same group room to merge + /// + public List AudioSources { get; set; } + /// + /// An array of track names to exclude + /// + public List AudioSourcesExcluded { get; set; } + /// + /// A string that describes the columns (width) and rows (height) of the generated composed video in pixels + /// + public string Resolution { get; set; } + /// + /// The container format of the composition's media files + /// + public CompositionResource.FormatEnum Format { get; set; } + /// + /// The URL we should call to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether to clip the intervals where there is no active media in the composition + /// + public bool? Trim { get; set; } + + /// + /// Construct a new CreateCompositionOptions + /// + /// The SID of the Group Room with the media tracks to be used as composition sources + public CreateCompositionOptions(string roomSid) + { + RoomSid = roomSid; + AudioSources = new List(); + AudioSourcesExcluded = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (RoomSid != null) + { + p.Add(new KeyValuePair("RoomSid", RoomSid.ToString())); + } + + if (VideoLayout != null) + { + p.Add(new KeyValuePair("VideoLayout", Serializers.JsonObject(VideoLayout))); + } + + if (AudioSources != null) + { + p.AddRange(AudioSources.Select(prop => new KeyValuePair("AudioSources", prop))); + } + + if (AudioSourcesExcluded != null) + { + p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair("AudioSourcesExcluded", prop))); + } + + if (Resolution != null) + { + p.Add(new KeyValuePair("Resolution", Resolution)); + } + + if (Format != null) + { + p.Add(new KeyValuePair("Format", Format.ToString())); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (Trim != null) + { + p.Add(new KeyValuePair("Trim", Trim.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionResource.cs b/src/Twilio/Rest/Video/V1/CompositionResource.cs index 9a5808c62..5299108a9 100644 --- a/src/Twilio/Rest/Video/V1/CompositionResource.cs +++ b/src/Twilio/Rest/Video/V1/CompositionResource.cs @@ -17,538 +17,538 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1 -{ - - public class CompositionResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Deleted = new StatusEnum("deleted"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class FormatEnum : StringEnum - { - private FormatEnum(string value) : base(value) {} - public FormatEnum() {} - public static implicit operator FormatEnum(string value) - { - return new FormatEnum(value); - } - - public static readonly FormatEnum Mp4 = new FormatEnum("mp4"); - public static readonly FormatEnum Webm = new FormatEnum("webm"); - } - - private static Request BuildFetchRequest(FetchCompositionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Compositions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single Composition resource identified by a Composition SID. - /// - /// Fetch Composition parameters - /// Client to make requests to Twilio - /// A single instance of Composition - public static CompositionResource Fetch(FetchCompositionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single Composition resource identified by a Composition SID. - /// - /// Fetch Composition parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single Composition resource identified by a Composition SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Composition - public static CompositionResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCompositionOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single Composition resource identified by a Composition SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCompositionOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCompositionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Compositions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List of all Recording compositions. - /// - /// Read Composition parameters - /// Client to make requests to Twilio - /// A single instance of Composition - public static ResourceSet Read(ReadCompositionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("compositions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List of all Recording compositions. - /// - /// Read Composition parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task> ReadAsync(ReadCompositionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("compositions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List of all Recording compositions. - /// - /// Read only Composition resources with this status - /// Read only Composition resources created on or after this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only Composition resources created before this ISO 8601 date-time with time - /// zone - /// Read only Composition resources with this Room SID - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Composition - public static ResourceSet Read(CompositionResource.StatusEnum status = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string roomSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCompositionOptions(){Status = status, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, RoomSid = roomSid, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List of all Recording compositions. - /// - /// Read only Composition resources with this status - /// Read only Composition resources created on or after this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only Composition resources created before this ISO 8601 date-time with time - /// zone - /// Read only Composition resources with this Room SID - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task> ReadAsync(CompositionResource.StatusEnum status = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - string roomSid = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCompositionOptions(){Status = status, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, RoomSid = roomSid, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("compositions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("compositions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("compositions", response.Content); - } - - private static Request BuildDeleteRequest(DeleteCompositionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Video, - "/v1/Compositions/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Recording Composition resource identified by a Composition SID. - /// - /// Delete Composition parameters - /// Client to make requests to Twilio - /// A single instance of Composition - public static bool Delete(DeleteCompositionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Recording Composition resource identified by a Composition SID. - /// - /// Delete Composition parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCompositionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Recording Composition resource identified by a Composition SID. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Composition - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCompositionOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Recording Composition resource identified by a Composition SID. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCompositionOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateCompositionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Compositions", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Composition parameters - /// Client to make requests to Twilio - /// A single instance of Composition - public static CompositionResource Create(CreateCompositionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Composition parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Group Room with the media tracks to be used as composition sources - /// An object that describes the video layout of the composition - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// A string that describes the columns (width) and rows (height) of the generated composed - /// video in pixels - /// The container format of the composition's media files - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Whether to clip the intervals where there is no active media in the composition - /// Client to make requests to Twilio - /// A single instance of Composition - public static CompositionResource Create(string roomSid, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - string resolution = null, - CompositionResource.FormatEnum format = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? trim = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionOptions(roomSid){VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Group Room with the media tracks to be used as composition sources - /// An object that describes the video layout of the composition - /// An array of track names from the same group room to merge - /// An array of track names to exclude - /// A string that describes the columns (width) and rows (height) of the generated composed - /// video in pixels - /// The container format of the composition's media files - /// The URL we should call to send status information to your application - /// The HTTP method we should use to call status_callback - /// Whether to clip the intervals where there is no active media in the composition - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Composition - public static async System.Threading.Tasks.Task CreateAsync(string roomSid, - object videoLayout = null, - List audioSources = null, - List audioSourcesExcluded = null, - string resolution = null, - CompositionResource.FormatEnum format = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? trim = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionOptions(roomSid){VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CompositionResource object - /// - /// Raw JSON string - /// CompositionResource object represented by the provided JSON - public static CompositionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The status of the composition - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CompositionResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// Date when the media processing task finished - /// - [JsonProperty("date_completed")] - public DateTime? DateCompleted { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the composition generated media was deleted - /// - [JsonProperty("date_deleted")] - public DateTime? DateDeleted { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Group Room that generated the audio and video tracks used in the composition - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// The array of track names to include in the composition - /// - [JsonProperty("audio_sources")] - public List AudioSources { get; private set; } - /// - /// The array of track names to exclude from the composition - /// - [JsonProperty("audio_sources_excluded")] - public List AudioSourcesExcluded { get; private set; } - /// - /// An object that describes the video layout of the composition - /// - [JsonProperty("video_layout")] - public object VideoLayout { get; private set; } - /// - /// The dimensions of the video image in pixels expressed as columns (width) and rows (height) - /// - [JsonProperty("resolution")] - public string Resolution { get; private set; } - /// - /// Whether to remove intervals with no media - /// - [JsonProperty("trim")] - public bool? Trim { get; private set; } - /// - /// The container format of the composition's media files as specified in the POST request that created the Composition resource - /// - [JsonProperty("format")] - [JsonConverter(typeof(StringEnumConverter))] - public CompositionResource.FormatEnum Format { get; private set; } - /// - /// The average bit rate of the composition's media - /// - [JsonProperty("bitrate")] - public int? Bitrate { get; private set; } - /// - /// The size of the composed media file in bytes - /// - [JsonProperty("size")] - public long? Size { get; private set; } - /// - /// The duration of the composition's media file in seconds - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URL of the media file associated with the composition - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private CompositionResource() - { - - } - } +{ + + public class CompositionResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Enqueued = new StatusEnum("enqueued"); + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Deleted = new StatusEnum("deleted"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class FormatEnum : StringEnum + { + private FormatEnum(string value) : base(value) { } + public FormatEnum() { } + public static implicit operator FormatEnum(string value) + { + return new FormatEnum(value); + } + + public static readonly FormatEnum Mp4 = new FormatEnum("mp4"); + public static readonly FormatEnum Webm = new FormatEnum("webm"); + } + + private static Request BuildFetchRequest(FetchCompositionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Compositions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single Composition resource identified by a Composition SID. + /// + /// Fetch Composition parameters + /// Client to make requests to Twilio + /// A single instance of Composition + public static CompositionResource Fetch(FetchCompositionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single Composition resource identified by a Composition SID. + /// + /// Fetch Composition parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single Composition resource identified by a Composition SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Composition + public static CompositionResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCompositionOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single Composition resource identified by a Composition SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCompositionOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCompositionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Compositions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List of all Recording compositions. + /// + /// Read Composition parameters + /// Client to make requests to Twilio + /// A single instance of Composition + public static ResourceSet Read(ReadCompositionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("compositions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List of all Recording compositions. + /// + /// Read Composition parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task> ReadAsync(ReadCompositionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("compositions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List of all Recording compositions. + /// + /// Read only Composition resources with this status + /// Read only Composition resources created on or after this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only Composition resources created before this ISO 8601 date-time with time + /// zone + /// Read only Composition resources with this Room SID + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Composition + public static ResourceSet Read(CompositionResource.StatusEnum status = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string roomSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCompositionOptions() { Status = status, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, RoomSid = roomSid, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List of all Recording compositions. + /// + /// Read only Composition resources with this status + /// Read only Composition resources created on or after this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only Composition resources created before this ISO 8601 date-time with time + /// zone + /// Read only Composition resources with this Room SID + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task> ReadAsync(CompositionResource.StatusEnum status = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + string roomSid = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCompositionOptions() { Status = status, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, RoomSid = roomSid, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("compositions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("compositions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("compositions", response.Content); + } + + private static Request BuildDeleteRequest(DeleteCompositionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Video, + "/v1/Compositions/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Recording Composition resource identified by a Composition SID. + /// + /// Delete Composition parameters + /// Client to make requests to Twilio + /// A single instance of Composition + public static bool Delete(DeleteCompositionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Recording Composition resource identified by a Composition SID. + /// + /// Delete Composition parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCompositionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Recording Composition resource identified by a Composition SID. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Composition + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCompositionOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Recording Composition resource identified by a Composition SID. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCompositionOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateCompositionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Compositions", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Composition parameters + /// Client to make requests to Twilio + /// A single instance of Composition + public static CompositionResource Create(CreateCompositionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Composition parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Group Room with the media tracks to be used as composition sources + /// An object that describes the video layout of the composition + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// A string that describes the columns (width) and rows (height) of the generated composed + /// video in pixels + /// The container format of the composition's media files + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Whether to clip the intervals where there is no active media in the composition + /// Client to make requests to Twilio + /// A single instance of Composition + public static CompositionResource Create(string roomSid, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + string resolution = null, + CompositionResource.FormatEnum format = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? trim = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionOptions(roomSid) { VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Group Room with the media tracks to be used as composition sources + /// An object that describes the video layout of the composition + /// An array of track names from the same group room to merge + /// An array of track names to exclude + /// A string that describes the columns (width) and rows (height) of the generated composed + /// video in pixels + /// The container format of the composition's media files + /// The URL we should call to send status information to your application + /// The HTTP method we should use to call status_callback + /// Whether to clip the intervals where there is no active media in the composition + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Composition + public static async System.Threading.Tasks.Task CreateAsync(string roomSid, + object videoLayout = null, + List audioSources = null, + List audioSourcesExcluded = null, + string resolution = null, + CompositionResource.FormatEnum format = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? trim = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionOptions(roomSid) { VideoLayout = videoLayout, AudioSources = audioSources, AudioSourcesExcluded = audioSourcesExcluded, Resolution = resolution, Format = format, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, Trim = trim }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CompositionResource object + /// + /// Raw JSON string + /// CompositionResource object represented by the provided JSON + public static CompositionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The status of the composition + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CompositionResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// Date when the media processing task finished + /// + [JsonProperty("date_completed")] + public DateTime? DateCompleted { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the composition generated media was deleted + /// + [JsonProperty("date_deleted")] + public DateTime? DateDeleted { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Group Room that generated the audio and video tracks used in the composition + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// The array of track names to include in the composition + /// + [JsonProperty("audio_sources")] + public List AudioSources { get; private set; } + /// + /// The array of track names to exclude from the composition + /// + [JsonProperty("audio_sources_excluded")] + public List AudioSourcesExcluded { get; private set; } + /// + /// An object that describes the video layout of the composition + /// + [JsonProperty("video_layout")] + public object VideoLayout { get; private set; } + /// + /// The dimensions of the video image in pixels expressed as columns (width) and rows (height) + /// + [JsonProperty("resolution")] + public string Resolution { get; private set; } + /// + /// Whether to remove intervals with no media + /// + [JsonProperty("trim")] + public bool? Trim { get; private set; } + /// + /// The container format of the composition's media files as specified in the POST request that created the Composition resource + /// + [JsonProperty("format")] + [JsonConverter(typeof(StringEnumConverter))] + public CompositionResource.FormatEnum Format { get; private set; } + /// + /// The average bit rate of the composition's media + /// + [JsonProperty("bitrate")] + public int? Bitrate { get; private set; } + /// + /// The size of the composed media file in bytes + /// + [JsonProperty("size")] + public long? Size { get; private set; } + /// + /// The duration of the composition's media file in seconds + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URL of the media file associated with the composition + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private CompositionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionSettingsOptions.cs b/src/Twilio/Rest/Video/V1/CompositionSettingsOptions.cs index 15d961ea9..0cda8114f 100644 --- a/src/Twilio/Rest/Video/V1/CompositionSettingsOptions.cs +++ b/src/Twilio/Rest/Video/V1/CompositionSettingsOptions.cs @@ -9,100 +9,100 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// FetchCompositionSettingsOptions + /// + public class FetchCompositionSettingsOptions : IOptions + { /// - /// FetchCompositionSettingsOptions + /// Generate the necessary parameters /// - public class FetchCompositionSettingsOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateCompositionSettingsOptions + /// + public class CreateCompositionSettingsOptions : IOptions + { /// - /// CreateCompositionSettingsOptions + /// A descriptive string that you create to describe the resource /// - public class CreateCompositionSettingsOptions : IOptions - { - /// - /// A descriptive string that you create to describe the resource - /// - public string FriendlyName { get; } - /// - /// The SID of the stored Credential resource - /// - public string AwsCredentialsSid { get; set; } - /// - /// The SID of the Public Key resource to use for encryption - /// - public string EncryptionKeySid { get; set; } - /// - /// The URL of the AWS S3 bucket where the compositions should be stored - /// - public Uri AwsS3Url { get; set; } - /// - /// Whether all compositions should be written to the aws_s3_url - /// - public bool? AwsStorageEnabled { get; set; } - /// - /// Whether all compositions should be stored in an encrypted form - /// - public bool? EncryptionEnabled { get; set; } - - /// - /// Construct a new CreateCompositionSettingsOptions - /// - /// A descriptive string that you create to describe the resource - public CreateCompositionSettingsOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (AwsCredentialsSid != null) - { - p.Add(new KeyValuePair("AwsCredentialsSid", AwsCredentialsSid.ToString())); - } - - if (EncryptionKeySid != null) - { - p.Add(new KeyValuePair("EncryptionKeySid", EncryptionKeySid.ToString())); - } - - if (AwsS3Url != null) - { - p.Add(new KeyValuePair("AwsS3Url", Serializers.Url(AwsS3Url))); - } - - if (AwsStorageEnabled != null) - { - p.Add(new KeyValuePair("AwsStorageEnabled", AwsStorageEnabled.Value.ToString().ToLower())); - } - - if (EncryptionEnabled != null) - { - p.Add(new KeyValuePair("EncryptionEnabled", EncryptionEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + public string FriendlyName { get; } + /// + /// The SID of the stored Credential resource + /// + public string AwsCredentialsSid { get; set; } + /// + /// The SID of the Public Key resource to use for encryption + /// + public string EncryptionKeySid { get; set; } + /// + /// The URL of the AWS S3 bucket where the compositions should be stored + /// + public Uri AwsS3Url { get; set; } + /// + /// Whether all compositions should be written to the aws_s3_url + /// + public bool? AwsStorageEnabled { get; set; } + /// + /// Whether all compositions should be stored in an encrypted form + /// + public bool? EncryptionEnabled { get; set; } + + /// + /// Construct a new CreateCompositionSettingsOptions + /// + /// A descriptive string that you create to describe the resource + public CreateCompositionSettingsOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (AwsCredentialsSid != null) + { + p.Add(new KeyValuePair("AwsCredentialsSid", AwsCredentialsSid.ToString())); + } + + if (EncryptionKeySid != null) + { + p.Add(new KeyValuePair("EncryptionKeySid", EncryptionKeySid.ToString())); + } + + if (AwsS3Url != null) + { + p.Add(new KeyValuePair("AwsS3Url", Serializers.Url(AwsS3Url))); + } + + if (AwsStorageEnabled != null) + { + p.Add(new KeyValuePair("AwsStorageEnabled", AwsStorageEnabled.Value.ToString().ToLower())); + } + + if (EncryptionEnabled != null) + { + p.Add(new KeyValuePair("EncryptionEnabled", EncryptionEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/CompositionSettingsResource.cs b/src/Twilio/Rest/Video/V1/CompositionSettingsResource.cs index 4de288020..65ae37f9d 100644 --- a/src/Twilio/Rest/Video/V1/CompositionSettingsResource.cs +++ b/src/Twilio/Rest/Video/V1/CompositionSettingsResource.cs @@ -16,227 +16,227 @@ using Twilio.Http; namespace Twilio.Rest.Video.V1 -{ - - public class CompositionSettingsResource : Resource - { - private static Request BuildFetchRequest(FetchCompositionSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/CompositionSettings/Default", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch CompositionSettings parameters - /// Client to make requests to Twilio - /// A single instance of CompositionSettings - public static CompositionSettingsResource Fetch(FetchCompositionSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch CompositionSettings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionSettings - public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// Client to make requests to Twilio - /// A single instance of CompositionSettings - public static CompositionSettingsResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchCompositionSettingsOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionSettings - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchCompositionSettingsOptions(); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateCompositionSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/CompositionSettings/Default", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create CompositionSettings parameters - /// Client to make requests to Twilio - /// A single instance of CompositionSettings - public static CompositionSettingsResource Create(CreateCompositionSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create CompositionSettings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionSettings - public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A descriptive string that you create to describe the resource - /// The SID of the stored Credential resource - /// The SID of the Public Key resource to use for encryption - /// The URL of the AWS S3 bucket where the compositions should be stored - /// Whether all compositions should be written to the aws_s3_url - /// Whether all compositions should be stored in an encrypted form - /// Client to make requests to Twilio - /// A single instance of CompositionSettings - public static CompositionSettingsResource Create(string friendlyName, - string awsCredentialsSid = null, - string encryptionKeySid = null, - Uri awsS3Url = null, - bool? awsStorageEnabled = null, - bool? encryptionEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionSettingsOptions(friendlyName){AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A descriptive string that you create to describe the resource - /// The SID of the stored Credential resource - /// The SID of the Public Key resource to use for encryption - /// The URL of the AWS S3 bucket where the compositions should be stored - /// Whether all compositions should be written to the aws_s3_url - /// Whether all compositions should be stored in an encrypted form - /// Client to make requests to Twilio - /// Task that resolves to A single instance of CompositionSettings - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string awsCredentialsSid = null, - string encryptionKeySid = null, - Uri awsS3Url = null, - bool? awsStorageEnabled = null, - bool? encryptionEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateCompositionSettingsOptions(friendlyName){AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CompositionSettingsResource object - /// - /// Raw JSON string - /// CompositionSettingsResource object represented by the provided JSON - public static CompositionSettingsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the stored Credential resource - /// - [JsonProperty("aws_credentials_sid")] - public string AwsCredentialsSid { get; private set; } - /// - /// The URL of the AWS S3 bucket where the compositions are stored - /// - [JsonProperty("aws_s3_url")] - public Uri AwsS3Url { get; private set; } - /// - /// Whether all compositions are written to the aws_s3_url - /// - [JsonProperty("aws_storage_enabled")] - public bool? AwsStorageEnabled { get; private set; } - /// - /// The SID of the Public Key resource used for encryption - /// - [JsonProperty("encryption_key_sid")] - public string EncryptionKeySid { get; private set; } - /// - /// Whether all compositions are stored in an encrypted form - /// - [JsonProperty("encryption_enabled")] - public bool? EncryptionEnabled { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CompositionSettingsResource() - { - - } - } +{ + + public class CompositionSettingsResource : Resource + { + private static Request BuildFetchRequest(FetchCompositionSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/CompositionSettings/Default", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch CompositionSettings parameters + /// Client to make requests to Twilio + /// A single instance of CompositionSettings + public static CompositionSettingsResource Fetch(FetchCompositionSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch CompositionSettings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionSettings + public static async System.Threading.Tasks.Task FetchAsync(FetchCompositionSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// Client to make requests to Twilio + /// A single instance of CompositionSettings + public static CompositionSettingsResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchCompositionSettingsOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionSettings + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchCompositionSettingsOptions(); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateCompositionSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/CompositionSettings/Default", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create CompositionSettings parameters + /// Client to make requests to Twilio + /// A single instance of CompositionSettings + public static CompositionSettingsResource Create(CreateCompositionSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create CompositionSettings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionSettings + public static async System.Threading.Tasks.Task CreateAsync(CreateCompositionSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A descriptive string that you create to describe the resource + /// The SID of the stored Credential resource + /// The SID of the Public Key resource to use for encryption + /// The URL of the AWS S3 bucket where the compositions should be stored + /// Whether all compositions should be written to the aws_s3_url + /// Whether all compositions should be stored in an encrypted form + /// Client to make requests to Twilio + /// A single instance of CompositionSettings + public static CompositionSettingsResource Create(string friendlyName, + string awsCredentialsSid = null, + string encryptionKeySid = null, + Uri awsS3Url = null, + bool? awsStorageEnabled = null, + bool? encryptionEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionSettingsOptions(friendlyName) { AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A descriptive string that you create to describe the resource + /// The SID of the stored Credential resource + /// The SID of the Public Key resource to use for encryption + /// The URL of the AWS S3 bucket where the compositions should be stored + /// Whether all compositions should be written to the aws_s3_url + /// Whether all compositions should be stored in an encrypted form + /// Client to make requests to Twilio + /// Task that resolves to A single instance of CompositionSettings + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string awsCredentialsSid = null, + string encryptionKeySid = null, + Uri awsS3Url = null, + bool? awsStorageEnabled = null, + bool? encryptionEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateCompositionSettingsOptions(friendlyName) { AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CompositionSettingsResource object + /// + /// Raw JSON string + /// CompositionSettingsResource object represented by the provided JSON + public static CompositionSettingsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the stored Credential resource + /// + [JsonProperty("aws_credentials_sid")] + public string AwsCredentialsSid { get; private set; } + /// + /// The URL of the AWS S3 bucket where the compositions are stored + /// + [JsonProperty("aws_s3_url")] + public Uri AwsS3Url { get; private set; } + /// + /// Whether all compositions are written to the aws_s3_url + /// + [JsonProperty("aws_storage_enabled")] + public bool? AwsStorageEnabled { get; private set; } + /// + /// The SID of the Public Key resource used for encryption + /// + [JsonProperty("encryption_key_sid")] + public string EncryptionKeySid { get; private set; } + /// + /// Whether all compositions are stored in an encrypted form + /// + [JsonProperty("encryption_enabled")] + public bool? EncryptionEnabled { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CompositionSettingsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RecordingOptions.cs b/src/Twilio/Rest/Video/V1/RecordingOptions.cs index 9f950f642..1c05f2f7a 100644 --- a/src/Twilio/Rest/Video/V1/RecordingOptions.cs +++ b/src/Twilio/Rest/Video/V1/RecordingOptions.cs @@ -10,147 +10,147 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// Returns a single Recording resource identified by a Recording SID. + /// + public class FetchRecordingOptions : IOptions + { /// - /// Returns a single Recording resource identified by a Recording SID. + /// The SID that identifies the resource to fetch /// - public class FetchRecordingOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRecordingOptions - /// - /// The SID that identifies the resource to fetch - public FetchRecordingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// List of all Track recordings. + /// Construct a new FetchRecordingOptions /// - public class ReadRecordingOptions : ReadOptions - { - /// - /// Read only the recordings that have this status - /// - public RecordingResource.StatusEnum Status { get; set; } - /// - /// Read only the recordings that have this source_sid - /// - public string SourceSid { get; set; } - /// - /// Read only recordings that have this grouping_sid - /// - public List GroupingSid { get; set; } - /// - /// Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// - public DateTime? DateCreatedBefore { get; set; } - /// - /// Read only recordings that have this media type - /// - public RecordingResource.TypeEnum MediaType { get; set; } - - /// - /// Construct a new ReadRecordingOptions - /// - public ReadRecordingOptions() - { - GroupingSid = new List(); - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (SourceSid != null) - { - p.Add(new KeyValuePair("SourceSid", SourceSid.ToString())); - } - - if (GroupingSid != null) - { - p.AddRange(GroupingSid.Select(prop => new KeyValuePair("GroupingSid", prop.ToString()))); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (MediaType != null) - { - p.Add(new KeyValuePair("MediaType", MediaType.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + public FetchRecordingOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Delete a Recording resource identified by a Recording SID. + /// Generate the necessary parameters /// - public class DeleteRecordingOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRecordingOptions - /// - /// The SID that identifies the resource to delete - public DeleteRecordingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// List of all Track recordings. + /// + public class ReadRecordingOptions : ReadOptions + { + /// + /// Read only the recordings that have this status + /// + public RecordingResource.StatusEnum Status { get; set; } + /// + /// Read only the recordings that have this source_sid + /// + public string SourceSid { get; set; } + /// + /// Read only recordings that have this grouping_sid + /// + public List GroupingSid { get; set; } + /// + /// Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// + public DateTime? DateCreatedBefore { get; set; } + /// + /// Read only recordings that have this media type + /// + public RecordingResource.TypeEnum MediaType { get; set; } + + /// + /// Construct a new ReadRecordingOptions + /// + public ReadRecordingOptions() + { + GroupingSid = new List(); + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (SourceSid != null) + { + p.Add(new KeyValuePair("SourceSid", SourceSid.ToString())); + } + + if (GroupingSid != null) + { + p.AddRange(GroupingSid.Select(prop => new KeyValuePair("GroupingSid", prop.ToString()))); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (MediaType != null) + { + p.Add(new KeyValuePair("MediaType", MediaType.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Delete a Recording resource identified by a Recording SID. + /// + public class DeleteRecordingOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRecordingOptions + /// + /// The SID that identifies the resource to delete + public DeleteRecordingOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RecordingResource.cs b/src/Twilio/Rest/Video/V1/RecordingResource.cs index 9fddab6e8..544bfed7b 100644 --- a/src/Twilio/Rest/Video/V1/RecordingResource.cs +++ b/src/Twilio/Rest/Video/V1/RecordingResource.cs @@ -17,459 +17,459 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1 -{ - - public class RecordingResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Deleted = new StatusEnum("deleted"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Audio = new TypeEnum("audio"); - public static readonly TypeEnum Video = new TypeEnum("video"); - public static readonly TypeEnum Data = new TypeEnum("data"); - } - - public sealed class FormatEnum : StringEnum - { - private FormatEnum(string value) : base(value) {} - public FormatEnum() {} - public static implicit operator FormatEnum(string value) - { - return new FormatEnum(value); - } - - public static readonly FormatEnum Mka = new FormatEnum("mka"); - public static readonly FormatEnum Mkv = new FormatEnum("mkv"); - } - - public sealed class CodecEnum : StringEnum - { - private CodecEnum(string value) : base(value) {} - public CodecEnum() {} - public static implicit operator CodecEnum(string value) - { - return new CodecEnum(value); - } - - public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); - public static readonly CodecEnum H264 = new CodecEnum("H264"); - public static readonly CodecEnum Opus = new CodecEnum("OPUS"); - public static readonly CodecEnum Pcmu = new CodecEnum("PCMU"); - } - - private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Recordings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single Recording resource identified by a Recording SID. - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single Recording resource identified by a Recording SID. - /// - /// Fetch Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single Recording resource identified by a Recording SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Recording - public static RecordingResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single Recording resource identified by a Recording SID. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRecordingOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Recordings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// List of all Track recordings. - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// List of all Track recordings. - /// - /// Read Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// List of all Track recordings. - /// - /// Read only the recordings that have this status - /// Read only the recordings that have this source_sid - /// Read only recordings that have this grouping_sid - /// Read only recordings that started on or after this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only recordings that started before this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only recordings that have this media type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Recording - public static ResourceSet Read(RecordingResource.StatusEnum status = null, - string sourceSid = null, - List groupingSid = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - RecordingResource.TypeEnum mediaType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(){Status = status, SourceSid = sourceSid, GroupingSid = groupingSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, MediaType = mediaType, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// List of all Track recordings. - /// - /// Read only the recordings that have this status - /// Read only the recordings that have this source_sid - /// Read only recordings that have this grouping_sid - /// Read only recordings that started on or after this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only recordings that started before this [ISO - /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone - /// Read only recordings that have this media type - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task> ReadAsync(RecordingResource.StatusEnum status = null, - string sourceSid = null, - List groupingSid = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - RecordingResource.TypeEnum mediaType = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRecordingOptions(){Status = status, SourceSid = sourceSid, GroupingSid = groupingSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, MediaType = mediaType, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Video, - "/v1/Recordings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Recording resource identified by a Recording SID. - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Recording resource identified by a Recording SID. - /// - /// Delete Recording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Recording resource identified by a Recording SID. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Recording - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Recording resource identified by a Recording SID. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Recording - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRecordingOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RecordingResource object - /// - /// Raw JSON string - /// RecordingResource object represented by the provided JSON - public static RecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The status of the recording - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the recording source - /// - [JsonProperty("source_sid")] - public string SourceSid { get; private set; } - /// - /// The size of the recorded track, in bytes - /// - [JsonProperty("size")] - public long? Size { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The recording's media type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.TypeEnum Type { get; private set; } - /// - /// The duration of the recording in seconds - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The file format for the recording - /// - [JsonProperty("container_format")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.FormatEnum ContainerFormat { get; private set; } - /// - /// The codec used to encode the track - /// - [JsonProperty("codec")] - [JsonConverter(typeof(StringEnumConverter))] - public RecordingResource.CodecEnum Codec { get; private set; } - /// - /// A list of SIDs related to the recording - /// - [JsonProperty("grouping_sids")] - public object GroupingSids { get; private set; } - /// - /// The name that was given to the source track of the recording - /// - [JsonProperty("track_name")] - public string TrackName { get; private set; } - /// - /// The number of milliseconds between a point in time that is common to all rooms in a group and when the source room of the recording started - /// - [JsonProperty("offset")] - public long? Offset { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private RecordingResource() - { - - } - } +{ + + public class RecordingResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Deleted = new StatusEnum("deleted"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Audio = new TypeEnum("audio"); + public static readonly TypeEnum Video = new TypeEnum("video"); + public static readonly TypeEnum Data = new TypeEnum("data"); + } + + public sealed class FormatEnum : StringEnum + { + private FormatEnum(string value) : base(value) { } + public FormatEnum() { } + public static implicit operator FormatEnum(string value) + { + return new FormatEnum(value); + } + + public static readonly FormatEnum Mka = new FormatEnum("mka"); + public static readonly FormatEnum Mkv = new FormatEnum("mkv"); + } + + public sealed class CodecEnum : StringEnum + { + private CodecEnum(string value) : base(value) { } + public CodecEnum() { } + public static implicit operator CodecEnum(string value) + { + return new CodecEnum(value); + } + + public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); + public static readonly CodecEnum H264 = new CodecEnum("H264"); + public static readonly CodecEnum Opus = new CodecEnum("OPUS"); + public static readonly CodecEnum Pcmu = new CodecEnum("PCMU"); + } + + private static Request BuildFetchRequest(FetchRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Recordings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single Recording resource identified by a Recording SID. + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(FetchRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single Recording resource identified by a Recording SID. + /// + /// Fetch Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single Recording resource identified by a Recording SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Recording + public static RecordingResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single Recording resource identified by a Recording SID. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRecordingOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Recordings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// List of all Track recordings. + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(ReadRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// List of all Track recordings. + /// + /// Read Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(ReadRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// List of all Track recordings. + /// + /// Read only the recordings that have this status + /// Read only the recordings that have this source_sid + /// Read only recordings that have this grouping_sid + /// Read only recordings that started on or after this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only recordings that started before this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only recordings that have this media type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Recording + public static ResourceSet Read(RecordingResource.StatusEnum status = null, + string sourceSid = null, + List groupingSid = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + RecordingResource.TypeEnum mediaType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions() { Status = status, SourceSid = sourceSid, GroupingSid = groupingSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, MediaType = mediaType, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// List of all Track recordings. + /// + /// Read only the recordings that have this status + /// Read only the recordings that have this source_sid + /// Read only recordings that have this grouping_sid + /// Read only recordings that started on or after this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only recordings that started before this [ISO + /// 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone + /// Read only recordings that have this media type + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task> ReadAsync(RecordingResource.StatusEnum status = null, + string sourceSid = null, + List groupingSid = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + RecordingResource.TypeEnum mediaType = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRecordingOptions() { Status = status, SourceSid = sourceSid, GroupingSid = groupingSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, MediaType = mediaType, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + private static Request BuildDeleteRequest(DeleteRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Video, + "/v1/Recordings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Recording resource identified by a Recording SID. + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(DeleteRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Recording resource identified by a Recording SID. + /// + /// Delete Recording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Recording resource identified by a Recording SID. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Recording + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Recording resource identified by a Recording SID. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Recording + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRecordingOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RecordingResource object + /// + /// Raw JSON string + /// RecordingResource object represented by the provided JSON + public static RecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The status of the recording + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the recording source + /// + [JsonProperty("source_sid")] + public string SourceSid { get; private set; } + /// + /// The size of the recorded track, in bytes + /// + [JsonProperty("size")] + public long? Size { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The recording's media type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.TypeEnum Type { get; private set; } + /// + /// The duration of the recording in seconds + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The file format for the recording + /// + [JsonProperty("container_format")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.FormatEnum ContainerFormat { get; private set; } + /// + /// The codec used to encode the track + /// + [JsonProperty("codec")] + [JsonConverter(typeof(StringEnumConverter))] + public RecordingResource.CodecEnum Codec { get; private set; } + /// + /// A list of SIDs related to the recording + /// + [JsonProperty("grouping_sids")] + public object GroupingSids { get; private set; } + /// + /// The name that was given to the source track of the recording + /// + [JsonProperty("track_name")] + public string TrackName { get; private set; } + /// + /// The number of milliseconds between a point in time that is common to all rooms in a group and when the source room of the recording started + /// + [JsonProperty("offset")] + public long? Offset { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private RecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RecordingSettingsOptions.cs b/src/Twilio/Rest/Video/V1/RecordingSettingsOptions.cs index 66de1cdcf..fb6d60f6c 100644 --- a/src/Twilio/Rest/Video/V1/RecordingSettingsOptions.cs +++ b/src/Twilio/Rest/Video/V1/RecordingSettingsOptions.cs @@ -9,100 +9,100 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// FetchRecordingSettingsOptions + /// + public class FetchRecordingSettingsOptions : IOptions + { /// - /// FetchRecordingSettingsOptions + /// Generate the necessary parameters /// - public class FetchRecordingSettingsOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRecordingSettingsOptions + /// + public class CreateRecordingSettingsOptions : IOptions + { /// - /// CreateRecordingSettingsOptions + /// A string to describe the resource /// - public class CreateRecordingSettingsOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; } - /// - /// The SID of the stored Credential resource - /// - public string AwsCredentialsSid { get; set; } - /// - /// The SID of the Public Key resource to use for encryption - /// - public string EncryptionKeySid { get; set; } - /// - /// The URL of the AWS S3 bucket where the recordings should be stored - /// - public Uri AwsS3Url { get; set; } - /// - /// Whether all recordings should be written to the aws_s3_url - /// - public bool? AwsStorageEnabled { get; set; } - /// - /// Whether all recordings should be stored in an encrypted form - /// - public bool? EncryptionEnabled { get; set; } - - /// - /// Construct a new CreateRecordingSettingsOptions - /// - /// A string to describe the resource - public CreateRecordingSettingsOptions(string friendlyName) - { - FriendlyName = friendlyName; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (AwsCredentialsSid != null) - { - p.Add(new KeyValuePair("AwsCredentialsSid", AwsCredentialsSid.ToString())); - } - - if (EncryptionKeySid != null) - { - p.Add(new KeyValuePair("EncryptionKeySid", EncryptionKeySid.ToString())); - } - - if (AwsS3Url != null) - { - p.Add(new KeyValuePair("AwsS3Url", Serializers.Url(AwsS3Url))); - } - - if (AwsStorageEnabled != null) - { - p.Add(new KeyValuePair("AwsStorageEnabled", AwsStorageEnabled.Value.ToString().ToLower())); - } - - if (EncryptionEnabled != null) - { - p.Add(new KeyValuePair("EncryptionEnabled", EncryptionEnabled.Value.ToString().ToLower())); - } - - return p; - } - } + public string FriendlyName { get; } + /// + /// The SID of the stored Credential resource + /// + public string AwsCredentialsSid { get; set; } + /// + /// The SID of the Public Key resource to use for encryption + /// + public string EncryptionKeySid { get; set; } + /// + /// The URL of the AWS S3 bucket where the recordings should be stored + /// + public Uri AwsS3Url { get; set; } + /// + /// Whether all recordings should be written to the aws_s3_url + /// + public bool? AwsStorageEnabled { get; set; } + /// + /// Whether all recordings should be stored in an encrypted form + /// + public bool? EncryptionEnabled { get; set; } + + /// + /// Construct a new CreateRecordingSettingsOptions + /// + /// A string to describe the resource + public CreateRecordingSettingsOptions(string friendlyName) + { + FriendlyName = friendlyName; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (AwsCredentialsSid != null) + { + p.Add(new KeyValuePair("AwsCredentialsSid", AwsCredentialsSid.ToString())); + } + + if (EncryptionKeySid != null) + { + p.Add(new KeyValuePair("EncryptionKeySid", EncryptionKeySid.ToString())); + } + + if (AwsS3Url != null) + { + p.Add(new KeyValuePair("AwsS3Url", Serializers.Url(AwsS3Url))); + } + + if (AwsStorageEnabled != null) + { + p.Add(new KeyValuePair("AwsStorageEnabled", AwsStorageEnabled.Value.ToString().ToLower())); + } + + if (EncryptionEnabled != null) + { + p.Add(new KeyValuePair("EncryptionEnabled", EncryptionEnabled.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RecordingSettingsResource.cs b/src/Twilio/Rest/Video/V1/RecordingSettingsResource.cs index 5f3a3216b..e39d944e8 100644 --- a/src/Twilio/Rest/Video/V1/RecordingSettingsResource.cs +++ b/src/Twilio/Rest/Video/V1/RecordingSettingsResource.cs @@ -16,226 +16,226 @@ using Twilio.Http; namespace Twilio.Rest.Video.V1 -{ - - public class RecordingSettingsResource : Resource - { - private static Request BuildFetchRequest(FetchRecordingSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/RecordingSettings/Default", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch RecordingSettings parameters - /// Client to make requests to Twilio - /// A single instance of RecordingSettings - public static RecordingSettingsResource Fetch(FetchRecordingSettingsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch RecordingSettings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingSettings - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// Client to make requests to Twilio - /// A single instance of RecordingSettings - public static RecordingSettingsResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchRecordingSettingsOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingSettings - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchRecordingSettingsOptions(); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRecordingSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/RecordingSettings/Default", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create RecordingSettings parameters - /// Client to make requests to Twilio - /// A single instance of RecordingSettings - public static RecordingSettingsResource Create(CreateRecordingSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create RecordingSettings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingSettings - public static async System.Threading.Tasks.Task CreateAsync(CreateRecordingSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The SID of the stored Credential resource - /// The SID of the Public Key resource to use for encryption - /// The URL of the AWS S3 bucket where the recordings should be stored - /// Whether all recordings should be written to the aws_s3_url - /// Whether all recordings should be stored in an encrypted form - /// Client to make requests to Twilio - /// A single instance of RecordingSettings - public static RecordingSettingsResource Create(string friendlyName, - string awsCredentialsSid = null, - string encryptionKeySid = null, - Uri awsS3Url = null, - bool? awsStorageEnabled = null, - bool? encryptionEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateRecordingSettingsOptions(friendlyName){AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The SID of the stored Credential resource - /// The SID of the Public Key resource to use for encryption - /// The URL of the AWS S3 bucket where the recordings should be stored - /// Whether all recordings should be written to the aws_s3_url - /// Whether all recordings should be stored in an encrypted form - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingSettings - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, - string awsCredentialsSid = null, - string encryptionKeySid = null, - Uri awsS3Url = null, - bool? awsStorageEnabled = null, - bool? encryptionEnabled = null, - ITwilioRestClient client = null) - { - var options = new CreateRecordingSettingsOptions(friendlyName){AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled}; - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RecordingSettingsResource object - /// - /// Raw JSON string - /// RecordingSettingsResource object represented by the provided JSON - public static RecordingSettingsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SID of the stored Credential resource - /// - [JsonProperty("aws_credentials_sid")] - public string AwsCredentialsSid { get; private set; } - /// - /// The URL of the AWS S3 bucket where the recordings are stored - /// - [JsonProperty("aws_s3_url")] - public Uri AwsS3Url { get; private set; } - /// - /// Whether all recordings are written to the aws_s3_url - /// - [JsonProperty("aws_storage_enabled")] - public bool? AwsStorageEnabled { get; private set; } - /// - /// The SID of the Public Key resource used for encryption - /// - [JsonProperty("encryption_key_sid")] - public string EncryptionKeySid { get; private set; } - /// - /// Whether all recordings are stored in an encrypted form - /// - [JsonProperty("encryption_enabled")] - public bool? EncryptionEnabled { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RecordingSettingsResource() - { - - } - } +{ + + public class RecordingSettingsResource : Resource + { + private static Request BuildFetchRequest(FetchRecordingSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/RecordingSettings/Default", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch RecordingSettings parameters + /// Client to make requests to Twilio + /// A single instance of RecordingSettings + public static RecordingSettingsResource Fetch(FetchRecordingSettingsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch RecordingSettings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingSettings + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// Client to make requests to Twilio + /// A single instance of RecordingSettings + public static RecordingSettingsResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchRecordingSettingsOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingSettings + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchRecordingSettingsOptions(); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRecordingSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/RecordingSettings/Default", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create RecordingSettings parameters + /// Client to make requests to Twilio + /// A single instance of RecordingSettings + public static RecordingSettingsResource Create(CreateRecordingSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create RecordingSettings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingSettings + public static async System.Threading.Tasks.Task CreateAsync(CreateRecordingSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The SID of the stored Credential resource + /// The SID of the Public Key resource to use for encryption + /// The URL of the AWS S3 bucket where the recordings should be stored + /// Whether all recordings should be written to the aws_s3_url + /// Whether all recordings should be stored in an encrypted form + /// Client to make requests to Twilio + /// A single instance of RecordingSettings + public static RecordingSettingsResource Create(string friendlyName, + string awsCredentialsSid = null, + string encryptionKeySid = null, + Uri awsS3Url = null, + bool? awsStorageEnabled = null, + bool? encryptionEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateRecordingSettingsOptions(friendlyName) { AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The SID of the stored Credential resource + /// The SID of the Public Key resource to use for encryption + /// The URL of the AWS S3 bucket where the recordings should be stored + /// Whether all recordings should be written to the aws_s3_url + /// Whether all recordings should be stored in an encrypted form + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingSettings + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName, + string awsCredentialsSid = null, + string encryptionKeySid = null, + Uri awsS3Url = null, + bool? awsStorageEnabled = null, + bool? encryptionEnabled = null, + ITwilioRestClient client = null) + { + var options = new CreateRecordingSettingsOptions(friendlyName) { AwsCredentialsSid = awsCredentialsSid, EncryptionKeySid = encryptionKeySid, AwsS3Url = awsS3Url, AwsStorageEnabled = awsStorageEnabled, EncryptionEnabled = encryptionEnabled }; + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RecordingSettingsResource object + /// + /// Raw JSON string + /// RecordingSettingsResource object represented by the provided JSON + public static RecordingSettingsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SID of the stored Credential resource + /// + [JsonProperty("aws_credentials_sid")] + public string AwsCredentialsSid { get; private set; } + /// + /// The URL of the AWS S3 bucket where the recordings are stored + /// + [JsonProperty("aws_s3_url")] + public Uri AwsS3Url { get; private set; } + /// + /// Whether all recordings are written to the aws_s3_url + /// + [JsonProperty("aws_storage_enabled")] + public bool? AwsStorageEnabled { get; private set; } + /// + /// The SID of the Public Key resource used for encryption + /// + [JsonProperty("encryption_key_sid")] + public string EncryptionKeySid { get; private set; } + /// + /// Whether all recordings are stored in an encrypted form + /// + [JsonProperty("encryption_enabled")] + public bool? EncryptionEnabled { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RecordingSettingsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackOptions.cs b/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackOptions.cs index 591b67242..ead9f989e 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackOptions.cs @@ -9,88 +9,88 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room.Participant -{ - +{ + + /// + /// Returns a single Track resource represented by TrackName or SID. + /// + public class FetchPublishedTrackOptions : IOptions + { /// - /// Returns a single Track resource represented by TrackName or SID. + /// The SID of the Room resource where the Track resource to fetch is published /// - public class FetchPublishedTrackOptions : IOptions - { - /// - /// The SID of the Room resource where the Track resource to fetch is published - /// - public string PathRoomSid { get; } - /// - /// The SID of the Participant resource with the published track to fetch - /// - public string PathParticipantSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchPublishedTrackOptions - /// - /// The SID of the Room resource where the Track resource to fetch is published - /// The SID of the Participant resource with the published track to fetch - /// The SID that identifies the resource to fetch - public FetchPublishedTrackOptions(string pathRoomSid, string pathParticipantSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } /// - /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list - /// resource. + /// The SID of the Participant resource with the published track to fetch /// - public class ReadPublishedTrackOptions : ReadOptions - { - /// - /// The SID of the Room resource where the Track resources to read are published - /// - public string PathRoomSid { get; } - /// - /// The SID of the Participant resource with the published tracks to read - /// - public string PathParticipantSid { get; } - - /// - /// Construct a new ReadPublishedTrackOptions - /// - /// The SID of the Room resource where the Track resources to read are published - /// The SID of the Participant resource with the published tracks to read - public ReadPublishedTrackOptions(string pathRoomSid, string pathParticipantSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathParticipantSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchPublishedTrackOptions + /// + /// The SID of the Room resource where the Track resource to fetch is published + /// The SID of the Participant resource with the published track to fetch + /// The SID that identifies the resource to fetch + public FetchPublishedTrackOptions(string pathRoomSid, string pathParticipantSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list + /// resource. + /// + public class ReadPublishedTrackOptions : ReadOptions + { + /// + /// The SID of the Room resource where the Track resources to read are published + /// + public string PathRoomSid { get; } + /// + /// The SID of the Participant resource with the published tracks to read + /// + public string PathParticipantSid { get; } + + /// + /// Construct a new ReadPublishedTrackOptions + /// + /// The SID of the Room resource where the Track resources to read are published + /// The SID of the Participant resource with the published tracks to read + public ReadPublishedTrackOptions(string pathRoomSid, string pathParticipantSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackResource.cs b/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackResource.cs index 1db3b9f42..07533a73f 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackResource.cs @@ -17,311 +17,311 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room.Participant -{ - - public class PublishedTrackResource : Resource - { - public sealed class KindEnum : StringEnum - { - private KindEnum(string value) : base(value) {} - public KindEnum() {} - public static implicit operator KindEnum(string value) - { - return new KindEnum(value); - } - - public static readonly KindEnum Audio = new KindEnum("audio"); - public static readonly KindEnum Video = new KindEnum("video"); - public static readonly KindEnum Data = new KindEnum("data"); - } - - private static Request BuildFetchRequest(FetchPublishedTrackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/PublishedTracks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single Track resource represented by TrackName or SID. - /// - /// Fetch PublishedTrack parameters - /// Client to make requests to Twilio - /// A single instance of PublishedTrack - public static PublishedTrackResource Fetch(FetchPublishedTrackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single Track resource represented by TrackName or SID. - /// - /// Fetch PublishedTrack parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublishedTrack - public static async System.Threading.Tasks.Task FetchAsync(FetchPublishedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single Track resource represented by TrackName or SID. - /// - /// The SID of the Room resource where the Track resource to fetch is published - /// The SID of the Participant resource with the published track to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of PublishedTrack - public static PublishedTrackResource Fetch(string pathRoomSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPublishedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single Track resource represented by TrackName or SID. - /// - /// The SID of the Room resource where the Track resource to fetch is published - /// The SID of the Participant resource with the published track to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublishedTrack - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchPublishedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadPublishedTrackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/PublishedTracks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list - /// resource. - /// - /// Read PublishedTrack parameters - /// Client to make requests to Twilio - /// A single instance of PublishedTrack - public static ResourceSet Read(ReadPublishedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("published_tracks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list - /// resource. - /// - /// Read PublishedTrack parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublishedTrack - public static async System.Threading.Tasks.Task> ReadAsync(ReadPublishedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("published_tracks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list - /// resource. - /// - /// The SID of the Room resource where the Track resources to read are published - /// The SID of the Participant resource with the published tracks to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of PublishedTrack - public static ResourceSet Read(string pathRoomSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPublishedTrackOptions(pathRoomSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list - /// resource. - /// - /// The SID of the Room resource where the Track resources to read are published - /// The SID of the Participant resource with the published tracks to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of PublishedTrack - public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadPublishedTrackOptions(pathRoomSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("published_tracks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("published_tracks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("published_tracks", response.Content); - } - - /// - /// Converts a JSON string into a PublishedTrackResource object - /// - /// Raw JSON string - /// PublishedTrackResource object represented by the provided JSON - public static PublishedTrackResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Participant resource with the published track - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The SID of the Room resource where the track is published - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// The track name - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Whether the track is enabled - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The track type - /// - [JsonProperty("kind")] - [JsonConverter(typeof(StringEnumConverter))] - public PublishedTrackResource.KindEnum Kind { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private PublishedTrackResource() - { - - } - } +{ + + public class PublishedTrackResource : Resource + { + public sealed class KindEnum : StringEnum + { + private KindEnum(string value) : base(value) { } + public KindEnum() { } + public static implicit operator KindEnum(string value) + { + return new KindEnum(value); + } + + public static readonly KindEnum Audio = new KindEnum("audio"); + public static readonly KindEnum Video = new KindEnum("video"); + public static readonly KindEnum Data = new KindEnum("data"); + } + + private static Request BuildFetchRequest(FetchPublishedTrackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/PublishedTracks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single Track resource represented by TrackName or SID. + /// + /// Fetch PublishedTrack parameters + /// Client to make requests to Twilio + /// A single instance of PublishedTrack + public static PublishedTrackResource Fetch(FetchPublishedTrackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single Track resource represented by TrackName or SID. + /// + /// Fetch PublishedTrack parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublishedTrack + public static async System.Threading.Tasks.Task FetchAsync(FetchPublishedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single Track resource represented by TrackName or SID. + /// + /// The SID of the Room resource where the Track resource to fetch is published + /// The SID of the Participant resource with the published track to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of PublishedTrack + public static PublishedTrackResource Fetch(string pathRoomSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPublishedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single Track resource represented by TrackName or SID. + /// + /// The SID of the Room resource where the Track resource to fetch is published + /// The SID of the Participant resource with the published track to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublishedTrack + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchPublishedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadPublishedTrackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/PublishedTracks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list + /// resource. + /// + /// Read PublishedTrack parameters + /// Client to make requests to Twilio + /// A single instance of PublishedTrack + public static ResourceSet Read(ReadPublishedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("published_tracks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list + /// resource. + /// + /// Read PublishedTrack parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublishedTrack + public static async System.Threading.Tasks.Task> ReadAsync(ReadPublishedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("published_tracks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list + /// resource. + /// + /// The SID of the Room resource where the Track resources to read are published + /// The SID of the Participant resource with the published tracks to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of PublishedTrack + public static ResourceSet Read(string pathRoomSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPublishedTrackOptions(pathRoomSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Returns a list of tracks associated with a given Participant. Only `currently` Published Tracks are in the list + /// resource. + /// + /// The SID of the Room resource where the Track resources to read are published + /// The SID of the Participant resource with the published tracks to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of PublishedTrack + public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadPublishedTrackOptions(pathRoomSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("published_tracks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("published_tracks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("published_tracks", response.Content); + } + + /// + /// Converts a JSON string into a PublishedTrackResource object + /// + /// Raw JSON string + /// PublishedTrackResource object represented by the provided JSON + public static PublishedTrackResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Participant resource with the published track + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The SID of the Room resource where the track is published + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// The track name + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Whether the track is enabled + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The track type + /// + [JsonProperty("kind")] + [JsonConverter(typeof(StringEnumConverter))] + public PublishedTrackResource.KindEnum Kind { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private PublishedTrackResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesOptions.cs b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesOptions.cs index 82f9a1b97..f6688f42a 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesOptions.cs @@ -9,85 +9,85 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room.Participant -{ - +{ + + /// + /// Returns a list of Subscribe Rules for the Participant. + /// + public class FetchSubscribeRulesOptions : IOptions + { /// - /// Returns a list of Subscribe Rules for the Participant. + /// The SID of the Room resource where the subscribe rules to fetch apply /// - public class FetchSubscribeRulesOptions : IOptions - { - /// - /// The SID of the Room resource where the subscribe rules to fetch apply - /// - public string PathRoomSid { get; } - /// - /// The SID of the Participant resource with the subscribe rules to fetch - /// - public string PathParticipantSid { get; } - - /// - /// Construct a new FetchSubscribeRulesOptions - /// - /// The SID of the Room resource where the subscribe rules to fetch apply - /// The SID of the Participant resource with the subscribe rules to fetch - public FetchSubscribeRulesOptions(string pathRoomSid, string pathParticipantSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } /// - /// Update the Subscribe Rules for the Participant + /// The SID of the Participant resource with the subscribe rules to fetch /// - public class UpdateSubscribeRulesOptions : IOptions - { - /// - /// The SID of the Room resource where the subscribe rules to update apply - /// - public string PathRoomSid { get; } - /// - /// The SID of the Participant resource to update the Subscribe Rules - /// - public string PathParticipantSid { get; } - /// - /// A JSON-encoded array of subscribe rules - /// - public object Rules { get; set; } - - /// - /// Construct a new UpdateSubscribeRulesOptions - /// - /// The SID of the Room resource where the subscribe rules to update apply - /// The SID of the Participant resource to update the Subscribe Rules - public UpdateSubscribeRulesOptions(string pathRoomSid, string pathParticipantSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Rules != null) - { - p.Add(new KeyValuePair("Rules", Serializers.JsonObject(Rules))); - } - - return p; - } - } + public string PathParticipantSid { get; } + + /// + /// Construct a new FetchSubscribeRulesOptions + /// + /// The SID of the Room resource where the subscribe rules to fetch apply + /// The SID of the Participant resource with the subscribe rules to fetch + public FetchSubscribeRulesOptions(string pathRoomSid, string pathParticipantSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the Subscribe Rules for the Participant + /// + public class UpdateSubscribeRulesOptions : IOptions + { + /// + /// The SID of the Room resource where the subscribe rules to update apply + /// + public string PathRoomSid { get; } + /// + /// The SID of the Participant resource to update the Subscribe Rules + /// + public string PathParticipantSid { get; } + /// + /// A JSON-encoded array of subscribe rules + /// + public object Rules { get; set; } + + /// + /// Construct a new UpdateSubscribeRulesOptions + /// + /// The SID of the Room resource where the subscribe rules to update apply + /// The SID of the Participant resource to update the Subscribe Rules + public UpdateSubscribeRulesOptions(string pathRoomSid, string pathParticipantSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Rules != null) + { + p.Add(new KeyValuePair("Rules", Serializers.JsonObject(Rules))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesResource.cs b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesResource.cs index c1d0160cc..064257906 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribeRulesResource.cs @@ -17,206 +17,206 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room.Participant -{ - - public class SubscribeRulesResource : Resource - { - private static Request BuildFetchRequest(FetchSubscribeRulesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribeRules", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of Subscribe Rules for the Participant. - /// - /// Fetch SubscribeRules parameters - /// Client to make requests to Twilio - /// A single instance of SubscribeRules - public static SubscribeRulesResource Fetch(FetchSubscribeRulesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a list of Subscribe Rules for the Participant. - /// - /// Fetch SubscribeRules parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribeRules - public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribeRulesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a list of Subscribe Rules for the Participant. - /// - /// The SID of the Room resource where the subscribe rules to fetch apply - /// The SID of the Participant resource with the subscribe rules to fetch - /// Client to make requests to Twilio - /// A single instance of SubscribeRules - public static SubscribeRulesResource Fetch(string pathRoomSid, - string pathParticipantSid, - ITwilioRestClient client = null) - { - var options = new FetchSubscribeRulesOptions(pathRoomSid, pathParticipantSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a list of Subscribe Rules for the Participant. - /// - /// The SID of the Room resource where the subscribe rules to fetch apply - /// The SID of the Participant resource with the subscribe rules to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribeRules - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathParticipantSid, - ITwilioRestClient client = null) - { - var options = new FetchSubscribeRulesOptions(pathRoomSid, pathParticipantSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSubscribeRulesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribeRules", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the Subscribe Rules for the Participant - /// - /// Update SubscribeRules parameters - /// Client to make requests to Twilio - /// A single instance of SubscribeRules - public static SubscribeRulesResource Update(UpdateSubscribeRulesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the Subscribe Rules for the Participant - /// - /// Update SubscribeRules parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribeRules - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscribeRulesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the Subscribe Rules for the Participant - /// - /// The SID of the Room resource where the subscribe rules to update apply - /// The SID of the Participant resource to update the Subscribe Rules - /// A JSON-encoded array of subscribe rules - /// Client to make requests to Twilio - /// A single instance of SubscribeRules - public static SubscribeRulesResource Update(string pathRoomSid, - string pathParticipantSid, - object rules = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscribeRulesOptions(pathRoomSid, pathParticipantSid){Rules = rules}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the Subscribe Rules for the Participant - /// - /// The SID of the Room resource where the subscribe rules to update apply - /// The SID of the Participant resource to update the Subscribe Rules - /// A JSON-encoded array of subscribe rules - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribeRules - public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, - string pathParticipantSid, - object rules = null, - ITwilioRestClient client = null) - { - var options = new UpdateSubscribeRulesOptions(pathRoomSid, pathParticipantSid){Rules = rules}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SubscribeRulesResource object - /// - /// Raw JSON string - /// SubscribeRulesResource object represented by the provided JSON - public static SubscribeRulesResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Participant resource for the Subscribe Rules - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The SID of the Room resource for the Subscribe Rules - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// A collection of Subscribe Rules that describe how to include or exclude matching tracks - /// - [JsonProperty("rules")] - public List Rules { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private SubscribeRulesResource() - { - - } - } +{ + + public class SubscribeRulesResource : Resource + { + private static Request BuildFetchRequest(FetchSubscribeRulesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribeRules", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of Subscribe Rules for the Participant. + /// + /// Fetch SubscribeRules parameters + /// Client to make requests to Twilio + /// A single instance of SubscribeRules + public static SubscribeRulesResource Fetch(FetchSubscribeRulesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a list of Subscribe Rules for the Participant. + /// + /// Fetch SubscribeRules parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribeRules + public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribeRulesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a list of Subscribe Rules for the Participant. + /// + /// The SID of the Room resource where the subscribe rules to fetch apply + /// The SID of the Participant resource with the subscribe rules to fetch + /// Client to make requests to Twilio + /// A single instance of SubscribeRules + public static SubscribeRulesResource Fetch(string pathRoomSid, + string pathParticipantSid, + ITwilioRestClient client = null) + { + var options = new FetchSubscribeRulesOptions(pathRoomSid, pathParticipantSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a list of Subscribe Rules for the Participant. + /// + /// The SID of the Room resource where the subscribe rules to fetch apply + /// The SID of the Participant resource with the subscribe rules to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribeRules + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathParticipantSid, + ITwilioRestClient client = null) + { + var options = new FetchSubscribeRulesOptions(pathRoomSid, pathParticipantSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSubscribeRulesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribeRules", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the Subscribe Rules for the Participant + /// + /// Update SubscribeRules parameters + /// Client to make requests to Twilio + /// A single instance of SubscribeRules + public static SubscribeRulesResource Update(UpdateSubscribeRulesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the Subscribe Rules for the Participant + /// + /// Update SubscribeRules parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribeRules + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSubscribeRulesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the Subscribe Rules for the Participant + /// + /// The SID of the Room resource where the subscribe rules to update apply + /// The SID of the Participant resource to update the Subscribe Rules + /// A JSON-encoded array of subscribe rules + /// Client to make requests to Twilio + /// A single instance of SubscribeRules + public static SubscribeRulesResource Update(string pathRoomSid, + string pathParticipantSid, + object rules = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscribeRulesOptions(pathRoomSid, pathParticipantSid) { Rules = rules }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the Subscribe Rules for the Participant + /// + /// The SID of the Room resource where the subscribe rules to update apply + /// The SID of the Participant resource to update the Subscribe Rules + /// A JSON-encoded array of subscribe rules + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribeRules + public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, + string pathParticipantSid, + object rules = null, + ITwilioRestClient client = null) + { + var options = new UpdateSubscribeRulesOptions(pathRoomSid, pathParticipantSid) { Rules = rules }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SubscribeRulesResource object + /// + /// Raw JSON string + /// SubscribeRulesResource object represented by the provided JSON + public static SubscribeRulesResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Participant resource for the Subscribe Rules + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The SID of the Room resource for the Subscribe Rules + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// A collection of Subscribe Rules that describe how to include or exclude matching tracks + /// + [JsonProperty("rules")] + public List Rules { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private SubscribeRulesResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackOptions.cs b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackOptions.cs index a7e8d9ad7..acdd5704c 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackOptions.cs @@ -9,88 +9,88 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room.Participant -{ - +{ + + /// + /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that + /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// + public class FetchSubscribedTrackOptions : IOptions + { /// - /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that - /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// The SID of the Room where the Track resource to fetch is subscribed /// - public class FetchSubscribedTrackOptions : IOptions - { - /// - /// The SID of the Room where the Track resource to fetch is subscribed - /// - public string PathRoomSid { get; } - /// - /// The SID of the participant that subscribes to the Track resource to fetch - /// - public string PathParticipantSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSubscribedTrackOptions - /// - /// The SID of the Room where the Track resource to fetch is subscribed - /// The SID of the participant that subscribes to the Track resource to fetch - /// The SID that identifies the resource to fetch - public FetchSubscribedTrackOptions(string pathRoomSid, string pathParticipantSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } /// - /// Returns a list of tracks that are subscribed for the participant. + /// The SID of the participant that subscribes to the Track resource to fetch /// - public class ReadSubscribedTrackOptions : ReadOptions - { - /// - /// The SID of the Room resource with the Track resources to read - /// - public string PathRoomSid { get; } - /// - /// The SID of the participant that subscribes to the Track resources to read - /// - public string PathParticipantSid { get; } - - /// - /// Construct a new ReadSubscribedTrackOptions - /// - /// The SID of the Room resource with the Track resources to read - /// The SID of the participant that subscribes to the Track resources to read - public ReadSubscribedTrackOptions(string pathRoomSid, string pathParticipantSid) - { - PathRoomSid = pathRoomSid; - PathParticipantSid = pathParticipantSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathParticipantSid { get; } + /// + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + + /// + /// Construct a new FetchSubscribedTrackOptions + /// + /// The SID of the Room where the Track resource to fetch is subscribed + /// The SID of the participant that subscribes to the Track resource to fetch + /// The SID that identifies the resource to fetch + public FetchSubscribedTrackOptions(string pathRoomSid, string pathParticipantSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Returns a list of tracks that are subscribed for the participant. + /// + public class ReadSubscribedTrackOptions : ReadOptions + { + /// + /// The SID of the Room resource with the Track resources to read + /// + public string PathRoomSid { get; } + /// + /// The SID of the participant that subscribes to the Track resources to read + /// + public string PathParticipantSid { get; } + + /// + /// Construct a new ReadSubscribedTrackOptions + /// + /// The SID of the Room resource with the Track resources to read + /// The SID of the participant that subscribes to the Track resources to read + public ReadSubscribedTrackOptions(string pathRoomSid, string pathParticipantSid) + { + PathRoomSid = pathRoomSid; + PathParticipantSid = pathParticipantSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackResource.cs b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackResource.cs index 03e4ca972..0cfc70d13 100644 --- a/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/Participant/SubscribedTrackResource.cs @@ -17,317 +17,317 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room.Participant -{ - - public class SubscribedTrackResource : Resource - { - public sealed class KindEnum : StringEnum - { - private KindEnum(string value) : base(value) {} - public KindEnum() {} - public static implicit operator KindEnum(string value) - { - return new KindEnum(value); - } - - public static readonly KindEnum Audio = new KindEnum("audio"); - public static readonly KindEnum Video = new KindEnum("video"); - public static readonly KindEnum Data = new KindEnum("data"); - } - - private static Request BuildFetchRequest(FetchSubscribedTrackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribedTracks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that - /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. - /// - /// Fetch SubscribedTrack parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedTrack - public static SubscribedTrackResource Fetch(FetchSubscribedTrackOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that - /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. - /// - /// Fetch SubscribedTrack parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedTrack - public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that - /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. - /// - /// The SID of the Room where the Track resource to fetch is subscribed - /// The SID of the participant that subscribes to the Track resource to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of SubscribedTrack - public static SubscribedTrackResource Fetch(string pathRoomSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSubscribedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that - /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. - /// - /// The SID of the Room where the Track resource to fetch is subscribed - /// The SID of the participant that subscribes to the Track resource to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedTrack - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathParticipantSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSubscribedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSubscribedTrackOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribedTracks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of tracks that are subscribed for the participant. - /// - /// Read SubscribedTrack parameters - /// Client to make requests to Twilio - /// A single instance of SubscribedTrack - public static ResourceSet Read(ReadSubscribedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("subscribed_tracks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Returns a list of tracks that are subscribed for the participant. - /// - /// Read SubscribedTrack parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedTrack - public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscribedTrackOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("subscribed_tracks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Returns a list of tracks that are subscribed for the participant. - /// - /// The SID of the Room resource with the Track resources to read - /// The SID of the participant that subscribes to the Track resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SubscribedTrack - public static ResourceSet Read(string pathRoomSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscribedTrackOptions(pathRoomSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Returns a list of tracks that are subscribed for the participant. - /// - /// The SID of the Room resource with the Track resources to read - /// The SID of the participant that subscribes to the Track resources to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SubscribedTrack - public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, - string pathParticipantSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSubscribedTrackOptions(pathRoomSid, pathParticipantSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("subscribed_tracks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("subscribed_tracks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("subscribed_tracks", response.Content); - } - - /// - /// Converts a JSON string into a SubscribedTrackResource object - /// - /// Raw JSON string - /// SubscribedTrackResource object represented by the provided JSON - public static SubscribedTrackResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the participant that subscribes to the track - /// - [JsonProperty("participant_sid")] - public string ParticipantSid { get; private set; } - /// - /// The SID of the participant that publishes the track - /// - [JsonProperty("publisher_sid")] - public string PublisherSid { get; private set; } - /// - /// The SID of the room where the track is published - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// The track name - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// Whether the track is enabled - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The track type - /// - [JsonProperty("kind")] - [JsonConverter(typeof(StringEnumConverter))] - public SubscribedTrackResource.KindEnum Kind { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SubscribedTrackResource() - { - - } - } +{ + + public class SubscribedTrackResource : Resource + { + public sealed class KindEnum : StringEnum + { + private KindEnum(string value) : base(value) { } + public KindEnum() { } + public static implicit operator KindEnum(string value) + { + return new KindEnum(value); + } + + public static readonly KindEnum Audio = new KindEnum("audio"); + public static readonly KindEnum Video = new KindEnum("video"); + public static readonly KindEnum Data = new KindEnum("data"); + } + + private static Request BuildFetchRequest(FetchSubscribedTrackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribedTracks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that + /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// + /// Fetch SubscribedTrack parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedTrack + public static SubscribedTrackResource Fetch(FetchSubscribedTrackOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that + /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// + /// Fetch SubscribedTrack parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedTrack + public static async System.Threading.Tasks.Task FetchAsync(FetchSubscribedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that + /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// + /// The SID of the Room where the Track resource to fetch is subscribed + /// The SID of the participant that subscribes to the Track resource to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of SubscribedTrack + public static SubscribedTrackResource Fetch(string pathRoomSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSubscribedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a single Track resource represented by `track_sid`. Note: This is one resource with the Video API that + /// requires a SID, be Track Name on the subscriber side is not guaranteed to be unique. + /// + /// The SID of the Room where the Track resource to fetch is subscribed + /// The SID of the participant that subscribes to the Track resource to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedTrack + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathParticipantSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSubscribedTrackOptions(pathRoomSid, pathParticipantSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSubscribedTrackOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathParticipantSid + "/SubscribedTracks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of tracks that are subscribed for the participant. + /// + /// Read SubscribedTrack parameters + /// Client to make requests to Twilio + /// A single instance of SubscribedTrack + public static ResourceSet Read(ReadSubscribedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("subscribed_tracks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Returns a list of tracks that are subscribed for the participant. + /// + /// Read SubscribedTrack parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedTrack + public static async System.Threading.Tasks.Task> ReadAsync(ReadSubscribedTrackOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("subscribed_tracks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Returns a list of tracks that are subscribed for the participant. + /// + /// The SID of the Room resource with the Track resources to read + /// The SID of the participant that subscribes to the Track resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SubscribedTrack + public static ResourceSet Read(string pathRoomSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscribedTrackOptions(pathRoomSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Returns a list of tracks that are subscribed for the participant. + /// + /// The SID of the Room resource with the Track resources to read + /// The SID of the participant that subscribes to the Track resources to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SubscribedTrack + public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, + string pathParticipantSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSubscribedTrackOptions(pathRoomSid, pathParticipantSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("subscribed_tracks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("subscribed_tracks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("subscribed_tracks", response.Content); + } + + /// + /// Converts a JSON string into a SubscribedTrackResource object + /// + /// Raw JSON string + /// SubscribedTrackResource object represented by the provided JSON + public static SubscribedTrackResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the participant that subscribes to the track + /// + [JsonProperty("participant_sid")] + public string ParticipantSid { get; private set; } + /// + /// The SID of the participant that publishes the track + /// + [JsonProperty("publisher_sid")] + public string PublisherSid { get; private set; } + /// + /// The SID of the room where the track is published + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// The track name + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// Whether the track is enabled + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The track type + /// + [JsonProperty("kind")] + [JsonConverter(typeof(StringEnumConverter))] + public SubscribedTrackResource.KindEnum Kind { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SubscribedTrackResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/ParticipantOptions.cs b/src/Twilio/Rest/Video/V1/Room/ParticipantOptions.cs index ecd533b41..650917547 100644 --- a/src/Twilio/Rest/Video/V1/Room/ParticipantOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/ParticipantOptions.cs @@ -9,155 +9,155 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room -{ - +{ + + /// + /// FetchParticipantOptions + /// + public class FetchParticipantOptions : IOptions + { /// - /// FetchParticipantOptions - /// - public class FetchParticipantOptions : IOptions - { - /// - /// The SID of the room with the Participant resource to fetch - /// - public string PathRoomSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchParticipantOptions - /// - /// The SID of the room with the Participant resource to fetch - /// The SID that identifies the resource to fetch - public FetchParticipantOptions(string pathRoomSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + /// The SID of the room with the Participant resource to fetch + /// + public string PathRoomSid { get; } /// - /// ReadParticipantOptions - /// - public class ReadParticipantOptions : ReadOptions - { - /// - /// The SID of the room with the Participant resources to read - /// - public string PathRoomSid { get; } - /// - /// Read only the participants with this status - /// - public ParticipantResource.StatusEnum Status { get; set; } - /// - /// Read only the Participants with this user identity value - /// - public string Identity { get; set; } - /// - /// Read only Participants that started after this date in UTC ISO 8601 format - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only Participants that started before this date in ISO 8601 format - /// - public DateTime? DateCreatedBefore { get; set; } - - /// - /// Construct a new ReadParticipantOptions - /// - /// The SID of the room with the Participant resources to read - public ReadParticipantOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Identity != null) - { - p.Add(new KeyValuePair("Identity", Identity)); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + /// + public string PathSid { get; } + /// - /// UpdateParticipantOptions - /// - public class UpdateParticipantOptions : IOptions - { - /// - /// The SID of the room with the participant to update - /// - public string PathRoomSid { get; } - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The new status of the resource - /// - public ParticipantResource.StatusEnum Status { get; set; } - - /// - /// Construct a new UpdateParticipantOptions - /// - /// The SID of the room with the participant to update - /// The SID that identifies the resource to update - public UpdateParticipantOptions(string pathRoomSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + /// Construct a new FetchParticipantOptions + /// + /// The SID of the room with the Participant resource to fetch + /// The SID that identifies the resource to fetch + public FetchParticipantOptions(string pathRoomSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadParticipantOptions + /// + public class ReadParticipantOptions : ReadOptions + { + /// + /// The SID of the room with the Participant resources to read + /// + public string PathRoomSid { get; } + /// + /// Read only the participants with this status + /// + public ParticipantResource.StatusEnum Status { get; set; } + /// + /// Read only the Participants with this user identity value + /// + public string Identity { get; set; } + /// + /// Read only Participants that started after this date in UTC ISO 8601 format + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only Participants that started before this date in ISO 8601 format + /// + public DateTime? DateCreatedBefore { get; set; } + + /// + /// Construct a new ReadParticipantOptions + /// + /// The SID of the room with the Participant resources to read + public ReadParticipantOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Identity != null) + { + p.Add(new KeyValuePair("Identity", Identity)); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateParticipantOptions + /// + public class UpdateParticipantOptions : IOptions + { + /// + /// The SID of the room with the participant to update + /// + public string PathRoomSid { get; } + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The new status of the resource + /// + public ParticipantResource.StatusEnum Status { get; set; } + + /// + /// Construct a new UpdateParticipantOptions + /// + /// The SID of the room with the participant to update + /// The SID that identifies the resource to update + public UpdateParticipantOptions(string pathRoomSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/ParticipantResource.cs b/src/Twilio/Rest/Video/V1/Room/ParticipantResource.cs index 336c015b7..682082016 100644 --- a/src/Twilio/Rest/Video/V1/Room/ParticipantResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/ParticipantResource.cs @@ -17,402 +17,402 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room -{ - - public class ParticipantResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Connected = new StatusEnum("connected"); - public static readonly StatusEnum Disconnected = new StatusEnum("disconnected"); - } - - private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the room with the Participant resource to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Fetch(string pathRoomSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathRoomSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the room with the Participant resource to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchParticipantOptions(pathRoomSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("participants", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the room with the Participant resources to read - /// Read only the participants with this status - /// Read only the Participants with this user identity value - /// Read only Participants that started after this date in UTC ISO 8601 format - /// Read only Participants that started before this date in ISO 8601 format - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Participant - public static ResourceSet Read(string pathRoomSid, - ParticipantResource.StatusEnum status = null, - string identity = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathRoomSid){Status = status, Identity = identity, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the room with the Participant resources to read - /// Read only the participants with this status - /// Read only the Participants with this user identity value - /// Read only Participants that started after this date in UTC ISO 8601 format - /// Read only Participants that started before this date in ISO 8601 format - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, - ParticipantResource.StatusEnum status = null, - string identity = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadParticipantOptions(pathRoomSid){Status = status, Identity = identity, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("participants", response.Content); - } - - private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Participant parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the room with the participant to update - /// The SID that identifies the resource to update - /// The new status of the resource - /// Client to make requests to Twilio - /// A single instance of Participant - public static ParticipantResource Update(string pathRoomSid, - string pathSid, - ParticipantResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathRoomSid, pathSid){Status = status}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the room with the participant to update - /// The SID that identifies the resource to update - /// The new status of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Participant - public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, - string pathSid, - ParticipantResource.StatusEnum status = null, - ITwilioRestClient client = null) - { - var options = new UpdateParticipantOptions(pathRoomSid, pathSid){Status = status}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ParticipantResource object - /// - /// Raw JSON string - /// ParticipantResource object represented by the provided JSON - public static ParticipantResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the participant's room - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The status of the Participant - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public ParticipantResource.StatusEnum Status { get; private set; } - /// - /// The string that identifies the resource's User - /// - [JsonProperty("identity")] - public string Identity { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The time of participant connected to the room in ISO 8601 format - /// - [JsonProperty("start_time")] - public DateTime? StartTime { get; private set; } - /// - /// The time when the participant disconnected from the room in ISO 8601 format - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// Duration of time in seconds the participant was connected - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ParticipantResource() - { - - } - } +{ + + public class ParticipantResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Connected = new StatusEnum("connected"); + public static readonly StatusEnum Disconnected = new StatusEnum("disconnected"); + } + + private static Request BuildFetchRequest(FetchParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(FetchParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(FetchParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the room with the Participant resource to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Fetch(string pathRoomSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathRoomSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the room with the Participant resource to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchParticipantOptions(pathRoomSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(ReadParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(ReadParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("participants", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the room with the Participant resources to read + /// Read only the participants with this status + /// Read only the Participants with this user identity value + /// Read only Participants that started after this date in UTC ISO 8601 format + /// Read only Participants that started before this date in ISO 8601 format + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Participant + public static ResourceSet Read(string pathRoomSid, + ParticipantResource.StatusEnum status = null, + string identity = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathRoomSid) { Status = status, Identity = identity, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the room with the Participant resources to read + /// Read only the participants with this status + /// Read only the Participants with this user identity value + /// Read only Participants that started after this date in UTC ISO 8601 format + /// Read only Participants that started before this date in ISO 8601 format + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, + ParticipantResource.StatusEnum status = null, + string identity = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadParticipantOptions(pathRoomSid) { Status = status, Identity = identity, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("participants", response.Content); + } + + private static Request BuildUpdateRequest(UpdateParticipantOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Participants/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(UpdateParticipantOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Participant parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(UpdateParticipantOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the room with the participant to update + /// The SID that identifies the resource to update + /// The new status of the resource + /// Client to make requests to Twilio + /// A single instance of Participant + public static ParticipantResource Update(string pathRoomSid, + string pathSid, + ParticipantResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathRoomSid, pathSid) { Status = status }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the room with the participant to update + /// The SID that identifies the resource to update + /// The new status of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Participant + public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, + string pathSid, + ParticipantResource.StatusEnum status = null, + ITwilioRestClient client = null) + { + var options = new UpdateParticipantOptions(pathRoomSid, pathSid) { Status = status }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ParticipantResource object + /// + /// Raw JSON string + /// ParticipantResource object represented by the provided JSON + public static ParticipantResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the participant's room + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The status of the Participant + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public ParticipantResource.StatusEnum Status { get; private set; } + /// + /// The string that identifies the resource's User + /// + [JsonProperty("identity")] + public string Identity { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The time of participant connected to the room in ISO 8601 format + /// + [JsonProperty("start_time")] + public DateTime? StartTime { get; private set; } + /// + /// The time when the participant disconnected from the room in ISO 8601 format + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// Duration of time in seconds the participant was connected + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ParticipantResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/RecordingRulesOptions.cs b/src/Twilio/Rest/Video/V1/Room/RecordingRulesOptions.cs index e437de313..6f50da847 100644 --- a/src/Twilio/Rest/Video/V1/Room/RecordingRulesOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/RecordingRulesOptions.cs @@ -9,73 +9,73 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room -{ - +{ + + /// + /// Returns a list of Recording Rules for the Room. + /// + public class FetchRecordingRulesOptions : IOptions + { /// - /// Returns a list of Recording Rules for the Room. + /// The SID of the Room resource where the recording rules to fetch apply /// - public class FetchRecordingRulesOptions : IOptions - { - /// - /// The SID of the Room resource where the recording rules to fetch apply - /// - public string PathRoomSid { get; } - - /// - /// Construct a new FetchRecordingRulesOptions - /// - /// The SID of the Room resource where the recording rules to fetch apply - public FetchRecordingRulesOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } + /// - /// Update the Recording Rules for the Room + /// Construct a new FetchRecordingRulesOptions /// - public class UpdateRecordingRulesOptions : IOptions - { - /// - /// The SID of the Room resource where the recording rules to update apply - /// - public string PathRoomSid { get; } - /// - /// A JSON-encoded array of recording rules - /// - public object Rules { get; set; } - - /// - /// Construct a new UpdateRecordingRulesOptions - /// - /// The SID of the Room resource where the recording rules to update apply - public UpdateRecordingRulesOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Rules != null) - { - p.Add(new KeyValuePair("Rules", Serializers.JsonObject(Rules))); - } - - return p; - } - } + /// The SID of the Room resource where the recording rules to fetch apply + public FetchRecordingRulesOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Update the Recording Rules for the Room + /// + public class UpdateRecordingRulesOptions : IOptions + { + /// + /// The SID of the Room resource where the recording rules to update apply + /// + public string PathRoomSid { get; } + /// + /// A JSON-encoded array of recording rules + /// + public object Rules { get; set; } + + /// + /// Construct a new UpdateRecordingRulesOptions + /// + /// The SID of the Room resource where the recording rules to update apply + public UpdateRecordingRulesOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Rules != null) + { + p.Add(new KeyValuePair("Rules", Serializers.JsonObject(Rules))); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/RecordingRulesResource.cs b/src/Twilio/Rest/Video/V1/Room/RecordingRulesResource.cs index c2358e238..d2373f315 100644 --- a/src/Twilio/Rest/Video/V1/Room/RecordingRulesResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/RecordingRulesResource.cs @@ -17,190 +17,190 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room -{ - - public class RecordingRulesResource : Resource - { - private static Request BuildFetchRequest(FetchRecordingRulesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/RecordingRules", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Returns a list of Recording Rules for the Room. - /// - /// Fetch RecordingRules parameters - /// Client to make requests to Twilio - /// A single instance of RecordingRules - public static RecordingRulesResource Fetch(FetchRecordingRulesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Returns a list of Recording Rules for the Room. - /// - /// Fetch RecordingRules parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingRules - public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingRulesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Returns a list of Recording Rules for the Room. - /// - /// The SID of the Room resource where the recording rules to fetch apply - /// Client to make requests to Twilio - /// A single instance of RecordingRules - public static RecordingRulesResource Fetch(string pathRoomSid, ITwilioRestClient client = null) - { - var options = new FetchRecordingRulesOptions(pathRoomSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Returns a list of Recording Rules for the Room. - /// - /// The SID of the Room resource where the recording rules to fetch apply - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingRules - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - ITwilioRestClient client = null) - { - var options = new FetchRecordingRulesOptions(pathRoomSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRecordingRulesOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/RecordingRules", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update the Recording Rules for the Room - /// - /// Update RecordingRules parameters - /// Client to make requests to Twilio - /// A single instance of RecordingRules - public static RecordingRulesResource Update(UpdateRecordingRulesOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update the Recording Rules for the Room - /// - /// Update RecordingRules parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingRules - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingRulesOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update the Recording Rules for the Room - /// - /// The SID of the Room resource where the recording rules to update apply - /// A JSON-encoded array of recording rules - /// Client to make requests to Twilio - /// A single instance of RecordingRules - public static RecordingRulesResource Update(string pathRoomSid, object rules = null, ITwilioRestClient client = null) - { - var options = new UpdateRecordingRulesOptions(pathRoomSid){Rules = rules}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update the Recording Rules for the Room - /// - /// The SID of the Room resource where the recording rules to update apply - /// A JSON-encoded array of recording rules - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RecordingRules - public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, - object rules = null, - ITwilioRestClient client = null) - { - var options = new UpdateRecordingRulesOptions(pathRoomSid){Rules = rules}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RecordingRulesResource object - /// - /// Raw JSON string - /// RecordingRulesResource object represented by the provided JSON - public static RecordingRulesResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Room resource for the Recording Rules - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// A collection of recording Rules that describe how to include or exclude matching tracks for recording - /// - [JsonProperty("rules")] - public List Rules { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - private RecordingRulesResource() - { - - } - } +{ + + public class RecordingRulesResource : Resource + { + private static Request BuildFetchRequest(FetchRecordingRulesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/RecordingRules", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Returns a list of Recording Rules for the Room. + /// + /// Fetch RecordingRules parameters + /// Client to make requests to Twilio + /// A single instance of RecordingRules + public static RecordingRulesResource Fetch(FetchRecordingRulesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Returns a list of Recording Rules for the Room. + /// + /// Fetch RecordingRules parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingRules + public static async System.Threading.Tasks.Task FetchAsync(FetchRecordingRulesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Returns a list of Recording Rules for the Room. + /// + /// The SID of the Room resource where the recording rules to fetch apply + /// Client to make requests to Twilio + /// A single instance of RecordingRules + public static RecordingRulesResource Fetch(string pathRoomSid, ITwilioRestClient client = null) + { + var options = new FetchRecordingRulesOptions(pathRoomSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Returns a list of Recording Rules for the Room. + /// + /// The SID of the Room resource where the recording rules to fetch apply + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingRules + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + ITwilioRestClient client = null) + { + var options = new FetchRecordingRulesOptions(pathRoomSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRecordingRulesOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/RecordingRules", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update the Recording Rules for the Room + /// + /// Update RecordingRules parameters + /// Client to make requests to Twilio + /// A single instance of RecordingRules + public static RecordingRulesResource Update(UpdateRecordingRulesOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update the Recording Rules for the Room + /// + /// Update RecordingRules parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingRules + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRecordingRulesOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update the Recording Rules for the Room + /// + /// The SID of the Room resource where the recording rules to update apply + /// A JSON-encoded array of recording rules + /// Client to make requests to Twilio + /// A single instance of RecordingRules + public static RecordingRulesResource Update(string pathRoomSid, object rules = null, ITwilioRestClient client = null) + { + var options = new UpdateRecordingRulesOptions(pathRoomSid) { Rules = rules }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update the Recording Rules for the Room + /// + /// The SID of the Room resource where the recording rules to update apply + /// A JSON-encoded array of recording rules + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RecordingRules + public static async System.Threading.Tasks.Task UpdateAsync(string pathRoomSid, + object rules = null, + ITwilioRestClient client = null) + { + var options = new UpdateRecordingRulesOptions(pathRoomSid) { Rules = rules }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RecordingRulesResource object + /// + /// Raw JSON string + /// RecordingRulesResource object represented by the provided JSON + public static RecordingRulesResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Room resource for the Recording Rules + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// A collection of recording Rules that describe how to include or exclude matching tracks for recording + /// + [JsonProperty("rules")] + public List Rules { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + private RecordingRulesResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/RoomRecordingOptions.cs b/src/Twilio/Rest/Video/V1/Room/RoomRecordingOptions.cs index e53d72aa0..37a95259d 100644 --- a/src/Twilio/Rest/Video/V1/Room/RoomRecordingOptions.cs +++ b/src/Twilio/Rest/Video/V1/Room/RoomRecordingOptions.cs @@ -9,146 +9,146 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1.Room -{ - +{ + + /// + /// FetchRoomRecordingOptions + /// + public class FetchRoomRecordingOptions : IOptions + { /// - /// FetchRoomRecordingOptions + /// The SID of the Room resource with the recording to fetch /// - public class FetchRoomRecordingOptions : IOptions - { - /// - /// The SID of the Room resource with the recording to fetch - /// - public string PathRoomSid { get; } - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoomRecordingOptions - /// - /// The SID of the Room resource with the recording to fetch - /// The SID that identifies the resource to fetch - public FetchRoomRecordingOptions(string pathRoomSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathRoomSid { get; } /// - /// ReadRoomRecordingOptions + /// The SID that identifies the resource to fetch /// - public class ReadRoomRecordingOptions : ReadOptions - { - /// - /// The SID of the room with the RoomRecording resources to read - /// - public string PathRoomSid { get; } - /// - /// Read only the recordings with this status - /// - public RoomRecordingResource.StatusEnum Status { get; set; } - /// - /// Read only the recordings that have this source_sid - /// - public string SourceSid { get; set; } - /// - /// Read only Recordings that started on or after this ISO 8601 datetime with time zone - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only Recordings that started before this ISO 8601 date-time with time zone - /// - public DateTime? DateCreatedBefore { get; set; } - - /// - /// Construct a new ReadRoomRecordingOptions - /// - /// The SID of the room with the RoomRecording resources to read - public ReadRoomRecordingOptions(string pathRoomSid) - { - PathRoomSid = pathRoomSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (SourceSid != null) - { - p.Add(new KeyValuePair("SourceSid", SourceSid.ToString())); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// DeleteRoomRecordingOptions + /// Construct a new FetchRoomRecordingOptions /// - public class DeleteRoomRecordingOptions : IOptions - { - /// - /// The SID of the room with the RoomRecording resource to delete - /// - public string PathRoomSid { get; } - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRoomRecordingOptions - /// - /// The SID of the room with the RoomRecording resource to delete - /// The SID that identifies the resource to delete - public DeleteRoomRecordingOptions(string pathRoomSid, string pathSid) - { - PathRoomSid = pathRoomSid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + /// The SID of the Room resource with the recording to fetch + /// The SID that identifies the resource to fetch + public FetchRoomRecordingOptions(string pathRoomSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadRoomRecordingOptions + /// + public class ReadRoomRecordingOptions : ReadOptions + { + /// + /// The SID of the room with the RoomRecording resources to read + /// + public string PathRoomSid { get; } + /// + /// Read only the recordings with this status + /// + public RoomRecordingResource.StatusEnum Status { get; set; } + /// + /// Read only the recordings that have this source_sid + /// + public string SourceSid { get; set; } + /// + /// Read only Recordings that started on or after this ISO 8601 datetime with time zone + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only Recordings that started before this ISO 8601 date-time with time zone + /// + public DateTime? DateCreatedBefore { get; set; } + + /// + /// Construct a new ReadRoomRecordingOptions + /// + /// The SID of the room with the RoomRecording resources to read + public ReadRoomRecordingOptions(string pathRoomSid) + { + PathRoomSid = pathRoomSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (SourceSid != null) + { + p.Add(new KeyValuePair("SourceSid", SourceSid.ToString())); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// DeleteRoomRecordingOptions + /// + public class DeleteRoomRecordingOptions : IOptions + { + /// + /// The SID of the room with the RoomRecording resource to delete + /// + public string PathRoomSid { get; } + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRoomRecordingOptions + /// + /// The SID of the room with the RoomRecording resource to delete + /// The SID that identifies the resource to delete + public DeleteRoomRecordingOptions(string pathRoomSid, string pathSid) + { + PathRoomSid = pathRoomSid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/Room/RoomRecordingResource.cs b/src/Twilio/Rest/Video/V1/Room/RoomRecordingResource.cs index e31e63718..76216f22c 100644 --- a/src/Twilio/Rest/Video/V1/Room/RoomRecordingResource.cs +++ b/src/Twilio/Rest/Video/V1/Room/RoomRecordingResource.cs @@ -17,468 +17,468 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1.Room -{ - - public class RoomRecordingResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Processing = new StatusEnum("processing"); - public static readonly StatusEnum Completed = new StatusEnum("completed"); - public static readonly StatusEnum Deleted = new StatusEnum("deleted"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - public TypeEnum() {} - public static implicit operator TypeEnum(string value) - { - return new TypeEnum(value); - } - - public static readonly TypeEnum Audio = new TypeEnum("audio"); - public static readonly TypeEnum Video = new TypeEnum("video"); - public static readonly TypeEnum Data = new TypeEnum("data"); - } - - public sealed class FormatEnum : StringEnum - { - private FormatEnum(string value) : base(value) {} - public FormatEnum() {} - public static implicit operator FormatEnum(string value) - { - return new FormatEnum(value); - } - - public static readonly FormatEnum Mka = new FormatEnum("mka"); - public static readonly FormatEnum Mkv = new FormatEnum("mkv"); - } - - public sealed class CodecEnum : StringEnum - { - private CodecEnum(string value) : base(value) {} - public CodecEnum() {} - public static implicit operator CodecEnum(string value) - { - return new CodecEnum(value); - } - - public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); - public static readonly CodecEnum H264 = new CodecEnum("H264"); - public static readonly CodecEnum Opus = new CodecEnum("OPUS"); - public static readonly CodecEnum Pcmu = new CodecEnum("PCMU"); - } - - private static Request BuildFetchRequest(FetchRoomRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Recordings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch RoomRecording parameters - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static RoomRecordingResource Fetch(FetchRoomRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch RoomRecording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task FetchAsync(FetchRoomRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Room resource with the recording to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static RoomRecordingResource Fetch(string pathRoomSid, string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoomRecordingOptions(pathRoomSid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Room resource with the recording to fetch - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoomRecordingOptions(pathRoomSid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoomRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Recordings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read RoomRecording parameters - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static ResourceSet Read(ReadRoomRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read RoomRecording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("recordings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the room with the RoomRecording resources to read - /// Read only the recordings with this status - /// Read only the recordings that have this source_sid - /// Read only Recordings that started on or after this ISO 8601 datetime with time zone - /// - /// Read only Recordings that started before this ISO 8601 date-time with time zone - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static ResourceSet Read(string pathRoomSid, - RoomRecordingResource.StatusEnum status = null, - string sourceSid = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomRecordingOptions(pathRoomSid){Status = status, SourceSid = sourceSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the room with the RoomRecording resources to read - /// Read only the recordings with this status - /// Read only the recordings that have this source_sid - /// Read only Recordings that started on or after this ISO 8601 datetime with time zone - /// - /// Read only Recordings that started before this ISO 8601 date-time with time zone - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, - RoomRecordingResource.StatusEnum status = null, - string sourceSid = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomRecordingOptions(pathRoomSid){Status = status, SourceSid = sourceSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("recordings", response.Content); - } - - private static Request BuildDeleteRequest(DeleteRoomRecordingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathRoomSid + "/Recordings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete RoomRecording parameters - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static bool Delete(DeleteRoomRecordingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete RoomRecording parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoomRecordingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the room with the RoomRecording resource to delete - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of RoomRecording - public static bool Delete(string pathRoomSid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRoomRecordingOptions(pathRoomSid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the room with the RoomRecording resource to delete - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RoomRecording - public static async System.Threading.Tasks.Task DeleteAsync(string pathRoomSid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteRoomRecordingOptions(pathRoomSid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoomRecordingResource object - /// - /// Raw JSON string - /// RoomRecordingResource object represented by the provided JSON - public static RoomRecordingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The status of the recording - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomRecordingResource.StatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the recording source - /// - [JsonProperty("source_sid")] - public string SourceSid { get; private set; } - /// - /// The size of the recorded track in bytes - /// - [JsonProperty("size")] - public long? Size { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The recording's media type - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomRecordingResource.TypeEnum Type { get; private set; } - /// - /// The duration of the recording in seconds - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The file format for the recording - /// - [JsonProperty("container_format")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomRecordingResource.FormatEnum ContainerFormat { get; private set; } - /// - /// The codec used for the recording - /// - [JsonProperty("codec")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomRecordingResource.CodecEnum Codec { get; private set; } - /// - /// A list of SIDs related to the Recording - /// - [JsonProperty("grouping_sids")] - public object GroupingSids { get; private set; } - /// - /// The name that was given to the source track of the recording - /// - [JsonProperty("track_name")] - public string TrackName { get; private set; } - /// - /// The number of milliseconds between a point in time that is common to all rooms in a group and when the source room of the recording started - /// - [JsonProperty("offset")] - public long? Offset { get; private set; } - /// - /// The SID of the Room resource the recording is associated with - /// - [JsonProperty("room_sid")] - public string RoomSid { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private RoomRecordingResource() - { - - } - } +{ + + public class RoomRecordingResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Processing = new StatusEnum("processing"); + public static readonly StatusEnum Completed = new StatusEnum("completed"); + public static readonly StatusEnum Deleted = new StatusEnum("deleted"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + public TypeEnum() { } + public static implicit operator TypeEnum(string value) + { + return new TypeEnum(value); + } + + public static readonly TypeEnum Audio = new TypeEnum("audio"); + public static readonly TypeEnum Video = new TypeEnum("video"); + public static readonly TypeEnum Data = new TypeEnum("data"); + } + + public sealed class FormatEnum : StringEnum + { + private FormatEnum(string value) : base(value) { } + public FormatEnum() { } + public static implicit operator FormatEnum(string value) + { + return new FormatEnum(value); + } + + public static readonly FormatEnum Mka = new FormatEnum("mka"); + public static readonly FormatEnum Mkv = new FormatEnum("mkv"); + } + + public sealed class CodecEnum : StringEnum + { + private CodecEnum(string value) : base(value) { } + public CodecEnum() { } + public static implicit operator CodecEnum(string value) + { + return new CodecEnum(value); + } + + public static readonly CodecEnum Vp8 = new CodecEnum("VP8"); + public static readonly CodecEnum H264 = new CodecEnum("H264"); + public static readonly CodecEnum Opus = new CodecEnum("OPUS"); + public static readonly CodecEnum Pcmu = new CodecEnum("PCMU"); + } + + private static Request BuildFetchRequest(FetchRoomRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Recordings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch RoomRecording parameters + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static RoomRecordingResource Fetch(FetchRoomRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch RoomRecording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task FetchAsync(FetchRoomRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Room resource with the recording to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static RoomRecordingResource Fetch(string pathRoomSid, string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoomRecordingOptions(pathRoomSid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Room resource with the recording to fetch + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task FetchAsync(string pathRoomSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoomRecordingOptions(pathRoomSid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoomRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Recordings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read RoomRecording parameters + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static ResourceSet Read(ReadRoomRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read RoomRecording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("recordings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the room with the RoomRecording resources to read + /// Read only the recordings with this status + /// Read only the recordings that have this source_sid + /// Read only Recordings that started on or after this ISO 8601 datetime with time zone + /// + /// Read only Recordings that started before this ISO 8601 date-time with time zone + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static ResourceSet Read(string pathRoomSid, + RoomRecordingResource.StatusEnum status = null, + string sourceSid = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomRecordingOptions(pathRoomSid) { Status = status, SourceSid = sourceSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the room with the RoomRecording resources to read + /// Read only the recordings with this status + /// Read only the recordings that have this source_sid + /// Read only Recordings that started on or after this ISO 8601 datetime with time zone + /// + /// Read only Recordings that started before this ISO 8601 date-time with time zone + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task> ReadAsync(string pathRoomSid, + RoomRecordingResource.StatusEnum status = null, + string sourceSid = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomRecordingOptions(pathRoomSid) { Status = status, SourceSid = sourceSid, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("recordings", response.Content); + } + + private static Request BuildDeleteRequest(DeleteRoomRecordingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathRoomSid + "/Recordings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete RoomRecording parameters + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static bool Delete(DeleteRoomRecordingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete RoomRecording parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRoomRecordingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the room with the RoomRecording resource to delete + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of RoomRecording + public static bool Delete(string pathRoomSid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRoomRecordingOptions(pathRoomSid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the room with the RoomRecording resource to delete + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RoomRecording + public static async System.Threading.Tasks.Task DeleteAsync(string pathRoomSid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteRoomRecordingOptions(pathRoomSid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoomRecordingResource object + /// + /// Raw JSON string + /// RoomRecordingResource object represented by the provided JSON + public static RoomRecordingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The status of the recording + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomRecordingResource.StatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the recording source + /// + [JsonProperty("source_sid")] + public string SourceSid { get; private set; } + /// + /// The size of the recorded track in bytes + /// + [JsonProperty("size")] + public long? Size { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The recording's media type + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomRecordingResource.TypeEnum Type { get; private set; } + /// + /// The duration of the recording in seconds + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The file format for the recording + /// + [JsonProperty("container_format")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomRecordingResource.FormatEnum ContainerFormat { get; private set; } + /// + /// The codec used for the recording + /// + [JsonProperty("codec")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomRecordingResource.CodecEnum Codec { get; private set; } + /// + /// A list of SIDs related to the Recording + /// + [JsonProperty("grouping_sids")] + public object GroupingSids { get; private set; } + /// + /// The name that was given to the source track of the recording + /// + [JsonProperty("track_name")] + public string TrackName { get; private set; } + /// + /// The number of milliseconds between a point in time that is common to all rooms in a group and when the source room of the recording started + /// + [JsonProperty("offset")] + public long? Offset { get; private set; } + /// + /// The SID of the Room resource the recording is associated with + /// + [JsonProperty("room_sid")] + public string RoomSid { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private RoomRecordingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RoomOptions.cs b/src/Twilio/Rest/Video/V1/RoomOptions.cs index d381c2ec8..16a32e2c6 100644 --- a/src/Twilio/Rest/Video/V1/RoomOptions.cs +++ b/src/Twilio/Rest/Video/V1/RoomOptions.cs @@ -10,282 +10,282 @@ using Twilio.Converters; namespace Twilio.Rest.Video.V1 -{ - +{ + + /// + /// FetchRoomOptions + /// + public class FetchRoomOptions : IOptions + { /// - /// FetchRoomOptions + /// The SID that identifies the resource to fetch /// - public class FetchRoomOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRoomOptions - /// - /// The SID that identifies the resource to fetch - public FetchRoomOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateRoomOptions + /// Construct a new FetchRoomOptions /// - public class CreateRoomOptions : IOptions - { - /// - /// Enable Twilio's Network Traversal TURN service - /// - public bool? EnableTurn { get; set; } - /// - /// The type of room - /// - public RoomResource.RoomTypeEnum Type { get; set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The URL to send status information to your application - /// - public Uri StatusCallback { get; set; } - /// - /// The HTTP method we should use to call status_callback - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// The maximum number of concurrent Participants allowed in the room - /// - public int? MaxParticipants { get; set; } - /// - /// Whether to start recording when Participants connect - /// - public bool? RecordParticipantsOnConnect { get; set; } - /// - /// An array of the video codecs that are supported when publishing a track in the room - /// - public List VideoCodecs { get; set; } - /// - /// The region for the media server in Group Rooms - /// - public string MediaRegion { get; set; } - /// - /// A collection of Recording Rules - /// - public object RecordingRules { get; set; } - /// - /// Indicates whether the room will only contain audio track participants for group rooms. - /// - public bool? AudioOnly { get; set; } - /// - /// The maximum number of seconds a Participant can be connected to the room - /// - public int? MaxParticipantDuration { get; set; } - /// - /// Configures the time a room will remain active after last participant leaves. - /// - public int? EmptyRoomTimeout { get; set; } - /// - /// Configures the time a room will remain active when no one joins. - /// - public int? UnusedRoomTimeout { get; set; } - - /// - /// Construct a new CreateRoomOptions - /// - public CreateRoomOptions() - { - VideoCodecs = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (EnableTurn != null) - { - p.Add(new KeyValuePair("EnableTurn", EnableTurn.Value.ToString().ToLower())); - } - - if (Type != null) - { - p.Add(new KeyValuePair("Type", Type.ToString())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (StatusCallback != null) - { - p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (MaxParticipants != null) - { - p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); - } - - if (RecordParticipantsOnConnect != null) - { - p.Add(new KeyValuePair("RecordParticipantsOnConnect", RecordParticipantsOnConnect.Value.ToString().ToLower())); - } - - if (VideoCodecs != null) - { - p.AddRange(VideoCodecs.Select(prop => new KeyValuePair("VideoCodecs", prop.ToString()))); - } - - if (MediaRegion != null) - { - p.Add(new KeyValuePair("MediaRegion", MediaRegion)); - } - - if (RecordingRules != null) - { - p.Add(new KeyValuePair("RecordingRules", Serializers.JsonObject(RecordingRules))); - } - - if (AudioOnly != null) - { - p.Add(new KeyValuePair("AudioOnly", AudioOnly.Value.ToString().ToLower())); - } - - if (MaxParticipantDuration != null) - { - p.Add(new KeyValuePair("MaxParticipantDuration", MaxParticipantDuration.ToString())); - } - - if (EmptyRoomTimeout != null) - { - p.Add(new KeyValuePair("EmptyRoomTimeout", EmptyRoomTimeout.ToString())); - } - - if (UnusedRoomTimeout != null) - { - p.Add(new KeyValuePair("UnusedRoomTimeout", UnusedRoomTimeout.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + public FetchRoomOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// ReadRoomOptions + /// Generate the necessary parameters /// - public class ReadRoomOptions : ReadOptions - { - /// - /// Read only the rooms with this status - /// - public RoomResource.RoomStatusEnum Status { get; set; } - /// - /// Read only rooms with this unique_name - /// - public string UniqueName { get; set; } - /// - /// Read only rooms that started on or after this date, given as YYYY-MM-DD - /// - public DateTime? DateCreatedAfter { get; set; } - /// - /// Read only rooms that started before this date, given as YYYY-MM-DD - /// - public DateTime? DateCreatedBefore { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (DateCreatedAfter != null) - { - p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); - } - - if (DateCreatedBefore != null) - { - p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRoomOptions + /// + public class CreateRoomOptions : IOptions + { /// - /// UpdateRoomOptions + /// Enable Twilio's Network Traversal TURN service /// - public class UpdateRoomOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// The new status of the resource - /// - public RoomResource.RoomStatusEnum Status { get; } - - /// - /// Construct a new UpdateRoomOptions - /// - /// The SID that identifies the resource to update - /// The new status of the resource - public UpdateRoomOptions(string pathSid, RoomResource.RoomStatusEnum status) - { - PathSid = pathSid; - Status = status; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - return p; - } - } + public bool? EnableTurn { get; set; } + /// + /// The type of room + /// + public RoomResource.RoomTypeEnum Type { get; set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The URL to send status information to your application + /// + public Uri StatusCallback { get; set; } + /// + /// The HTTP method we should use to call status_callback + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// The maximum number of concurrent Participants allowed in the room + /// + public int? MaxParticipants { get; set; } + /// + /// Whether to start recording when Participants connect + /// + public bool? RecordParticipantsOnConnect { get; set; } + /// + /// An array of the video codecs that are supported when publishing a track in the room + /// + public List VideoCodecs { get; set; } + /// + /// The region for the media server in Group Rooms + /// + public string MediaRegion { get; set; } + /// + /// A collection of Recording Rules + /// + public object RecordingRules { get; set; } + /// + /// Indicates whether the room will only contain audio track participants for group rooms. + /// + public bool? AudioOnly { get; set; } + /// + /// The maximum number of seconds a Participant can be connected to the room + /// + public int? MaxParticipantDuration { get; set; } + /// + /// Configures the time a room will remain active after last participant leaves. + /// + public int? EmptyRoomTimeout { get; set; } + /// + /// Configures the time a room will remain active when no one joins. + /// + public int? UnusedRoomTimeout { get; set; } + + /// + /// Construct a new CreateRoomOptions + /// + public CreateRoomOptions() + { + VideoCodecs = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (EnableTurn != null) + { + p.Add(new KeyValuePair("EnableTurn", EnableTurn.Value.ToString().ToLower())); + } + + if (Type != null) + { + p.Add(new KeyValuePair("Type", Type.ToString())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (StatusCallback != null) + { + p.Add(new KeyValuePair("StatusCallback", Serializers.Url(StatusCallback))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (MaxParticipants != null) + { + p.Add(new KeyValuePair("MaxParticipants", MaxParticipants.ToString())); + } + + if (RecordParticipantsOnConnect != null) + { + p.Add(new KeyValuePair("RecordParticipantsOnConnect", RecordParticipantsOnConnect.Value.ToString().ToLower())); + } + + if (VideoCodecs != null) + { + p.AddRange(VideoCodecs.Select(prop => new KeyValuePair("VideoCodecs", prop.ToString()))); + } + + if (MediaRegion != null) + { + p.Add(new KeyValuePair("MediaRegion", MediaRegion)); + } + + if (RecordingRules != null) + { + p.Add(new KeyValuePair("RecordingRules", Serializers.JsonObject(RecordingRules))); + } + + if (AudioOnly != null) + { + p.Add(new KeyValuePair("AudioOnly", AudioOnly.Value.ToString().ToLower())); + } + + if (MaxParticipantDuration != null) + { + p.Add(new KeyValuePair("MaxParticipantDuration", MaxParticipantDuration.ToString())); + } + + if (EmptyRoomTimeout != null) + { + p.Add(new KeyValuePair("EmptyRoomTimeout", EmptyRoomTimeout.ToString())); + } + + if (UnusedRoomTimeout != null) + { + p.Add(new KeyValuePair("UnusedRoomTimeout", UnusedRoomTimeout.ToString())); + } + + return p; + } + } + + /// + /// ReadRoomOptions + /// + public class ReadRoomOptions : ReadOptions + { + /// + /// Read only the rooms with this status + /// + public RoomResource.RoomStatusEnum Status { get; set; } + /// + /// Read only rooms with this unique_name + /// + public string UniqueName { get; set; } + /// + /// Read only rooms that started on or after this date, given as YYYY-MM-DD + /// + public DateTime? DateCreatedAfter { get; set; } + /// + /// Read only rooms that started before this date, given as YYYY-MM-DD + /// + public DateTime? DateCreatedBefore { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (DateCreatedAfter != null) + { + p.Add(new KeyValuePair("DateCreatedAfter", Serializers.DateTimeIso8601(DateCreatedAfter))); + } + + if (DateCreatedBefore != null) + { + p.Add(new KeyValuePair("DateCreatedBefore", Serializers.DateTimeIso8601(DateCreatedBefore))); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateRoomOptions + /// + public class UpdateRoomOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// The new status of the resource + /// + public RoomResource.RoomStatusEnum Status { get; } + + /// + /// Construct a new UpdateRoomOptions + /// + /// The SID that identifies the resource to update + /// The new status of the resource + public UpdateRoomOptions(string pathSid, RoomResource.RoomStatusEnum status) + { + PathSid = pathSid; + Status = status; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Video/V1/RoomResource.cs b/src/Twilio/Rest/Video/V1/RoomResource.cs index d9a24eb3a..ba2825175 100644 --- a/src/Twilio/Rest/Video/V1/RoomResource.cs +++ b/src/Twilio/Rest/Video/V1/RoomResource.cs @@ -17,606 +17,606 @@ using Twilio.Types; namespace Twilio.Rest.Video.V1 -{ - - public class RoomResource : Resource - { - public sealed class RoomStatusEnum : StringEnum - { - private RoomStatusEnum(string value) : base(value) {} - public RoomStatusEnum() {} - public static implicit operator RoomStatusEnum(string value) - { - return new RoomStatusEnum(value); - } - - public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in-progress"); - public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); - public static readonly RoomStatusEnum Failed = new RoomStatusEnum("failed"); - } - - public sealed class RoomTypeEnum : StringEnum - { - private RoomTypeEnum(string value) : base(value) {} - public RoomTypeEnum() {} - public static implicit operator RoomTypeEnum(string value) - { - return new RoomTypeEnum(value); - } - - public static readonly RoomTypeEnum Go = new RoomTypeEnum("go"); - public static readonly RoomTypeEnum PeerToPeer = new RoomTypeEnum("peer-to-peer"); - public static readonly RoomTypeEnum Group = new RoomTypeEnum("group"); - public static readonly RoomTypeEnum GroupSmall = new RoomTypeEnum("group-small"); - } - - public sealed class VideoCodecEnum : StringEnum - { - private VideoCodecEnum(string value) : base(value) {} - public VideoCodecEnum() {} - public static implicit operator VideoCodecEnum(string value) - { - return new VideoCodecEnum(value); - } - - public static readonly VideoCodecEnum Vp8 = new VideoCodecEnum("VP8"); - public static readonly VideoCodecEnum H264 = new VideoCodecEnum("H264"); - } - - private static Request BuildFetchRequest(FetchRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Fetch(FetchRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task FetchAsync(FetchRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRoomOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRoomOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Rooms", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Create(CreateRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task CreateAsync(CreateRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// Enable Twilio's Network Traversal TURN service - /// The type of room - /// An application-defined string that uniquely identifies the resource - /// The URL to send status information to your application - /// The HTTP method we should use to call status_callback - /// The maximum number of concurrent Participants allowed in the room - /// Whether to start recording when Participants connect - /// An array of the video codecs that are supported when publishing a track in the room - /// - /// The region for the media server in Group Rooms - /// A collection of Recording Rules - /// Indicates whether the room will only contain audio track participants for group rooms. - /// - /// The maximum number of seconds a Participant can be connected to the room - /// - /// Configures the time a room will remain active after last participant leaves. - /// - /// Configures the time a room will remain active when no one joins. - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Create(bool? enableTurn = null, - RoomResource.RoomTypeEnum type = null, - string uniqueName = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - int? maxParticipants = null, - bool? recordParticipantsOnConnect = null, - List videoCodecs = null, - string mediaRegion = null, - object recordingRules = null, - bool? audioOnly = null, - int? maxParticipantDuration = null, - int? emptyRoomTimeout = null, - int? unusedRoomTimeout = null, - ITwilioRestClient client = null) - { - var options = new CreateRoomOptions(){EnableTurn = enableTurn, Type = type, UniqueName = uniqueName, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxParticipants = maxParticipants, RecordParticipantsOnConnect = recordParticipantsOnConnect, VideoCodecs = videoCodecs, MediaRegion = mediaRegion, RecordingRules = recordingRules, AudioOnly = audioOnly, MaxParticipantDuration = maxParticipantDuration, EmptyRoomTimeout = emptyRoomTimeout, UnusedRoomTimeout = unusedRoomTimeout}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// Enable Twilio's Network Traversal TURN service - /// The type of room - /// An application-defined string that uniquely identifies the resource - /// The URL to send status information to your application - /// The HTTP method we should use to call status_callback - /// The maximum number of concurrent Participants allowed in the room - /// Whether to start recording when Participants connect - /// An array of the video codecs that are supported when publishing a track in the room - /// - /// The region for the media server in Group Rooms - /// A collection of Recording Rules - /// Indicates whether the room will only contain audio track participants for group rooms. - /// - /// The maximum number of seconds a Participant can be connected to the room - /// - /// Configures the time a room will remain active after last participant leaves. - /// - /// Configures the time a room will remain active when no one joins. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task CreateAsync(bool? enableTurn = null, - RoomResource.RoomTypeEnum type = null, - string uniqueName = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - int? maxParticipants = null, - bool? recordParticipantsOnConnect = null, - List videoCodecs = null, - string mediaRegion = null, - object recordingRules = null, - bool? audioOnly = null, - int? maxParticipantDuration = null, - int? emptyRoomTimeout = null, - int? unusedRoomTimeout = null, - ITwilioRestClient client = null) - { - var options = new CreateRoomOptions(){EnableTurn = enableTurn, Type = type, UniqueName = uniqueName, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxParticipants = maxParticipants, RecordParticipantsOnConnect = recordParticipantsOnConnect, VideoCodecs = videoCodecs, MediaRegion = mediaRegion, RecordingRules = recordingRules, AudioOnly = audioOnly, MaxParticipantDuration = maxParticipantDuration, EmptyRoomTimeout = emptyRoomTimeout, UnusedRoomTimeout = unusedRoomTimeout}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Video, - "/v1/Rooms", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static ResourceSet Read(ReadRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("rooms", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("rooms", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Read only the rooms with this status - /// Read only rooms with this unique_name - /// Read only rooms that started on or after this date, given as YYYY-MM-DD - /// Read only rooms that started before this date, given as YYYY-MM-DD - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Room - public static ResourceSet Read(RoomResource.RoomStatusEnum status = null, - string uniqueName = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomOptions(){Status = status, UniqueName = uniqueName, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read only the rooms with this status - /// Read only rooms with this unique_name - /// Read only rooms that started on or after this date, given as YYYY-MM-DD - /// Read only rooms that started before this date, given as YYYY-MM-DD - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task> ReadAsync(RoomResource.RoomStatusEnum status = null, - string uniqueName = null, - DateTime? dateCreatedAfter = null, - DateTime? dateCreatedBefore = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRoomOptions(){Status = status, UniqueName = uniqueName, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Video) - ); - - var response = client.Request(request); - return Page.FromJson("rooms", response.Content); - } - - private static Request BuildUpdateRequest(UpdateRoomOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Video, - "/v1/Rooms/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update Room parameters - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Update(UpdateRoomOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update Room parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoomOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// The new status of the resource - /// Client to make requests to Twilio - /// A single instance of Room - public static RoomResource Update(string pathSid, - RoomResource.RoomStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateRoomOptions(pathSid, status); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// The new status of the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Room - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - RoomResource.RoomStatusEnum status, - ITwilioRestClient client = null) - { - var options = new UpdateRoomOptions(pathSid, status); - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RoomResource object - /// - /// Raw JSON string - /// RoomResource object represented by the provided JSON - public static RoomResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The status of the room - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.RoomStatusEnum Status { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// Enable Twilio's Network Traversal TURN service - /// - [JsonProperty("enable_turn")] - public bool? EnableTurn { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The URL to send status information to your application - /// - [JsonProperty("status_callback")] - public Uri StatusCallback { get; private set; } - /// - /// The HTTP method we use to call status_callback - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// The UTC end time of the room in UTC ISO 8601 format - /// - [JsonProperty("end_time")] - public DateTime? EndTime { get; private set; } - /// - /// The duration of the room in seconds - /// - [JsonProperty("duration")] - public int? Duration { get; private set; } - /// - /// The type of room - /// - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public RoomResource.RoomTypeEnum Type { get; private set; } - /// - /// The maximum number of concurrent Participants allowed in the room - /// - [JsonProperty("max_participants")] - public int? MaxParticipants { get; private set; } - /// - /// The maximum number of seconds a Participant can be connected to the room - /// - [JsonProperty("max_participant_duration")] - public int? MaxParticipantDuration { get; private set; } - /// - /// The maximum number of published tracks allowed in the room at the same time - /// - [JsonProperty("max_concurrent_published_tracks")] - public int? MaxConcurrentPublishedTracks { get; private set; } - /// - /// Whether to start recording when Participants connect - /// - [JsonProperty("record_participants_on_connect")] - public bool? RecordParticipantsOnConnect { get; private set; } - /// - /// An array of the video codecs that are supported when publishing a track in the room - /// - [JsonProperty("video_codecs")] - [JsonConverter(typeof(StringEnumConverter))] - public List VideoCodecs { get; private set; } - /// - /// The region for the media server in Group Rooms - /// - [JsonProperty("media_region")] - public string MediaRegion { get; private set; } - /// - /// Indicates whether the room will only contain audio track participants for group rooms. - /// - [JsonProperty("audio_only")] - public bool? AudioOnly { get; private set; } - /// - /// The time a room will remain active after last participant leaves. - /// - [JsonProperty("empty_room_timeout")] - public int? EmptyRoomTimeout { get; private set; } - /// - /// The time a room will remain active when no one joins. - /// - [JsonProperty("unused_room_timeout")] - public int? UnusedRoomTimeout { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private RoomResource() - { - - } - } +{ + + public class RoomResource : Resource + { + public sealed class RoomStatusEnum : StringEnum + { + private RoomStatusEnum(string value) : base(value) { } + public RoomStatusEnum() { } + public static implicit operator RoomStatusEnum(string value) + { + return new RoomStatusEnum(value); + } + + public static readonly RoomStatusEnum InProgress = new RoomStatusEnum("in-progress"); + public static readonly RoomStatusEnum Completed = new RoomStatusEnum("completed"); + public static readonly RoomStatusEnum Failed = new RoomStatusEnum("failed"); + } + + public sealed class RoomTypeEnum : StringEnum + { + private RoomTypeEnum(string value) : base(value) { } + public RoomTypeEnum() { } + public static implicit operator RoomTypeEnum(string value) + { + return new RoomTypeEnum(value); + } + + public static readonly RoomTypeEnum Go = new RoomTypeEnum("go"); + public static readonly RoomTypeEnum PeerToPeer = new RoomTypeEnum("peer-to-peer"); + public static readonly RoomTypeEnum Group = new RoomTypeEnum("group"); + public static readonly RoomTypeEnum GroupSmall = new RoomTypeEnum("group-small"); + } + + public sealed class VideoCodecEnum : StringEnum + { + private VideoCodecEnum(string value) : base(value) { } + public VideoCodecEnum() { } + public static implicit operator VideoCodecEnum(string value) + { + return new VideoCodecEnum(value); + } + + public static readonly VideoCodecEnum Vp8 = new VideoCodecEnum("VP8"); + public static readonly VideoCodecEnum H264 = new VideoCodecEnum("H264"); + } + + private static Request BuildFetchRequest(FetchRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Fetch(FetchRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task FetchAsync(FetchRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRoomOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRoomOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Rooms", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Create(CreateRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task CreateAsync(CreateRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// Enable Twilio's Network Traversal TURN service + /// The type of room + /// An application-defined string that uniquely identifies the resource + /// The URL to send status information to your application + /// The HTTP method we should use to call status_callback + /// The maximum number of concurrent Participants allowed in the room + /// Whether to start recording when Participants connect + /// An array of the video codecs that are supported when publishing a track in the room + /// + /// The region for the media server in Group Rooms + /// A collection of Recording Rules + /// Indicates whether the room will only contain audio track participants for group rooms. + /// + /// The maximum number of seconds a Participant can be connected to the room + /// + /// Configures the time a room will remain active after last participant leaves. + /// + /// Configures the time a room will remain active when no one joins. + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Create(bool? enableTurn = null, + RoomResource.RoomTypeEnum type = null, + string uniqueName = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + int? maxParticipants = null, + bool? recordParticipantsOnConnect = null, + List videoCodecs = null, + string mediaRegion = null, + object recordingRules = null, + bool? audioOnly = null, + int? maxParticipantDuration = null, + int? emptyRoomTimeout = null, + int? unusedRoomTimeout = null, + ITwilioRestClient client = null) + { + var options = new CreateRoomOptions() { EnableTurn = enableTurn, Type = type, UniqueName = uniqueName, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxParticipants = maxParticipants, RecordParticipantsOnConnect = recordParticipantsOnConnect, VideoCodecs = videoCodecs, MediaRegion = mediaRegion, RecordingRules = recordingRules, AudioOnly = audioOnly, MaxParticipantDuration = maxParticipantDuration, EmptyRoomTimeout = emptyRoomTimeout, UnusedRoomTimeout = unusedRoomTimeout }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// Enable Twilio's Network Traversal TURN service + /// The type of room + /// An application-defined string that uniquely identifies the resource + /// The URL to send status information to your application + /// The HTTP method we should use to call status_callback + /// The maximum number of concurrent Participants allowed in the room + /// Whether to start recording when Participants connect + /// An array of the video codecs that are supported when publishing a track in the room + /// + /// The region for the media server in Group Rooms + /// A collection of Recording Rules + /// Indicates whether the room will only contain audio track participants for group rooms. + /// + /// The maximum number of seconds a Participant can be connected to the room + /// + /// Configures the time a room will remain active after last participant leaves. + /// + /// Configures the time a room will remain active when no one joins. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task CreateAsync(bool? enableTurn = null, + RoomResource.RoomTypeEnum type = null, + string uniqueName = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + int? maxParticipants = null, + bool? recordParticipantsOnConnect = null, + List videoCodecs = null, + string mediaRegion = null, + object recordingRules = null, + bool? audioOnly = null, + int? maxParticipantDuration = null, + int? emptyRoomTimeout = null, + int? unusedRoomTimeout = null, + ITwilioRestClient client = null) + { + var options = new CreateRoomOptions() { EnableTurn = enableTurn, Type = type, UniqueName = uniqueName, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, MaxParticipants = maxParticipants, RecordParticipantsOnConnect = recordParticipantsOnConnect, VideoCodecs = videoCodecs, MediaRegion = mediaRegion, RecordingRules = recordingRules, AudioOnly = audioOnly, MaxParticipantDuration = maxParticipantDuration, EmptyRoomTimeout = emptyRoomTimeout, UnusedRoomTimeout = unusedRoomTimeout }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Video, + "/v1/Rooms", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static ResourceSet Read(ReadRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("rooms", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task> ReadAsync(ReadRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("rooms", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Read only the rooms with this status + /// Read only rooms with this unique_name + /// Read only rooms that started on or after this date, given as YYYY-MM-DD + /// Read only rooms that started before this date, given as YYYY-MM-DD + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Room + public static ResourceSet Read(RoomResource.RoomStatusEnum status = null, + string uniqueName = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomOptions() { Status = status, UniqueName = uniqueName, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read only the rooms with this status + /// Read only rooms with this unique_name + /// Read only rooms that started on or after this date, given as YYYY-MM-DD + /// Read only rooms that started before this date, given as YYYY-MM-DD + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task> ReadAsync(RoomResource.RoomStatusEnum status = null, + string uniqueName = null, + DateTime? dateCreatedAfter = null, + DateTime? dateCreatedBefore = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRoomOptions() { Status = status, UniqueName = uniqueName, DateCreatedAfter = dateCreatedAfter, DateCreatedBefore = dateCreatedBefore, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Video) + ); + + var response = client.Request(request); + return Page.FromJson("rooms", response.Content); + } + + private static Request BuildUpdateRequest(UpdateRoomOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Video, + "/v1/Rooms/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update Room parameters + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Update(UpdateRoomOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update Room parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRoomOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// The new status of the resource + /// Client to make requests to Twilio + /// A single instance of Room + public static RoomResource Update(string pathSid, + RoomResource.RoomStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateRoomOptions(pathSid, status); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// The new status of the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Room + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + RoomResource.RoomStatusEnum status, + ITwilioRestClient client = null) + { + var options = new UpdateRoomOptions(pathSid, status); + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RoomResource object + /// + /// Raw JSON string + /// RoomResource object represented by the provided JSON + public static RoomResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The status of the room + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.RoomStatusEnum Status { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// Enable Twilio's Network Traversal TURN service + /// + [JsonProperty("enable_turn")] + public bool? EnableTurn { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The URL to send status information to your application + /// + [JsonProperty("status_callback")] + public Uri StatusCallback { get; private set; } + /// + /// The HTTP method we use to call status_callback + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// The UTC end time of the room in UTC ISO 8601 format + /// + [JsonProperty("end_time")] + public DateTime? EndTime { get; private set; } + /// + /// The duration of the room in seconds + /// + [JsonProperty("duration")] + public int? Duration { get; private set; } + /// + /// The type of room + /// + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public RoomResource.RoomTypeEnum Type { get; private set; } + /// + /// The maximum number of concurrent Participants allowed in the room + /// + [JsonProperty("max_participants")] + public int? MaxParticipants { get; private set; } + /// + /// The maximum number of seconds a Participant can be connected to the room + /// + [JsonProperty("max_participant_duration")] + public int? MaxParticipantDuration { get; private set; } + /// + /// The maximum number of published tracks allowed in the room at the same time + /// + [JsonProperty("max_concurrent_published_tracks")] + public int? MaxConcurrentPublishedTracks { get; private set; } + /// + /// Whether to start recording when Participants connect + /// + [JsonProperty("record_participants_on_connect")] + public bool? RecordParticipantsOnConnect { get; private set; } + /// + /// An array of the video codecs that are supported when publishing a track in the room + /// + [JsonProperty("video_codecs")] + [JsonConverter(typeof(StringEnumConverter))] + public List VideoCodecs { get; private set; } + /// + /// The region for the media server in Group Rooms + /// + [JsonProperty("media_region")] + public string MediaRegion { get; private set; } + /// + /// Indicates whether the room will only contain audio track participants for group rooms. + /// + [JsonProperty("audio_only")] + public bool? AudioOnly { get; private set; } + /// + /// The time a room will remain active after last participant leaves. + /// + [JsonProperty("empty_room_timeout")] + public int? EmptyRoomTimeout { get; private set; } + /// + /// The time a room will remain active when no one joins. + /// + [JsonProperty("unused_room_timeout")] + public int? UnusedRoomTimeout { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private RoomResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ArchivedCallOptions.cs b/src/Twilio/Rest/Voice/V1/ArchivedCallOptions.cs index 064e64848..ab16fcba9 100644 --- a/src/Twilio/Rest/Voice/V1/ArchivedCallOptions.cs +++ b/src/Twilio/Rest/Voice/V1/ArchivedCallOptions.cs @@ -9,43 +9,43 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1 -{ - +{ + + /// + /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. + /// + /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// + public class DeleteArchivedCallOptions : IOptions + { /// - /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. - /// - /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// The date of the Call in UTC. /// - public class DeleteArchivedCallOptions : IOptions - { - /// - /// The date of the Call in UTC. - /// - public DateTime? PathDate { get; } - /// - /// The unique string that identifies this resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteArchivedCallOptions - /// - /// The date of the Call in UTC. - /// The unique string that identifies this resource - public DeleteArchivedCallOptions(DateTime? pathDate, string pathSid) - { - PathDate = pathDate; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public DateTime? PathDate { get; } + /// + /// The unique string that identifies this resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteArchivedCallOptions + /// + /// The date of the Call in UTC. + /// The unique string that identifies this resource + public DeleteArchivedCallOptions(DateTime? pathDate, string pathSid) + { + PathDate = pathDate; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ArchivedCallResource.cs b/src/Twilio/Rest/Voice/V1/ArchivedCallResource.cs index 179809438..7f71a5d02 100644 --- a/src/Twilio/Rest/Voice/V1/ArchivedCallResource.cs +++ b/src/Twilio/Rest/Voice/V1/ArchivedCallResource.cs @@ -18,118 +18,118 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1 -{ - - public class ArchivedCallResource : Resource - { - private static Request BuildDeleteRequest(DeleteArchivedCallOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/Archives/" + (options.PathDate.Value.ToString("yyyy-MM-dd")) + "/Calls/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. - /// - /// Delete ArchivedCall parameters - /// Client to make requests to Twilio - /// A single instance of ArchivedCall - public static bool Delete(DeleteArchivedCallOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. - /// - /// Delete ArchivedCall parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ArchivedCall - public static async System.Threading.Tasks.Task DeleteAsync(DeleteArchivedCallOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. - /// - /// The date of the Call in UTC. - /// The unique string that identifies this resource - /// Client to make requests to Twilio - /// A single instance of ArchivedCall - public static bool Delete(DateTime? pathDate, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteArchivedCallOptions(pathDate, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. - /// - /// The date of the Call in UTC. - /// The unique string that identifies this resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ArchivedCall - public static async System.Threading.Tasks.Task DeleteAsync(DateTime? pathDate, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteArchivedCallOptions(pathDate, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ArchivedCallResource object - /// - /// Raw JSON string - /// ArchivedCallResource object represented by the provided JSON - public static ArchivedCallResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// date - /// - [JsonProperty("date")] - public DateTime? Date { get; private set; } - /// - /// sid - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ArchivedCallResource() - { - - } - } +{ + + public class ArchivedCallResource : Resource + { + private static Request BuildDeleteRequest(DeleteArchivedCallOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/Archives/" + (options.PathDate.Value.ToString("yyyy-MM-dd")) + "/Calls/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// + /// Delete ArchivedCall parameters + /// Client to make requests to Twilio + /// A single instance of ArchivedCall + public static bool Delete(DeleteArchivedCallOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// + /// Delete ArchivedCall parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ArchivedCall + public static async System.Threading.Tasks.Task DeleteAsync(DeleteArchivedCallOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// + /// The date of the Call in UTC. + /// The unique string that identifies this resource + /// Client to make requests to Twilio + /// A single instance of ArchivedCall + public static bool Delete(DateTime? pathDate, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteArchivedCallOptions(pathDate, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API. + /// + /// The date of the Call in UTC. + /// The unique string that identifies this resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ArchivedCall + public static async System.Threading.Tasks.Task DeleteAsync(DateTime? pathDate, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteArchivedCallOptions(pathDate, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ArchivedCallResource object + /// + /// Raw JSON string + /// ArchivedCallResource object represented by the provided JSON + public static ArchivedCallResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// date + /// + [JsonProperty("date")] + public DateTime? Date { get; private set; } + /// + /// sid + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ArchivedCallResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ByocTrunkOptions.cs b/src/Twilio/Rest/Voice/V1/ByocTrunkOptions.cs index a7094bf3c..5ac2fffbd 100644 --- a/src/Twilio/Rest/Voice/V1/ByocTrunkOptions.cs +++ b/src/Twilio/Rest/Voice/V1/ByocTrunkOptions.cs @@ -9,309 +9,309 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1 -{ - +{ + + /// + /// CreateByocTrunkOptions + /// + public class CreateByocTrunkOptions : IOptions + { /// - /// CreateByocTrunkOptions + /// A string to describe the resource /// - public class CreateByocTrunkOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The URL we should call when receiving a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The HTTP method to use with voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when an error occurs in executing TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method to use with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL that we should call to pass status updates - /// - public Uri StatusCallbackUrl { get; set; } - /// - /// The HTTP method we should use to call `status_callback_url` - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// - public bool? CnamLookupEnabled { get; set; } - /// - /// Origination Connection Policy (to your Carrier) - /// - public string ConnectionPolicySid { get; set; } - /// - /// The SID of the SIP Domain that should be used in the `From` header of originating calls - /// - public string FromDomainSid { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (StatusCallbackUrl != null) - { - p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (CnamLookupEnabled != null) - { - p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); - } - - if (ConnectionPolicySid != null) - { - p.Add(new KeyValuePair("ConnectionPolicySid", ConnectionPolicySid.ToString())); - } - - if (FromDomainSid != null) - { - p.Add(new KeyValuePair("FromDomainSid", FromDomainSid.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; set; } /// - /// FetchByocTrunkOptions + /// The URL we should call when receiving a call /// - public class FetchByocTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchByocTrunkOptions - /// - /// The unique string that identifies the resource - public FetchByocTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public Uri VoiceUrl { get; set; } /// - /// ReadByocTrunkOptions + /// The HTTP method to use with voice_url /// - public class ReadByocTrunkOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public Twilio.Http.HttpMethod VoiceMethod { get; set; } /// - /// UpdateByocTrunkOptions + /// The URL we should call when an error occurs in executing TwiML /// - public class UpdateByocTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The URL we should call when receiving a call - /// - public Uri VoiceUrl { get; set; } - /// - /// The HTTP method we should use with voice_url - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// The URL we should call when an error occurs in executing TwiML - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// The HTTP method used with voice_fallback_url - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// The URL that we should call to pass status updates - /// - public Uri StatusCallbackUrl { get; set; } - /// - /// The HTTP method we should use to call status_callback_url - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// - public bool? CnamLookupEnabled { get; set; } - /// - /// Origination Connection Policy (to your Carrier) - /// - public string ConnectionPolicySid { get; set; } - /// - /// The SID of the SIP Domain that should be used in the `From` header of originating calls - /// - public string FromDomainSid { get; set; } - - /// - /// Construct a new UpdateByocTrunkOptions - /// - /// The unique string that identifies the resource - public UpdateByocTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (StatusCallbackUrl != null) - { - p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); - } - - if (StatusCallbackMethod != null) - { - p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); - } - - if (CnamLookupEnabled != null) - { - p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); - } - - if (ConnectionPolicySid != null) - { - p.Add(new KeyValuePair("ConnectionPolicySid", ConnectionPolicySid.ToString())); - } - - if (FromDomainSid != null) - { - p.Add(new KeyValuePair("FromDomainSid", FromDomainSid.ToString())); - } - - return p; - } - } - + public Uri VoiceFallbackUrl { get; set; } /// - /// DeleteByocTrunkOptions + /// The HTTP method to use with voice_fallback_url /// - public class DeleteByocTrunkOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteByocTrunkOptions - /// - /// The unique string that identifies the resource - public DeleteByocTrunkOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL that we should call to pass status updates + /// + public Uri StatusCallbackUrl { get; set; } + /// + /// The HTTP method we should use to call `status_callback_url` + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// + public bool? CnamLookupEnabled { get; set; } + /// + /// Origination Connection Policy (to your Carrier) + /// + public string ConnectionPolicySid { get; set; } + /// + /// The SID of the SIP Domain that should be used in the `From` header of originating calls + /// + public string FromDomainSid { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (StatusCallbackUrl != null) + { + p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (CnamLookupEnabled != null) + { + p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); + } + + if (ConnectionPolicySid != null) + { + p.Add(new KeyValuePair("ConnectionPolicySid", ConnectionPolicySid.ToString())); + } + + if (FromDomainSid != null) + { + p.Add(new KeyValuePair("FromDomainSid", FromDomainSid.ToString())); + } + + return p; + } + } + + /// + /// FetchByocTrunkOptions + /// + public class FetchByocTrunkOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchByocTrunkOptions + /// + /// The unique string that identifies the resource + public FetchByocTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadByocTrunkOptions + /// + public class ReadByocTrunkOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateByocTrunkOptions + /// + public class UpdateByocTrunkOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The URL we should call when receiving a call + /// + public Uri VoiceUrl { get; set; } + /// + /// The HTTP method we should use with voice_url + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// The URL we should call when an error occurs in executing TwiML + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// The HTTP method used with voice_fallback_url + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// The URL that we should call to pass status updates + /// + public Uri StatusCallbackUrl { get; set; } + /// + /// The HTTP method we should use to call status_callback_url + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// + public bool? CnamLookupEnabled { get; set; } + /// + /// Origination Connection Policy (to your Carrier) + /// + public string ConnectionPolicySid { get; set; } + /// + /// The SID of the SIP Domain that should be used in the `From` header of originating calls + /// + public string FromDomainSid { get; set; } + + /// + /// Construct a new UpdateByocTrunkOptions + /// + /// The unique string that identifies the resource + public UpdateByocTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (StatusCallbackUrl != null) + { + p.Add(new KeyValuePair("StatusCallbackUrl", Serializers.Url(StatusCallbackUrl))); + } + + if (StatusCallbackMethod != null) + { + p.Add(new KeyValuePair("StatusCallbackMethod", StatusCallbackMethod.ToString())); + } + + if (CnamLookupEnabled != null) + { + p.Add(new KeyValuePair("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); + } + + if (ConnectionPolicySid != null) + { + p.Add(new KeyValuePair("ConnectionPolicySid", ConnectionPolicySid.ToString())); + } + + if (FromDomainSid != null) + { + p.Add(new KeyValuePair("FromDomainSid", FromDomainSid.ToString())); + } + + return p; + } + } + + /// + /// DeleteByocTrunkOptions + /// + public class DeleteByocTrunkOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteByocTrunkOptions + /// + /// The unique string that identifies the resource + public DeleteByocTrunkOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ByocTrunkResource.cs b/src/Twilio/Rest/Voice/V1/ByocTrunkResource.cs index 51ceb6946..07cb6aa0d 100644 --- a/src/Twilio/Rest/Voice/V1/ByocTrunkResource.cs +++ b/src/Twilio/Rest/Voice/V1/ByocTrunkResource.cs @@ -16,589 +16,589 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1 -{ - - public class ByocTrunkResource : Resource - { - private static Request BuildCreateRequest(CreateByocTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ByocTrunks", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ByocTrunk parameters - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Create(CreateByocTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ByocTrunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task CreateAsync(CreateByocTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method to use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method to use with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call `status_callback_url` - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// Origination Connection Policy (to your Carrier) - /// The SID of the SIP Domain that should be used in the `From` header of originating - /// calls - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Create(string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? cnamLookupEnabled = null, - string connectionPolicySid = null, - string fromDomainSid = null, - ITwilioRestClient client = null) - { - var options = new CreateByocTrunkOptions(){FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method to use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method to use with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call `status_callback_url` - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// Origination Connection Policy (to your Carrier) - /// The SID of the SIP Domain that should be used in the `From` header of originating - /// calls - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? cnamLookupEnabled = null, - string connectionPolicySid = null, - string fromDomainSid = null, - ITwilioRestClient client = null) - { - var options = new CreateByocTrunkOptions(){FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchByocTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ByocTrunks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ByocTrunk parameters - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Fetch(FetchByocTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ByocTrunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task FetchAsync(FetchByocTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchByocTrunkOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchByocTrunkOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadByocTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ByocTrunks", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ByocTrunk parameters - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ResourceSet Read(ReadByocTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("byoc_trunks", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ByocTrunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task> ReadAsync(ReadByocTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("byoc_trunks", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadByocTrunkOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadByocTrunkOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("byoc_trunks", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("byoc_trunks", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("byoc_trunks", response.Content); - } - - private static Request BuildUpdateRequest(UpdateByocTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ByocTrunks/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update ByocTrunk parameters - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Update(UpdateByocTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update ByocTrunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task UpdateAsync(UpdateByocTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method we should use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method used with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call status_callback_url - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// Origination Connection Policy (to your Carrier) - /// The SID of the SIP Domain that should be used in the `From` header of originating - /// calls - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static ByocTrunkResource Update(string pathSid, - string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? cnamLookupEnabled = null, - string connectionPolicySid = null, - string fromDomainSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateByocTrunkOptions(pathSid){FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// The URL we should call when receiving a call - /// The HTTP method we should use with voice_url - /// The URL we should call when an error occurs in executing TwiML - /// The HTTP method used with voice_fallback_url - /// The URL that we should call to pass status updates - /// The HTTP method we should use to call status_callback_url - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// Origination Connection Policy (to your Carrier) - /// The SID of the SIP Domain that should be used in the `From` header of originating - /// calls - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - Uri voiceUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri statusCallbackUrl = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - bool? cnamLookupEnabled = null, - string connectionPolicySid = null, - string fromDomainSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateByocTrunkOptions(pathSid){FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteByocTrunkOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/ByocTrunks/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ByocTrunk parameters - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static bool Delete(DeleteByocTrunkOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ByocTrunk parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task DeleteAsync(DeleteByocTrunkOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ByocTrunk - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteByocTrunkOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ByocTrunk - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteByocTrunkOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ByocTrunkResource object - /// - /// Raw JSON string - /// ByocTrunkResource object represented by the provided JSON - public static ByocTrunkResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The URL we call when receiving a call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// The HTTP method to use with voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// The URL we call when an error occurs while executing TwiML - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// The HTTP method used with voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// The URL that we call with status updates - /// - [JsonProperty("status_callback_url")] - public Uri StatusCallbackUrl { get; private set; } - /// - /// The HTTP method we use to call status_callback_url - /// - [JsonProperty("status_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } - /// - /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk - /// - [JsonProperty("cnam_lookup_enabled")] - public bool? CnamLookupEnabled { get; private set; } - /// - /// Origination Connection Policy (to your Carrier) - /// - [JsonProperty("connection_policy_sid")] - public string ConnectionPolicySid { get; private set; } - /// - /// The SID of the SIP Domain that should be used in the `From` header of originating calls - /// - [JsonProperty("from_domain_sid")] - public string FromDomainSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ByocTrunkResource() - { - - } - } +{ + + public class ByocTrunkResource : Resource + { + private static Request BuildCreateRequest(CreateByocTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ByocTrunks", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ByocTrunk parameters + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Create(CreateByocTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ByocTrunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task CreateAsync(CreateByocTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method to use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method to use with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call `status_callback_url` + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// Origination Connection Policy (to your Carrier) + /// The SID of the SIP Domain that should be used in the `From` header of originating + /// calls + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Create(string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? cnamLookupEnabled = null, + string connectionPolicySid = null, + string fromDomainSid = null, + ITwilioRestClient client = null) + { + var options = new CreateByocTrunkOptions() { FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method to use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method to use with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call `status_callback_url` + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// Origination Connection Policy (to your Carrier) + /// The SID of the SIP Domain that should be used in the `From` header of originating + /// calls + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? cnamLookupEnabled = null, + string connectionPolicySid = null, + string fromDomainSid = null, + ITwilioRestClient client = null) + { + var options = new CreateByocTrunkOptions() { FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchByocTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ByocTrunks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ByocTrunk parameters + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Fetch(FetchByocTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ByocTrunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task FetchAsync(FetchByocTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchByocTrunkOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchByocTrunkOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadByocTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ByocTrunks", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ByocTrunk parameters + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ResourceSet Read(ReadByocTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("byoc_trunks", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ByocTrunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task> ReadAsync(ReadByocTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("byoc_trunks", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadByocTrunkOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadByocTrunkOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("byoc_trunks", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("byoc_trunks", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("byoc_trunks", response.Content); + } + + private static Request BuildUpdateRequest(UpdateByocTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ByocTrunks/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update ByocTrunk parameters + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Update(UpdateByocTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update ByocTrunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task UpdateAsync(UpdateByocTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method we should use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method used with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call status_callback_url + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// Origination Connection Policy (to your Carrier) + /// The SID of the SIP Domain that should be used in the `From` header of originating + /// calls + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static ByocTrunkResource Update(string pathSid, + string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? cnamLookupEnabled = null, + string connectionPolicySid = null, + string fromDomainSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateByocTrunkOptions(pathSid) { FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// The URL we should call when receiving a call + /// The HTTP method we should use with voice_url + /// The URL we should call when an error occurs in executing TwiML + /// The HTTP method used with voice_fallback_url + /// The URL that we should call to pass status updates + /// The HTTP method we should use to call status_callback_url + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// Origination Connection Policy (to your Carrier) + /// The SID of the SIP Domain that should be used in the `From` header of originating + /// calls + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + Uri voiceUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri statusCallbackUrl = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + bool? cnamLookupEnabled = null, + string connectionPolicySid = null, + string fromDomainSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateByocTrunkOptions(pathSid) { FriendlyName = friendlyName, VoiceUrl = voiceUrl, VoiceMethod = voiceMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceFallbackMethod = voiceFallbackMethod, StatusCallbackUrl = statusCallbackUrl, StatusCallbackMethod = statusCallbackMethod, CnamLookupEnabled = cnamLookupEnabled, ConnectionPolicySid = connectionPolicySid, FromDomainSid = fromDomainSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteByocTrunkOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/ByocTrunks/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ByocTrunk parameters + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static bool Delete(DeleteByocTrunkOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ByocTrunk parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task DeleteAsync(DeleteByocTrunkOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ByocTrunk + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteByocTrunkOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ByocTrunk + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteByocTrunkOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ByocTrunkResource object + /// + /// Raw JSON string + /// ByocTrunkResource object represented by the provided JSON + public static ByocTrunkResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The URL we call when receiving a call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// The HTTP method to use with voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// The URL we call when an error occurs while executing TwiML + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// The HTTP method used with voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// The URL that we call with status updates + /// + [JsonProperty("status_callback_url")] + public Uri StatusCallbackUrl { get; private set; } + /// + /// The HTTP method we use to call status_callback_url + /// + [JsonProperty("status_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod StatusCallbackMethod { get; private set; } + /// + /// Whether Caller ID Name (CNAM) lookup is enabled for the trunk + /// + [JsonProperty("cnam_lookup_enabled")] + public bool? CnamLookupEnabled { get; private set; } + /// + /// Origination Connection Policy (to your Carrier) + /// + [JsonProperty("connection_policy_sid")] + public string ConnectionPolicySid { get; private set; } + /// + /// The SID of the SIP Domain that should be used in the `From` header of originating calls + /// + [JsonProperty("from_domain_sid")] + public string FromDomainSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ByocTrunkResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetOptions.cs b/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetOptions.cs index 098a1089e..d43e5b19a 100644 --- a/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetOptions.cs +++ b/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetOptions.cs @@ -9,266 +9,266 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1.ConnectionPolicy -{ - +{ + + /// + /// CreateConnectionPolicyTargetOptions + /// + public class CreateConnectionPolicyTargetOptions : IOptions + { /// - /// CreateConnectionPolicyTargetOptions + /// The SID of the Connection Policy that owns the Target /// - public class CreateConnectionPolicyTargetOptions : IOptions - { - /// - /// The SID of the Connection Policy that owns the Target - /// - public string PathConnectionPolicySid { get; } - /// - /// The SIP address you want Twilio to route your calls to - /// - public Uri Target { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The relative importance of the target - /// - public int? Priority { get; set; } - /// - /// The value that determines the relative load the Target should receive compared to others with the same priority - /// - public int? Weight { get; set; } - /// - /// Whether the Target is enabled - /// - public bool? Enabled { get; set; } - - /// - /// Construct a new CreateConnectionPolicyTargetOptions - /// - /// The SID of the Connection Policy that owns the Target - /// The SIP address you want Twilio to route your calls to - public CreateConnectionPolicyTargetOptions(string pathConnectionPolicySid, Uri target) - { - PathConnectionPolicySid = pathConnectionPolicySid; - Target = target; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Target != null) - { - p.Add(new KeyValuePair("Target", Serializers.Url(Target))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (Weight != null) - { - p.Add(new KeyValuePair("Weight", Weight.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - return p; - } - } - + public string PathConnectionPolicySid { get; } /// - /// FetchConnectionPolicyTargetOptions + /// The SIP address you want Twilio to route your calls to /// - public class FetchConnectionPolicyTargetOptions : IOptions - { - /// - /// The SID of the Connection Policy that owns the Target - /// - public string PathConnectionPolicySid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConnectionPolicyTargetOptions - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - public FetchConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) - { - PathConnectionPolicySid = pathConnectionPolicySid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public Uri Target { get; } /// - /// ReadConnectionPolicyTargetOptions + /// A string to describe the resource /// - public class ReadConnectionPolicyTargetOptions : ReadOptions - { - /// - /// The SID of the Connection Policy from which to read the Targets - /// - public string PathConnectionPolicySid { get; } - - /// - /// Construct a new ReadConnectionPolicyTargetOptions - /// - /// The SID of the Connection Policy from which to read the Targets - public ReadConnectionPolicyTargetOptions(string pathConnectionPolicySid) - { - PathConnectionPolicySid = pathConnectionPolicySid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string FriendlyName { get; set; } /// - /// UpdateConnectionPolicyTargetOptions + /// The relative importance of the target /// - public class UpdateConnectionPolicyTargetOptions : IOptions - { - /// - /// The SID of the Connection Policy that owns the Target - /// - public string PathConnectionPolicySid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// The SIP address you want Twilio to route your calls to - /// - public Uri Target { get; set; } - /// - /// The relative importance of the target - /// - public int? Priority { get; set; } - /// - /// The value that determines the relative load the Target should receive compared to others with the same priority - /// - public int? Weight { get; set; } - /// - /// Whether the Target is enabled - /// - public bool? Enabled { get; set; } - - /// - /// Construct a new UpdateConnectionPolicyTargetOptions - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - public UpdateConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) - { - PathConnectionPolicySid = pathConnectionPolicySid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (Target != null) - { - p.Add(new KeyValuePair("Target", Serializers.Url(Target))); - } - - if (Priority != null) - { - p.Add(new KeyValuePair("Priority", Priority.ToString())); - } - - if (Weight != null) - { - p.Add(new KeyValuePair("Weight", Weight.ToString())); - } - - if (Enabled != null) - { - p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); - } - - return p; - } - } - + public int? Priority { get; set; } /// - /// DeleteConnectionPolicyTargetOptions + /// The value that determines the relative load the Target should receive compared to others with the same priority /// - public class DeleteConnectionPolicyTargetOptions : IOptions - { - /// - /// The SID of the Connection Policy that owns the Target - /// - public string PathConnectionPolicySid { get; } - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteConnectionPolicyTargetOptions - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - public DeleteConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) - { - PathConnectionPolicySid = pathConnectionPolicySid; - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public int? Weight { get; set; } + /// + /// Whether the Target is enabled + /// + public bool? Enabled { get; set; } + + /// + /// Construct a new CreateConnectionPolicyTargetOptions + /// + /// The SID of the Connection Policy that owns the Target + /// The SIP address you want Twilio to route your calls to + public CreateConnectionPolicyTargetOptions(string pathConnectionPolicySid, Uri target) + { + PathConnectionPolicySid = pathConnectionPolicySid; + Target = target; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Target != null) + { + p.Add(new KeyValuePair("Target", Serializers.Url(Target))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (Weight != null) + { + p.Add(new KeyValuePair("Weight", Weight.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// FetchConnectionPolicyTargetOptions + /// + public class FetchConnectionPolicyTargetOptions : IOptions + { + /// + /// The SID of the Connection Policy that owns the Target + /// + public string PathConnectionPolicySid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchConnectionPolicyTargetOptions + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + public FetchConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) + { + PathConnectionPolicySid = pathConnectionPolicySid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadConnectionPolicyTargetOptions + /// + public class ReadConnectionPolicyTargetOptions : ReadOptions + { + /// + /// The SID of the Connection Policy from which to read the Targets + /// + public string PathConnectionPolicySid { get; } + + /// + /// Construct a new ReadConnectionPolicyTargetOptions + /// + /// The SID of the Connection Policy from which to read the Targets + public ReadConnectionPolicyTargetOptions(string pathConnectionPolicySid) + { + PathConnectionPolicySid = pathConnectionPolicySid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateConnectionPolicyTargetOptions + /// + public class UpdateConnectionPolicyTargetOptions : IOptions + { + /// + /// The SID of the Connection Policy that owns the Target + /// + public string PathConnectionPolicySid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// The SIP address you want Twilio to route your calls to + /// + public Uri Target { get; set; } + /// + /// The relative importance of the target + /// + public int? Priority { get; set; } + /// + /// The value that determines the relative load the Target should receive compared to others with the same priority + /// + public int? Weight { get; set; } + /// + /// Whether the Target is enabled + /// + public bool? Enabled { get; set; } + + /// + /// Construct a new UpdateConnectionPolicyTargetOptions + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + public UpdateConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) + { + PathConnectionPolicySid = pathConnectionPolicySid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (Target != null) + { + p.Add(new KeyValuePair("Target", Serializers.Url(Target))); + } + + if (Priority != null) + { + p.Add(new KeyValuePair("Priority", Priority.ToString())); + } + + if (Weight != null) + { + p.Add(new KeyValuePair("Weight", Weight.ToString())); + } + + if (Enabled != null) + { + p.Add(new KeyValuePair("Enabled", Enabled.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// DeleteConnectionPolicyTargetOptions + /// + public class DeleteConnectionPolicyTargetOptions : IOptions + { + /// + /// The SID of the Connection Policy that owns the Target + /// + public string PathConnectionPolicySid { get; } + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteConnectionPolicyTargetOptions + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + public DeleteConnectionPolicyTargetOptions(string pathConnectionPolicySid, string pathSid) + { + PathConnectionPolicySid = pathConnectionPolicySid; + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetResource.cs b/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetResource.cs index d75990c24..46af3c732 100644 --- a/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetResource.cs +++ b/src/Twilio/Rest/Voice/V1/ConnectionPolicy/ConnectionPolicyTargetResource.cs @@ -16,553 +16,553 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1.ConnectionPolicy -{ - - public class ConnectionPolicyTargetResource : Resource - { - private static Request BuildCreateRequest(CreateConnectionPolicyTargetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Create(CreateConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task CreateAsync(CreateConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The SID of the Connection Policy that owns the Target - /// The SIP address you want Twilio to route your calls to - /// A string to describe the resource - /// The relative importance of the target - /// The value that determines the relative load the Target should receive compared to others with - /// the same priority - /// Whether the Target is enabled - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Create(string pathConnectionPolicySid, - Uri target, - string friendlyName = null, - int? priority = null, - int? weight = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConnectionPolicyTargetOptions(pathConnectionPolicySid, target){FriendlyName = friendlyName, Priority = priority, Weight = weight, Enabled = enabled}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The SID of the Connection Policy that owns the Target - /// The SIP address you want Twilio to route your calls to - /// A string to describe the resource - /// The relative importance of the target - /// The value that determines the relative load the Target should receive compared to others with - /// the same priority - /// Whether the Target is enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task CreateAsync(string pathConnectionPolicySid, - Uri target, - string friendlyName = null, - int? priority = null, - int? weight = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new CreateConnectionPolicyTargetOptions(pathConnectionPolicySid, target){FriendlyName = friendlyName, Priority = priority, Weight = weight, Enabled = enabled}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchConnectionPolicyTargetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Fetch(FetchConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task FetchAsync(FetchConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Fetch(string pathConnectionPolicySid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task FetchAsync(string pathConnectionPolicySid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConnectionPolicyTargetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ResourceSet Read(ReadConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("targets", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("targets", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Connection Policy from which to read the Targets - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ResourceSet Read(string pathConnectionPolicySid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectionPolicyTargetOptions(pathConnectionPolicySid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Connection Policy from which to read the Targets - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task> ReadAsync(string pathConnectionPolicySid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectionPolicyTargetOptions(pathConnectionPolicySid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("targets", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("targets", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("targets", response.Content); - } - - private static Request BuildUpdateRequest(UpdateConnectionPolicyTargetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Update(UpdateConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// A string to describe the resource - /// The SIP address you want Twilio to route your calls to - /// The relative importance of the target - /// The value that determines the relative load the Target should receive compared to others with - /// the same priority - /// Whether the Target is enabled - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static ConnectionPolicyTargetResource Update(string pathConnectionPolicySid, - string pathSid, - string friendlyName = null, - Uri target = null, - int? priority = null, - int? weight = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid){FriendlyName = friendlyName, Target = target, Priority = priority, Weight = weight, Enabled = enabled}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// A string to describe the resource - /// The SIP address you want Twilio to route your calls to - /// The relative importance of the target - /// The value that determines the relative load the Target should receive compared to others with - /// the same priority - /// Whether the Target is enabled - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task UpdateAsync(string pathConnectionPolicySid, - string pathSid, - string friendlyName = null, - Uri target = null, - int? priority = null, - int? weight = null, - bool? enabled = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid){FriendlyName = friendlyName, Target = target, Priority = priority, Weight = weight, Enabled = enabled}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteConnectionPolicyTargetOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static bool Delete(DeleteConnectionPolicyTargetOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ConnectionPolicyTarget parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectionPolicyTargetOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicyTarget - public static bool Delete(string pathConnectionPolicySid, string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID of the Connection Policy that owns the Target - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicyTarget - public static async System.Threading.Tasks.Task DeleteAsync(string pathConnectionPolicySid, - string pathSid, - ITwilioRestClient client = null) - { - var options = new DeleteConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConnectionPolicyTargetResource object - /// - /// Raw JSON string - /// ConnectionPolicyTargetResource object represented by the provided JSON - public static ConnectionPolicyTargetResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Connection Policy that owns the Target - /// - [JsonProperty("connection_policy_sid")] - public string ConnectionPolicySid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The SIP address you want Twilio to route your calls to - /// - [JsonProperty("target")] - public Uri Target { get; private set; } - /// - /// The relative importance of the target - /// - [JsonProperty("priority")] - public int? Priority { get; private set; } - /// - /// The value that determines the relative load the Target should receive compared to others with the same priority - /// - [JsonProperty("weight")] - public int? Weight { get; private set; } - /// - /// Whether the target is enabled - /// - [JsonProperty("enabled")] - public bool? Enabled { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private ConnectionPolicyTargetResource() - { - - } - } +{ + + public class ConnectionPolicyTargetResource : Resource + { + private static Request BuildCreateRequest(CreateConnectionPolicyTargetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Create(CreateConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task CreateAsync(CreateConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The SID of the Connection Policy that owns the Target + /// The SIP address you want Twilio to route your calls to + /// A string to describe the resource + /// The relative importance of the target + /// The value that determines the relative load the Target should receive compared to others with + /// the same priority + /// Whether the Target is enabled + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Create(string pathConnectionPolicySid, + Uri target, + string friendlyName = null, + int? priority = null, + int? weight = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConnectionPolicyTargetOptions(pathConnectionPolicySid, target) { FriendlyName = friendlyName, Priority = priority, Weight = weight, Enabled = enabled }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The SID of the Connection Policy that owns the Target + /// The SIP address you want Twilio to route your calls to + /// A string to describe the resource + /// The relative importance of the target + /// The value that determines the relative load the Target should receive compared to others with + /// the same priority + /// Whether the Target is enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task CreateAsync(string pathConnectionPolicySid, + Uri target, + string friendlyName = null, + int? priority = null, + int? weight = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new CreateConnectionPolicyTargetOptions(pathConnectionPolicySid, target) { FriendlyName = friendlyName, Priority = priority, Weight = weight, Enabled = enabled }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchConnectionPolicyTargetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Fetch(FetchConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task FetchAsync(FetchConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Fetch(string pathConnectionPolicySid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task FetchAsync(string pathConnectionPolicySid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConnectionPolicyTargetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ResourceSet Read(ReadConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("targets", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("targets", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Connection Policy from which to read the Targets + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ResourceSet Read(string pathConnectionPolicySid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectionPolicyTargetOptions(pathConnectionPolicySid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Connection Policy from which to read the Targets + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task> ReadAsync(string pathConnectionPolicySid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectionPolicyTargetOptions(pathConnectionPolicySid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("targets", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("targets", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("targets", response.Content); + } + + private static Request BuildUpdateRequest(UpdateConnectionPolicyTargetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Update(UpdateConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// A string to describe the resource + /// The SIP address you want Twilio to route your calls to + /// The relative importance of the target + /// The value that determines the relative load the Target should receive compared to others with + /// the same priority + /// Whether the Target is enabled + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static ConnectionPolicyTargetResource Update(string pathConnectionPolicySid, + string pathSid, + string friendlyName = null, + Uri target = null, + int? priority = null, + int? weight = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid) { FriendlyName = friendlyName, Target = target, Priority = priority, Weight = weight, Enabled = enabled }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// A string to describe the resource + /// The SIP address you want Twilio to route your calls to + /// The relative importance of the target + /// The value that determines the relative load the Target should receive compared to others with + /// the same priority + /// Whether the Target is enabled + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task UpdateAsync(string pathConnectionPolicySid, + string pathSid, + string friendlyName = null, + Uri target = null, + int? priority = null, + int? weight = null, + bool? enabled = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid) { FriendlyName = friendlyName, Target = target, Priority = priority, Weight = weight, Enabled = enabled }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteConnectionPolicyTargetOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathConnectionPolicySid + "/Targets/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static bool Delete(DeleteConnectionPolicyTargetOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ConnectionPolicyTarget parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectionPolicyTargetOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicyTarget + public static bool Delete(string pathConnectionPolicySid, string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID of the Connection Policy that owns the Target + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicyTarget + public static async System.Threading.Tasks.Task DeleteAsync(string pathConnectionPolicySid, + string pathSid, + ITwilioRestClient client = null) + { + var options = new DeleteConnectionPolicyTargetOptions(pathConnectionPolicySid, pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConnectionPolicyTargetResource object + /// + /// Raw JSON string + /// ConnectionPolicyTargetResource object represented by the provided JSON + public static ConnectionPolicyTargetResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Connection Policy that owns the Target + /// + [JsonProperty("connection_policy_sid")] + public string ConnectionPolicySid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The SIP address you want Twilio to route your calls to + /// + [JsonProperty("target")] + public Uri Target { get; private set; } + /// + /// The relative importance of the target + /// + [JsonProperty("priority")] + public int? Priority { get; private set; } + /// + /// The value that determines the relative load the Target should receive compared to others with the same priority + /// + [JsonProperty("weight")] + public int? Weight { get; private set; } + /// + /// Whether the target is enabled + /// + [JsonProperty("enabled")] + public bool? Enabled { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private ConnectionPolicyTargetResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ConnectionPolicyOptions.cs b/src/Twilio/Rest/Voice/V1/ConnectionPolicyOptions.cs index a837e8ecf..5dd930dfa 100644 --- a/src/Twilio/Rest/Voice/V1/ConnectionPolicyOptions.cs +++ b/src/Twilio/Rest/Voice/V1/ConnectionPolicyOptions.cs @@ -9,147 +9,147 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1 -{ - +{ + + /// + /// CreateConnectionPolicyOptions + /// + public class CreateConnectionPolicyOptions : IOptions + { /// - /// CreateConnectionPolicyOptions + /// A string to describe the resource /// - public class CreateConnectionPolicyOptions : IOptions - { - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public string FriendlyName { get; set; } + /// - /// FetchConnectionPolicyOptions + /// Generate the necessary parameters /// - public class FetchConnectionPolicyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchConnectionPolicyOptions - /// - /// The unique string that identifies the resource - public FetchConnectionPolicyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// FetchConnectionPolicyOptions + /// + public class FetchConnectionPolicyOptions : IOptions + { /// - /// ReadConnectionPolicyOptions + /// The unique string that identifies the resource /// - public class ReadConnectionPolicyOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public string PathSid { get; } + /// - /// UpdateConnectionPolicyOptions + /// Construct a new FetchConnectionPolicyOptions /// - public class UpdateConnectionPolicyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateConnectionPolicyOptions - /// - /// The unique string that identifies the resource - public UpdateConnectionPolicyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// The unique string that identifies the resource + public FetchConnectionPolicyOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// DeleteConnectionPolicyOptions + /// Generate the necessary parameters /// - public class DeleteConnectionPolicyOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteConnectionPolicyOptions - /// - /// The unique string that identifies the resource - public DeleteConnectionPolicyOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadConnectionPolicyOptions + /// + public class ReadConnectionPolicyOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateConnectionPolicyOptions + /// + public class UpdateConnectionPolicyOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateConnectionPolicyOptions + /// + /// The unique string that identifies the resource + public UpdateConnectionPolicyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteConnectionPolicyOptions + /// + public class DeleteConnectionPolicyOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteConnectionPolicyOptions + /// + /// The unique string that identifies the resource + public DeleteConnectionPolicyOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/ConnectionPolicyResource.cs b/src/Twilio/Rest/Voice/V1/ConnectionPolicyResource.cs index 57192c1a1..cf7dc1d4d 100644 --- a/src/Twilio/Rest/Voice/V1/ConnectionPolicyResource.cs +++ b/src/Twilio/Rest/Voice/V1/ConnectionPolicyResource.cs @@ -16,471 +16,471 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1 -{ - - public class ConnectionPolicyResource : Resource - { - private static Request BuildCreateRequest(CreateConnectionPolicyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ConnectionPolicies", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create ConnectionPolicy parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Create(CreateConnectionPolicyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create ConnectionPolicy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task CreateAsync(CreateConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Create(string friendlyName = null, ITwilioRestClient client = null) - { - var options = new CreateConnectionPolicyOptions(){FriendlyName = friendlyName}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new CreateConnectionPolicyOptions(){FriendlyName = friendlyName}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchConnectionPolicyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch ConnectionPolicy parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Fetch(FetchConnectionPolicyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch ConnectionPolicy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task FetchAsync(FetchConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchConnectionPolicyOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchConnectionPolicyOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadConnectionPolicyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/ConnectionPolicies", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read ConnectionPolicy parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ResourceSet Read(ReadConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("connection_policies", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read ConnectionPolicy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("connection_policies", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectionPolicyOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadConnectionPolicyOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("connection_policies", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("connection_policies", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("connection_policies", response.Content); - } - - private static Request BuildUpdateRequest(UpdateConnectionPolicyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update ConnectionPolicy parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Update(UpdateConnectionPolicyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update ConnectionPolicy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static ConnectionPolicyResource Update(string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectionPolicyOptions(pathSid){FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateConnectionPolicyOptions(pathSid){FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteConnectionPolicyOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/ConnectionPolicies/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete ConnectionPolicy parameters - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static bool Delete(DeleteConnectionPolicyOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete ConnectionPolicy parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectionPolicyOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of ConnectionPolicy - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteConnectionPolicyOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of ConnectionPolicy - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteConnectionPolicyOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a ConnectionPolicyResource object - /// - /// Raw JSON string - /// ConnectionPolicyResource object represented by the provided JSON - public static ConnectionPolicyResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT when the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related resources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private ConnectionPolicyResource() - { - - } - } +{ + + public class ConnectionPolicyResource : Resource + { + private static Request BuildCreateRequest(CreateConnectionPolicyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ConnectionPolicies", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create ConnectionPolicy parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Create(CreateConnectionPolicyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create ConnectionPolicy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task CreateAsync(CreateConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Create(string friendlyName = null, ITwilioRestClient client = null) + { + var options = new CreateConnectionPolicyOptions() { FriendlyName = friendlyName }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task CreateAsync(string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new CreateConnectionPolicyOptions() { FriendlyName = friendlyName }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchConnectionPolicyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch ConnectionPolicy parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Fetch(FetchConnectionPolicyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch ConnectionPolicy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task FetchAsync(FetchConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchConnectionPolicyOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchConnectionPolicyOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadConnectionPolicyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/ConnectionPolicies", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read ConnectionPolicy parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ResourceSet Read(ReadConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("connection_policies", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read ConnectionPolicy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task> ReadAsync(ReadConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("connection_policies", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectionPolicyOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadConnectionPolicyOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("connection_policies", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("connection_policies", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("connection_policies", response.Content); + } + + private static Request BuildUpdateRequest(UpdateConnectionPolicyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update ConnectionPolicy parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Update(UpdateConnectionPolicyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update ConnectionPolicy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task UpdateAsync(UpdateConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static ConnectionPolicyResource Update(string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectionPolicyOptions(pathSid) { FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateConnectionPolicyOptions(pathSid) { FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteConnectionPolicyOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/ConnectionPolicies/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete ConnectionPolicy parameters + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static bool Delete(DeleteConnectionPolicyOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete ConnectionPolicy parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task DeleteAsync(DeleteConnectionPolicyOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of ConnectionPolicy + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteConnectionPolicyOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of ConnectionPolicy + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteConnectionPolicyOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a ConnectionPolicyResource object + /// + /// Raw JSON string + /// ConnectionPolicyResource object represented by the provided JSON + public static ConnectionPolicyResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT when the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related resources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private ConnectionPolicyResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateOptions.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateOptions.cs index 2da0f2496..1d0c25daf 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateOptions.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the + /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + public class CreateBulkCountryUpdateOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the - /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// URL encoded JSON array of update objects /// - public class CreateBulkCountryUpdateOptions : IOptions - { - /// - /// URL encoded JSON array of update objects - /// - public string UpdateRequest { get; } - - /// - /// Construct a new CreateBulkCountryUpdateOptions - /// - /// URL encoded JSON array of update objects - public CreateBulkCountryUpdateOptions(string updateRequest) - { - UpdateRequest = updateRequest; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UpdateRequest != null) - { - p.Add(new KeyValuePair("UpdateRequest", UpdateRequest)); - } - - return p; - } - } + public string UpdateRequest { get; } + + /// + /// Construct a new CreateBulkCountryUpdateOptions + /// + /// URL encoded JSON array of update objects + public CreateBulkCountryUpdateOptions(string updateRequest) + { + UpdateRequest = updateRequest; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UpdateRequest != null) + { + p.Add(new KeyValuePair("UpdateRequest", UpdateRequest)); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateResource.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateResource.cs index 6e3850b99..b43aeacdb 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateResource.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/BulkCountryUpdateResource.cs @@ -19,115 +19,115 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - - public class BulkCountryUpdateResource : Resource - { - private static Request BuildCreateRequest(CreateBulkCountryUpdateOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/DialingPermissions/BulkCountryUpdates", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the - /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// Create BulkCountryUpdate parameters - /// Client to make requests to Twilio - /// A single instance of BulkCountryUpdate - public static BulkCountryUpdateResource Create(CreateBulkCountryUpdateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the - /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// Create BulkCountryUpdate parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BulkCountryUpdate - public static async System.Threading.Tasks.Task CreateAsync(CreateBulkCountryUpdateOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the - /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// URL encoded JSON array of update objects - /// Client to make requests to Twilio - /// A single instance of BulkCountryUpdate - public static BulkCountryUpdateResource Create(string updateRequest, ITwilioRestClient client = null) - { - var options = new CreateBulkCountryUpdateOptions(updateRequest); - return Create(options, client); - } - - #if !NET35 - /// - /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the - /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// URL encoded JSON array of update objects - /// Client to make requests to Twilio - /// Task that resolves to A single instance of BulkCountryUpdate - public static async System.Threading.Tasks.Task CreateAsync(string updateRequest, - ITwilioRestClient client = null) - { - var options = new CreateBulkCountryUpdateOptions(updateRequest); - return await CreateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a BulkCountryUpdateResource object - /// - /// Raw JSON string - /// BulkCountryUpdateResource object represented by the provided JSON - public static BulkCountryUpdateResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The number of countries updated - /// - [JsonProperty("update_count")] - public int? UpdateCount { get; private set; } - /// - /// A URL encoded JSON array of update objects - /// - [JsonProperty("update_request")] - public string UpdateRequest { get; private set; } - - private BulkCountryUpdateResource() - { - - } - } +{ + + public class BulkCountryUpdateResource : Resource + { + private static Request BuildCreateRequest(CreateBulkCountryUpdateOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/DialingPermissions/BulkCountryUpdates", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the + /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// Create BulkCountryUpdate parameters + /// Client to make requests to Twilio + /// A single instance of BulkCountryUpdate + public static BulkCountryUpdateResource Create(CreateBulkCountryUpdateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the + /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// Create BulkCountryUpdate parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BulkCountryUpdate + public static async System.Threading.Tasks.Task CreateAsync(CreateBulkCountryUpdateOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the + /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// URL encoded JSON array of update objects + /// Client to make requests to Twilio + /// A single instance of BulkCountryUpdate + public static BulkCountryUpdateResource Create(string updateRequest, ITwilioRestClient client = null) + { + var options = new CreateBulkCountryUpdateOptions(updateRequest); + return Create(options, client); + } + +#if !NET35 + /// + /// Create a bulk update request to change voice dialing country permissions of one or more countries identified by the + /// corresponding [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// URL encoded JSON array of update objects + /// Client to make requests to Twilio + /// Task that resolves to A single instance of BulkCountryUpdate + public static async System.Threading.Tasks.Task CreateAsync(string updateRequest, + ITwilioRestClient client = null) + { + var options = new CreateBulkCountryUpdateOptions(updateRequest); + return await CreateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a BulkCountryUpdateResource object + /// + /// Raw JSON string + /// BulkCountryUpdateResource object represented by the provided JSON + public static BulkCountryUpdateResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The number of countries updated + /// + [JsonProperty("update_count")] + public int? UpdateCount { get; private set; } + /// + /// A URL encoded JSON array of update objects + /// + [JsonProperty("update_request")] + public string UpdateRequest { get; private set; } + + private BulkCountryUpdateResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixOptions.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixOptions.cs index e5460dbd2..205e6b4aa 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixOptions.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixOptions.cs @@ -9,44 +9,44 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1.DialingPermissions.Country -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country + /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + public class ReadHighriskSpecialPrefixOptions : ReadOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country - /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// The ISO 3166-1 country code /// - public class ReadHighriskSpecialPrefixOptions : ReadOptions - { - /// - /// The ISO 3166-1 country code - /// - public string PathIsoCode { get; } - - /// - /// Construct a new ReadHighriskSpecialPrefixOptions - /// - /// The ISO 3166-1 country code - public ReadHighriskSpecialPrefixOptions(string pathIsoCode) - { - PathIsoCode = pathIsoCode; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathIsoCode { get; } + + /// + /// Construct a new ReadHighriskSpecialPrefixOptions + /// + /// The ISO 3166-1 country code + public ReadHighriskSpecialPrefixOptions(string pathIsoCode) + { + PathIsoCode = pathIsoCode; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixResource.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixResource.cs index 107f81f1e..cbbb065e7 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixResource.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/Country/HighriskSpecialPrefixResource.cs @@ -19,178 +19,178 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1.DialingPermissions.Country -{ - - public class HighriskSpecialPrefixResource : Resource - { - private static Request BuildReadRequest(ReadHighriskSpecialPrefixOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/DialingPermissions/Countries/" + options.PathIsoCode + "/HighRiskSpecialPrefixes", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country - /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// Read HighriskSpecialPrefix parameters - /// Client to make requests to Twilio - /// A single instance of HighriskSpecialPrefix - public static ResourceSet Read(ReadHighriskSpecialPrefixOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("content", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country - /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// Read HighriskSpecialPrefix parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HighriskSpecialPrefix - public static async System.Threading.Tasks.Task> ReadAsync(ReadHighriskSpecialPrefixOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("content", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country - /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// The ISO 3166-1 country code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of HighriskSpecialPrefix - public static ResourceSet Read(string pathIsoCode, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadHighriskSpecialPrefixOptions(pathIsoCode){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country - /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - /// - /// The ISO 3166-1 country code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of HighriskSpecialPrefix - public static async System.Threading.Tasks.Task> ReadAsync(string pathIsoCode, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadHighriskSpecialPrefixOptions(pathIsoCode){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Converts a JSON string into a HighriskSpecialPrefixResource object - /// - /// Raw JSON string - /// HighriskSpecialPrefixResource object represented by the provided JSON - public static HighriskSpecialPrefixResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// A prefix that includes the E.164 assigned country code - /// - [JsonProperty("prefix")] - public string Prefix { get; private set; } - - private HighriskSpecialPrefixResource() - { - - } - } +{ + + public class HighriskSpecialPrefixResource : Resource + { + private static Request BuildReadRequest(ReadHighriskSpecialPrefixOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/DialingPermissions/Countries/" + options.PathIsoCode + "/HighRiskSpecialPrefixes", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country + /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// Read HighriskSpecialPrefix parameters + /// Client to make requests to Twilio + /// A single instance of HighriskSpecialPrefix + public static ResourceSet Read(ReadHighriskSpecialPrefixOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("content", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country + /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// Read HighriskSpecialPrefix parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HighriskSpecialPrefix + public static async System.Threading.Tasks.Task> ReadAsync(ReadHighriskSpecialPrefixOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("content", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country + /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// The ISO 3166-1 country code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of HighriskSpecialPrefix + public static ResourceSet Read(string pathIsoCode, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadHighriskSpecialPrefixOptions(pathIsoCode) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Fetch the high-risk special services prefixes from the country resource corresponding to the [ISO country + /// code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + /// + /// The ISO 3166-1 country code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of HighriskSpecialPrefix + public static async System.Threading.Tasks.Task> ReadAsync(string pathIsoCode, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadHighriskSpecialPrefixOptions(pathIsoCode) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Converts a JSON string into a HighriskSpecialPrefixResource object + /// + /// Raw JSON string + /// HighriskSpecialPrefixResource object represented by the provided JSON + public static HighriskSpecialPrefixResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// A prefix that includes the E.164 assigned country code + /// + [JsonProperty("prefix")] + public string Prefix { get; private set; } + + private HighriskSpecialPrefixResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryOptions.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryOptions.cs index 933f854fa..5489b1b4e 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryOptions.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryOptions.cs @@ -9,116 +9,116 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve voice dialing country permissions identified by the given ISO country code + /// + public class FetchCountryOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve voice dialing country permissions identified by the given ISO country code + /// The ISO country code /// - public class FetchCountryOptions : IOptions - { - /// - /// The ISO country code - /// - public string PathIsoCode { get; } - - /// - /// Construct a new FetchCountryOptions - /// - /// The ISO country code - public FetchCountryOptions(string pathIsoCode) - { - PathIsoCode = pathIsoCode; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathIsoCode { get; } + /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve all voice dialing country permissions for this account + /// Construct a new FetchCountryOptions /// - public class ReadCountryOptions : ReadOptions - { - /// - /// Filter to retrieve the country permissions by specifying the ISO country code - /// - public string IsoCode { get; set; } - /// - /// Filter to retrieve the country permissions by specifying the continent - /// - public string Continent { get; set; } - /// - /// Country code filter - /// - public string CountryCode { get; set; } - /// - /// Filter to retrieve the country permissions with dialing to low-risk numbers enabled - /// - public bool? LowRiskNumbersEnabled { get; set; } - /// - /// Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled - /// - public bool? HighRiskSpecialNumbersEnabled { get; set; } - /// - /// Filter to retrieve the country permissions with dialing to high-risk toll fraud numbers enabled - /// - public bool? HighRiskTollfraudNumbersEnabled { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (IsoCode != null) - { - p.Add(new KeyValuePair("IsoCode", IsoCode.ToString())); - } - - if (Continent != null) - { - p.Add(new KeyValuePair("Continent", Continent)); - } - - if (CountryCode != null) - { - p.Add(new KeyValuePair("CountryCode", CountryCode)); - } - - if (LowRiskNumbersEnabled != null) - { - p.Add(new KeyValuePair("LowRiskNumbersEnabled", LowRiskNumbersEnabled.Value.ToString().ToLower())); - } - - if (HighRiskSpecialNumbersEnabled != null) - { - p.Add(new KeyValuePair("HighRiskSpecialNumbersEnabled", HighRiskSpecialNumbersEnabled.Value.ToString().ToLower())); - } - - if (HighRiskTollfraudNumbersEnabled != null) - { - p.Add(new KeyValuePair("HighRiskTollfraudNumbersEnabled", HighRiskTollfraudNumbersEnabled.Value.ToString().ToLower())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + /// The ISO country code + public FetchCountryOptions(string pathIsoCode) + { + PathIsoCode = pathIsoCode; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve all voice dialing country permissions for this account + /// + public class ReadCountryOptions : ReadOptions + { + /// + /// Filter to retrieve the country permissions by specifying the ISO country code + /// + public string IsoCode { get; set; } + /// + /// Filter to retrieve the country permissions by specifying the continent + /// + public string Continent { get; set; } + /// + /// Country code filter + /// + public string CountryCode { get; set; } + /// + /// Filter to retrieve the country permissions with dialing to low-risk numbers enabled + /// + public bool? LowRiskNumbersEnabled { get; set; } + /// + /// Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled + /// + public bool? HighRiskSpecialNumbersEnabled { get; set; } + /// + /// Filter to retrieve the country permissions with dialing to high-risk toll fraud numbers enabled + /// + public bool? HighRiskTollfraudNumbersEnabled { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (IsoCode != null) + { + p.Add(new KeyValuePair("IsoCode", IsoCode.ToString())); + } + + if (Continent != null) + { + p.Add(new KeyValuePair("Continent", Continent)); + } + + if (CountryCode != null) + { + p.Add(new KeyValuePair("CountryCode", CountryCode)); + } + + if (LowRiskNumbersEnabled != null) + { + p.Add(new KeyValuePair("LowRiskNumbersEnabled", LowRiskNumbersEnabled.Value.ToString().ToLower())); + } + + if (HighRiskSpecialNumbersEnabled != null) + { + p.Add(new KeyValuePair("HighRiskSpecialNumbersEnabled", HighRiskSpecialNumbersEnabled.Value.ToString().ToLower())); + } + + if (HighRiskTollfraudNumbersEnabled != null) + { + p.Add(new KeyValuePair("HighRiskTollfraudNumbersEnabled", HighRiskTollfraudNumbersEnabled.Value.ToString().ToLower())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryResource.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryResource.cs index e73737a2b..39f816920 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryResource.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/CountryResource.cs @@ -19,304 +19,304 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - - public class CountryResource : Resource - { - private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/DialingPermissions/Countries/" + options.PathIsoCode + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve voice dialing country permissions identified by the given ISO country code - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve voice dialing country permissions identified by the given ISO country code - /// - /// Fetch Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve voice dialing country permissions identified by the given ISO country code - /// - /// The ISO country code - /// Client to make requests to Twilio - /// A single instance of Country - public static CountryResource Fetch(string pathIsoCode, ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCode); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve voice dialing country permissions identified by the given ISO country code - /// - /// The ISO country code - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCode, - ITwilioRestClient client = null) - { - var options = new FetchCountryOptions(pathIsoCode); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/DialingPermissions/Countries", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve all voice dialing country permissions for this account - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("content", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve all voice dialing country permissions for this account - /// - /// Read Country parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("content", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve all voice dialing country permissions for this account - /// - /// Filter to retrieve the country permissions by specifying the ISO country code - /// Filter to retrieve the country permissions by specifying the continent - /// Country code filter - /// Filter to retrieve the country permissions with dialing to low-risk numbers - /// enabled - /// Filter to retrieve the country permissions with dialing to high-risk - /// special service numbers enabled - /// Filter to retrieve the country permissions with dialing to high-risk - /// toll fraud numbers enabled - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Country - public static ResourceSet Read(string isoCode = null, - string continent = null, - string countryCode = null, - bool? lowRiskNumbersEnabled = null, - bool? highRiskSpecialNumbersEnabled = null, - bool? highRiskTollfraudNumbersEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){IsoCode = isoCode, Continent = continent, CountryCode = countryCode, LowRiskNumbersEnabled = lowRiskNumbersEnabled, HighRiskSpecialNumbersEnabled = highRiskSpecialNumbersEnabled, HighRiskTollfraudNumbersEnabled = highRiskTollfraudNumbersEnabled, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve all voice dialing country permissions for this account - /// - /// Filter to retrieve the country permissions by specifying the ISO country code - /// Filter to retrieve the country permissions by specifying the continent - /// Country code filter - /// Filter to retrieve the country permissions with dialing to low-risk numbers - /// enabled - /// Filter to retrieve the country permissions with dialing to high-risk - /// special service numbers enabled - /// Filter to retrieve the country permissions with dialing to high-risk - /// toll fraud numbers enabled - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Country - public static async System.Threading.Tasks.Task> ReadAsync(string isoCode = null, - string continent = null, - string countryCode = null, - bool? lowRiskNumbersEnabled = null, - bool? highRiskSpecialNumbersEnabled = null, - bool? highRiskTollfraudNumbersEnabled = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCountryOptions(){IsoCode = isoCode, Continent = continent, CountryCode = countryCode, LowRiskNumbersEnabled = lowRiskNumbersEnabled, HighRiskSpecialNumbersEnabled = highRiskSpecialNumbersEnabled, HighRiskTollfraudNumbersEnabled = highRiskTollfraudNumbersEnabled, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("content", response.Content); - } - - /// - /// Converts a JSON string into a CountryResource object - /// - /// Raw JSON string - /// CountryResource object represented by the provided JSON - public static CountryResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The ISO country code - /// - [JsonProperty("iso_code")] - public string IsoCode { get; private set; } - /// - /// The name of the country - /// - [JsonProperty("name")] - public string Name { get; private set; } - /// - /// The name of the continent in which the country is located - /// - [JsonProperty("continent")] - public string Continent { get; private set; } - /// - /// The E.164 assigned country codes(s) - /// - [JsonProperty("country_codes")] - public List CountryCodes { get; private set; } - /// - /// Whether dialing to low-risk numbers is enabled - /// - [JsonProperty("low_risk_numbers_enabled")] - public bool? LowRiskNumbersEnabled { get; private set; } - /// - /// Whether dialing to high-risk special services numbers is enabled - /// - [JsonProperty("high_risk_special_numbers_enabled")] - public bool? HighRiskSpecialNumbersEnabled { get; private set; } - /// - /// Whether dialing to high-risk toll fraud numbers is enabled, else `false` - /// - [JsonProperty("high_risk_tollfraud_numbers_enabled")] - public bool? HighRiskTollfraudNumbersEnabled { get; private set; } - /// - /// The absolute URL of this resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// A list of URLs related to this resource - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - - private CountryResource() - { - - } - } +{ + + public class CountryResource : Resource + { + private static Request BuildFetchRequest(FetchCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/DialingPermissions/Countries/" + options.PathIsoCode + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve voice dialing country permissions identified by the given ISO country code + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(FetchCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve voice dialing country permissions identified by the given ISO country code + /// + /// Fetch Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(FetchCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve voice dialing country permissions identified by the given ISO country code + /// + /// The ISO country code + /// Client to make requests to Twilio + /// A single instance of Country + public static CountryResource Fetch(string pathIsoCode, ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCode); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve voice dialing country permissions identified by the given ISO country code + /// + /// The ISO country code + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task FetchAsync(string pathIsoCode, + ITwilioRestClient client = null) + { + var options = new FetchCountryOptions(pathIsoCode); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCountryOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/DialingPermissions/Countries", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve all voice dialing country permissions for this account + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(ReadCountryOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("content", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve all voice dialing country permissions for this account + /// + /// Read Country parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(ReadCountryOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("content", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve all voice dialing country permissions for this account + /// + /// Filter to retrieve the country permissions by specifying the ISO country code + /// Filter to retrieve the country permissions by specifying the continent + /// Country code filter + /// Filter to retrieve the country permissions with dialing to low-risk numbers + /// enabled + /// Filter to retrieve the country permissions with dialing to high-risk + /// special service numbers enabled + /// Filter to retrieve the country permissions with dialing to high-risk + /// toll fraud numbers enabled + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Country + public static ResourceSet Read(string isoCode = null, + string continent = null, + string countryCode = null, + bool? lowRiskNumbersEnabled = null, + bool? highRiskSpecialNumbersEnabled = null, + bool? highRiskTollfraudNumbersEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { IsoCode = isoCode, Continent = continent, CountryCode = countryCode, LowRiskNumbersEnabled = lowRiskNumbersEnabled, HighRiskSpecialNumbersEnabled = highRiskSpecialNumbersEnabled, HighRiskTollfraudNumbersEnabled = highRiskTollfraudNumbersEnabled, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve all voice dialing country permissions for this account + /// + /// Filter to retrieve the country permissions by specifying the ISO country code + /// Filter to retrieve the country permissions by specifying the continent + /// Country code filter + /// Filter to retrieve the country permissions with dialing to low-risk numbers + /// enabled + /// Filter to retrieve the country permissions with dialing to high-risk + /// special service numbers enabled + /// Filter to retrieve the country permissions with dialing to high-risk + /// toll fraud numbers enabled + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Country + public static async System.Threading.Tasks.Task> ReadAsync(string isoCode = null, + string continent = null, + string countryCode = null, + bool? lowRiskNumbersEnabled = null, + bool? highRiskSpecialNumbersEnabled = null, + bool? highRiskTollfraudNumbersEnabled = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCountryOptions() { IsoCode = isoCode, Continent = continent, CountryCode = countryCode, LowRiskNumbersEnabled = lowRiskNumbersEnabled, HighRiskSpecialNumbersEnabled = highRiskSpecialNumbersEnabled, HighRiskTollfraudNumbersEnabled = highRiskTollfraudNumbersEnabled, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("content", response.Content); + } + + /// + /// Converts a JSON string into a CountryResource object + /// + /// Raw JSON string + /// CountryResource object represented by the provided JSON + public static CountryResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The ISO country code + /// + [JsonProperty("iso_code")] + public string IsoCode { get; private set; } + /// + /// The name of the country + /// + [JsonProperty("name")] + public string Name { get; private set; } + /// + /// The name of the continent in which the country is located + /// + [JsonProperty("continent")] + public string Continent { get; private set; } + /// + /// The E.164 assigned country codes(s) + /// + [JsonProperty("country_codes")] + public List CountryCodes { get; private set; } + /// + /// Whether dialing to low-risk numbers is enabled + /// + [JsonProperty("low_risk_numbers_enabled")] + public bool? LowRiskNumbersEnabled { get; private set; } + /// + /// Whether dialing to high-risk special services numbers is enabled + /// + [JsonProperty("high_risk_special_numbers_enabled")] + public bool? HighRiskSpecialNumbersEnabled { get; private set; } + /// + /// Whether dialing to high-risk toll fraud numbers is enabled, else `false` + /// + [JsonProperty("high_risk_tollfraud_numbers_enabled")] + public bool? HighRiskTollfraudNumbersEnabled { get; private set; } + /// + /// The absolute URL of this resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// A list of URLs related to this resource + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + + private CountryResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsOptions.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsOptions.cs index 4daf42ed8..17c49911b 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsOptions.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsOptions.cs @@ -9,52 +9,52 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - +{ + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Retrieve voice dialing permissions inheritance for the sub-account + /// + public class FetchSettingsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Retrieve voice dialing permissions inheritance for the sub-account + /// Generate the necessary parameters /// - public class FetchSettingsOptions : IOptions - { - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you + /// currently do not have developer preview access, please contact help@twilio.com. + /// + /// Update voice dialing permissions inheritance for the sub-account + /// + public class UpdateSettingsOptions : IOptions + { /// - /// PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you - /// currently do not have developer preview access, please contact help@twilio.com. - /// - /// Update voice dialing permissions inheritance for the sub-account + /// `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false` /// - public class UpdateSettingsOptions : IOptions - { - /// - /// `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false` - /// - public bool? DialingPermissionsInheritance { get; set; } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (DialingPermissionsInheritance != null) - { - p.Add(new KeyValuePair("DialingPermissionsInheritance", DialingPermissionsInheritance.Value.ToString().ToLower())); - } - - return p; - } - } + public bool? DialingPermissionsInheritance { get; set; } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (DialingPermissionsInheritance != null) + { + p.Add(new KeyValuePair("DialingPermissionsInheritance", DialingPermissionsInheritance.Value.ToString().ToLower())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsResource.cs b/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsResource.cs index 805f7fa1b..cafc05b09 100644 --- a/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsResource.cs +++ b/src/Twilio/Rest/Voice/V1/DialingPermissions/SettingsResource.cs @@ -19,176 +19,176 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1.DialingPermissions -{ - - public class SettingsResource : Resource - { - private static Request BuildFetchRequest(FetchSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/Settings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve voice dialing permissions inheritance for the sub-account - /// - /// Fetch Settings parameters - /// Client to make requests to Twilio - /// A single instance of Settings - public static SettingsResource Fetch(FetchSettingsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Retrieve voice dialing permissions inheritance for the sub-account - /// - /// Fetch Settings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Settings - public static async System.Threading.Tasks.Task FetchAsync(FetchSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Retrieve voice dialing permissions inheritance for the sub-account - /// - /// Client to make requests to Twilio - /// A single instance of Settings - public static SettingsResource Fetch(ITwilioRestClient client = null) - { - var options = new FetchSettingsOptions(); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Retrieve voice dialing permissions inheritance for the sub-account - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Settings - public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) - { - var options = new FetchSettingsOptions(); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateSettingsOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/Settings", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Update voice dialing permissions inheritance for the sub-account - /// - /// Update Settings parameters - /// Client to make requests to Twilio - /// A single instance of Settings - public static SettingsResource Update(UpdateSettingsOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Update voice dialing permissions inheritance for the sub-account - /// - /// Update Settings parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Settings - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSettingsOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Update voice dialing permissions inheritance for the sub-account - /// - /// `true` for the sub-account to inherit voice dialing permissions from - /// the Master Project; otherwise `false` - /// Client to make requests to Twilio - /// A single instance of Settings - public static SettingsResource Update(bool? dialingPermissionsInheritance = null, ITwilioRestClient client = null) - { - var options = new UpdateSettingsOptions(){DialingPermissionsInheritance = dialingPermissionsInheritance}; - return Update(options, client); - } - - #if !NET35 - /// - /// Update voice dialing permissions inheritance for the sub-account - /// - /// `true` for the sub-account to inherit voice dialing permissions from - /// the Master Project; otherwise `false` - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Settings - public static async System.Threading.Tasks.Task UpdateAsync(bool? dialingPermissionsInheritance = null, - ITwilioRestClient client = null) - { - var options = new UpdateSettingsOptions(){DialingPermissionsInheritance = dialingPermissionsInheritance}; - return await UpdateAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SettingsResource object - /// - /// Raw JSON string - /// SettingsResource object represented by the provided JSON - public static SettingsResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// `true` if the sub-account will inherit voice dialing permissions from the Master Project; otherwise `false` - /// - [JsonProperty("dialing_permissions_inheritance")] - public bool? DialingPermissionsInheritance { get; private set; } - /// - /// The absolute URL of this resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SettingsResource() - { - - } - } +{ + + public class SettingsResource : Resource + { + private static Request BuildFetchRequest(FetchSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/Settings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve voice dialing permissions inheritance for the sub-account + /// + /// Fetch Settings parameters + /// Client to make requests to Twilio + /// A single instance of Settings + public static SettingsResource Fetch(FetchSettingsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Retrieve voice dialing permissions inheritance for the sub-account + /// + /// Fetch Settings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Settings + public static async System.Threading.Tasks.Task FetchAsync(FetchSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Retrieve voice dialing permissions inheritance for the sub-account + /// + /// Client to make requests to Twilio + /// A single instance of Settings + public static SettingsResource Fetch(ITwilioRestClient client = null) + { + var options = new FetchSettingsOptions(); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Retrieve voice dialing permissions inheritance for the sub-account + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Settings + public static async System.Threading.Tasks.Task FetchAsync(ITwilioRestClient client = null) + { + var options = new FetchSettingsOptions(); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateSettingsOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/Settings", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Update voice dialing permissions inheritance for the sub-account + /// + /// Update Settings parameters + /// Client to make requests to Twilio + /// A single instance of Settings + public static SettingsResource Update(UpdateSettingsOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Update voice dialing permissions inheritance for the sub-account + /// + /// Update Settings parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Settings + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSettingsOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Update voice dialing permissions inheritance for the sub-account + /// + /// `true` for the sub-account to inherit voice dialing permissions from + /// the Master Project; otherwise `false` + /// Client to make requests to Twilio + /// A single instance of Settings + public static SettingsResource Update(bool? dialingPermissionsInheritance = null, ITwilioRestClient client = null) + { + var options = new UpdateSettingsOptions() { DialingPermissionsInheritance = dialingPermissionsInheritance }; + return Update(options, client); + } + +#if !NET35 + /// + /// Update voice dialing permissions inheritance for the sub-account + /// + /// `true` for the sub-account to inherit voice dialing permissions from + /// the Master Project; otherwise `false` + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Settings + public static async System.Threading.Tasks.Task UpdateAsync(bool? dialingPermissionsInheritance = null, + ITwilioRestClient client = null) + { + var options = new UpdateSettingsOptions() { DialingPermissionsInheritance = dialingPermissionsInheritance }; + return await UpdateAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SettingsResource object + /// + /// Raw JSON string + /// SettingsResource object represented by the provided JSON + public static SettingsResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// `true` if the sub-account will inherit voice dialing permissions from the Master Project; otherwise `false` + /// + [JsonProperty("dialing_permissions_inheritance")] + public bool? DialingPermissionsInheritance { get; private set; } + /// + /// The absolute URL of this resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SettingsResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/IpRecordOptions.cs b/src/Twilio/Rest/Voice/V1/IpRecordOptions.cs index ba2e308c9..3cd23815a 100644 --- a/src/Twilio/Rest/Voice/V1/IpRecordOptions.cs +++ b/src/Twilio/Rest/Voice/V1/IpRecordOptions.cs @@ -9,174 +9,174 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1 -{ - +{ + + /// + /// CreateIpRecordOptions + /// + public class CreateIpRecordOptions : IOptions + { /// - /// CreateIpRecordOptions - /// - public class CreateIpRecordOptions : IOptions - { - /// - /// An IP address in dotted decimal notation, IPv4 only. - /// - public string IpAddress { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32. - /// - public int? CidrPrefixLength { get; set; } - - /// - /// Construct a new CreateIpRecordOptions - /// - /// An IP address in dotted decimal notation, IPv4 only. - public CreateIpRecordOptions(string ipAddress) - { - IpAddress = ipAddress; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpAddress != null) - { - p.Add(new KeyValuePair("IpAddress", IpAddress)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (CidrPrefixLength != null) - { - p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); - } - - return p; - } - } - + /// An IP address in dotted decimal notation, IPv4 only. + /// + public string IpAddress { get; } /// - /// FetchIpRecordOptions + /// A string to describe the resource /// - public class FetchIpRecordOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchIpRecordOptions - /// - /// The unique string that identifies the resource - public FetchIpRecordOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string FriendlyName { get; set; } /// - /// ReadIpRecordOptions - /// - public class ReadIpRecordOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32. + /// + public int? CidrPrefixLength { get; set; } + /// - /// UpdateIpRecordOptions - /// - public class UpdateIpRecordOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateIpRecordOptions - /// - /// The unique string that identifies the resource - public UpdateIpRecordOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + /// Construct a new CreateIpRecordOptions + /// + /// An IP address in dotted decimal notation, IPv4 only. + public CreateIpRecordOptions(string ipAddress) + { + IpAddress = ipAddress; + } + /// - /// DeleteIpRecordOptions + /// Generate the necessary parameters /// - public class DeleteIpRecordOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteIpRecordOptions - /// - /// The unique string that identifies the resource - public DeleteIpRecordOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public List> GetParams() + { + var p = new List>(); + if (IpAddress != null) + { + p.Add(new KeyValuePair("IpAddress", IpAddress)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (CidrPrefixLength != null) + { + p.Add(new KeyValuePair("CidrPrefixLength", CidrPrefixLength.ToString())); + } + + return p; + } + } + + /// + /// FetchIpRecordOptions + /// + public class FetchIpRecordOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new FetchIpRecordOptions + /// + /// The unique string that identifies the resource + public FetchIpRecordOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadIpRecordOptions + /// + public class ReadIpRecordOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateIpRecordOptions + /// + public class UpdateIpRecordOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateIpRecordOptions + /// + /// The unique string that identifies the resource + public UpdateIpRecordOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteIpRecordOptions + /// + public class DeleteIpRecordOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteIpRecordOptions + /// + /// The unique string that identifies the resource + public DeleteIpRecordOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/IpRecordResource.cs b/src/Twilio/Rest/Voice/V1/IpRecordResource.cs index d9f591111..4a2dec423 100644 --- a/src/Twilio/Rest/Voice/V1/IpRecordResource.cs +++ b/src/Twilio/Rest/Voice/V1/IpRecordResource.cs @@ -16,485 +16,485 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1 -{ - - public class IpRecordResource : Resource - { - private static Request BuildCreateRequest(CreateIpRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/IpRecords", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create IpRecord parameters - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Create(CreateIpRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create IpRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task CreateAsync(CreateIpRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// An IP address in dotted decimal notation, IPv4 only. - /// A string to describe the resource - /// An integer representing the length of the - /// [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default - /// the entire IP address is used, which for IPv4 is value 32. - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Create(string ipAddress, - string friendlyName = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new CreateIpRecordOptions(ipAddress){FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// An IP address in dotted decimal notation, IPv4 only. - /// A string to describe the resource - /// An integer representing the length of the - /// [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default - /// the entire IP address is used, which for IPv4 is value 32. - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task CreateAsync(string ipAddress, - string friendlyName = null, - int? cidrPrefixLength = null, - ITwilioRestClient client = null) - { - var options = new CreateIpRecordOptions(ipAddress){FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchIpRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/IpRecords/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch IpRecord parameters - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Fetch(FetchIpRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch IpRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task FetchAsync(FetchIpRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchIpRecordOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchIpRecordOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadIpRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/IpRecords", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read IpRecord parameters - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static ResourceSet Read(ReadIpRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read IpRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task> ReadAsync(ReadIpRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("ip_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpRecordOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadIpRecordOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("ip_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("ip_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("ip_records", response.Content); - } - - private static Request BuildUpdateRequest(UpdateIpRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/IpRecords/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update IpRecord parameters - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Update(UpdateIpRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update IpRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static IpRecordResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) - { - var options = new UpdateIpRecordOptions(pathSid){FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateIpRecordOptions(pathSid){FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteIpRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/IpRecords/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete IpRecord parameters - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static bool Delete(DeleteIpRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete IpRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of IpRecord - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteIpRecordOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of IpRecord - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteIpRecordOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a IpRecordResource object - /// - /// Raw JSON string - /// IpRecordResource object represented by the provided JSON - public static IpRecordResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// An IP address in dotted decimal notation, IPv4 only. - /// - [JsonProperty("ip_address")] - public string IpAddress { get; private set; } - /// - /// An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32. - /// - [JsonProperty("cidr_prefix_length")] - public int? CidrPrefixLength { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private IpRecordResource() - { - - } - } +{ + + public class IpRecordResource : Resource + { + private static Request BuildCreateRequest(CreateIpRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/IpRecords", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create IpRecord parameters + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Create(CreateIpRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create IpRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task CreateAsync(CreateIpRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// An IP address in dotted decimal notation, IPv4 only. + /// A string to describe the resource + /// An integer representing the length of the + /// [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default + /// the entire IP address is used, which for IPv4 is value 32. + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Create(string ipAddress, + string friendlyName = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new CreateIpRecordOptions(ipAddress) { FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// An IP address in dotted decimal notation, IPv4 only. + /// A string to describe the resource + /// An integer representing the length of the + /// [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default + /// the entire IP address is used, which for IPv4 is value 32. + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task CreateAsync(string ipAddress, + string friendlyName = null, + int? cidrPrefixLength = null, + ITwilioRestClient client = null) + { + var options = new CreateIpRecordOptions(ipAddress) { FriendlyName = friendlyName, CidrPrefixLength = cidrPrefixLength }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchIpRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/IpRecords/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch IpRecord parameters + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Fetch(FetchIpRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch IpRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task FetchAsync(FetchIpRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchIpRecordOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchIpRecordOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadIpRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/IpRecords", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read IpRecord parameters + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static ResourceSet Read(ReadIpRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read IpRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task> ReadAsync(ReadIpRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("ip_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpRecordOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadIpRecordOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("ip_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("ip_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("ip_records", response.Content); + } + + private static Request BuildUpdateRequest(UpdateIpRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/IpRecords/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update IpRecord parameters + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Update(UpdateIpRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update IpRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task UpdateAsync(UpdateIpRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static IpRecordResource Update(string pathSid, string friendlyName = null, ITwilioRestClient client = null) + { + var options = new UpdateIpRecordOptions(pathSid) { FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateIpRecordOptions(pathSid) { FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteIpRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/IpRecords/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete IpRecord parameters + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static bool Delete(DeleteIpRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete IpRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task DeleteAsync(DeleteIpRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of IpRecord + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteIpRecordOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of IpRecord + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteIpRecordOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a IpRecordResource object + /// + /// Raw JSON string + /// IpRecordResource object represented by the provided JSON + public static IpRecordResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// An IP address in dotted decimal notation, IPv4 only. + /// + [JsonProperty("ip_address")] + public string IpAddress { get; private set; } + /// + /// An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32. + /// + [JsonProperty("cidr_prefix_length")] + public int? CidrPrefixLength { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private IpRecordResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/SourceIpMappingOptions.cs b/src/Twilio/Rest/Voice/V1/SourceIpMappingOptions.cs index 6818c0c6b..bb5900da9 100644 --- a/src/Twilio/Rest/Voice/V1/SourceIpMappingOptions.cs +++ b/src/Twilio/Rest/Voice/V1/SourceIpMappingOptions.cs @@ -9,169 +9,169 @@ using Twilio.Converters; namespace Twilio.Rest.Voice.V1 -{ - +{ + + /// + /// CreateSourceIpMappingOptions + /// + public class CreateSourceIpMappingOptions : IOptions + { /// - /// CreateSourceIpMappingOptions + /// The unique string that identifies an IP Record /// - public class CreateSourceIpMappingOptions : IOptions - { - /// - /// The unique string that identifies an IP Record - /// - public string IpRecordSid { get; } - /// - /// The unique string that identifies a SIP Domain - /// - public string SipDomainSid { get; } - - /// - /// Construct a new CreateSourceIpMappingOptions - /// - /// The unique string that identifies an IP Record - /// The unique string that identifies a SIP Domain - public CreateSourceIpMappingOptions(string ipRecordSid, string sipDomainSid) - { - IpRecordSid = ipRecordSid; - SipDomainSid = sipDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (IpRecordSid != null) - { - p.Add(new KeyValuePair("IpRecordSid", IpRecordSid.ToString())); - } - - if (SipDomainSid != null) - { - p.Add(new KeyValuePair("SipDomainSid", SipDomainSid.ToString())); - } - - return p; - } - } - + public string IpRecordSid { get; } /// - /// FetchSourceIpMappingOptions + /// The unique string that identifies a SIP Domain /// - public class FetchSourceIpMappingOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSourceIpMappingOptions - /// - /// The unique string that identifies the resource - public FetchSourceIpMappingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string SipDomainSid { get; } + /// - /// ReadSourceIpMappingOptions + /// Construct a new CreateSourceIpMappingOptions /// - public class ReadSourceIpMappingOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// The unique string that identifies an IP Record + /// The unique string that identifies a SIP Domain + public CreateSourceIpMappingOptions(string ipRecordSid, string sipDomainSid) + { + IpRecordSid = ipRecordSid; + SipDomainSid = sipDomainSid; + } + /// - /// UpdateSourceIpMappingOptions + /// Generate the necessary parameters /// - public class UpdateSourceIpMappingOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - /// - /// The unique string that identifies a SIP Domain - /// - public string SipDomainSid { get; } - - /// - /// Construct a new UpdateSourceIpMappingOptions - /// - /// The unique string that identifies the resource - /// The unique string that identifies a SIP Domain - public UpdateSourceIpMappingOptions(string pathSid, string sipDomainSid) - { - PathSid = pathSid; - SipDomainSid = sipDomainSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (SipDomainSid != null) - { - p.Add(new KeyValuePair("SipDomainSid", SipDomainSid.ToString())); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + if (IpRecordSid != null) + { + p.Add(new KeyValuePair("IpRecordSid", IpRecordSid.ToString())); + } + + if (SipDomainSid != null) + { + p.Add(new KeyValuePair("SipDomainSid", SipDomainSid.ToString())); + } + + return p; + } + } + + /// + /// FetchSourceIpMappingOptions + /// + public class FetchSourceIpMappingOptions : IOptions + { /// - /// DeleteSourceIpMappingOptions + /// The unique string that identifies the resource /// - public class DeleteSourceIpMappingOptions : IOptions - { - /// - /// The unique string that identifies the resource - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSourceIpMappingOptions - /// - /// The unique string that identifies the resource - public DeleteSourceIpMappingOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string PathSid { get; } + + /// + /// Construct a new FetchSourceIpMappingOptions + /// + /// The unique string that identifies the resource + public FetchSourceIpMappingOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// ReadSourceIpMappingOptions + /// + public class ReadSourceIpMappingOptions : ReadOptions + { + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// UpdateSourceIpMappingOptions + /// + public class UpdateSourceIpMappingOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + /// + /// The unique string that identifies a SIP Domain + /// + public string SipDomainSid { get; } + + /// + /// Construct a new UpdateSourceIpMappingOptions + /// + /// The unique string that identifies the resource + /// The unique string that identifies a SIP Domain + public UpdateSourceIpMappingOptions(string pathSid, string sipDomainSid) + { + PathSid = pathSid; + SipDomainSid = sipDomainSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (SipDomainSid != null) + { + p.Add(new KeyValuePair("SipDomainSid", SipDomainSid.ToString())); + } + + return p; + } + } + + /// + /// DeleteSourceIpMappingOptions + /// + public class DeleteSourceIpMappingOptions : IOptions + { + /// + /// The unique string that identifies the resource + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSourceIpMappingOptions + /// + /// The unique string that identifies the resource + public DeleteSourceIpMappingOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Voice/V1/SourceIpMappingResource.cs b/src/Twilio/Rest/Voice/V1/SourceIpMappingResource.cs index 305dcdb24..bd9e47cb1 100644 --- a/src/Twilio/Rest/Voice/V1/SourceIpMappingResource.cs +++ b/src/Twilio/Rest/Voice/V1/SourceIpMappingResource.cs @@ -16,469 +16,469 @@ using Twilio.Http; namespace Twilio.Rest.Voice.V1 -{ - - public class SourceIpMappingResource : Resource - { - private static Request BuildCreateRequest(CreateSourceIpMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/SourceIpMappings", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create SourceIpMapping parameters - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Create(CreateSourceIpMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create SourceIpMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task CreateAsync(CreateSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// The unique string that identifies an IP Record - /// The unique string that identifies a SIP Domain - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Create(string ipRecordSid, - string sipDomainSid, - ITwilioRestClient client = null) - { - var options = new CreateSourceIpMappingOptions(ipRecordSid, sipDomainSid); - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// The unique string that identifies an IP Record - /// The unique string that identifies a SIP Domain - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task CreateAsync(string ipRecordSid, - string sipDomainSid, - ITwilioRestClient client = null) - { - var options = new CreateSourceIpMappingOptions(ipRecordSid, sipDomainSid); - return await CreateAsync(options, client); - } - #endif - - private static Request BuildFetchRequest(FetchSourceIpMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/SourceIpMappings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch SourceIpMapping parameters - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Fetch(FetchSourceIpMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch SourceIpMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task FetchAsync(FetchSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSourceIpMappingOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSourceIpMappingOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSourceIpMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Voice, - "/v1/SourceIpMappings", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read SourceIpMapping parameters - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static ResourceSet Read(ReadSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("source_ip_mappings", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read SourceIpMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task> ReadAsync(ReadSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("source_ip_mappings", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSourceIpMappingOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSourceIpMappingOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("source_ip_mappings", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("source_ip_mappings", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, - ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Voice) - ); - - var response = client.Request(request); - return Page.FromJson("source_ip_mappings", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSourceIpMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Voice, - "/v1/SourceIpMappings/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update SourceIpMapping parameters - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Update(UpdateSourceIpMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update SourceIpMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The unique string that identifies the resource - /// The unique string that identifies a SIP Domain - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static SourceIpMappingResource Update(string pathSid, string sipDomainSid, ITwilioRestClient client = null) - { - var options = new UpdateSourceIpMappingOptions(pathSid, sipDomainSid); - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The unique string that identifies the resource - /// The unique string that identifies a SIP Domain - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string sipDomainSid, - ITwilioRestClient client = null) - { - var options = new UpdateSourceIpMappingOptions(pathSid, sipDomainSid); - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSourceIpMappingOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Voice, - "/v1/SourceIpMappings/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete SourceIpMapping parameters - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static bool Delete(DeleteSourceIpMappingOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete SourceIpMapping parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSourceIpMappingOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// A single instance of SourceIpMapping - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSourceIpMappingOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The unique string that identifies the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of SourceIpMapping - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSourceIpMappingOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SourceIpMappingResource object - /// - /// Raw JSON string - /// SourceIpMappingResource object represented by the provided JSON - public static SourceIpMappingResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The unique string that identifies an IP Record - /// - [JsonProperty("ip_record_sid")] - public string IpRecordSid { get; private set; } - /// - /// The unique string that identifies a SIP Domain - /// - [JsonProperty("sip_domain_sid")] - public string SipDomainSid { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The RFC 2822 date and time in GMT that the resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private SourceIpMappingResource() - { - - } - } +{ + + public class SourceIpMappingResource : Resource + { + private static Request BuildCreateRequest(CreateSourceIpMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/SourceIpMappings", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create SourceIpMapping parameters + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Create(CreateSourceIpMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create SourceIpMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task CreateAsync(CreateSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// The unique string that identifies an IP Record + /// The unique string that identifies a SIP Domain + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Create(string ipRecordSid, + string sipDomainSid, + ITwilioRestClient client = null) + { + var options = new CreateSourceIpMappingOptions(ipRecordSid, sipDomainSid); + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// The unique string that identifies an IP Record + /// The unique string that identifies a SIP Domain + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task CreateAsync(string ipRecordSid, + string sipDomainSid, + ITwilioRestClient client = null) + { + var options = new CreateSourceIpMappingOptions(ipRecordSid, sipDomainSid); + return await CreateAsync(options, client); + } +#endif + + private static Request BuildFetchRequest(FetchSourceIpMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/SourceIpMappings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch SourceIpMapping parameters + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Fetch(FetchSourceIpMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch SourceIpMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task FetchAsync(FetchSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSourceIpMappingOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSourceIpMappingOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSourceIpMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Voice, + "/v1/SourceIpMappings", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read SourceIpMapping parameters + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static ResourceSet Read(ReadSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("source_ip_mappings", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read SourceIpMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task> ReadAsync(ReadSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("source_ip_mappings", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSourceIpMappingOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSourceIpMappingOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("source_ip_mappings", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("source_ip_mappings", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, + ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Voice) + ); + + var response = client.Request(request); + return Page.FromJson("source_ip_mappings", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSourceIpMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Voice, + "/v1/SourceIpMappings/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update SourceIpMapping parameters + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Update(UpdateSourceIpMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update SourceIpMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The unique string that identifies the resource + /// The unique string that identifies a SIP Domain + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static SourceIpMappingResource Update(string pathSid, string sipDomainSid, ITwilioRestClient client = null) + { + var options = new UpdateSourceIpMappingOptions(pathSid, sipDomainSid); + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The unique string that identifies the resource + /// The unique string that identifies a SIP Domain + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string sipDomainSid, + ITwilioRestClient client = null) + { + var options = new UpdateSourceIpMappingOptions(pathSid, sipDomainSid); + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSourceIpMappingOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Voice, + "/v1/SourceIpMappings/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete SourceIpMapping parameters + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static bool Delete(DeleteSourceIpMappingOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete SourceIpMapping parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSourceIpMappingOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// A single instance of SourceIpMapping + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSourceIpMappingOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The unique string that identifies the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of SourceIpMapping + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSourceIpMappingOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SourceIpMappingResource object + /// + /// Raw JSON string + /// SourceIpMappingResource object represented by the provided JSON + public static SourceIpMappingResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The unique string that identifies an IP Record + /// + [JsonProperty("ip_record_sid")] + public string IpRecordSid { get; private set; } + /// + /// The unique string that identifies a SIP Domain + /// + [JsonProperty("sip_domain_sid")] + public string SipDomainSid { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The RFC 2822 date and time in GMT that the resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private SourceIpMappingResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/CommandOptions.cs b/src/Twilio/Rest/Wireless/V1/CommandOptions.cs index 836e4ac73..a67f07161 100644 --- a/src/Twilio/Rest/Wireless/V1/CommandOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/CommandOptions.cs @@ -9,209 +9,209 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1 -{ - +{ + + /// + /// Fetch a Command instance from your account. + /// + public class FetchCommandOptions : IOptions + { /// - /// Fetch a Command instance from your account. + /// The SID that identifies the resource to fetch /// - public class FetchCommandOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchCommandOptions - /// - /// The SID that identifies the resource to fetch - public FetchCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a list of Commands from your account. - /// - public class ReadCommandOptions : ReadOptions - { - /// - /// The sid or unique_name of the Sim resources to read - /// - public string Sim { get; set; } - /// - /// The status of the resources to read - /// - public CommandResource.StatusEnum Status { get; set; } - /// - /// Only return Commands with this direction value - /// - public CommandResource.DirectionEnum Direction { get; set; } - /// - /// Only return Commands with this transport value - /// - public CommandResource.TransportEnum Transport { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim)); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Direction != null) - { - p.Add(new KeyValuePair("Direction", Direction.ToString())); - } - - if (Transport != null) - { - p.Add(new KeyValuePair("Transport", Transport.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchCommandOptions + /// + /// The SID that identifies the resource to fetch + public FetchCommandOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Send a Command to a Sim. - /// - public class CreateCommandOptions : IOptions - { - /// - /// The message body of the Command or a Base64 encoded byte string in binary mode - /// - public string Command { get; } - /// - /// The sid or unique_name of the SIM to send the Command to - /// - public string Sim { get; set; } - /// - /// The HTTP method we use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// he URL we call when the Command has finished sending - /// - public Uri CallbackUrl { get; set; } - /// - /// The mode to use when sending the SMS message - /// - public CommandResource.CommandModeEnum CommandMode { get; set; } - /// - /// Whether to include the SID of the command in the message body - /// - public string IncludeSid { get; set; } - /// - /// Whether to request delivery receipt from the recipient - /// - public bool? DeliveryReceiptRequested { get; set; } - - /// - /// Construct a new CreateCommandOptions - /// - /// The message body of the Command or a Base64 encoded byte string in binary mode - public CreateCommandOptions(string command) - { - Command = command; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (Command != null) - { - p.Add(new KeyValuePair("Command", Command)); - } - - if (Sim != null) - { - p.Add(new KeyValuePair("Sim", Sim)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (CommandMode != null) - { - p.Add(new KeyValuePair("CommandMode", CommandMode.ToString())); - } - - if (IncludeSid != null) - { - p.Add(new KeyValuePair("IncludeSid", IncludeSid)); - } - - if (DeliveryReceiptRequested != null) - { - p.Add(new KeyValuePair("DeliveryReceiptRequested", DeliveryReceiptRequested.Value.ToString().ToLower())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of Commands from your account. + /// + public class ReadCommandOptions : ReadOptions + { /// - /// Delete a Command instance from your account. + /// The sid or unique_name of the Sim resources to read /// - public class DeleteCommandOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteCommandOptions - /// - /// The SID that identifies the resource to delete - public DeleteCommandOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string Sim { get; set; } + /// + /// The status of the resources to read + /// + public CommandResource.StatusEnum Status { get; set; } + /// + /// Only return Commands with this direction value + /// + public CommandResource.DirectionEnum Direction { get; set; } + /// + /// Only return Commands with this transport value + /// + public CommandResource.TransportEnum Transport { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim)); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Direction != null) + { + p.Add(new KeyValuePair("Direction", Direction.ToString())); + } + + if (Transport != null) + { + p.Add(new KeyValuePair("Transport", Transport.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Send a Command to a Sim. + /// + public class CreateCommandOptions : IOptions + { + /// + /// The message body of the Command or a Base64 encoded byte string in binary mode + /// + public string Command { get; } + /// + /// The sid or unique_name of the SIM to send the Command to + /// + public string Sim { get; set; } + /// + /// The HTTP method we use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// he URL we call when the Command has finished sending + /// + public Uri CallbackUrl { get; set; } + /// + /// The mode to use when sending the SMS message + /// + public CommandResource.CommandModeEnum CommandMode { get; set; } + /// + /// Whether to include the SID of the command in the message body + /// + public string IncludeSid { get; set; } + /// + /// Whether to request delivery receipt from the recipient + /// + public bool? DeliveryReceiptRequested { get; set; } + + /// + /// Construct a new CreateCommandOptions + /// + /// The message body of the Command or a Base64 encoded byte string in binary mode + public CreateCommandOptions(string command) + { + Command = command; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (Command != null) + { + p.Add(new KeyValuePair("Command", Command)); + } + + if (Sim != null) + { + p.Add(new KeyValuePair("Sim", Sim)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (CommandMode != null) + { + p.Add(new KeyValuePair("CommandMode", CommandMode.ToString())); + } + + if (IncludeSid != null) + { + p.Add(new KeyValuePair("IncludeSid", IncludeSid)); + } + + if (DeliveryReceiptRequested != null) + { + p.Add(new KeyValuePair("DeliveryReceiptRequested", DeliveryReceiptRequested.Value.ToString().ToLower())); + } + + return p; + } + } + + /// + /// Delete a Command instance from your account. + /// + public class DeleteCommandOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteCommandOptions + /// + /// The SID that identifies the resource to delete + public DeleteCommandOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/CommandResource.cs b/src/Twilio/Rest/Wireless/V1/CommandResource.cs index 8bb3fcee2..c275ffbc5 100644 --- a/src/Twilio/Rest/Wireless/V1/CommandResource.cs +++ b/src/Twilio/Rest/Wireless/V1/CommandResource.cs @@ -17,522 +17,522 @@ using Twilio.Types; namespace Twilio.Rest.Wireless.V1 -{ - - public class CommandResource : Resource - { - public sealed class DirectionEnum : StringEnum - { - private DirectionEnum(string value) : base(value) {} - public DirectionEnum() {} - public static implicit operator DirectionEnum(string value) - { - return new DirectionEnum(value); - } - - public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); - public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); - } - - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum Queued = new StatusEnum("queued"); - public static readonly StatusEnum Sent = new StatusEnum("sent"); - public static readonly StatusEnum Delivered = new StatusEnum("delivered"); - public static readonly StatusEnum Received = new StatusEnum("received"); - public static readonly StatusEnum Failed = new StatusEnum("failed"); - } - - public sealed class CommandModeEnum : StringEnum - { - private CommandModeEnum(string value) : base(value) {} - public CommandModeEnum() {} - public static implicit operator CommandModeEnum(string value) - { - return new CommandModeEnum(value); - } - - public static readonly CommandModeEnum Text = new CommandModeEnum("text"); - public static readonly CommandModeEnum Binary = new CommandModeEnum("binary"); - } - - public sealed class TransportEnum : StringEnum - { - private TransportEnum(string value) : base(value) {} - public TransportEnum() {} - public static implicit operator TransportEnum(string value) - { - return new TransportEnum(value); - } - - public static readonly TransportEnum Sms = new TransportEnum("sms"); - public static readonly TransportEnum Ip = new TransportEnum("ip"); - } - - private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Commands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Command instance from your account. - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Command instance from your account. - /// - /// Fetch Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Command instance from your account. - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchCommandOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Commands", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Commands from your account. - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Commands from your account. - /// - /// Read Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("commands", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Commands from your account. - /// - /// The sid or unique_name of the Sim resources to read - /// The status of the resources to read - /// Only return Commands with this direction value - /// Only return Commands with this transport value - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Command - public static ResourceSet Read(string sim = null, - CommandResource.StatusEnum status = null, - CommandResource.DirectionEnum direction = null, - CommandResource.TransportEnum transport = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Sim = sim, Status = status, Direction = direction, Transport = transport, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Commands from your account. - /// - /// The sid or unique_name of the Sim resources to read - /// The status of the resources to read - /// Only return Commands with this direction value - /// Only return Commands with this transport value - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, - CommandResource.StatusEnum status = null, - CommandResource.DirectionEnum direction = null, - CommandResource.TransportEnum transport = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadCommandOptions(){Sim = sim, Status = status, Direction = direction, Transport = transport, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("commands", response.Content); - } - - private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Wireless, - "/v1/Commands", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Send a Command to a Sim. - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Send a Command to a Sim. - /// - /// Create Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Send a Command to a Sim. - /// - /// The message body of the Command or a Base64 encoded byte string in binary mode - /// The sid or unique_name of the SIM to send the Command to - /// The HTTP method we use to call callback_url - /// he URL we call when the Command has finished sending - /// The mode to use when sending the SMS message - /// Whether to include the SID of the command in the message body - /// Whether to request delivery receipt from the recipient - /// Client to make requests to Twilio - /// A single instance of Command - public static CommandResource Create(string command, - string sim = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - CommandResource.CommandModeEnum commandMode = null, - string includeSid = null, - bool? deliveryReceiptRequested = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(command){Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid, DeliveryReceiptRequested = deliveryReceiptRequested}; - return Create(options, client); - } - - #if !NET35 - /// - /// Send a Command to a Sim. - /// - /// The message body of the Command or a Base64 encoded byte string in binary mode - /// The sid or unique_name of the SIM to send the Command to - /// The HTTP method we use to call callback_url - /// he URL we call when the Command has finished sending - /// The mode to use when sending the SMS message - /// Whether to include the SID of the command in the message body - /// Whether to request delivery receipt from the recipient - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task CreateAsync(string command, - string sim = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - CommandResource.CommandModeEnum commandMode = null, - string includeSid = null, - bool? deliveryReceiptRequested = null, - ITwilioRestClient client = null) - { - var options = new CreateCommandOptions(command){Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid, DeliveryReceiptRequested = deliveryReceiptRequested}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteCommandOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Wireless, - "/v1/Commands/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Command instance from your account. - /// - /// Delete Command parameters - /// Client to make requests to Twilio - /// A single instance of Command - public static bool Delete(DeleteCommandOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Command instance from your account. - /// - /// Delete Command parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task DeleteAsync(DeleteCommandOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Command instance from your account. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of Command - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCommandOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Command instance from your account. - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Command - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteCommandOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a CommandResource object - /// - /// Raw JSON string - /// CommandResource object represented by the provided JSON - public static CommandResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the Sim resource that the Command was sent to or from - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The message being sent to or from the SIM - /// - [JsonProperty("command")] - public string Command { get; private set; } - /// - /// The mode used to send the SMS message - /// - [JsonProperty("command_mode")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.CommandModeEnum CommandMode { get; private set; } - /// - /// The type of transport used - /// - [JsonProperty("transport")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.TransportEnum Transport { get; private set; } - /// - /// Whether to request a delivery receipt - /// - [JsonProperty("delivery_receipt_requested")] - public bool? DeliveryReceiptRequested { get; private set; } - /// - /// The status of the Command - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.StatusEnum Status { get; private set; } - /// - /// The direction of the Command - /// - [JsonProperty("direction")] - [JsonConverter(typeof(StringEnumConverter))] - public CommandResource.DirectionEnum Direction { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was last updated format - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private CommandResource() - { - - } - } +{ + + public class CommandResource : Resource + { + public sealed class DirectionEnum : StringEnum + { + private DirectionEnum(string value) : base(value) { } + public DirectionEnum() { } + public static implicit operator DirectionEnum(string value) + { + return new DirectionEnum(value); + } + + public static readonly DirectionEnum FromSim = new DirectionEnum("from_sim"); + public static readonly DirectionEnum ToSim = new DirectionEnum("to_sim"); + } + + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum Queued = new StatusEnum("queued"); + public static readonly StatusEnum Sent = new StatusEnum("sent"); + public static readonly StatusEnum Delivered = new StatusEnum("delivered"); + public static readonly StatusEnum Received = new StatusEnum("received"); + public static readonly StatusEnum Failed = new StatusEnum("failed"); + } + + public sealed class CommandModeEnum : StringEnum + { + private CommandModeEnum(string value) : base(value) { } + public CommandModeEnum() { } + public static implicit operator CommandModeEnum(string value) + { + return new CommandModeEnum(value); + } + + public static readonly CommandModeEnum Text = new CommandModeEnum("text"); + public static readonly CommandModeEnum Binary = new CommandModeEnum("binary"); + } + + public sealed class TransportEnum : StringEnum + { + private TransportEnum(string value) : base(value) { } + public TransportEnum() { } + public static implicit operator TransportEnum(string value) + { + return new TransportEnum(value); + } + + public static readonly TransportEnum Sms = new TransportEnum("sms"); + public static readonly TransportEnum Ip = new TransportEnum("ip"); + } + + private static Request BuildFetchRequest(FetchCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Commands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Command instance from your account. + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(FetchCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Command instance from your account. + /// + /// Fetch Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(FetchCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Command instance from your account. + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchCommandOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Commands", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Commands from your account. + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(ReadCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Commands from your account. + /// + /// Read Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(ReadCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("commands", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Commands from your account. + /// + /// The sid or unique_name of the Sim resources to read + /// The status of the resources to read + /// Only return Commands with this direction value + /// Only return Commands with this transport value + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Command + public static ResourceSet Read(string sim = null, + CommandResource.StatusEnum status = null, + CommandResource.DirectionEnum direction = null, + CommandResource.TransportEnum transport = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Sim = sim, Status = status, Direction = direction, Transport = transport, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Commands from your account. + /// + /// The sid or unique_name of the Sim resources to read + /// The status of the resources to read + /// Only return Commands with this direction value + /// Only return Commands with this transport value + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task> ReadAsync(string sim = null, + CommandResource.StatusEnum status = null, + CommandResource.DirectionEnum direction = null, + CommandResource.TransportEnum transport = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadCommandOptions() { Sim = sim, Status = status, Direction = direction, Transport = transport, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("commands", response.Content); + } + + private static Request BuildCreateRequest(CreateCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Wireless, + "/v1/Commands", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Send a Command to a Sim. + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(CreateCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Send a Command to a Sim. + /// + /// Create Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(CreateCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Send a Command to a Sim. + /// + /// The message body of the Command or a Base64 encoded byte string in binary mode + /// The sid or unique_name of the SIM to send the Command to + /// The HTTP method we use to call callback_url + /// he URL we call when the Command has finished sending + /// The mode to use when sending the SMS message + /// Whether to include the SID of the command in the message body + /// Whether to request delivery receipt from the recipient + /// Client to make requests to Twilio + /// A single instance of Command + public static CommandResource Create(string command, + string sim = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + CommandResource.CommandModeEnum commandMode = null, + string includeSid = null, + bool? deliveryReceiptRequested = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(command) { Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid, DeliveryReceiptRequested = deliveryReceiptRequested }; + return Create(options, client); + } + +#if !NET35 + /// + /// Send a Command to a Sim. + /// + /// The message body of the Command or a Base64 encoded byte string in binary mode + /// The sid or unique_name of the SIM to send the Command to + /// The HTTP method we use to call callback_url + /// he URL we call when the Command has finished sending + /// The mode to use when sending the SMS message + /// Whether to include the SID of the command in the message body + /// Whether to request delivery receipt from the recipient + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task CreateAsync(string command, + string sim = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + CommandResource.CommandModeEnum commandMode = null, + string includeSid = null, + bool? deliveryReceiptRequested = null, + ITwilioRestClient client = null) + { + var options = new CreateCommandOptions(command) { Sim = sim, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, CommandMode = commandMode, IncludeSid = includeSid, DeliveryReceiptRequested = deliveryReceiptRequested }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteCommandOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Wireless, + "/v1/Commands/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Command instance from your account. + /// + /// Delete Command parameters + /// Client to make requests to Twilio + /// A single instance of Command + public static bool Delete(DeleteCommandOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Command instance from your account. + /// + /// Delete Command parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task DeleteAsync(DeleteCommandOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Command instance from your account. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of Command + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCommandOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Command instance from your account. + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Command + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteCommandOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a CommandResource object + /// + /// Raw JSON string + /// CommandResource object represented by the provided JSON + public static CommandResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the Sim resource that the Command was sent to or from + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The message being sent to or from the SIM + /// + [JsonProperty("command")] + public string Command { get; private set; } + /// + /// The mode used to send the SMS message + /// + [JsonProperty("command_mode")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.CommandModeEnum CommandMode { get; private set; } + /// + /// The type of transport used + /// + [JsonProperty("transport")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.TransportEnum Transport { get; private set; } + /// + /// Whether to request a delivery receipt + /// + [JsonProperty("delivery_receipt_requested")] + public bool? DeliveryReceiptRequested { get; private set; } + /// + /// The status of the Command + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.StatusEnum Status { get; private set; } + /// + /// The direction of the Command + /// + [JsonProperty("direction")] + [JsonConverter(typeof(StringEnumConverter))] + public CommandResource.DirectionEnum Direction { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was last updated format + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private CommandResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/RatePlanOptions.cs b/src/Twilio/Rest/Wireless/V1/RatePlanOptions.cs index db056b0eb..850c6e430 100644 --- a/src/Twilio/Rest/Wireless/V1/RatePlanOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/RatePlanOptions.cs @@ -10,254 +10,254 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1 -{ - +{ + + /// + /// ReadRatePlanOptions + /// + public class ReadRatePlanOptions : ReadOptions + { /// - /// ReadRatePlanOptions + /// Generate the necessary parameters /// - public class ReadRatePlanOptions : ReadOptions - { - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// FetchRatePlanOptions + /// + public class FetchRatePlanOptions : IOptions + { /// - /// FetchRatePlanOptions + /// The SID that identifies the resource to fetch /// - public class FetchRatePlanOptions : IOptions - { - /// - /// The SID that identifies the resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchRatePlanOptions - /// - /// The SID that identifies the resource to fetch - public FetchRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// CreateRatePlanOptions + /// Construct a new FetchRatePlanOptions /// - public class CreateRatePlanOptions : IOptions - { - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - /// - /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity - /// - public bool? DataEnabled { get; set; } - /// - /// The total data usage in Megabytes that the Network allows during one month on the home network - /// - public int? DataLimit { get; set; } - /// - /// The model used to meter data usage - /// - public string DataMetering { get; set; } - /// - /// Whether SIMs can make, send, and receive SMS using Commands - /// - public bool? MessagingEnabled { get; set; } - /// - /// Deprecated - /// - public bool? VoiceEnabled { get; set; } - /// - /// Whether SIMs can roam on networks other than the home network in the United States - /// - public bool? NationalRoamingEnabled { get; set; } - /// - /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States - /// - public List InternationalRoaming { get; set; } - /// - /// The total data usage in Megabytes that the Network allows during one month on non-home networks in the United States - /// - public int? NationalRoamingDataLimit { get; set; } - /// - /// The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States - /// - public int? InternationalRoamingDataLimit { get; set; } - - /// - /// Construct a new CreateRatePlanOptions - /// - public CreateRatePlanOptions() - { - InternationalRoaming = new List(); - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (DataEnabled != null) - { - p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); - } - - if (DataLimit != null) - { - p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); - } - - if (DataMetering != null) - { - p.Add(new KeyValuePair("DataMetering", DataMetering)); - } - - if (MessagingEnabled != null) - { - p.Add(new KeyValuePair("MessagingEnabled", MessagingEnabled.Value.ToString().ToLower())); - } - - if (VoiceEnabled != null) - { - p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); - } - - if (NationalRoamingEnabled != null) - { - p.Add(new KeyValuePair("NationalRoamingEnabled", NationalRoamingEnabled.Value.ToString().ToLower())); - } - - if (InternationalRoaming != null) - { - p.AddRange(InternationalRoaming.Select(prop => new KeyValuePair("InternationalRoaming", prop))); - } - - if (NationalRoamingDataLimit != null) - { - p.Add(new KeyValuePair("NationalRoamingDataLimit", NationalRoamingDataLimit.ToString())); - } - - if (InternationalRoamingDataLimit != null) - { - p.Add(new KeyValuePair("InternationalRoamingDataLimit", InternationalRoamingDataLimit.ToString())); - } - - return p; - } - } - + /// The SID that identifies the resource to fetch + public FetchRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// UpdateRatePlanOptions + /// Generate the necessary parameters /// - public class UpdateRatePlanOptions : IOptions - { - /// - /// The SID that identifies the resource to update - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// A string to describe the resource - /// - public string FriendlyName { get; set; } - - /// - /// Construct a new UpdateRatePlanOptions - /// - /// The SID that identifies the resource to update - public UpdateRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - return p; - } - } - + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// CreateRatePlanOptions + /// + public class CreateRatePlanOptions : IOptions + { /// - /// DeleteRatePlanOptions + /// An application-defined string that uniquely identifies the resource /// - public class DeleteRatePlanOptions : IOptions - { - /// - /// The SID that identifies the resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteRatePlanOptions - /// - /// The SID that identifies the resource to delete - public DeleteRatePlanOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public string UniqueName { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + /// + /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity + /// + public bool? DataEnabled { get; set; } + /// + /// The total data usage in Megabytes that the Network allows during one month on the home network + /// + public int? DataLimit { get; set; } + /// + /// The model used to meter data usage + /// + public string DataMetering { get; set; } + /// + /// Whether SIMs can make, send, and receive SMS using Commands + /// + public bool? MessagingEnabled { get; set; } + /// + /// Deprecated + /// + public bool? VoiceEnabled { get; set; } + /// + /// Whether SIMs can roam on networks other than the home network in the United States + /// + public bool? NationalRoamingEnabled { get; set; } + /// + /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States + /// + public List InternationalRoaming { get; set; } + /// + /// The total data usage in Megabytes that the Network allows during one month on non-home networks in the United States + /// + public int? NationalRoamingDataLimit { get; set; } + /// + /// The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States + /// + public int? InternationalRoamingDataLimit { get; set; } + + /// + /// Construct a new CreateRatePlanOptions + /// + public CreateRatePlanOptions() + { + InternationalRoaming = new List(); + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (DataEnabled != null) + { + p.Add(new KeyValuePair("DataEnabled", DataEnabled.Value.ToString().ToLower())); + } + + if (DataLimit != null) + { + p.Add(new KeyValuePair("DataLimit", DataLimit.ToString())); + } + + if (DataMetering != null) + { + p.Add(new KeyValuePair("DataMetering", DataMetering)); + } + + if (MessagingEnabled != null) + { + p.Add(new KeyValuePair("MessagingEnabled", MessagingEnabled.Value.ToString().ToLower())); + } + + if (VoiceEnabled != null) + { + p.Add(new KeyValuePair("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower())); + } + + if (NationalRoamingEnabled != null) + { + p.Add(new KeyValuePair("NationalRoamingEnabled", NationalRoamingEnabled.Value.ToString().ToLower())); + } + + if (InternationalRoaming != null) + { + p.AddRange(InternationalRoaming.Select(prop => new KeyValuePair("InternationalRoaming", prop))); + } + + if (NationalRoamingDataLimit != null) + { + p.Add(new KeyValuePair("NationalRoamingDataLimit", NationalRoamingDataLimit.ToString())); + } + + if (InternationalRoamingDataLimit != null) + { + p.Add(new KeyValuePair("InternationalRoamingDataLimit", InternationalRoamingDataLimit.ToString())); + } + + return p; + } + } + + /// + /// UpdateRatePlanOptions + /// + public class UpdateRatePlanOptions : IOptions + { + /// + /// The SID that identifies the resource to update + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// A string to describe the resource + /// + public string FriendlyName { get; set; } + + /// + /// Construct a new UpdateRatePlanOptions + /// + /// The SID that identifies the resource to update + public UpdateRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + return p; + } + } + + /// + /// DeleteRatePlanOptions + /// + public class DeleteRatePlanOptions : IOptions + { + /// + /// The SID that identifies the resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteRatePlanOptions + /// + /// The SID that identifies the resource to delete + public DeleteRatePlanOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/RatePlanResource.cs b/src/Twilio/Rest/Wireless/V1/RatePlanResource.cs index af00c39e5..7d691347f 100644 --- a/src/Twilio/Rest/Wireless/V1/RatePlanResource.cs +++ b/src/Twilio/Rest/Wireless/V1/RatePlanResource.cs @@ -17,584 +17,584 @@ using Twilio.Types; namespace Twilio.Rest.Wireless.V1 -{ - - public class RatePlanResource : Resource - { - public sealed class DataLimitStrategyEnum : StringEnum - { - private DataLimitStrategyEnum(string value) : base(value) {} - public DataLimitStrategyEnum() {} - public static implicit operator DataLimitStrategyEnum(string value) - { - return new DataLimitStrategyEnum(value); - } - - public static readonly DataLimitStrategyEnum Block = new DataLimitStrategyEnum("block"); - public static readonly DataLimitStrategyEnum Throttle = new DataLimitStrategyEnum("throttle"); - } - - private static Request BuildReadRequest(ReadRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/RatePlans", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static ResourceSet Read(ReadRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_plans", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task> ReadAsync(ReadRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("rate_plans", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static ResourceSet Read(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRatePlanOptions(){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadRatePlanOptions(){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("rate_plans", response.Content); - } - - private static Request BuildFetchRequest(FetchRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/RatePlans/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// fetch - /// - /// Fetch RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Fetch(FetchRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// fetch - /// - /// Fetch RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task FetchAsync(FetchRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchRatePlanOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// fetch - /// - /// The SID that identifies the resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchRatePlanOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildCreateRequest(CreateRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Wireless, - "/v1/RatePlans", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// create - /// - /// Create RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Create(CreateRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// create - /// - /// Create RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task CreateAsync(CreateRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// create - /// - /// An application-defined string that uniquely identifies the resource - /// A string to describe the resource - /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity - /// The total data usage in Megabytes that the Network allows during one month on the home - /// network - /// The model used to meter data usage - /// Whether SIMs can make, send, and receive SMS using Commands - /// Deprecated - /// Whether SIMs can roam on networks other than the home network in the United - /// States - /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can - /// use outside of the United States - /// The total data usage in Megabytes that the Network allows during one month - /// on non-home networks in the United States - /// The total data usage (download and upload combined) in Megabytes that - /// the Network allows during one month when roaming outside the United States - /// - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Create(string uniqueName = null, - string friendlyName = null, - bool? dataEnabled = null, - int? dataLimit = null, - string dataMetering = null, - bool? messagingEnabled = null, - bool? voiceEnabled = null, - bool? nationalRoamingEnabled = null, - List internationalRoaming = null, - int? nationalRoamingDataLimit = null, - int? internationalRoamingDataLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateRatePlanOptions(){UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming, NationalRoamingDataLimit = nationalRoamingDataLimit, InternationalRoamingDataLimit = internationalRoamingDataLimit}; - return Create(options, client); - } - - #if !NET35 - /// - /// create - /// - /// An application-defined string that uniquely identifies the resource - /// A string to describe the resource - /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity - /// The total data usage in Megabytes that the Network allows during one month on the home - /// network - /// The model used to meter data usage - /// Whether SIMs can make, send, and receive SMS using Commands - /// Deprecated - /// Whether SIMs can roam on networks other than the home network in the United - /// States - /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can - /// use outside of the United States - /// The total data usage in Megabytes that the Network allows during one month - /// on non-home networks in the United States - /// The total data usage (download and upload combined) in Megabytes that - /// the Network allows during one month when roaming outside the United States - /// - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, - string friendlyName = null, - bool? dataEnabled = null, - int? dataLimit = null, - string dataMetering = null, - bool? messagingEnabled = null, - bool? voiceEnabled = null, - bool? nationalRoamingEnabled = null, - List internationalRoaming = null, - int? nationalRoamingDataLimit = null, - int? internationalRoamingDataLimit = null, - ITwilioRestClient client = null) - { - var options = new CreateRatePlanOptions(){UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming, NationalRoamingDataLimit = nationalRoamingDataLimit, InternationalRoamingDataLimit = internationalRoamingDataLimit}; - return await CreateAsync(options, client); - } - #endif - - private static Request BuildUpdateRequest(UpdateRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Wireless, - "/v1/RatePlans/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// update - /// - /// Update RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Update(UpdateRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// update - /// - /// Update RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task UpdateAsync(UpdateRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// update - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static RatePlanResource Update(string pathSid, - string uniqueName = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateRatePlanOptions(pathSid){UniqueName = uniqueName, FriendlyName = friendlyName}; - return Update(options, client); - } - - #if !NET35 - /// - /// update - /// - /// The SID that identifies the resource to update - /// An application-defined string that uniquely identifies the resource - /// A string to describe the resource - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - string friendlyName = null, - ITwilioRestClient client = null) - { - var options = new UpdateRatePlanOptions(pathSid){UniqueName = uniqueName, FriendlyName = friendlyName}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteRatePlanOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Wireless, - "/v1/RatePlans/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// delete - /// - /// Delete RatePlan parameters - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static bool Delete(DeleteRatePlanOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// delete - /// - /// Delete RatePlan parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task DeleteAsync(DeleteRatePlanOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// A single instance of RatePlan - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRatePlanOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// delete - /// - /// The SID that identifies the resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of RatePlan - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteRatePlanOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a RatePlanResource object - /// - /// Raw JSON string - /// RatePlanResource object represented by the provided JSON - public static RatePlanResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The string that you assigned to describe the resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity - /// - [JsonProperty("data_enabled")] - public bool? DataEnabled { get; private set; } - /// - /// The model used to meter data usage - /// - [JsonProperty("data_metering")] - public string DataMetering { get; private set; } - /// - /// The total data usage in Megabytes that the Network allows during one month on the home network - /// - [JsonProperty("data_limit")] - public int? DataLimit { get; private set; } - /// - /// Whether SIMs can make, send, and receive SMS using Commands - /// - [JsonProperty("messaging_enabled")] - public bool? MessagingEnabled { get; private set; } - /// - /// Deprecated. Whether SIMs can make and receive voice calls - /// - [JsonProperty("voice_enabled")] - public bool? VoiceEnabled { get; private set; } - /// - /// Whether SIMs can roam on networks other than the home network in the United States - /// - [JsonProperty("national_roaming_enabled")] - public bool? NationalRoamingEnabled { get; private set; } - /// - /// The total data usage in Megabytes that the Network allows during one month on non-home networks in the United States - /// - [JsonProperty("national_roaming_data_limit")] - public int? NationalRoamingDataLimit { get; private set; } - /// - /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States - /// - [JsonProperty("international_roaming")] - public List InternationalRoaming { get; private set; } - /// - /// The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States - /// - [JsonProperty("international_roaming_data_limit")] - public int? InternationalRoamingDataLimit { get; private set; } - /// - /// The date when the resource was created, given as GMT in ISO 8601 format - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The date when the resource was last updated, given as GMT in ISO 8601 format - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - - private RatePlanResource() - { - - } - } +{ + + public class RatePlanResource : Resource + { + public sealed class DataLimitStrategyEnum : StringEnum + { + private DataLimitStrategyEnum(string value) : base(value) { } + public DataLimitStrategyEnum() { } + public static implicit operator DataLimitStrategyEnum(string value) + { + return new DataLimitStrategyEnum(value); + } + + public static readonly DataLimitStrategyEnum Block = new DataLimitStrategyEnum("block"); + public static readonly DataLimitStrategyEnum Throttle = new DataLimitStrategyEnum("throttle"); + } + + private static Request BuildReadRequest(ReadRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/RatePlans", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static ResourceSet Read(ReadRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_plans", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task> ReadAsync(ReadRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("rate_plans", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static ResourceSet Read(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRatePlanOptions() { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task> ReadAsync(int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadRatePlanOptions() { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("rate_plans", response.Content); + } + + private static Request BuildFetchRequest(FetchRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/RatePlans/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// fetch + /// + /// Fetch RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Fetch(FetchRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// fetch + /// + /// Fetch RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task FetchAsync(FetchRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchRatePlanOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// fetch + /// + /// The SID that identifies the resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchRatePlanOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildCreateRequest(CreateRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Wireless, + "/v1/RatePlans", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// create + /// + /// Create RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Create(CreateRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// create + /// + /// Create RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task CreateAsync(CreateRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// create + /// + /// An application-defined string that uniquely identifies the resource + /// A string to describe the resource + /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity + /// The total data usage in Megabytes that the Network allows during one month on the home + /// network + /// The model used to meter data usage + /// Whether SIMs can make, send, and receive SMS using Commands + /// Deprecated + /// Whether SIMs can roam on networks other than the home network in the United + /// States + /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can + /// use outside of the United States + /// The total data usage in Megabytes that the Network allows during one month + /// on non-home networks in the United States + /// The total data usage (download and upload combined) in Megabytes that + /// the Network allows during one month when roaming outside the United States + /// + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Create(string uniqueName = null, + string friendlyName = null, + bool? dataEnabled = null, + int? dataLimit = null, + string dataMetering = null, + bool? messagingEnabled = null, + bool? voiceEnabled = null, + bool? nationalRoamingEnabled = null, + List internationalRoaming = null, + int? nationalRoamingDataLimit = null, + int? internationalRoamingDataLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateRatePlanOptions() { UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming, NationalRoamingDataLimit = nationalRoamingDataLimit, InternationalRoamingDataLimit = internationalRoamingDataLimit }; + return Create(options, client); + } + +#if !NET35 + /// + /// create + /// + /// An application-defined string that uniquely identifies the resource + /// A string to describe the resource + /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity + /// The total data usage in Megabytes that the Network allows during one month on the home + /// network + /// The model used to meter data usage + /// Whether SIMs can make, send, and receive SMS using Commands + /// Deprecated + /// Whether SIMs can roam on networks other than the home network in the United + /// States + /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can + /// use outside of the United States + /// The total data usage in Megabytes that the Network allows during one month + /// on non-home networks in the United States + /// The total data usage (download and upload combined) in Megabytes that + /// the Network allows during one month when roaming outside the United States + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task CreateAsync(string uniqueName = null, + string friendlyName = null, + bool? dataEnabled = null, + int? dataLimit = null, + string dataMetering = null, + bool? messagingEnabled = null, + bool? voiceEnabled = null, + bool? nationalRoamingEnabled = null, + List internationalRoaming = null, + int? nationalRoamingDataLimit = null, + int? internationalRoamingDataLimit = null, + ITwilioRestClient client = null) + { + var options = new CreateRatePlanOptions() { UniqueName = uniqueName, FriendlyName = friendlyName, DataEnabled = dataEnabled, DataLimit = dataLimit, DataMetering = dataMetering, MessagingEnabled = messagingEnabled, VoiceEnabled = voiceEnabled, NationalRoamingEnabled = nationalRoamingEnabled, InternationalRoaming = internationalRoaming, NationalRoamingDataLimit = nationalRoamingDataLimit, InternationalRoamingDataLimit = internationalRoamingDataLimit }; + return await CreateAsync(options, client); + } +#endif + + private static Request BuildUpdateRequest(UpdateRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Wireless, + "/v1/RatePlans/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// update + /// + /// Update RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Update(UpdateRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// update + /// + /// Update RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task UpdateAsync(UpdateRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// update + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static RatePlanResource Update(string pathSid, + string uniqueName = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateRatePlanOptions(pathSid) { UniqueName = uniqueName, FriendlyName = friendlyName }; + return Update(options, client); + } + +#if !NET35 + /// + /// update + /// + /// The SID that identifies the resource to update + /// An application-defined string that uniquely identifies the resource + /// A string to describe the resource + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + string friendlyName = null, + ITwilioRestClient client = null) + { + var options = new UpdateRatePlanOptions(pathSid) { UniqueName = uniqueName, FriendlyName = friendlyName }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteRatePlanOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Wireless, + "/v1/RatePlans/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// delete + /// + /// Delete RatePlan parameters + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static bool Delete(DeleteRatePlanOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// delete + /// + /// Delete RatePlan parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task DeleteAsync(DeleteRatePlanOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// A single instance of RatePlan + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRatePlanOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// delete + /// + /// The SID that identifies the resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of RatePlan + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteRatePlanOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a RatePlanResource object + /// + /// Raw JSON string + /// RatePlanResource object represented by the provided JSON + public static RatePlanResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The string that you assigned to describe the resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// Whether SIMs can use GPRS/3G/4G/LTE data connectivity + /// + [JsonProperty("data_enabled")] + public bool? DataEnabled { get; private set; } + /// + /// The model used to meter data usage + /// + [JsonProperty("data_metering")] + public string DataMetering { get; private set; } + /// + /// The total data usage in Megabytes that the Network allows during one month on the home network + /// + [JsonProperty("data_limit")] + public int? DataLimit { get; private set; } + /// + /// Whether SIMs can make, send, and receive SMS using Commands + /// + [JsonProperty("messaging_enabled")] + public bool? MessagingEnabled { get; private set; } + /// + /// Deprecated. Whether SIMs can make and receive voice calls + /// + [JsonProperty("voice_enabled")] + public bool? VoiceEnabled { get; private set; } + /// + /// Whether SIMs can roam on networks other than the home network in the United States + /// + [JsonProperty("national_roaming_enabled")] + public bool? NationalRoamingEnabled { get; private set; } + /// + /// The total data usage in Megabytes that the Network allows during one month on non-home networks in the United States + /// + [JsonProperty("national_roaming_data_limit")] + public int? NationalRoamingDataLimit { get; private set; } + /// + /// The services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States + /// + [JsonProperty("international_roaming")] + public List InternationalRoaming { get; private set; } + /// + /// The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States + /// + [JsonProperty("international_roaming_data_limit")] + public int? InternationalRoamingDataLimit { get; private set; } + /// + /// The date when the resource was created, given as GMT in ISO 8601 format + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The date when the resource was last updated, given as GMT in ISO 8601 format + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + + private RatePlanResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/Sim/DataSessionOptions.cs b/src/Twilio/Rest/Wireless/V1/Sim/DataSessionOptions.cs index 87b3f79fd..67b47a2d6 100644 --- a/src/Twilio/Rest/Wireless/V1/Sim/DataSessionOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/Sim/DataSessionOptions.cs @@ -9,40 +9,40 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1.Sim -{ - +{ + + /// + /// ReadDataSessionOptions + /// + public class ReadDataSessionOptions : ReadOptions + { /// - /// ReadDataSessionOptions + /// The SID of the Sim resource with the Data Sessions to read /// - public class ReadDataSessionOptions : ReadOptions - { - /// - /// The SID of the Sim resource with the Data Sessions to read - /// - public string PathSimSid { get; } - - /// - /// Construct a new ReadDataSessionOptions - /// - /// The SID of the Sim resource with the Data Sessions to read - public ReadDataSessionOptions(string pathSimSid) - { - PathSimSid = pathSimSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSimSid { get; } + + /// + /// Construct a new ReadDataSessionOptions + /// + /// The SID of the Sim resource with the Data Sessions to read + public ReadDataSessionOptions(string pathSimSid) + { + PathSimSid = pathSimSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/Sim/DataSessionResource.cs b/src/Twilio/Rest/Wireless/V1/Sim/DataSessionResource.cs index 4b9010a9a..5df72ad45 100644 --- a/src/Twilio/Rest/Wireless/V1/Sim/DataSessionResource.cs +++ b/src/Twilio/Rest/Wireless/V1/Sim/DataSessionResource.cs @@ -16,246 +16,246 @@ using Twilio.Http; namespace Twilio.Rest.Wireless.V1.Sim -{ - - public class DataSessionResource : Resource - { - private static Request BuildReadRequest(ReadDataSessionOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Sims/" + options.PathSimSid + "/DataSessions", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read DataSession parameters - /// Client to make requests to Twilio - /// A single instance of DataSession - public static ResourceSet Read(ReadDataSessionOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("data_sessions", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read DataSession parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DataSession - public static async System.Threading.Tasks.Task> ReadAsync(ReadDataSessionOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("data_sessions", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sim resource with the Data Sessions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of DataSession - public static ResourceSet Read(string pathSimSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDataSessionOptions(pathSimSid){PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sim resource with the Data Sessions to read - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of DataSession - public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadDataSessionOptions(pathSimSid){PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("data_sessions", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("data_sessions", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("data_sessions", response.Content); - } - - /// - /// Converts a JSON string into a DataSessionResource object - /// - /// Raw JSON string - /// DataSessionResource object represented by the provided JSON - public static DataSessionResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// The SID of the Sim resource that the Data Session is for - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The generation of wireless technology that the device was using - /// - [JsonProperty("radio_link")] - public string RadioLink { get; private set; } - /// - /// The 'mobile country code' is the unique ID of the home country where the Data Session took place - /// - [JsonProperty("operator_mcc")] - public string OperatorMcc { get; private set; } - /// - /// The 'mobile network code' is the unique ID specific to the mobile operator network where the Data Session took place - /// - [JsonProperty("operator_mnc")] - public string OperatorMnc { get; private set; } - /// - /// The three letter country code representing where the device's Data Session took place - /// - [JsonProperty("operator_country")] - public string OperatorCountry { get; private set; } - /// - /// The friendly name of the mobile operator network that the SIM-connected device is attached to - /// - [JsonProperty("operator_name")] - public string OperatorName { get; private set; } - /// - /// The unique ID of the cellular tower that the device was attached to at the moment when the Data Session was last updated - /// - [JsonProperty("cell_id")] - public string CellId { get; private set; } - /// - /// An object with the estimated location where the device's Data Session took place - /// - [JsonProperty("cell_location_estimate")] - public object CellLocationEstimate { get; private set; } - /// - /// The number of packets uploaded by the device between the start time and when the Data Session was last updated - /// - [JsonProperty("packets_uploaded")] - public int? PacketsUploaded { get; private set; } - /// - /// The number of packets downloaded by the device between the start time and when the Data Session was last updated - /// - [JsonProperty("packets_downloaded")] - public int? PacketsDownloaded { get; private set; } - /// - /// The date that the resource was last updated, given as GMT in ISO 8601 format - /// - [JsonProperty("last_updated")] - public DateTime? LastUpdated { get; private set; } - /// - /// The date that the Data Session started, given as GMT in ISO 8601 format - /// - [JsonProperty("start")] - public DateTime? Start { get; private set; } - /// - /// The date that the record ended, given as GMT in ISO 8601 format - /// - [JsonProperty("end")] - public DateTime? End { get; private set; } - /// - /// The unique ID of the device using the SIM to connect - /// - [JsonProperty("imei")] - public string Imei { get; private set; } - - private DataSessionResource() - { - - } - } +{ + + public class DataSessionResource : Resource + { + private static Request BuildReadRequest(ReadDataSessionOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Sims/" + options.PathSimSid + "/DataSessions", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read DataSession parameters + /// Client to make requests to Twilio + /// A single instance of DataSession + public static ResourceSet Read(ReadDataSessionOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("data_sessions", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read DataSession parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DataSession + public static async System.Threading.Tasks.Task> ReadAsync(ReadDataSessionOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("data_sessions", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sim resource with the Data Sessions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of DataSession + public static ResourceSet Read(string pathSimSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDataSessionOptions(pathSimSid) { PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sim resource with the Data Sessions to read + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of DataSession + public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadDataSessionOptions(pathSimSid) { PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("data_sessions", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("data_sessions", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("data_sessions", response.Content); + } + + /// + /// Converts a JSON string into a DataSessionResource object + /// + /// Raw JSON string + /// DataSessionResource object represented by the provided JSON + public static DataSessionResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// The SID of the Sim resource that the Data Session is for + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The generation of wireless technology that the device was using + /// + [JsonProperty("radio_link")] + public string RadioLink { get; private set; } + /// + /// The 'mobile country code' is the unique ID of the home country where the Data Session took place + /// + [JsonProperty("operator_mcc")] + public string OperatorMcc { get; private set; } + /// + /// The 'mobile network code' is the unique ID specific to the mobile operator network where the Data Session took place + /// + [JsonProperty("operator_mnc")] + public string OperatorMnc { get; private set; } + /// + /// The three letter country code representing where the device's Data Session took place + /// + [JsonProperty("operator_country")] + public string OperatorCountry { get; private set; } + /// + /// The friendly name of the mobile operator network that the SIM-connected device is attached to + /// + [JsonProperty("operator_name")] + public string OperatorName { get; private set; } + /// + /// The unique ID of the cellular tower that the device was attached to at the moment when the Data Session was last updated + /// + [JsonProperty("cell_id")] + public string CellId { get; private set; } + /// + /// An object with the estimated location where the device's Data Session took place + /// + [JsonProperty("cell_location_estimate")] + public object CellLocationEstimate { get; private set; } + /// + /// The number of packets uploaded by the device between the start time and when the Data Session was last updated + /// + [JsonProperty("packets_uploaded")] + public int? PacketsUploaded { get; private set; } + /// + /// The number of packets downloaded by the device between the start time and when the Data Session was last updated + /// + [JsonProperty("packets_downloaded")] + public int? PacketsDownloaded { get; private set; } + /// + /// The date that the resource was last updated, given as GMT in ISO 8601 format + /// + [JsonProperty("last_updated")] + public DateTime? LastUpdated { get; private set; } + /// + /// The date that the Data Session started, given as GMT in ISO 8601 format + /// + [JsonProperty("start")] + public DateTime? Start { get; private set; } + /// + /// The date that the record ended, given as GMT in ISO 8601 format + /// + [JsonProperty("end")] + public DateTime? End { get; private set; } + /// + /// The unique ID of the device using the SIM to connect + /// + [JsonProperty("imei")] + public string Imei { get; private set; } + + private DataSessionResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordOptions.cs b/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordOptions.cs index dff66844f..3124f7df3 100644 --- a/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordOptions.cs @@ -9,67 +9,67 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1.Sim -{ - +{ + + /// + /// ReadUsageRecordOptions + /// + public class ReadUsageRecordOptions : ReadOptions + { /// - /// ReadUsageRecordOptions + /// The SID of the Sim resource to read the usage from /// - public class ReadUsageRecordOptions : ReadOptions - { - /// - /// The SID of the Sim resource to read the usage from - /// - public string PathSimSid { get; } - /// - /// Only include usage that occurred on or before this date - /// - public DateTime? End { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? Start { get; set; } - /// - /// The time-based grouping that results are aggregated by - /// - public UsageRecordResource.GranularityEnum Granularity { get; set; } - - /// - /// Construct a new ReadUsageRecordOptions - /// - /// The SID of the Sim resource to read the usage from - public ReadUsageRecordOptions(string pathSimSid) - { - PathSimSid = pathSimSid; - } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (End != null) - { - p.Add(new KeyValuePair("End", Serializers.DateTimeIso8601(End))); - } - - if (Start != null) - { - p.Add(new KeyValuePair("Start", Serializers.DateTimeIso8601(Start))); - } - - if (Granularity != null) - { - p.Add(new KeyValuePair("Granularity", Granularity.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public string PathSimSid { get; } + /// + /// Only include usage that occurred on or before this date + /// + public DateTime? End { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? Start { get; set; } + /// + /// The time-based grouping that results are aggregated by + /// + public UsageRecordResource.GranularityEnum Granularity { get; set; } + + /// + /// Construct a new ReadUsageRecordOptions + /// + /// The SID of the Sim resource to read the usage from + public ReadUsageRecordOptions(string pathSimSid) + { + PathSimSid = pathSimSid; + } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (End != null) + { + p.Add(new KeyValuePair("End", Serializers.DateTimeIso8601(End))); + } + + if (Start != null) + { + p.Add(new KeyValuePair("Start", Serializers.DateTimeIso8601(Start))); + } + + if (Granularity != null) + { + p.Add(new KeyValuePair("Granularity", Granularity.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordResource.cs b/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordResource.cs index 2ca090238..9fff4a120 100644 --- a/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordResource.cs +++ b/src/Twilio/Rest/Wireless/V1/Sim/UsageRecordResource.cs @@ -17,217 +17,217 @@ using Twilio.Types; namespace Twilio.Rest.Wireless.V1.Sim -{ - - public class UsageRecordResource : Resource - { - public sealed class GranularityEnum : StringEnum - { - private GranularityEnum(string value) : base(value) {} - public GranularityEnum() {} - public static implicit operator GranularityEnum(string value) - { - return new GranularityEnum(value); - } - - public static readonly GranularityEnum Hourly = new GranularityEnum("hourly"); - public static readonly GranularityEnum Daily = new GranularityEnum("daily"); - public static readonly GranularityEnum All = new GranularityEnum("all"); - } - - private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Sims/" + options.PathSimSid + "/UsageRecords", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// The SID of the Sim resource to read the usage from - /// Only include usage that occurred on or before this date - /// Only include usage that has occurred on or after this date - /// The time-based grouping that results are aggregated by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(string pathSimSid, - DateTime? end = null, - DateTime? start = null, - UsageRecordResource.GranularityEnum granularity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(pathSimSid){End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// The SID of the Sim resource to read the usage from - /// Only include usage that occurred on or before this date - /// Only include usage that has occurred on or after this date - /// The time-based grouping that results are aggregated by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, - DateTime? end = null, - DateTime? start = null, - UsageRecordResource.GranularityEnum granularity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(pathSimSid){End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a UsageRecordResource object - /// - /// Raw JSON string - /// UsageRecordResource object represented by the provided JSON - public static UsageRecordResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Sim resource that this Usage Record is for - /// - [JsonProperty("sim_sid")] - public string SimSid { get; private set; } - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The time period for which the usage is reported - /// - [JsonProperty("period")] - public object Period { get; private set; } - /// - /// An object that describes the SIM's usage of Commands during the specified period - /// - [JsonProperty("commands")] - public object Commands { get; private set; } - /// - /// An object that describes the SIM's data usage during the specified period - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private UsageRecordResource() - { - - } - } +{ + + public class UsageRecordResource : Resource + { + public sealed class GranularityEnum : StringEnum + { + private GranularityEnum(string value) : base(value) { } + public GranularityEnum() { } + public static implicit operator GranularityEnum(string value) + { + return new GranularityEnum(value); + } + + public static readonly GranularityEnum Hourly = new GranularityEnum("hourly"); + public static readonly GranularityEnum Daily = new GranularityEnum("daily"); + public static readonly GranularityEnum All = new GranularityEnum("all"); + } + + private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Sims/" + options.PathSimSid + "/UsageRecords", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// The SID of the Sim resource to read the usage from + /// Only include usage that occurred on or before this date + /// Only include usage that has occurred on or after this date + /// The time-based grouping that results are aggregated by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(string pathSimSid, + DateTime? end = null, + DateTime? start = null, + UsageRecordResource.GranularityEnum granularity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions(pathSimSid) { End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// The SID of the Sim resource to read the usage from + /// Only include usage that occurred on or before this date + /// Only include usage that has occurred on or after this date + /// The time-based grouping that results are aggregated by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(string pathSimSid, + DateTime? end = null, + DateTime? start = null, + UsageRecordResource.GranularityEnum granularity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions(pathSimSid) { End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a UsageRecordResource object + /// + /// Raw JSON string + /// UsageRecordResource object represented by the provided JSON + public static UsageRecordResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Sim resource that this Usage Record is for + /// + [JsonProperty("sim_sid")] + public string SimSid { get; private set; } + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The time period for which the usage is reported + /// + [JsonProperty("period")] + public object Period { get; private set; } + /// + /// An object that describes the SIM's usage of Commands during the specified period + /// + [JsonProperty("commands")] + public object Commands { get; private set; } + /// + /// An object that describes the SIM's data usage during the specified period + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private UsageRecordResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/SimOptions.cs b/src/Twilio/Rest/Wireless/V1/SimOptions.cs index e5fb05f85..9f0539348 100644 --- a/src/Twilio/Rest/Wireless/V1/SimOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/SimOptions.cs @@ -9,321 +9,321 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1 -{ - +{ + + /// + /// Fetch a Sim resource on your Account. + /// + public class FetchSimOptions : IOptions + { /// - /// Fetch a Sim resource on your Account. + /// The SID of the Sim resource to fetch /// - public class FetchSimOptions : IOptions - { - /// - /// The SID of the Sim resource to fetch - /// - public string PathSid { get; } - - /// - /// Construct a new FetchSimOptions - /// - /// The SID of the Sim resource to fetch - public FetchSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } - + public string PathSid { get; } + /// - /// Retrieve a list of Sim resources on your Account. - /// - public class ReadSimOptions : ReadOptions - { - /// - /// Only return Sim resources with this status - /// - public SimResource.StatusEnum Status { get; set; } - /// - /// Only return Sim resources with this ICCID - /// - public string Iccid { get; set; } - /// - /// Only return Sim resources assigned to this RatePlan resource - /// - public string RatePlan { get; set; } - /// - /// Deprecated - /// - public string EId { get; set; } - /// - /// Only return Sim resources with this registration code - /// - public string SimRegistrationCode { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (Iccid != null) - { - p.Add(new KeyValuePair("Iccid", Iccid)); - } - - if (RatePlan != null) - { - p.Add(new KeyValuePair("RatePlan", RatePlan)); - } - - if (EId != null) - { - p.Add(new KeyValuePair("EId", EId)); - } - - if (SimRegistrationCode != null) - { - p.Add(new KeyValuePair("SimRegistrationCode", SimRegistrationCode)); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } - + /// Construct a new FetchSimOptions + /// + /// The SID of the Sim resource to fetch + public FetchSimOptions(string pathSid) + { + PathSid = pathSid; + } + /// - /// Updates the given properties of a Sim resource on your Account. - /// - public class UpdateSimOptions : IOptions - { - /// - /// The SID of the Sim resource to update - /// - public string PathSid { get; } - /// - /// An application-defined string that uniquely identifies the resource - /// - public string UniqueName { get; set; } - /// - /// The HTTP method we should use to call callback_url - /// - public Twilio.Http.HttpMethod CallbackMethod { get; set; } - /// - /// The URL we should call when the Sim resource has finished updating - /// - public Uri CallbackUrl { get; set; } - /// - /// A string to describe the Sim resource - /// - public string FriendlyName { get; set; } - /// - /// The SID or unique name of the RatePlan resource to which the Sim resource should be assigned - /// - public string RatePlan { get; set; } - /// - /// The new status of the Sim resource - /// - public SimResource.StatusEnum Status { get; set; } - /// - /// The HTTP method we should use to call commands_callback_url - /// - public Twilio.Http.HttpMethod CommandsCallbackMethod { get; set; } - /// - /// The URL we should call when the SIM sends a Command - /// - public Uri CommandsCallbackUrl { get; set; } - /// - /// The HTTP method we should use to call sms_fallback_url - /// - public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } - /// - /// The URL we should call when an error occurs while retrieving or executing the TwiML requested from sms_url - /// - public Uri SmsFallbackUrl { get; set; } - /// - /// The HTTP method we should use to call sms_url - /// - public Twilio.Http.HttpMethod SmsMethod { get; set; } - /// - /// The URL we should call when the SIM-connected device sends an SMS message that is not a Command - /// - public Uri SmsUrl { get; set; } - /// - /// Deprecated - /// - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } - /// - /// Deprecated - /// - public Uri VoiceFallbackUrl { get; set; } - /// - /// Deprecated - /// - public Twilio.Http.HttpMethod VoiceMethod { get; set; } - /// - /// Deprecated - /// - public Uri VoiceUrl { get; set; } - /// - /// Initiate a connectivity reset on a SIM - /// - public SimResource.ResetStatusEnum ResetStatus { get; set; } - /// - /// The SID of the Account to which the Sim resource should belong - /// - public string AccountSid { get; set; } - - /// - /// Construct a new UpdateSimOptions - /// - /// The SID of the Sim resource to update - public UpdateSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - if (UniqueName != null) - { - p.Add(new KeyValuePair("UniqueName", UniqueName)); - } - - if (CallbackMethod != null) - { - p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); - } - - if (CallbackUrl != null) - { - p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); - } - - if (FriendlyName != null) - { - p.Add(new KeyValuePair("FriendlyName", FriendlyName)); - } - - if (RatePlan != null) - { - p.Add(new KeyValuePair("RatePlan", RatePlan.ToString())); - } - - if (Status != null) - { - p.Add(new KeyValuePair("Status", Status.ToString())); - } - - if (CommandsCallbackMethod != null) - { - p.Add(new KeyValuePair("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); - } - - if (CommandsCallbackUrl != null) - { - p.Add(new KeyValuePair("CommandsCallbackUrl", Serializers.Url(CommandsCallbackUrl))); - } - - if (SmsFallbackMethod != null) - { - p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); - } - - if (SmsFallbackUrl != null) - { - p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); - } - - if (SmsMethod != null) - { - p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); - } - - if (SmsUrl != null) - { - p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); - } - - if (VoiceFallbackMethod != null) - { - p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); - } - - if (VoiceFallbackUrl != null) - { - p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); - } - - if (VoiceMethod != null) - { - p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); - } - - if (VoiceUrl != null) - { - p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); - } - - if (ResetStatus != null) - { - p.Add(new KeyValuePair("ResetStatus", ResetStatus.ToString())); - } - - if (AccountSid != null) - { - p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); - } - - return p; - } - } - + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } + + /// + /// Retrieve a list of Sim resources on your Account. + /// + public class ReadSimOptions : ReadOptions + { /// - /// Delete a Sim resource on your Account. + /// Only return Sim resources with this status /// - public class DeleteSimOptions : IOptions - { - /// - /// The SID of the Sim Resource to delete - /// - public string PathSid { get; } - - /// - /// Construct a new DeleteSimOptions - /// - /// The SID of the Sim Resource to delete - public DeleteSimOptions(string pathSid) - { - PathSid = pathSid; - } - - /// - /// Generate the necessary parameters - /// - public List> GetParams() - { - var p = new List>(); - return p; - } - } + public SimResource.StatusEnum Status { get; set; } + /// + /// Only return Sim resources with this ICCID + /// + public string Iccid { get; set; } + /// + /// Only return Sim resources assigned to this RatePlan resource + /// + public string RatePlan { get; set; } + /// + /// Deprecated + /// + public string EId { get; set; } + /// + /// Only return Sim resources with this registration code + /// + public string SimRegistrationCode { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (Iccid != null) + { + p.Add(new KeyValuePair("Iccid", Iccid)); + } + + if (RatePlan != null) + { + p.Add(new KeyValuePair("RatePlan", RatePlan)); + } + + if (EId != null) + { + p.Add(new KeyValuePair("EId", EId)); + } + + if (SimRegistrationCode != null) + { + p.Add(new KeyValuePair("SimRegistrationCode", SimRegistrationCode)); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } + + /// + /// Updates the given properties of a Sim resource on your Account. + /// + public class UpdateSimOptions : IOptions + { + /// + /// The SID of the Sim resource to update + /// + public string PathSid { get; } + /// + /// An application-defined string that uniquely identifies the resource + /// + public string UniqueName { get; set; } + /// + /// The HTTP method we should use to call callback_url + /// + public Twilio.Http.HttpMethod CallbackMethod { get; set; } + /// + /// The URL we should call when the Sim resource has finished updating + /// + public Uri CallbackUrl { get; set; } + /// + /// A string to describe the Sim resource + /// + public string FriendlyName { get; set; } + /// + /// The SID or unique name of the RatePlan resource to which the Sim resource should be assigned + /// + public string RatePlan { get; set; } + /// + /// The new status of the Sim resource + /// + public SimResource.StatusEnum Status { get; set; } + /// + /// The HTTP method we should use to call commands_callback_url + /// + public Twilio.Http.HttpMethod CommandsCallbackMethod { get; set; } + /// + /// The URL we should call when the SIM sends a Command + /// + public Uri CommandsCallbackUrl { get; set; } + /// + /// The HTTP method we should use to call sms_fallback_url + /// + public Twilio.Http.HttpMethod SmsFallbackMethod { get; set; } + /// + /// The URL we should call when an error occurs while retrieving or executing the TwiML requested from sms_url + /// + public Uri SmsFallbackUrl { get; set; } + /// + /// The HTTP method we should use to call sms_url + /// + public Twilio.Http.HttpMethod SmsMethod { get; set; } + /// + /// The URL we should call when the SIM-connected device sends an SMS message that is not a Command + /// + public Uri SmsUrl { get; set; } + /// + /// Deprecated + /// + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; set; } + /// + /// Deprecated + /// + public Uri VoiceFallbackUrl { get; set; } + /// + /// Deprecated + /// + public Twilio.Http.HttpMethod VoiceMethod { get; set; } + /// + /// Deprecated + /// + public Uri VoiceUrl { get; set; } + /// + /// Initiate a connectivity reset on a SIM + /// + public SimResource.ResetStatusEnum ResetStatus { get; set; } + /// + /// The SID of the Account to which the Sim resource should belong + /// + public string AccountSid { get; set; } + + /// + /// Construct a new UpdateSimOptions + /// + /// The SID of the Sim resource to update + public UpdateSimOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + if (UniqueName != null) + { + p.Add(new KeyValuePair("UniqueName", UniqueName)); + } + + if (CallbackMethod != null) + { + p.Add(new KeyValuePair("CallbackMethod", CallbackMethod.ToString())); + } + + if (CallbackUrl != null) + { + p.Add(new KeyValuePair("CallbackUrl", Serializers.Url(CallbackUrl))); + } + + if (FriendlyName != null) + { + p.Add(new KeyValuePair("FriendlyName", FriendlyName)); + } + + if (RatePlan != null) + { + p.Add(new KeyValuePair("RatePlan", RatePlan.ToString())); + } + + if (Status != null) + { + p.Add(new KeyValuePair("Status", Status.ToString())); + } + + if (CommandsCallbackMethod != null) + { + p.Add(new KeyValuePair("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); + } + + if (CommandsCallbackUrl != null) + { + p.Add(new KeyValuePair("CommandsCallbackUrl", Serializers.Url(CommandsCallbackUrl))); + } + + if (SmsFallbackMethod != null) + { + p.Add(new KeyValuePair("SmsFallbackMethod", SmsFallbackMethod.ToString())); + } + + if (SmsFallbackUrl != null) + { + p.Add(new KeyValuePair("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl))); + } + + if (SmsMethod != null) + { + p.Add(new KeyValuePair("SmsMethod", SmsMethod.ToString())); + } + + if (SmsUrl != null) + { + p.Add(new KeyValuePair("SmsUrl", Serializers.Url(SmsUrl))); + } + + if (VoiceFallbackMethod != null) + { + p.Add(new KeyValuePair("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); + } + + if (VoiceFallbackUrl != null) + { + p.Add(new KeyValuePair("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl))); + } + + if (VoiceMethod != null) + { + p.Add(new KeyValuePair("VoiceMethod", VoiceMethod.ToString())); + } + + if (VoiceUrl != null) + { + p.Add(new KeyValuePair("VoiceUrl", Serializers.Url(VoiceUrl))); + } + + if (ResetStatus != null) + { + p.Add(new KeyValuePair("ResetStatus", ResetStatus.ToString())); + } + + if (AccountSid != null) + { + p.Add(new KeyValuePair("AccountSid", AccountSid.ToString())); + } + + return p; + } + } + + /// + /// Delete a Sim resource on your Account. + /// + public class DeleteSimOptions : IOptions + { + /// + /// The SID of the Sim Resource to delete + /// + public string PathSid { get; } + + /// + /// Construct a new DeleteSimOptions + /// + /// The SID of the Sim Resource to delete + public DeleteSimOptions(string pathSid) + { + PathSid = pathSid; + } + + /// + /// Generate the necessary parameters + /// + public List> GetParams() + { + var p = new List>(); + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/SimResource.cs b/src/Twilio/Rest/Wireless/V1/SimResource.cs index 09aec8385..9dc4942f2 100644 --- a/src/Twilio/Rest/Wireless/V1/SimResource.cs +++ b/src/Twilio/Rest/Wireless/V1/SimResource.cs @@ -17,619 +17,619 @@ using Twilio.Types; namespace Twilio.Rest.Wireless.V1 -{ - - public class SimResource : Resource - { - public sealed class StatusEnum : StringEnum - { - private StatusEnum(string value) : base(value) {} - public StatusEnum() {} - public static implicit operator StatusEnum(string value) - { - return new StatusEnum(value); - } - - public static readonly StatusEnum New = new StatusEnum("new"); - public static readonly StatusEnum Ready = new StatusEnum("ready"); - public static readonly StatusEnum Active = new StatusEnum("active"); - public static readonly StatusEnum Suspended = new StatusEnum("suspended"); - public static readonly StatusEnum Deactivated = new StatusEnum("deactivated"); - public static readonly StatusEnum Canceled = new StatusEnum("canceled"); - public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); - public static readonly StatusEnum Updating = new StatusEnum("updating"); - } - - public sealed class ResetStatusEnum : StringEnum - { - private ResetStatusEnum(string value) : base(value) {} - public ResetStatusEnum() {} - public static implicit operator ResetStatusEnum(string value) - { - return new ResetStatusEnum(value); - } - - public static readonly ResetStatusEnum Resetting = new ResetStatusEnum("resetting"); - } - - private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Sims/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Fetch a Sim resource on your Account. - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Fetch a Sim resource on your Account. - /// - /// Fetch Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Fetch a Sim resource on your Account. - /// - /// The SID of the Sim resource to fetch - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return Fetch(options, client); - } - - #if !NET35 - /// - /// Fetch a Sim resource on your Account. - /// - /// The SID of the Sim resource to fetch - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, - ITwilioRestClient client = null) - { - var options = new FetchSimOptions(pathSid); - return await FetchAsync(options, client); - } - #endif - - private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/Sims", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Retrieve a list of Sim resources on your Account. - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Sim resources on your Account. - /// - /// Read Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("sims", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// Retrieve a list of Sim resources on your Account. - /// - /// Only return Sim resources with this status - /// Only return Sim resources with this ICCID - /// Only return Sim resources assigned to this RatePlan resource - /// Deprecated - /// Only return Sim resources with this registration code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of Sim - public static ResourceSet Read(SimResource.StatusEnum status = null, - string iccid = null, - string ratePlan = null, - string eId = null, - string simRegistrationCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// Retrieve a list of Sim resources on your Account. - /// - /// Only return Sim resources with this status - /// Only return Sim resources with this ICCID - /// Only return Sim resources assigned to this RatePlan resource - /// Deprecated - /// Only return Sim resources with this registration code - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task> ReadAsync(SimResource.StatusEnum status = null, - string iccid = null, - string ratePlan = null, - string eId = null, - string simRegistrationCode = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadSimOptions(){Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("sims", response.Content); - } - - private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Post, - Rest.Domain.Wireless, - "/v1/Sims/" + options.PathSid + "", - postParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Updates the given properties of a Sim resource on your Account. - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - - #if !NET35 - /// - /// Updates the given properties of a Sim resource on your Account. - /// - /// Update Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); - } - #endif - - /// - /// Updates the given properties of a Sim resource on your Account. - /// - /// The SID of the Sim resource to update - /// An application-defined string that uniquely identifies the resource - /// The HTTP method we should use to call callback_url - /// The URL we should call when the Sim resource has finished updating - /// A string to describe the Sim resource - /// The SID or unique name of the RatePlan resource to which the Sim resource should be - /// assigned - /// The new status of the Sim resource - /// The HTTP method we should use to call commands_callback_url - /// The URL we should call when the SIM sends a Command - /// The HTTP method we should use to call sms_fallback_url - /// The URL we should call when an error occurs while retrieving or executing the TwiML - /// requested from sms_url - /// The HTTP method we should use to call sms_url - /// The URL we should call when the SIM-connected device sends an SMS message that is not a - /// Command - /// Deprecated - /// Deprecated - /// Deprecated - /// Deprecated - /// Initiate a connectivity reset on a SIM - /// The SID of the Account to which the Sim resource should belong - /// Client to make requests to Twilio - /// A single instance of Sim - public static SimResource Update(string pathSid, - string uniqueName = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - string ratePlan = null, - SimResource.StatusEnum status = null, - Twilio.Http.HttpMethod commandsCallbackMethod = null, - Uri commandsCallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - SimResource.ResetStatusEnum resetStatus = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, ResetStatus = resetStatus, AccountSid = accountSid}; - return Update(options, client); - } - - #if !NET35 - /// - /// Updates the given properties of a Sim resource on your Account. - /// - /// The SID of the Sim resource to update - /// An application-defined string that uniquely identifies the resource - /// The HTTP method we should use to call callback_url - /// The URL we should call when the Sim resource has finished updating - /// A string to describe the Sim resource - /// The SID or unique name of the RatePlan resource to which the Sim resource should be - /// assigned - /// The new status of the Sim resource - /// The HTTP method we should use to call commands_callback_url - /// The URL we should call when the SIM sends a Command - /// The HTTP method we should use to call sms_fallback_url - /// The URL we should call when an error occurs while retrieving or executing the TwiML - /// requested from sms_url - /// The HTTP method we should use to call sms_url - /// The URL we should call when the SIM-connected device sends an SMS message that is not a - /// Command - /// Deprecated - /// Deprecated - /// Deprecated - /// Deprecated - /// Initiate a connectivity reset on a SIM - /// The SID of the Account to which the Sim resource should belong - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, - string uniqueName = null, - Twilio.Http.HttpMethod callbackMethod = null, - Uri callbackUrl = null, - string friendlyName = null, - string ratePlan = null, - SimResource.StatusEnum status = null, - Twilio.Http.HttpMethod commandsCallbackMethod = null, - Uri commandsCallbackUrl = null, - Twilio.Http.HttpMethod smsFallbackMethod = null, - Uri smsFallbackUrl = null, - Twilio.Http.HttpMethod smsMethod = null, - Uri smsUrl = null, - Twilio.Http.HttpMethod voiceFallbackMethod = null, - Uri voiceFallbackUrl = null, - Twilio.Http.HttpMethod voiceMethod = null, - Uri voiceUrl = null, - SimResource.ResetStatusEnum resetStatus = null, - string accountSid = null, - ITwilioRestClient client = null) - { - var options = new UpdateSimOptions(pathSid){UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, ResetStatus = resetStatus, AccountSid = accountSid}; - return await UpdateAsync(options, client); - } - #endif - - private static Request BuildDeleteRequest(DeleteSimOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Delete, - Rest.Domain.Wireless, - "/v1/Sims/" + options.PathSid + "", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// Delete a Sim resource on your Account. - /// - /// Delete Sim parameters - /// Client to make requests to Twilio - /// A single instance of Sim - public static bool Delete(DeleteSimOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - - #if !NET35 - /// - /// Delete a Sim resource on your Account. - /// - /// Delete Sim parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task DeleteAsync(DeleteSimOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildDeleteRequest(options, client)); - return response.StatusCode == System.Net.HttpStatusCode.NoContent; - } - #endif - - /// - /// Delete a Sim resource on your Account. - /// - /// The SID of the Sim Resource to delete - /// Client to make requests to Twilio - /// A single instance of Sim - public static bool Delete(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSimOptions(pathSid); - return Delete(options, client); - } - - #if !NET35 - /// - /// Delete a Sim resource on your Account. - /// - /// The SID of the Sim Resource to delete - /// Client to make requests to Twilio - /// Task that resolves to A single instance of Sim - public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) - { - var options = new DeleteSimOptions(pathSid); - return await DeleteAsync(options, client); - } - #endif - - /// - /// Converts a JSON string into a SimResource object - /// - /// Raw JSON string - /// SimResource object represented by the provided JSON - public static SimResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The unique string that identifies the Sim resource - /// - [JsonProperty("sid")] - public string Sid { get; private set; } - /// - /// An application-defined string that uniquely identifies the resource - /// - [JsonProperty("unique_name")] - public string UniqueName { get; private set; } - /// - /// The SID of the Account to which the Sim resource belongs - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The SID of the RatePlan resource to which the Sim resource is assigned. - /// - [JsonProperty("rate_plan_sid")] - public string RatePlanSid { get; private set; } - /// - /// The string that you assigned to describe the Sim resource - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - /// - /// The ICCID associated with the SIM - /// - [JsonProperty("iccid")] - public string Iccid { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("e_id")] - public string EId { get; private set; } - /// - /// The status of the Sim resource - /// - [JsonProperty("status")] - [JsonConverter(typeof(StringEnumConverter))] - public SimResource.StatusEnum Status { get; private set; } - /// - /// The connectivity reset status of the SIM - /// - [JsonProperty("reset_status")] - [JsonConverter(typeof(StringEnumConverter))] - public SimResource.ResetStatusEnum ResetStatus { get; private set; } - /// - /// The URL we call when the SIM originates a machine-to-machine Command - /// - [JsonProperty("commands_callback_url")] - public Uri CommandsCallbackUrl { get; private set; } - /// - /// The HTTP method we use to call commands_callback_url - /// - [JsonProperty("commands_callback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod CommandsCallbackMethod { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("sms_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("sms_fallback_url")] - public Uri SmsFallbackUrl { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("sms_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod SmsMethod { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("sms_url")] - public Uri SmsUrl { get; private set; } - /// - /// Deprecated. The HTTP method we use to call voice_fallback_url - /// - [JsonProperty("voice_fallback_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } - /// - /// Deprecated. The URL we call when an error occurs while retrieving or executing the TwiML requested from voice_url - /// - [JsonProperty("voice_fallback_url")] - public Uri VoiceFallbackUrl { get; private set; } - /// - /// Deprecated. The HTTP method we use to call voice_url - /// - [JsonProperty("voice_method")] - [JsonConverter(typeof(HttpMethodConverter))] - public Twilio.Http.HttpMethod VoiceMethod { get; private set; } - /// - /// Deprecated. The URL we call when the SIM-connected device makes a voice call - /// - [JsonProperty("voice_url")] - public Uri VoiceUrl { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the resource was created - /// - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - /// - /// The ISO 8601 date and time in GMT when the Sim resource was last updated - /// - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - /// - /// The absolute URL of the resource - /// - [JsonProperty("url")] - public Uri Url { get; private set; } - /// - /// The URLs of related subresources - /// - [JsonProperty("links")] - public Dictionary Links { get; private set; } - /// - /// Deprecated - /// - [JsonProperty("ip_address")] - public string IpAddress { get; private set; } - - private SimResource() - { - - } - } +{ + + public class SimResource : Resource + { + public sealed class StatusEnum : StringEnum + { + private StatusEnum(string value) : base(value) { } + public StatusEnum() { } + public static implicit operator StatusEnum(string value) + { + return new StatusEnum(value); + } + + public static readonly StatusEnum New = new StatusEnum("new"); + public static readonly StatusEnum Ready = new StatusEnum("ready"); + public static readonly StatusEnum Active = new StatusEnum("active"); + public static readonly StatusEnum Suspended = new StatusEnum("suspended"); + public static readonly StatusEnum Deactivated = new StatusEnum("deactivated"); + public static readonly StatusEnum Canceled = new StatusEnum("canceled"); + public static readonly StatusEnum Scheduled = new StatusEnum("scheduled"); + public static readonly StatusEnum Updating = new StatusEnum("updating"); + } + + public sealed class ResetStatusEnum : StringEnum + { + private ResetStatusEnum(string value) : base(value) { } + public ResetStatusEnum() { } + public static implicit operator ResetStatusEnum(string value) + { + return new ResetStatusEnum(value); + } + + public static readonly ResetStatusEnum Resetting = new ResetStatusEnum("resetting"); + } + + private static Request BuildFetchRequest(FetchSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Sims/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Fetch a Sim resource on your Account. + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(FetchSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Fetch a Sim resource on your Account. + /// + /// Fetch Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(FetchSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Fetch a Sim resource on your Account. + /// + /// The SID of the Sim resource to fetch + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Fetch(string pathSid, ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return Fetch(options, client); + } + +#if !NET35 + /// + /// Fetch a Sim resource on your Account. + /// + /// The SID of the Sim resource to fetch + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, + ITwilioRestClient client = null) + { + var options = new FetchSimOptions(pathSid); + return await FetchAsync(options, client); + } +#endif + + private static Request BuildReadRequest(ReadSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/Sims", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Retrieve a list of Sim resources on your Account. + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(ReadSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Sim resources on your Account. + /// + /// Read Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(ReadSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("sims", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// Retrieve a list of Sim resources on your Account. + /// + /// Only return Sim resources with this status + /// Only return Sim resources with this ICCID + /// Only return Sim resources assigned to this RatePlan resource + /// Deprecated + /// Only return Sim resources with this registration code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of Sim + public static ResourceSet Read(SimResource.StatusEnum status = null, + string iccid = null, + string ratePlan = null, + string eId = null, + string simRegistrationCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// Retrieve a list of Sim resources on your Account. + /// + /// Only return Sim resources with this status + /// Only return Sim resources with this ICCID + /// Only return Sim resources assigned to this RatePlan resource + /// Deprecated + /// Only return Sim resources with this registration code + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task> ReadAsync(SimResource.StatusEnum status = null, + string iccid = null, + string ratePlan = null, + string eId = null, + string simRegistrationCode = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadSimOptions() { Status = status, Iccid = iccid, RatePlan = ratePlan, EId = eId, SimRegistrationCode = simRegistrationCode, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("sims", response.Content); + } + + private static Request BuildUpdateRequest(UpdateSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Post, + Rest.Domain.Wireless, + "/v1/Sims/" + options.PathSid + "", + postParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Updates the given properties of a Sim resource on your Account. + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(UpdateSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + +#if !NET35 + /// + /// Updates the given properties of a Sim resource on your Account. + /// + /// Update Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(UpdateSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } +#endif + + /// + /// Updates the given properties of a Sim resource on your Account. + /// + /// The SID of the Sim resource to update + /// An application-defined string that uniquely identifies the resource + /// The HTTP method we should use to call callback_url + /// The URL we should call when the Sim resource has finished updating + /// A string to describe the Sim resource + /// The SID or unique name of the RatePlan resource to which the Sim resource should be + /// assigned + /// The new status of the Sim resource + /// The HTTP method we should use to call commands_callback_url + /// The URL we should call when the SIM sends a Command + /// The HTTP method we should use to call sms_fallback_url + /// The URL we should call when an error occurs while retrieving or executing the TwiML + /// requested from sms_url + /// The HTTP method we should use to call sms_url + /// The URL we should call when the SIM-connected device sends an SMS message that is not a + /// Command + /// Deprecated + /// Deprecated + /// Deprecated + /// Deprecated + /// Initiate a connectivity reset on a SIM + /// The SID of the Account to which the Sim resource should belong + /// Client to make requests to Twilio + /// A single instance of Sim + public static SimResource Update(string pathSid, + string uniqueName = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + string ratePlan = null, + SimResource.StatusEnum status = null, + Twilio.Http.HttpMethod commandsCallbackMethod = null, + Uri commandsCallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + SimResource.ResetStatusEnum resetStatus = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, ResetStatus = resetStatus, AccountSid = accountSid }; + return Update(options, client); + } + +#if !NET35 + /// + /// Updates the given properties of a Sim resource on your Account. + /// + /// The SID of the Sim resource to update + /// An application-defined string that uniquely identifies the resource + /// The HTTP method we should use to call callback_url + /// The URL we should call when the Sim resource has finished updating + /// A string to describe the Sim resource + /// The SID or unique name of the RatePlan resource to which the Sim resource should be + /// assigned + /// The new status of the Sim resource + /// The HTTP method we should use to call commands_callback_url + /// The URL we should call when the SIM sends a Command + /// The HTTP method we should use to call sms_fallback_url + /// The URL we should call when an error occurs while retrieving or executing the TwiML + /// requested from sms_url + /// The HTTP method we should use to call sms_url + /// The URL we should call when the SIM-connected device sends an SMS message that is not a + /// Command + /// Deprecated + /// Deprecated + /// Deprecated + /// Deprecated + /// Initiate a connectivity reset on a SIM + /// The SID of the Account to which the Sim resource should belong + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task UpdateAsync(string pathSid, + string uniqueName = null, + Twilio.Http.HttpMethod callbackMethod = null, + Uri callbackUrl = null, + string friendlyName = null, + string ratePlan = null, + SimResource.StatusEnum status = null, + Twilio.Http.HttpMethod commandsCallbackMethod = null, + Uri commandsCallbackUrl = null, + Twilio.Http.HttpMethod smsFallbackMethod = null, + Uri smsFallbackUrl = null, + Twilio.Http.HttpMethod smsMethod = null, + Uri smsUrl = null, + Twilio.Http.HttpMethod voiceFallbackMethod = null, + Uri voiceFallbackUrl = null, + Twilio.Http.HttpMethod voiceMethod = null, + Uri voiceUrl = null, + SimResource.ResetStatusEnum resetStatus = null, + string accountSid = null, + ITwilioRestClient client = null) + { + var options = new UpdateSimOptions(pathSid) { UniqueName = uniqueName, CallbackMethod = callbackMethod, CallbackUrl = callbackUrl, FriendlyName = friendlyName, RatePlan = ratePlan, Status = status, CommandsCallbackMethod = commandsCallbackMethod, CommandsCallbackUrl = commandsCallbackUrl, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, ResetStatus = resetStatus, AccountSid = accountSid }; + return await UpdateAsync(options, client); + } +#endif + + private static Request BuildDeleteRequest(DeleteSimOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Delete, + Rest.Domain.Wireless, + "/v1/Sims/" + options.PathSid + "", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// Delete a Sim resource on your Account. + /// + /// Delete Sim parameters + /// Client to make requests to Twilio + /// A single instance of Sim + public static bool Delete(DeleteSimOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + +#if !NET35 + /// + /// Delete a Sim resource on your Account. + /// + /// Delete Sim parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task DeleteAsync(DeleteSimOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } +#endif + + /// + /// Delete a Sim resource on your Account. + /// + /// The SID of the Sim Resource to delete + /// Client to make requests to Twilio + /// A single instance of Sim + public static bool Delete(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSimOptions(pathSid); + return Delete(options, client); + } + +#if !NET35 + /// + /// Delete a Sim resource on your Account. + /// + /// The SID of the Sim Resource to delete + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Sim + public static async System.Threading.Tasks.Task DeleteAsync(string pathSid, ITwilioRestClient client = null) + { + var options = new DeleteSimOptions(pathSid); + return await DeleteAsync(options, client); + } +#endif + + /// + /// Converts a JSON string into a SimResource object + /// + /// Raw JSON string + /// SimResource object represented by the provided JSON + public static SimResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The unique string that identifies the Sim resource + /// + [JsonProperty("sid")] + public string Sid { get; private set; } + /// + /// An application-defined string that uniquely identifies the resource + /// + [JsonProperty("unique_name")] + public string UniqueName { get; private set; } + /// + /// The SID of the Account to which the Sim resource belongs + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The SID of the RatePlan resource to which the Sim resource is assigned. + /// + [JsonProperty("rate_plan_sid")] + public string RatePlanSid { get; private set; } + /// + /// The string that you assigned to describe the Sim resource + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + /// + /// The ICCID associated with the SIM + /// + [JsonProperty("iccid")] + public string Iccid { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("e_id")] + public string EId { get; private set; } + /// + /// The status of the Sim resource + /// + [JsonProperty("status")] + [JsonConverter(typeof(StringEnumConverter))] + public SimResource.StatusEnum Status { get; private set; } + /// + /// The connectivity reset status of the SIM + /// + [JsonProperty("reset_status")] + [JsonConverter(typeof(StringEnumConverter))] + public SimResource.ResetStatusEnum ResetStatus { get; private set; } + /// + /// The URL we call when the SIM originates a machine-to-machine Command + /// + [JsonProperty("commands_callback_url")] + public Uri CommandsCallbackUrl { get; private set; } + /// + /// The HTTP method we use to call commands_callback_url + /// + [JsonProperty("commands_callback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod CommandsCallbackMethod { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("sms_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsFallbackMethod { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("sms_fallback_url")] + public Uri SmsFallbackUrl { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("sms_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod SmsMethod { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("sms_url")] + public Uri SmsUrl { get; private set; } + /// + /// Deprecated. The HTTP method we use to call voice_fallback_url + /// + [JsonProperty("voice_fallback_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceFallbackMethod { get; private set; } + /// + /// Deprecated. The URL we call when an error occurs while retrieving or executing the TwiML requested from voice_url + /// + [JsonProperty("voice_fallback_url")] + public Uri VoiceFallbackUrl { get; private set; } + /// + /// Deprecated. The HTTP method we use to call voice_url + /// + [JsonProperty("voice_method")] + [JsonConverter(typeof(HttpMethodConverter))] + public Twilio.Http.HttpMethod VoiceMethod { get; private set; } + /// + /// Deprecated. The URL we call when the SIM-connected device makes a voice call + /// + [JsonProperty("voice_url")] + public Uri VoiceUrl { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the resource was created + /// + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + /// + /// The ISO 8601 date and time in GMT when the Sim resource was last updated + /// + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + /// + /// The absolute URL of the resource + /// + [JsonProperty("url")] + public Uri Url { get; private set; } + /// + /// The URLs of related subresources + /// + [JsonProperty("links")] + public Dictionary Links { get; private set; } + /// + /// Deprecated + /// + [JsonProperty("ip_address")] + public string IpAddress { get; private set; } + + private SimResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/UsageRecordOptions.cs b/src/Twilio/Rest/Wireless/V1/UsageRecordOptions.cs index d643ad188..dbfd12ba3 100644 --- a/src/Twilio/Rest/Wireless/V1/UsageRecordOptions.cs +++ b/src/Twilio/Rest/Wireless/V1/UsageRecordOptions.cs @@ -9,54 +9,54 @@ using Twilio.Converters; namespace Twilio.Rest.Wireless.V1 -{ - +{ + + /// + /// ReadUsageRecordOptions + /// + public class ReadUsageRecordOptions : ReadOptions + { /// - /// ReadUsageRecordOptions + /// Only include usage that has occurred on or before this date /// - public class ReadUsageRecordOptions : ReadOptions - { - /// - /// Only include usage that has occurred on or before this date - /// - public DateTime? End { get; set; } - /// - /// Only include usage that has occurred on or after this date - /// - public DateTime? Start { get; set; } - /// - /// The time-based grouping that results are aggregated by - /// - public UsageRecordResource.GranularityEnum Granularity { get; set; } - - /// - /// Generate the necessary parameters - /// - public override List> GetParams() - { - var p = new List>(); - if (End != null) - { - p.Add(new KeyValuePair("End", Serializers.DateTimeIso8601(End))); - } - - if (Start != null) - { - p.Add(new KeyValuePair("Start", Serializers.DateTimeIso8601(Start))); - } - - if (Granularity != null) - { - p.Add(new KeyValuePair("Granularity", Granularity.ToString())); - } - - if (PageSize != null) - { - p.Add(new KeyValuePair("PageSize", PageSize.ToString())); - } - - return p; - } - } + public DateTime? End { get; set; } + /// + /// Only include usage that has occurred on or after this date + /// + public DateTime? Start { get; set; } + /// + /// The time-based grouping that results are aggregated by + /// + public UsageRecordResource.GranularityEnum Granularity { get; set; } + + /// + /// Generate the necessary parameters + /// + public override List> GetParams() + { + var p = new List>(); + if (End != null) + { + p.Add(new KeyValuePair("End", Serializers.DateTimeIso8601(End))); + } + + if (Start != null) + { + p.Add(new KeyValuePair("Start", Serializers.DateTimeIso8601(Start))); + } + + if (Granularity != null) + { + p.Add(new KeyValuePair("Granularity", Granularity.ToString())); + } + + if (PageSize != null) + { + p.Add(new KeyValuePair("PageSize", PageSize.ToString())); + } + + return p; + } + } } \ No newline at end of file diff --git a/src/Twilio/Rest/Wireless/V1/UsageRecordResource.cs b/src/Twilio/Rest/Wireless/V1/UsageRecordResource.cs index 1d1abd5a3..646b0293b 100644 --- a/src/Twilio/Rest/Wireless/V1/UsageRecordResource.cs +++ b/src/Twilio/Rest/Wireless/V1/UsageRecordResource.cs @@ -17,208 +17,208 @@ using Twilio.Types; namespace Twilio.Rest.Wireless.V1 -{ - - public class UsageRecordResource : Resource - { - public sealed class GranularityEnum : StringEnum - { - private GranularityEnum(string value) : base(value) {} - public GranularityEnum() {} - public static implicit operator GranularityEnum(string value) - { - return new GranularityEnum(value); - } - - public static readonly GranularityEnum Hourly = new GranularityEnum("hourly"); - public static readonly GranularityEnum Daily = new GranularityEnum("daily"); - public static readonly GranularityEnum All = new GranularityEnum("all"); - } - - private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) - { - return new Request( - HttpMethod.Get, - Rest.Domain.Wireless, - "/v1/UsageRecords", - queryParams: options.GetParams(), - headerParams: null - ); - } - - /// - /// read - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = client.Request(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - - #if !NET35 - /// - /// read - /// - /// Read UsageRecord parameters - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, - ITwilioRestClient client = null) - { - client = client ?? TwilioClient.GetRestClient(); - var response = await client.RequestAsync(BuildReadRequest(options, client)); - - var page = Page.FromJson("usage_records", response.Content); - return new ResourceSet(page, options, client); - } - #endif - - /// - /// read - /// - /// Only include usage that has occurred on or before this date - /// Only include usage that has occurred on or after this date - /// The time-based grouping that results are aggregated by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// A single instance of UsageRecord - public static ResourceSet Read(DateTime? end = null, - DateTime? start = null, - UsageRecordResource.GranularityEnum granularity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(){End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit}; - return Read(options, client); - } - - #if !NET35 - /// - /// read - /// - /// Only include usage that has occurred on or before this date - /// Only include usage that has occurred on or after this date - /// The time-based grouping that results are aggregated by - /// Page size - /// Record limit - /// Client to make requests to Twilio - /// Task that resolves to A single instance of UsageRecord - public static async System.Threading.Tasks.Task> ReadAsync(DateTime? end = null, - DateTime? start = null, - UsageRecordResource.GranularityEnum granularity = null, - int? pageSize = null, - long? limit = null, - ITwilioRestClient client = null) - { - var options = new ReadUsageRecordOptions(){End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit}; - return await ReadAsync(options, client); - } - #endif - - /// - /// Fetch the target page of records - /// - /// API-generated URL for the requested results page - /// Client to make requests to Twilio - /// The target page of records - public static Page GetPage(string targetUrl, ITwilioRestClient client) - { - client = client ?? TwilioClient.GetRestClient(); - - var request = new Request( - HttpMethod.Get, - targetUrl - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the next page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The next page of records - public static Page NextPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetNextPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Fetch the previous page of records - /// - /// current page of records - /// Client to make requests to Twilio - /// The previous page of records - public static Page PreviousPage(Page page, ITwilioRestClient client) - { - var request = new Request( - HttpMethod.Get, - page.GetPreviousPageUrl(Rest.Domain.Wireless) - ); - - var response = client.Request(request); - return Page.FromJson("usage_records", response.Content); - } - - /// - /// Converts a JSON string into a UsageRecordResource object - /// - /// Raw JSON string - /// UsageRecordResource object represented by the provided JSON - public static UsageRecordResource FromJson(string json) - { - // Convert all checked exceptions to Runtime - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - /// - /// The SID of the Account that created the resource - /// - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - /// - /// The time period for which usage is reported - /// - [JsonProperty("period")] - public object Period { get; private set; } - /// - /// An object that describes the aggregated Commands usage for all SIMs during the specified period - /// - [JsonProperty("commands")] - public object Commands { get; private set; } - /// - /// An object that describes the aggregated Data usage for all SIMs over the period - /// - [JsonProperty("data")] - public object Data { get; private set; } - - private UsageRecordResource() - { - - } - } +{ + + public class UsageRecordResource : Resource + { + public sealed class GranularityEnum : StringEnum + { + private GranularityEnum(string value) : base(value) { } + public GranularityEnum() { } + public static implicit operator GranularityEnum(string value) + { + return new GranularityEnum(value); + } + + public static readonly GranularityEnum Hourly = new GranularityEnum("hourly"); + public static readonly GranularityEnum Daily = new GranularityEnum("daily"); + public static readonly GranularityEnum All = new GranularityEnum("all"); + } + + private static Request BuildReadRequest(ReadUsageRecordOptions options, ITwilioRestClient client) + { + return new Request( + HttpMethod.Get, + Rest.Domain.Wireless, + "/v1/UsageRecords", + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// + /// read + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(ReadUsageRecordOptions options, ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } + +#if !NET35 + /// + /// read + /// + /// Read UsageRecord parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(ReadUsageRecordOptions options, + ITwilioRestClient client = null) + { + client = client ?? TwilioClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("usage_records", response.Content); + return new ResourceSet(page, options, client); + } +#endif + + /// + /// read + /// + /// Only include usage that has occurred on or before this date + /// Only include usage that has occurred on or after this date + /// The time-based grouping that results are aggregated by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// A single instance of UsageRecord + public static ResourceSet Read(DateTime? end = null, + DateTime? start = null, + UsageRecordResource.GranularityEnum granularity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions() { End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit }; + return Read(options, client); + } + +#if !NET35 + /// + /// read + /// + /// Only include usage that has occurred on or before this date + /// Only include usage that has occurred on or after this date + /// The time-based grouping that results are aggregated by + /// Page size + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of UsageRecord + public static async System.Threading.Tasks.Task> ReadAsync(DateTime? end = null, + DateTime? start = null, + UsageRecordResource.GranularityEnum granularity = null, + int? pageSize = null, + long? limit = null, + ITwilioRestClient client = null) + { + var options = new ReadUsageRecordOptions() { End = end, Start = start, Granularity = granularity, PageSize = pageSize, Limit = limit }; + return await ReadAsync(options, client); + } +#endif + + /// + /// Fetch the target page of records + /// + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, ITwilioRestClient client) + { + client = client ?? TwilioClient.GetRestClient(); + + var request = new Request( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the next page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Fetch the previous page of records + /// + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, ITwilioRestClient client) + { + var request = new Request( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Wireless) + ); + + var response = client.Request(request); + return Page.FromJson("usage_records", response.Content); + } + + /// + /// Converts a JSON string into a UsageRecordResource object + /// + /// Raw JSON string + /// UsageRecordResource object represented by the provided JSON + public static UsageRecordResource FromJson(string json) + { + // Convert all checked exceptions to Runtime + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + /// + /// The SID of the Account that created the resource + /// + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + /// + /// The time period for which usage is reported + /// + [JsonProperty("period")] + public object Period { get; private set; } + /// + /// An object that describes the aggregated Commands usage for all SIMs during the specified period + /// + [JsonProperty("commands")] + public object Commands { get; private set; } + /// + /// An object that describes the aggregated Data usage for all SIMs over the period + /// + [JsonProperty("data")] + public object Data { get; private set; } + + private UsageRecordResource() + { + + } + } } \ No newline at end of file diff --git a/src/Twilio/Security/RequestValidator.cs b/src/Twilio/Security/RequestValidator.cs index aa94ada48..21a9d6c88 100644 --- a/src/Twilio/Security/RequestValidator.cs +++ b/src/Twilio/Security/RequestValidator.cs @@ -5,160 +5,160 @@ using System.Text; namespace Twilio.Security -{ +{ + /// + /// Twilio request validator + /// + public class RequestValidator + { + private readonly HMACSHA1 _hmac; + private readonly SHA256 _sha; + /// - /// Twilio request validator + /// Create a new RequestValidator /// - public class RequestValidator - { - private readonly HMACSHA1 _hmac; - private readonly SHA256 _sha; - - /// - /// Create a new RequestValidator - /// - /// Signing secret - public RequestValidator(string secret) - { - _hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secret)); - _sha = SHA256.Create(); - } - - /// - /// Validate against a request - /// - /// Request URL - /// Request parameters - /// Expected result - /// true if the signature matches the result; false otherwise - public bool Validate(string url, NameValueCollection parameters, string expected) - { - return Validate(url, ToDictionary(parameters), expected); - } - - /// - /// Validate against a request - /// - /// Request URL - /// Request parameters - /// Expected result - /// true if the signature matches the result; false otherwise - public bool Validate(string url, IDictionary parameters, string expected) - { - // check signature of url with and without port, since sig generation on back end is inconsistent - var signatureWithoutPort = GetValidationSignature(RemovePort(url), parameters); - var signatureWithPort = GetValidationSignature(AddPort(url), parameters); - // If either url produces a valid signature, we accept the request as valid - return SecureCompare(signatureWithoutPort, expected) || SecureCompare(signatureWithPort, expected); - } - - public bool Validate(string url, string body, string expected) - { - var paramString = new UriBuilder(url).Query.TrimStart('?'); - var bodyHash = ""; - foreach (var param in paramString.Split('&')) - { - var split = param.Split('='); - if (split[0] == "bodySHA256") - { - bodyHash = Uri.UnescapeDataString(split[1]); - } - } - - return Validate(url, new Dictionary(), expected) && ValidateBody(body, bodyHash); - } - - public bool ValidateBody(string rawBody, string expected) - { - var signature = _sha.ComputeHash(Encoding.UTF8.GetBytes(rawBody)); - return SecureCompare(BitConverter.ToString(signature).Replace("-","").ToLower(), expected); - } - - private static IDictionary ToDictionary(NameValueCollection col) - { - var dict = new Dictionary(); - foreach (var k in col.AllKeys) - { - dict.Add(k, col[k]); - } - return dict; - } - - private string GetValidationSignature(string url, IDictionary parameters) - { - var b = new StringBuilder(url); - if (parameters != null) - { - var sortedKeys = new List(parameters.Keys); - sortedKeys.Sort(StringComparer.Ordinal); - - foreach (var key in sortedKeys) - { - b.Append(key).Append(parameters[key] ?? ""); - } - } - - var hash = _hmac.ComputeHash(Encoding.UTF8.GetBytes(b.ToString())); - return Convert.ToBase64String(hash); - } - - private static bool SecureCompare(string a, string b) - { - if (a == null || b == null) - { - return false; - } - - var n = a.Length; - if (n != b.Length) - { - return false; - } - - var mismatch = 0; - for (var i = 0; i < n; i++) - { - mismatch |= a[i] ^ b[i]; - } - - return mismatch == 0; - } - - private string RemovePort(string url) - { - return SetPort(url, -1); - } - - private string AddPort(string url) - { - var uri = new UriBuilder(url); - return SetPort(url, uri.Port); - } - - private string SetPort(string url, int port) - { - var uri = new UriBuilder(url); - uri.Host = PreserveCase(url, uri.Host); - if (port == -1) - { - uri.Port = port; - } - else if ((port != 443) && (port != 80)) - { - uri.Port = port; - } - else - { - uri.Port = uri.Scheme == "https" ? 443 : 80; - } - var scheme = PreserveCase(url, uri.Scheme); - return uri.Uri.OriginalString.Replace(uri.Scheme, scheme); - } - - private string PreserveCase(string url, string replacementString) - { - var startIndex = url.IndexOf(replacementString, StringComparison.OrdinalIgnoreCase); - return url.Substring(startIndex, replacementString.Length); - } - } + /// Signing secret + public RequestValidator(string secret) + { + _hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secret)); + _sha = SHA256.Create(); + } + + /// + /// Validate against a request + /// + /// Request URL + /// Request parameters + /// Expected result + /// true if the signature matches the result; false otherwise + public bool Validate(string url, NameValueCollection parameters, string expected) + { + return Validate(url, ToDictionary(parameters), expected); + } + + /// + /// Validate against a request + /// + /// Request URL + /// Request parameters + /// Expected result + /// true if the signature matches the result; false otherwise + public bool Validate(string url, IDictionary parameters, string expected) + { + // check signature of url with and without port, since sig generation on back end is inconsistent + var signatureWithoutPort = GetValidationSignature(RemovePort(url), parameters); + var signatureWithPort = GetValidationSignature(AddPort(url), parameters); + // If either url produces a valid signature, we accept the request as valid + return SecureCompare(signatureWithoutPort, expected) || SecureCompare(signatureWithPort, expected); + } + + public bool Validate(string url, string body, string expected) + { + var paramString = new UriBuilder(url).Query.TrimStart('?'); + var bodyHash = ""; + foreach (var param in paramString.Split('&')) + { + var split = param.Split('='); + if (split[0] == "bodySHA256") + { + bodyHash = Uri.UnescapeDataString(split[1]); + } + } + + return Validate(url, new Dictionary(), expected) && ValidateBody(body, bodyHash); + } + + public bool ValidateBody(string rawBody, string expected) + { + var signature = _sha.ComputeHash(Encoding.UTF8.GetBytes(rawBody)); + return SecureCompare(BitConverter.ToString(signature).Replace("-", "").ToLower(), expected); + } + + private static IDictionary ToDictionary(NameValueCollection col) + { + var dict = new Dictionary(); + foreach (var k in col.AllKeys) + { + dict.Add(k, col[k]); + } + return dict; + } + + private string GetValidationSignature(string url, IDictionary parameters) + { + var b = new StringBuilder(url); + if (parameters != null) + { + var sortedKeys = new List(parameters.Keys); + sortedKeys.Sort(StringComparer.Ordinal); + + foreach (var key in sortedKeys) + { + b.Append(key).Append(parameters[key] ?? ""); + } + } + + var hash = _hmac.ComputeHash(Encoding.UTF8.GetBytes(b.ToString())); + return Convert.ToBase64String(hash); + } + + private static bool SecureCompare(string a, string b) + { + if (a == null || b == null) + { + return false; + } + + var n = a.Length; + if (n != b.Length) + { + return false; + } + + var mismatch = 0; + for (var i = 0; i < n; i++) + { + mismatch |= a[i] ^ b[i]; + } + + return mismatch == 0; + } + + private string RemovePort(string url) + { + return SetPort(url, -1); + } + + private string AddPort(string url) + { + var uri = new UriBuilder(url); + return SetPort(url, uri.Port); + } + + private string SetPort(string url, int port) + { + var uri = new UriBuilder(url); + uri.Host = PreserveCase(url, uri.Host); + if (port == -1) + { + uri.Port = port; + } + else if ((port != 443) && (port != 80)) + { + uri.Port = port; + } + else + { + uri.Port = uri.Scheme == "https" ? 443 : 80; + } + var scheme = PreserveCase(url, uri.Scheme); + return uri.Uri.OriginalString.Replace(uri.Scheme, scheme); + } + + private string PreserveCase(string url, string replacementString) + { + var startIndex = url.IndexOf(replacementString, StringComparison.OrdinalIgnoreCase); + return url.Substring(startIndex, replacementString.Length); + } + } } diff --git a/src/Twilio/TwiML/Fax/Receive.cs b/src/Twilio/TwiML/Fax/Receive.cs index a30217243..b509e9791 100644 --- a/src/Twilio/TwiML/Fax/Receive.cs +++ b/src/Twilio/TwiML/Fax/Receive.cs @@ -12,129 +12,129 @@ using Twilio.Types; namespace Twilio.TwiML.Fax -{ - +{ + + /// + /// Receive TwiML Verb + /// + public class Receive : TwiML + { + public sealed class MediaTypeEnum : StringEnum + { + private MediaTypeEnum(string value) : base(value) { } + public MediaTypeEnum() { } + public static implicit operator MediaTypeEnum(string value) + { + return new MediaTypeEnum(value); + } + + public static readonly MediaTypeEnum ApplicationPdf = new MediaTypeEnum("application/pdf"); + public static readonly MediaTypeEnum ImageTiff = new MediaTypeEnum("image/tiff"); + } + + public sealed class PageSizeEnum : StringEnum + { + private PageSizeEnum(string value) : base(value) { } + public PageSizeEnum() { } + public static implicit operator PageSizeEnum(string value) + { + return new PageSizeEnum(value); + } + + public static readonly PageSizeEnum Letter = new PageSizeEnum("letter"); + public static readonly PageSizeEnum Legal = new PageSizeEnum("legal"); + public static readonly PageSizeEnum A4 = new PageSizeEnum("a4"); + } + /// - /// Receive TwiML Verb + /// Receive action URL /// - public class Receive : TwiML - { - public sealed class MediaTypeEnum : StringEnum - { - private MediaTypeEnum(string value) : base(value) {} - public MediaTypeEnum() {} - public static implicit operator MediaTypeEnum(string value) - { - return new MediaTypeEnum(value); - } - - public static readonly MediaTypeEnum ApplicationPdf = new MediaTypeEnum("application/pdf"); - public static readonly MediaTypeEnum ImageTiff = new MediaTypeEnum("image/tiff"); - } - - public sealed class PageSizeEnum : StringEnum - { - private PageSizeEnum(string value) : base(value) {} - public PageSizeEnum() {} - public static implicit operator PageSizeEnum(string value) - { - return new PageSizeEnum(value); - } - - public static readonly PageSizeEnum Letter = new PageSizeEnum("letter"); - public static readonly PageSizeEnum Legal = new PageSizeEnum("legal"); - public static readonly PageSizeEnum A4 = new PageSizeEnum("a4"); - } - - /// - /// Receive action URL - /// - public Uri Action { get; set; } - /// - /// Receive action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// The media type used to store media in the fax media store - /// - public Receive.MediaTypeEnum MediaType { get; set; } - /// - /// What size to interpret received pages as - /// - public Receive.PageSizeEnum PageSize { get; set; } - /// - /// Whether or not to store received media in the fax media store - /// - public bool? StoreMedia { get; set; } - - /// - /// Create a new Receive - /// - /// Receive action URL - /// Receive action URL method - /// The media type used to store media in the fax media store - /// What size to interpret received pages as - /// Whether or not to store received media in the fax media store - public Receive(Uri action = null, - Twilio.Http.HttpMethod method = null, - Receive.MediaTypeEnum mediaType = null, - Receive.PageSizeEnum pageSize = null, - bool? storeMedia = null) : base("Receive") - { - this.Action = action; - this.Method = method; - this.MediaType = mediaType; - this.PageSize = pageSize; - this.StoreMedia = storeMedia; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.MediaType != null) - { - attributes.Add(new XAttribute("mediaType", this.MediaType.ToString())); - } - if (this.PageSize != null) - { - attributes.Add(new XAttribute("pageSize", this.PageSize.ToString())); - } - if (this.StoreMedia != null) - { - attributes.Add(new XAttribute("storeMedia", this.StoreMedia.Value.ToString().ToLower())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Receive Append(TwiML childElem) - { - return (Receive) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Receive SetOption(string key, object value) - { - return (Receive) base.SetOption(key, value); - } - } + public Uri Action { get; set; } + /// + /// Receive action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// The media type used to store media in the fax media store + /// + public Receive.MediaTypeEnum MediaType { get; set; } + /// + /// What size to interpret received pages as + /// + public Receive.PageSizeEnum PageSize { get; set; } + /// + /// Whether or not to store received media in the fax media store + /// + public bool? StoreMedia { get; set; } + + /// + /// Create a new Receive + /// + /// Receive action URL + /// Receive action URL method + /// The media type used to store media in the fax media store + /// What size to interpret received pages as + /// Whether or not to store received media in the fax media store + public Receive(Uri action = null, + Twilio.Http.HttpMethod method = null, + Receive.MediaTypeEnum mediaType = null, + Receive.PageSizeEnum pageSize = null, + bool? storeMedia = null) : base("Receive") + { + this.Action = action; + this.Method = method; + this.MediaType = mediaType; + this.PageSize = pageSize; + this.StoreMedia = storeMedia; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.MediaType != null) + { + attributes.Add(new XAttribute("mediaType", this.MediaType.ToString())); + } + if (this.PageSize != null) + { + attributes.Add(new XAttribute("pageSize", this.PageSize.ToString())); + } + if (this.StoreMedia != null) + { + attributes.Add(new XAttribute("storeMedia", this.StoreMedia.Value.ToString().ToLower())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Receive Append(TwiML childElem) + { + return (Receive)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Receive SetOption(string key, object value) + { + return (Receive)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/FaxResponse.cs b/src/Twilio/TwiML/FaxResponse.cs index 107a913a4..6a974162d 100644 --- a/src/Twilio/TwiML/FaxResponse.cs +++ b/src/Twilio/TwiML/FaxResponse.cs @@ -11,68 +11,68 @@ using Twilio.TwiML.Fax; namespace Twilio.TwiML -{ - +{ + + /// + /// Response TwiML for Faxes + /// + public class FaxResponse : TwiML + { /// - /// Response TwiML for Faxes + /// Create a new FaxResponse /// - public class FaxResponse : TwiML - { - /// - /// Create a new FaxResponse - /// - public FaxResponse() : base("Response") - { - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Receive action URL - /// Receive action URL method - /// The media type used to store media in the fax media store - /// What size to interpret received pages as - /// Whether or not to store received media in the fax media store - public FaxResponse Receive(Uri action = null, - Twilio.Http.HttpMethod method = null, - Receive.MediaTypeEnum mediaType = null, - Receive.PageSizeEnum pageSize = null, - bool? storeMedia = null) - { - var newChild = new Receive(action, method, mediaType, pageSize, storeMedia); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Receive instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public FaxResponse Receive(Receive receive) - { - this.Append(receive); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new FaxResponse Append(TwiML childElem) - { - return (FaxResponse) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new FaxResponse SetOption(string key, object value) - { - return (FaxResponse) base.SetOption(key, value); - } - } + public FaxResponse() : base("Response") + { + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Receive action URL + /// Receive action URL method + /// The media type used to store media in the fax media store + /// What size to interpret received pages as + /// Whether or not to store received media in the fax media store + public FaxResponse Receive(Uri action = null, + Twilio.Http.HttpMethod method = null, + Receive.MediaTypeEnum mediaType = null, + Receive.PageSizeEnum pageSize = null, + bool? storeMedia = null) + { + var newChild = new Receive(action, method, mediaType, pageSize, storeMedia); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Receive instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public FaxResponse Receive(Receive receive) + { + this.Append(receive); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new FaxResponse Append(TwiML childElem) + { + return (FaxResponse)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new FaxResponse SetOption(string key, object value) + { + return (FaxResponse)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Messaging/Body.cs b/src/Twilio/TwiML/Messaging/Body.cs index 06e6fafc8..7115ac61b 100644 --- a/src/Twilio/TwiML/Messaging/Body.cs +++ b/src/Twilio/TwiML/Messaging/Body.cs @@ -8,53 +8,53 @@ using System.Xml.Linq; namespace Twilio.TwiML.Messaging -{ - +{ + + /// + /// Body TwiML Noun + /// + public class Body : TwiML + { /// - /// Body TwiML Noun + /// Message Body /// - public class Body : TwiML - { - /// - /// Message Body - /// - public string Message { get; set; } - - /// - /// Create a new Body - /// - /// Message Body, the body of the TwiML Element. - public Body(string message = null) : base("Body") - { - this.Message = message; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Message != null ? this.Message : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Body Append(TwiML childElem) - { - return (Body) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Body SetOption(string key, object value) - { - return (Body) base.SetOption(key, value); - } - } + public string Message { get; set; } + + /// + /// Create a new Body + /// + /// Message Body, the body of the TwiML Element. + public Body(string message = null) : base("Body") + { + this.Message = message; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Message != null ? this.Message : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Body Append(TwiML childElem) + { + return (Body)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Body SetOption(string key, object value) + { + return (Body)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Messaging/Media.cs b/src/Twilio/TwiML/Messaging/Media.cs index f8184b565..b1a5f7847 100644 --- a/src/Twilio/TwiML/Messaging/Media.cs +++ b/src/Twilio/TwiML/Messaging/Media.cs @@ -10,53 +10,53 @@ using Twilio.Converters; namespace Twilio.TwiML.Messaging -{ - +{ + + /// + /// Media TwiML Noun + /// + public class Media : TwiML + { /// - /// Media TwiML Noun + /// Media URL /// - public class Media : TwiML - { - /// - /// Media URL - /// - public Uri Url { get; set; } - - /// - /// Create a new Media - /// - /// Media URL, the body of the TwiML Element. - public Media(Uri url = null) : base("Media") - { - this.Url = url; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Url != null ? Serializers.Url(this.Url) : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Media Append(TwiML childElem) - { - return (Media) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Media SetOption(string key, object value) - { - return (Media) base.SetOption(key, value); - } - } + public Uri Url { get; set; } + + /// + /// Create a new Media + /// + /// Media URL, the body of the TwiML Element. + public Media(Uri url = null) : base("Media") + { + this.Url = url; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Url != null ? Serializers.Url(this.Url) : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Media Append(TwiML childElem) + { + return (Media)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Media SetOption(string key, object value) + { + return (Media)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Messaging/Message.cs b/src/Twilio/TwiML/Messaging/Message.cs index 85ffda8eb..3d71f1e8f 100644 --- a/src/Twilio/TwiML/Messaging/Message.cs +++ b/src/Twilio/TwiML/Messaging/Message.cs @@ -11,161 +11,161 @@ using Twilio.Converters; namespace Twilio.TwiML.Messaging -{ - +{ + + /// + /// Message TwiML Verb + /// + public class Message : TwiML + { /// - /// Message TwiML Verb + /// Message Body /// - public class Message : TwiML - { - /// - /// Message Body - /// - public string BodyAttribute { get; set; } - /// - /// Phone Number to send Message to - /// - public string To { get; set; } - /// - /// Phone Number to send Message from - /// - public string From { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL Method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Status callback URL. Deprecated in favor of action. - /// - public Uri StatusCallback { get; set; } - - /// - /// Create a new Message - /// - /// Message Body, the body of the TwiML Element. - /// Phone Number to send Message to. Also accepts stringified Types.PhoneNumber - /// Phone Number to send Message from. Also accepts stringified Types.PhoneNumber - /// Action URL - /// Action URL Method - /// Status callback URL. Deprecated in favor of action. - public Message(string body = null, - string to = null, - string from = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri statusCallback = null) : base("Message") - { - this.BodyAttribute = body; - this.To = to; - this.From = from; - this.Action = action; - this.Method = method; - this.StatusCallback = statusCallback; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.BodyAttribute != null ? this.BodyAttribute : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.To != null) - { - attributes.Add(new XAttribute("to", this.To)); - } - if (this.From != null) - { - attributes.Add(new XAttribute("from", this.From)); - } - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message Body, the body of the TwiML Element. - public Message Body(string message = null) - { - var newChild = new Body(message); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Body instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Message Body(Body body) - { - this.Append(body); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Media URL, the body of the TwiML Element. - public Message Media(Uri url = null) - { - var newChild = new Media(url); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Media instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Message Media(Media media) - { - this.Append(media); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Message Append(TwiML childElem) - { - return (Message) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Message SetOption(string key, object value) - { - return (Message) base.SetOption(key, value); - } - } + public string BodyAttribute { get; set; } + /// + /// Phone Number to send Message to + /// + public string To { get; set; } + /// + /// Phone Number to send Message from + /// + public string From { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL Method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Status callback URL. Deprecated in favor of action. + /// + public Uri StatusCallback { get; set; } + + /// + /// Create a new Message + /// + /// Message Body, the body of the TwiML Element. + /// Phone Number to send Message to. Also accepts stringified Types.PhoneNumber + /// Phone Number to send Message from. Also accepts stringified Types.PhoneNumber + /// Action URL + /// Action URL Method + /// Status callback URL. Deprecated in favor of action. + public Message(string body = null, + string to = null, + string from = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri statusCallback = null) : base("Message") + { + this.BodyAttribute = body; + this.To = to; + this.From = from; + this.Action = action; + this.Method = method; + this.StatusCallback = statusCallback; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.BodyAttribute != null ? this.BodyAttribute : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.To != null) + { + attributes.Add(new XAttribute("to", this.To)); + } + if (this.From != null) + { + attributes.Add(new XAttribute("from", this.From)); + } + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message Body, the body of the TwiML Element. + public Message Body(string message = null) + { + var newChild = new Body(message); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Body instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Message Body(Body body) + { + this.Append(body); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Media URL, the body of the TwiML Element. + public Message Media(Uri url = null) + { + var newChild = new Media(url); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Media instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Message Media(Media media) + { + this.Append(media); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Message Append(TwiML childElem) + { + return (Message)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Message SetOption(string key, object value) + { + return (Message)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Messaging/Redirect.cs b/src/Twilio/TwiML/Messaging/Redirect.cs index 2a7647caf..73231845a 100644 --- a/src/Twilio/TwiML/Messaging/Redirect.cs +++ b/src/Twilio/TwiML/Messaging/Redirect.cs @@ -11,72 +11,72 @@ using Twilio.Converters; namespace Twilio.TwiML.Messaging -{ - +{ + + /// + /// Redirect TwiML Verb + /// + public class Redirect : TwiML + { /// - /// Redirect TwiML Verb + /// Redirect URL /// - public class Redirect : TwiML - { - /// - /// Redirect URL - /// - public Uri Url { get; set; } - /// - /// Redirect URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Create a new Redirect - /// - /// Redirect URL, the body of the TwiML Element. - /// Redirect URL method - public Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) : base("Redirect") - { - this.Url = url; - this.Method = method; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Url != null ? Serializers.Url(this.Url) : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Redirect Append(TwiML childElem) - { - return (Redirect) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Redirect SetOption(string key, object value) - { - return (Redirect) base.SetOption(key, value); - } - } + public Uri Url { get; set; } + /// + /// Redirect URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Create a new Redirect + /// + /// Redirect URL, the body of the TwiML Element. + /// Redirect URL method + public Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) : base("Redirect") + { + this.Url = url; + this.Method = method; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Url != null ? Serializers.Url(this.Url) : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Redirect Append(TwiML childElem) + { + return (Redirect)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Redirect SetOption(string key, object value) + { + return (Redirect)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/MessagingResponse.cs b/src/Twilio/TwiML/MessagingResponse.cs index ef6d3462b..e214c0c04 100644 --- a/src/Twilio/TwiML/MessagingResponse.cs +++ b/src/Twilio/TwiML/MessagingResponse.cs @@ -11,93 +11,93 @@ using Twilio.TwiML.Messaging; namespace Twilio.TwiML -{ - +{ + + /// + /// Response TwiML for Messages + /// + public class MessagingResponse : TwiML + { /// - /// Response TwiML for Messages + /// Create a new MessagingResponse /// - public class MessagingResponse : TwiML - { - /// - /// Create a new MessagingResponse - /// - public MessagingResponse() : base("Response") - { - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message Body, the body of the TwiML Element. - /// Phone Number to send Message to. Also accepts stringified Types.PhoneNumber - /// Phone Number to send Message from. Also accepts stringified Types.PhoneNumber - /// Action URL - /// Action URL Method - /// Status callback URL. Deprecated in favor of action. - public MessagingResponse Message(string body = null, - string to = null, - string from = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri statusCallback = null) - { - var newChild = new Message(body, to, from, action, method, statusCallback); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Message instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public MessagingResponse Message(Message message) - { - this.Append(message); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Redirect URL, the body of the TwiML Element. - /// Redirect URL method - public MessagingResponse Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) - { - var newChild = new Redirect(url, method); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Redirect instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public MessagingResponse Redirect(Redirect redirect) - { - this.Append(redirect); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new MessagingResponse Append(TwiML childElem) - { - return (MessagingResponse) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new MessagingResponse SetOption(string key, object value) - { - return (MessagingResponse) base.SetOption(key, value); - } - } + public MessagingResponse() : base("Response") + { + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message Body, the body of the TwiML Element. + /// Phone Number to send Message to. Also accepts stringified Types.PhoneNumber + /// Phone Number to send Message from. Also accepts stringified Types.PhoneNumber + /// Action URL + /// Action URL Method + /// Status callback URL. Deprecated in favor of action. + public MessagingResponse Message(string body = null, + string to = null, + string from = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri statusCallback = null) + { + var newChild = new Message(body, to, from, action, method, statusCallback); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Message instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public MessagingResponse Message(Message message) + { + this.Append(message); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Redirect URL, the body of the TwiML Element. + /// Redirect URL method + public MessagingResponse Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) + { + var newChild = new Redirect(url, method); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Redirect instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public MessagingResponse Redirect(Redirect redirect) + { + this.Append(redirect); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new MessagingResponse Append(TwiML childElem) + { + return (MessagingResponse)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new MessagingResponse SetOption(string key, object value) + { + return (MessagingResponse)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Text.cs b/src/Twilio/TwiML/Text.cs index 5efb4a6e6..e3ad28ef9 100644 --- a/src/Twilio/TwiML/Text.cs +++ b/src/Twilio/TwiML/Text.cs @@ -1,19 +1,19 @@ using System.Xml.Linq; namespace Twilio.TwiML -{ - internal class Text : TwiML - { - private readonly string _content; - - internal Text(string content) : base(null) - { - _content = content; - } - - protected override XNode ToXml() - { - return new XText(_content); - } - } +{ + internal class Text : TwiML + { + private readonly string _content; + + internal Text(string content) : base(null) + { + _content = content; + } + + protected override XNode ToXml() + { + return new XText(_content); + } + } } diff --git a/src/Twilio/TwiML/TwiML.cs b/src/Twilio/TwiML/TwiML.cs index f69e71668..34d1bcdba 100644 --- a/src/Twilio/TwiML/TwiML.cs +++ b/src/Twilio/TwiML/TwiML.cs @@ -6,177 +6,177 @@ using Twilio.Exceptions; namespace Twilio.TwiML -{ - +{ + + /// + /// Base class for all TwiML Objects. + /// + public class TwiML + { /// - /// Base class for all TwiML Objects. + /// Tag name /// - public class TwiML - { - /// - /// Tag name - /// - private string TagName { get; } - /// - /// Children elements - /// - private List Children { get; } - /// - /// Additional tag attributes to set on the generated xml - /// - private List> Options { get; } - /// - /// Attribute names to be transformed on the generated xml - /// - private Dictionary AttributeNameMapper = new Dictionary { { "for_", "for" } }; - - /// - /// Base constructor to create any TwiML instance. - /// - /// TwiML tag name - protected TwiML(string tagName) - { - this.TagName = tagName; - this.Children = new List(); - this.Options = new List>(); - } - - /// - /// Get the TwiML element body. - /// - protected virtual string GetElementBody() - { - return string.Empty; - } - - /// - /// Get the TwiML element attributes. - /// - protected virtual List GetElementAttributes() - { - return new List(); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public virtual TwiML Append(TwiML childElem) - { - this.Children.Add(childElem); - return this; - } - - public TwiML AddText(string text) - { - this.Children.Add(new Text(text)); - return this; - } - - /// - /// Append a child TwiML element to this element returning the newly created element. - /// - /// Child TwiML element to add - public T Nest(T childElem) where T : TwiML - { - this.Children.Add(childElem); - return childElem; - } - - /// - /// Add a generic child TwiML object - /// - /// TwiML tag name - public TwiML AddChild(string tagName) - { - return this.Nest(new TwiML(tagName)); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public TwiML SetOption(string key, object value) - { - if (this.Options.Exists(e => e.Key.Equals(key))) - { - this.Options.Remove(this.Options.Find(e => e.Key.Equals(key))); - } - - this.Options.Add(new KeyValuePair(key, value.ToString())); - return this; - } - - /// - /// Get freeform key-value attributes attached to this class - /// - /// Option key - public virtual string GetOption(string key) - { - return this.Options.Find(e => e.Key.Equals(key)).Value; - } - - /// - /// Generate XElement from TwiML object - /// - protected virtual XNode ToXml() - { - var elem = new XElement(this.TagName, this.GetElementBody()); - - this.GetElementAttributes().ForEach(attr => - { - string transformedAttr = attr.Name.LocalName; - if (AttributeNameMapper.TryGetValue(attr.Name.LocalName, out transformedAttr)) - { - elem.Add(new XAttribute(transformedAttr, attr.Value)); - } - else - { - elem.Add(attr); - } - }); - - this.Options.ForEach(e => - { - if (e.Key.StartsWith("xml:")) - { - var attribute = new XAttribute(XNamespace.Xml + e.Key.Substring(4), e.Value); - elem.Add(attribute); - } - else - { - elem.Add(new XAttribute(e.Key, e.Value)); - } - }); - - this.Children.ForEach(child => elem.Add(child.ToXml())); - - return elem; - } - - /// - /// Generate XML string from TwiML object - /// - /// Change generated string format. - public string ToString(SaveOptions formattingOptions = SaveOptions.None) - { - var declaration = new XDeclaration("1.0", "utf-8", null); - var elem = this.ToXml(); - - var document = new XDocument(declaration, elem); - var writer = new Utf8StringWriter(); - document.Save(writer, formattingOptions); - return writer.GetStringBuilder().ToString(); - } - } - + private string TagName { get; } + /// + /// Children elements + /// + private List Children { get; } + /// + /// Additional tag attributes to set on the generated xml + /// + private List> Options { get; } + /// + /// Attribute names to be transformed on the generated xml + /// + private Dictionary AttributeNameMapper = new Dictionary { { "for_", "for" } }; + + /// + /// Base constructor to create any TwiML instance. + /// + /// TwiML tag name + protected TwiML(string tagName) + { + this.TagName = tagName; + this.Children = new List(); + this.Options = new List>(); + } + + /// + /// Get the TwiML element body. + /// + protected virtual string GetElementBody() + { + return string.Empty; + } + + /// + /// Get the TwiML element attributes. + /// + protected virtual List GetElementAttributes() + { + return new List(); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public virtual TwiML Append(TwiML childElem) + { + this.Children.Add(childElem); + return this; + } + + public TwiML AddText(string text) + { + this.Children.Add(new Text(text)); + return this; + } + + /// + /// Append a child TwiML element to this element returning the newly created element. + /// + /// Child TwiML element to add + public T Nest(T childElem) where T : TwiML + { + this.Children.Add(childElem); + return childElem; + } + + /// + /// Add a generic child TwiML object + /// + /// TwiML tag name + public TwiML AddChild(string tagName) + { + return this.Nest(new TwiML(tagName)); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public TwiML SetOption(string key, object value) + { + if (this.Options.Exists(e => e.Key.Equals(key))) + { + this.Options.Remove(this.Options.Find(e => e.Key.Equals(key))); + } + + this.Options.Add(new KeyValuePair(key, value.ToString())); + return this; + } + + /// + /// Get freeform key-value attributes attached to this class + /// + /// Option key + public virtual string GetOption(string key) + { + return this.Options.Find(e => e.Key.Equals(key)).Value; + } + + /// + /// Generate XElement from TwiML object + /// + protected virtual XNode ToXml() + { + var elem = new XElement(this.TagName, this.GetElementBody()); + + this.GetElementAttributes().ForEach(attr => + { + string transformedAttr = attr.Name.LocalName; + if (AttributeNameMapper.TryGetValue(attr.Name.LocalName, out transformedAttr)) + { + elem.Add(new XAttribute(transformedAttr, attr.Value)); + } + else + { + elem.Add(attr); + } + }); + + this.Options.ForEach(e => + { + if (e.Key.StartsWith("xml:")) + { + var attribute = new XAttribute(XNamespace.Xml + e.Key.Substring(4), e.Value); + elem.Add(attribute); + } + else + { + elem.Add(new XAttribute(e.Key, e.Value)); + } + }); + + this.Children.ForEach(child => elem.Add(child.ToXml())); + + return elem; + } + /// - /// StringWriter which overrides default encoding to use UTF8. + /// Generate XML string from TwiML object /// - public class Utf8StringWriter : StringWriter - { - public override Encoding Encoding => Encoding.UTF8; - } + /// Change generated string format. + public string ToString(SaveOptions formattingOptions = SaveOptions.None) + { + var declaration = new XDeclaration("1.0", "utf-8", null); + var elem = this.ToXml(); + + var document = new XDocument(declaration, elem); + var writer = new Utf8StringWriter(); + document.Save(writer, formattingOptions); + return writer.GetStringBuilder().ToString(); + } + } + + /// + /// StringWriter which overrides default encoding to use UTF8. + /// + public class Utf8StringWriter : StringWriter + { + public override Encoding Encoding => Encoding.UTF8; + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Video/Room.cs b/src/Twilio/TwiML/Video/Room.cs index 285281812..8d18019d6 100644 --- a/src/Twilio/TwiML/Video/Room.cs +++ b/src/Twilio/TwiML/Video/Room.cs @@ -7,54 +7,54 @@ using System.Text; using System.Xml.Linq; -namespace Twilio.TwiML.Video -{ - +namespace Twilio.TwiML.Video +{ + + /// + /// Room TwiML Noun + /// + public class Room : TwiML + { /// - /// Room TwiML Noun + /// Room name /// - public class Room : TwiML - { - /// - /// Room name - /// - public string Name { get; set; } - - /// - /// Create a new Room - /// - /// Room name, the body of the TwiML Element. - public Room(string name = null) : base("Room") - { - this.Name = name; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Room Append(TwiML childElem) - { - return (Room) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Room SetOption(string key, object value) - { - return (Room) base.SetOption(key, value); - } - } + public string Name { get; set; } + + /// + /// Create a new Room + /// + /// Room name, the body of the TwiML Element. + public Room(string name = null) : base("Room") + { + this.Name = name; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Room Append(TwiML childElem) + { + return (Room)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Room SetOption(string key, object value) + { + return (Room)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Autopilot.cs b/src/Twilio/TwiML/Voice/Autopilot.cs index b81d49d1e..de4fe7ab5 100644 --- a/src/Twilio/TwiML/Voice/Autopilot.cs +++ b/src/Twilio/TwiML/Voice/Autopilot.cs @@ -8,53 +8,53 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Autopilot TwiML Noun + /// + public class Autopilot : TwiML + { /// - /// Autopilot TwiML Noun + /// Autopilot assistant sid or unique name /// - public class Autopilot : TwiML - { - /// - /// Autopilot assistant sid or unique name - /// - public string Name { get; set; } - - /// - /// Create a new Autopilot - /// - /// Autopilot assistant sid or unique name, the body of the TwiML Element. - public Autopilot(string name = null) : base("Autopilot") - { - this.Name = name; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Autopilot Append(TwiML childElem) - { - return (Autopilot) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Autopilot SetOption(string key, object value) - { - return (Autopilot) base.SetOption(key, value); - } - } + public string Name { get; set; } + + /// + /// Create a new Autopilot + /// + /// Autopilot assistant sid or unique name, the body of the TwiML Element. + public Autopilot(string name = null) : base("Autopilot") + { + this.Name = name; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Autopilot Append(TwiML childElem) + { + return (Autopilot)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Autopilot SetOption(string key, object value) + { + return (Autopilot)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Client.cs b/src/Twilio/TwiML/Voice/Client.cs index 7096b05db..973bf04b2 100644 --- a/src/Twilio/TwiML/Voice/Client.cs +++ b/src/Twilio/TwiML/Voice/Client.cs @@ -13,177 +13,177 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Client TwiML Noun + /// + public class Client : TwiML + { + public sealed class EventEnum : StringEnum + { + private EventEnum(string value) : base(value) { } + public EventEnum() { } + public static implicit operator EventEnum(string value) + { + return new EventEnum(value); + } + + public static readonly EventEnum Initiated = new EventEnum("initiated"); + public static readonly EventEnum Ringing = new EventEnum("ringing"); + public static readonly EventEnum Answered = new EventEnum("answered"); + public static readonly EventEnum Completed = new EventEnum("completed"); + } + /// - /// Client TwiML Noun + /// Client identity /// - public class Client : TwiML - { - public sealed class EventEnum : StringEnum - { - private EventEnum(string value) : base(value) {} - public EventEnum() {} - public static implicit operator EventEnum(string value) - { - return new EventEnum(value); - } - - public static readonly EventEnum Initiated = new EventEnum("initiated"); - public static readonly EventEnum Ringing = new EventEnum("ringing"); - public static readonly EventEnum Answered = new EventEnum("answered"); - public static readonly EventEnum Completed = new EventEnum("completed"); - } - - /// - /// Client identity - /// - public string IdentityAttribute { get; set; } - /// - /// Client URL - /// - public Uri Url { get; set; } - /// - /// Client URL Method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Events to trigger status callback - /// - public List StatusCallbackEvent { get; set; } - /// - /// Status Callback URL - /// - public Uri StatusCallback { get; set; } - /// - /// Status Callback URL Method - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Create a new Client - /// - /// Client identity, the body of the TwiML Element. - /// Client URL - /// Client URL Method - /// Events to trigger status callback - /// Status Callback URL - /// Status Callback URL Method - public Client(string identity = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null) : base("Client") - { - this.IdentityAttribute = identity; - this.Url = url; - this.Method = method; - this.StatusCallbackEvent = statusCallbackEvent; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.IdentityAttribute != null ? this.IdentityAttribute : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Url != null) - { - attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.StatusCallbackEvent != null) - { - attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Identity of the client to dial, the body of the TwiML Element. - public Client Identity(string clientIdentity = null) - { - var newChild = new Identity(clientIdentity); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Identity instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Client Identity(Identity identity) - { - this.Append(identity); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// The name of the custom parameter - /// The value of the custom parameter - public Client Parameter(string name = null, string value = null) - { - var newChild = new Parameter(name, value); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Parameter instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Client Parameter(Parameter parameter) - { - this.Append(parameter); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Client Append(TwiML childElem) - { - return (Client) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Client SetOption(string key, object value) - { - return (Client) base.SetOption(key, value); - } - } + public string IdentityAttribute { get; set; } + /// + /// Client URL + /// + public Uri Url { get; set; } + /// + /// Client URL Method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Events to trigger status callback + /// + public List StatusCallbackEvent { get; set; } + /// + /// Status Callback URL + /// + public Uri StatusCallback { get; set; } + /// + /// Status Callback URL Method + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Create a new Client + /// + /// Client identity, the body of the TwiML Element. + /// Client URL + /// Client URL Method + /// Events to trigger status callback + /// Status Callback URL + /// Status Callback URL Method + public Client(string identity = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null) : base("Client") + { + this.IdentityAttribute = identity; + this.Url = url; + this.Method = method; + this.StatusCallbackEvent = statusCallbackEvent; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.IdentityAttribute != null ? this.IdentityAttribute : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Url != null) + { + attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.StatusCallbackEvent != null) + { + attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Identity of the client to dial, the body of the TwiML Element. + public Client Identity(string clientIdentity = null) + { + var newChild = new Identity(clientIdentity); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Identity instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Client Identity(Identity identity) + { + this.Append(identity); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// The name of the custom parameter + /// The value of the custom parameter + public Client Parameter(string name = null, string value = null) + { + var newChild = new Parameter(name, value); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Parameter instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Client Parameter(Parameter parameter) + { + this.Append(parameter); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Client Append(TwiML childElem) + { + return (Client)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Client SetOption(string key, object value) + { + return (Client)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Conference.cs b/src/Twilio/TwiML/Voice/Conference.cs index f88d7814d..8ae858b3b 100644 --- a/src/Twilio/TwiML/Voice/Conference.cs +++ b/src/Twilio/TwiML/Voice/Conference.cs @@ -13,390 +13,390 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Conference TwiML Noun + /// + public class Conference : TwiML + { + public sealed class BeepEnum : StringEnum + { + private BeepEnum(string value) : base(value) { } + public BeepEnum() { } + public static implicit operator BeepEnum(string value) + { + return new BeepEnum(value); + } + + public static readonly BeepEnum True = new BeepEnum("true"); + public static readonly BeepEnum False = new BeepEnum("false"); + public static readonly BeepEnum Onenter = new BeepEnum("onEnter"); + public static readonly BeepEnum Onexit = new BeepEnum("onExit"); + } + + public sealed class RecordEnum : StringEnum + { + private RecordEnum(string value) : base(value) { } + public RecordEnum() { } + public static implicit operator RecordEnum(string value) + { + return new RecordEnum(value); + } + + public static readonly RecordEnum DoNotRecord = new RecordEnum("do-not-record"); + public static readonly RecordEnum RecordFromStart = new RecordEnum("record-from-start"); + } + + public sealed class RegionEnum : StringEnum + { + private RegionEnum(string value) : base(value) { } + public RegionEnum() { } + public static implicit operator RegionEnum(string value) + { + return new RegionEnum(value); + } + + public static readonly RegionEnum Us1 = new RegionEnum("us1"); + public static readonly RegionEnum Ie1 = new RegionEnum("ie1"); + public static readonly RegionEnum Sg1 = new RegionEnum("sg1"); + public static readonly RegionEnum Br1 = new RegionEnum("br1"); + public static readonly RegionEnum Au1 = new RegionEnum("au1"); + public static readonly RegionEnum Jp1 = new RegionEnum("jp1"); + public static readonly RegionEnum De1 = new RegionEnum("de1"); + } + + public sealed class EventEnum : StringEnum + { + private EventEnum(string value) : base(value) { } + public EventEnum() { } + public static implicit operator EventEnum(string value) + { + return new EventEnum(value); + } + + public static readonly EventEnum Start = new EventEnum("start"); + public static readonly EventEnum End = new EventEnum("end"); + public static readonly EventEnum Join = new EventEnum("join"); + public static readonly EventEnum Leave = new EventEnum("leave"); + public static readonly EventEnum Mute = new EventEnum("mute"); + public static readonly EventEnum Hold = new EventEnum("hold"); + public static readonly EventEnum Modify = new EventEnum("modify"); + public static readonly EventEnum Speaker = new EventEnum("speaker"); + public static readonly EventEnum Announcement = new EventEnum("announcement"); + } + + public sealed class TrimEnum : StringEnum + { + private TrimEnum(string value) : base(value) { } + public TrimEnum() { } + public static implicit operator TrimEnum(string value) + { + return new TrimEnum(value); + } + + public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); + public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); + } + + public sealed class RecordingEventEnum : StringEnum + { + private RecordingEventEnum(string value) : base(value) { } + public RecordingEventEnum() { } + public static implicit operator RecordingEventEnum(string value) + { + return new RecordingEventEnum(value); + } + + public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); + public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); + public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); + } + + public sealed class JitterBufferSizeEnum : StringEnum + { + private JitterBufferSizeEnum(string value) : base(value) { } + public JitterBufferSizeEnum() { } + public static implicit operator JitterBufferSizeEnum(string value) + { + return new JitterBufferSizeEnum(value); + } + + public static readonly JitterBufferSizeEnum Large = new JitterBufferSizeEnum("large"); + public static readonly JitterBufferSizeEnum Medium = new JitterBufferSizeEnum("medium"); + public static readonly JitterBufferSizeEnum Small = new JitterBufferSizeEnum("small"); + public static readonly JitterBufferSizeEnum Off = new JitterBufferSizeEnum("off"); + } + /// - /// Conference TwiML Noun + /// Conference name /// - public class Conference : TwiML - { - public sealed class BeepEnum : StringEnum - { - private BeepEnum(string value) : base(value) {} - public BeepEnum() {} - public static implicit operator BeepEnum(string value) - { - return new BeepEnum(value); - } - - public static readonly BeepEnum True = new BeepEnum("true"); - public static readonly BeepEnum False = new BeepEnum("false"); - public static readonly BeepEnum Onenter = new BeepEnum("onEnter"); - public static readonly BeepEnum Onexit = new BeepEnum("onExit"); - } - - public sealed class RecordEnum : StringEnum - { - private RecordEnum(string value) : base(value) {} - public RecordEnum() {} - public static implicit operator RecordEnum(string value) - { - return new RecordEnum(value); - } - - public static readonly RecordEnum DoNotRecord = new RecordEnum("do-not-record"); - public static readonly RecordEnum RecordFromStart = new RecordEnum("record-from-start"); - } - - public sealed class RegionEnum : StringEnum - { - private RegionEnum(string value) : base(value) {} - public RegionEnum() {} - public static implicit operator RegionEnum(string value) - { - return new RegionEnum(value); - } - - public static readonly RegionEnum Us1 = new RegionEnum("us1"); - public static readonly RegionEnum Ie1 = new RegionEnum("ie1"); - public static readonly RegionEnum Sg1 = new RegionEnum("sg1"); - public static readonly RegionEnum Br1 = new RegionEnum("br1"); - public static readonly RegionEnum Au1 = new RegionEnum("au1"); - public static readonly RegionEnum Jp1 = new RegionEnum("jp1"); - public static readonly RegionEnum De1 = new RegionEnum("de1"); - } - - public sealed class EventEnum : StringEnum - { - private EventEnum(string value) : base(value) {} - public EventEnum() {} - public static implicit operator EventEnum(string value) - { - return new EventEnum(value); - } - - public static readonly EventEnum Start = new EventEnum("start"); - public static readonly EventEnum End = new EventEnum("end"); - public static readonly EventEnum Join = new EventEnum("join"); - public static readonly EventEnum Leave = new EventEnum("leave"); - public static readonly EventEnum Mute = new EventEnum("mute"); - public static readonly EventEnum Hold = new EventEnum("hold"); - public static readonly EventEnum Modify = new EventEnum("modify"); - public static readonly EventEnum Speaker = new EventEnum("speaker"); - public static readonly EventEnum Announcement = new EventEnum("announcement"); - } - - public sealed class TrimEnum : StringEnum - { - private TrimEnum(string value) : base(value) {} - public TrimEnum() {} - public static implicit operator TrimEnum(string value) - { - return new TrimEnum(value); - } - - public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); - public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); - } - - public sealed class RecordingEventEnum : StringEnum - { - private RecordingEventEnum(string value) : base(value) {} - public RecordingEventEnum() {} - public static implicit operator RecordingEventEnum(string value) - { - return new RecordingEventEnum(value); - } - - public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); - public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); - public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); - } - - public sealed class JitterBufferSizeEnum : StringEnum - { - private JitterBufferSizeEnum(string value) : base(value) {} - public JitterBufferSizeEnum() {} - public static implicit operator JitterBufferSizeEnum(string value) - { - return new JitterBufferSizeEnum(value); - } - - public static readonly JitterBufferSizeEnum Large = new JitterBufferSizeEnum("large"); - public static readonly JitterBufferSizeEnum Medium = new JitterBufferSizeEnum("medium"); - public static readonly JitterBufferSizeEnum Small = new JitterBufferSizeEnum("small"); - public static readonly JitterBufferSizeEnum Off = new JitterBufferSizeEnum("off"); - } - - /// - /// Conference name - /// - public string Name { get; set; } - /// - /// Join the conference muted - /// - public bool? Muted { get; set; } - /// - /// Play beep when joining - /// - public Conference.BeepEnum Beep { get; set; } - /// - /// Start the conference on enter - /// - public bool? StartConferenceOnEnter { get; set; } - /// - /// End the conferenceon exit - /// - public bool? EndConferenceOnExit { get; set; } - /// - /// Wait URL - /// - public Uri WaitUrl { get; set; } - /// - /// Wait URL method - /// - public Twilio.Http.HttpMethod WaitMethod { get; set; } - /// - /// Maximum number of participants - /// - public int? MaxParticipants { get; set; } - /// - /// Record the conference - /// - public Conference.RecordEnum Record { get; set; } - /// - /// Conference region - /// - public Conference.RegionEnum Region { get; set; } - /// - /// Call coach - /// - public string Coach { get; set; } - /// - /// Trim the conference recording - /// - public Conference.TrimEnum Trim { get; set; } - /// - /// Events to call status callback URL - /// - public List StatusCallbackEvent { get; set; } - /// - /// Status callback URL - /// - public Uri StatusCallback { get; set; } - /// - /// Status callback URL method - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// Recording status callback URL - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// Recording status callback URL method - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// Recording status callback events - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// Event callback URL - /// - public Uri EventCallbackUrl { get; set; } - /// - /// Size of jitter buffer for participant - /// - public Conference.JitterBufferSizeEnum JitterBufferSize { get; set; } - /// - /// A label for participant - /// - public string ParticipantLabel { get; set; } - - /// - /// Create a new Conference - /// - /// Conference name, the body of the TwiML Element. - /// Join the conference muted - /// Play beep when joining - /// Start the conference on enter - /// End the conferenceon exit - /// Wait URL - /// Wait URL method - /// Maximum number of participants - /// Record the conference - /// Conference region - /// Call coach - /// Trim the conference recording - /// Events to call status callback URL - /// Status callback URL - /// Status callback URL method - /// Recording status callback URL - /// Recording status callback URL method - /// Recording status callback events - /// Event callback URL - /// Size of jitter buffer for participant - /// A label for participant - public Conference(string name = null, - bool? muted = null, - Conference.BeepEnum beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - int? maxParticipants = null, - Conference.RecordEnum record = null, - Conference.RegionEnum region = null, - string coach = null, - Conference.TrimEnum trim = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - Uri eventCallbackUrl = null, - Conference.JitterBufferSizeEnum jitterBufferSize = null, - string participantLabel = null) : base("Conference") - { - this.Name = name; - this.Muted = muted; - this.Beep = beep; - this.StartConferenceOnEnter = startConferenceOnEnter; - this.EndConferenceOnExit = endConferenceOnExit; - this.WaitUrl = waitUrl; - this.WaitMethod = waitMethod; - this.MaxParticipants = maxParticipants; - this.Record = record; - this.Region = region; - this.Coach = coach; - this.Trim = trim; - this.StatusCallbackEvent = statusCallbackEvent; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - this.RecordingStatusCallback = recordingStatusCallback; - this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; - this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; - this.EventCallbackUrl = eventCallbackUrl; - this.JitterBufferSize = jitterBufferSize; - this.ParticipantLabel = participantLabel; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Muted != null) - { - attributes.Add(new XAttribute("muted", this.Muted.Value.ToString().ToLower())); - } - if (this.Beep != null) - { - attributes.Add(new XAttribute("beep", this.Beep.ToString())); - } - if (this.StartConferenceOnEnter != null) - { - attributes.Add(new XAttribute("startConferenceOnEnter", this.StartConferenceOnEnter.Value.ToString().ToLower())); - } - if (this.EndConferenceOnExit != null) - { - attributes.Add(new XAttribute("endConferenceOnExit", this.EndConferenceOnExit.Value.ToString().ToLower())); - } - if (this.WaitUrl != null) - { - attributes.Add(new XAttribute("waitUrl", Serializers.Url(this.WaitUrl))); - } - if (this.WaitMethod != null) - { - attributes.Add(new XAttribute("waitMethod", this.WaitMethod.ToString())); - } - if (this.MaxParticipants != null) - { - attributes.Add(new XAttribute("maxParticipants", this.MaxParticipants.ToString())); - } - if (this.Record != null) - { - attributes.Add(new XAttribute("record", this.Record.ToString())); - } - if (this.Region != null) - { - attributes.Add(new XAttribute("region", this.Region.ToString())); - } - if (this.Coach != null) - { - attributes.Add(new XAttribute("coach", this.Coach.ToString())); - } - if (this.Trim != null) - { - attributes.Add(new XAttribute("trim", this.Trim.ToString())); - } - if (this.StatusCallbackEvent != null) - { - attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - if (this.RecordingStatusCallback != null) - { - attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); - } - if (this.RecordingStatusCallbackMethod != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); - } - if (this.RecordingStatusCallbackEvent != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.EventCallbackUrl != null) - { - attributes.Add(new XAttribute("eventCallbackUrl", Serializers.Url(this.EventCallbackUrl))); - } - if (this.JitterBufferSize != null) - { - attributes.Add(new XAttribute("jitterBufferSize", this.JitterBufferSize.ToString())); - } - if (this.ParticipantLabel != null) - { - attributes.Add(new XAttribute("participantLabel", this.ParticipantLabel)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Conference Append(TwiML childElem) - { - return (Conference) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Conference SetOption(string key, object value) - { - return (Conference) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Join the conference muted + /// + public bool? Muted { get; set; } + /// + /// Play beep when joining + /// + public Conference.BeepEnum Beep { get; set; } + /// + /// Start the conference on enter + /// + public bool? StartConferenceOnEnter { get; set; } + /// + /// End the conferenceon exit + /// + public bool? EndConferenceOnExit { get; set; } + /// + /// Wait URL + /// + public Uri WaitUrl { get; set; } + /// + /// Wait URL method + /// + public Twilio.Http.HttpMethod WaitMethod { get; set; } + /// + /// Maximum number of participants + /// + public int? MaxParticipants { get; set; } + /// + /// Record the conference + /// + public Conference.RecordEnum Record { get; set; } + /// + /// Conference region + /// + public Conference.RegionEnum Region { get; set; } + /// + /// Call coach + /// + public string Coach { get; set; } + /// + /// Trim the conference recording + /// + public Conference.TrimEnum Trim { get; set; } + /// + /// Events to call status callback URL + /// + public List StatusCallbackEvent { get; set; } + /// + /// Status callback URL + /// + public Uri StatusCallback { get; set; } + /// + /// Status callback URL method + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// Recording status callback URL + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// Recording status callback URL method + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// Recording status callback events + /// + public List RecordingStatusCallbackEvent { get; set; } + /// + /// Event callback URL + /// + public Uri EventCallbackUrl { get; set; } + /// + /// Size of jitter buffer for participant + /// + public Conference.JitterBufferSizeEnum JitterBufferSize { get; set; } + /// + /// A label for participant + /// + public string ParticipantLabel { get; set; } + + /// + /// Create a new Conference + /// + /// Conference name, the body of the TwiML Element. + /// Join the conference muted + /// Play beep when joining + /// Start the conference on enter + /// End the conferenceon exit + /// Wait URL + /// Wait URL method + /// Maximum number of participants + /// Record the conference + /// Conference region + /// Call coach + /// Trim the conference recording + /// Events to call status callback URL + /// Status callback URL + /// Status callback URL method + /// Recording status callback URL + /// Recording status callback URL method + /// Recording status callback events + /// Event callback URL + /// Size of jitter buffer for participant + /// A label for participant + public Conference(string name = null, + bool? muted = null, + Conference.BeepEnum beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + int? maxParticipants = null, + Conference.RecordEnum record = null, + Conference.RegionEnum region = null, + string coach = null, + Conference.TrimEnum trim = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + Uri eventCallbackUrl = null, + Conference.JitterBufferSizeEnum jitterBufferSize = null, + string participantLabel = null) : base("Conference") + { + this.Name = name; + this.Muted = muted; + this.Beep = beep; + this.StartConferenceOnEnter = startConferenceOnEnter; + this.EndConferenceOnExit = endConferenceOnExit; + this.WaitUrl = waitUrl; + this.WaitMethod = waitMethod; + this.MaxParticipants = maxParticipants; + this.Record = record; + this.Region = region; + this.Coach = coach; + this.Trim = trim; + this.StatusCallbackEvent = statusCallbackEvent; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + this.RecordingStatusCallback = recordingStatusCallback; + this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; + this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; + this.EventCallbackUrl = eventCallbackUrl; + this.JitterBufferSize = jitterBufferSize; + this.ParticipantLabel = participantLabel; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Muted != null) + { + attributes.Add(new XAttribute("muted", this.Muted.Value.ToString().ToLower())); + } + if (this.Beep != null) + { + attributes.Add(new XAttribute("beep", this.Beep.ToString())); + } + if (this.StartConferenceOnEnter != null) + { + attributes.Add(new XAttribute("startConferenceOnEnter", this.StartConferenceOnEnter.Value.ToString().ToLower())); + } + if (this.EndConferenceOnExit != null) + { + attributes.Add(new XAttribute("endConferenceOnExit", this.EndConferenceOnExit.Value.ToString().ToLower())); + } + if (this.WaitUrl != null) + { + attributes.Add(new XAttribute("waitUrl", Serializers.Url(this.WaitUrl))); + } + if (this.WaitMethod != null) + { + attributes.Add(new XAttribute("waitMethod", this.WaitMethod.ToString())); + } + if (this.MaxParticipants != null) + { + attributes.Add(new XAttribute("maxParticipants", this.MaxParticipants.ToString())); + } + if (this.Record != null) + { + attributes.Add(new XAttribute("record", this.Record.ToString())); + } + if (this.Region != null) + { + attributes.Add(new XAttribute("region", this.Region.ToString())); + } + if (this.Coach != null) + { + attributes.Add(new XAttribute("coach", this.Coach.ToString())); + } + if (this.Trim != null) + { + attributes.Add(new XAttribute("trim", this.Trim.ToString())); + } + if (this.StatusCallbackEvent != null) + { + attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + if (this.RecordingStatusCallback != null) + { + attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); + } + if (this.RecordingStatusCallbackMethod != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); + } + if (this.RecordingStatusCallbackEvent != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.EventCallbackUrl != null) + { + attributes.Add(new XAttribute("eventCallbackUrl", Serializers.Url(this.EventCallbackUrl))); + } + if (this.JitterBufferSize != null) + { + attributes.Add(new XAttribute("jitterBufferSize", this.JitterBufferSize.ToString())); + } + if (this.ParticipantLabel != null) + { + attributes.Add(new XAttribute("participantLabel", this.ParticipantLabel)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Conference Append(TwiML childElem) + { + return (Conference)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Conference SetOption(string key, object value) + { + return (Conference)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Connect.cs b/src/Twilio/TwiML/Voice/Connect.cs index ca0ebbdc8..3e6364dd2 100644 --- a/src/Twilio/TwiML/Voice/Connect.cs +++ b/src/Twilio/TwiML/Voice/Connect.cs @@ -11,173 +11,173 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Connect TwiML Verb + /// + public class Connect : TwiML + { /// - /// Connect TwiML Verb + /// Action URL /// - public class Connect : TwiML - { - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Create a new Connect - /// - /// Action URL - /// Action URL method - public Connect(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Connect") - { - this.Action = action; - this.Method = method; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Room name, the body of the TwiML Element. - /// Participant identity when connecting to the Room - public Connect Room(string name = null, string participantIdentity = null) - { - var newChild = new Room(name, participantIdentity); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Room instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Connect Room(Room room) - { - this.Append(room); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Autopilot assistant sid or unique name, the body of the TwiML Element. - public Connect Autopilot(string name = null) - { - var newChild = new Autopilot(name); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Autopilot instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Connect Autopilot(Autopilot autopilot) - { - this.Append(autopilot); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name given to the Stream - /// Unique name for Stream Connector - /// URL of the remote service where the Stream is routed - /// Track to be streamed to remote service - /// Status Callback URL - /// Status Callback URL method - public Connect Stream(string name = null, - string connectorName = null, - string url = null, - Stream.TrackEnum track = null, - string statusCallback = null, - Stream.StatusCallbackMethodEnum statusCallbackMethod = null) - { - var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Stream instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Connect Stream(Stream stream) - { - this.Append(stream); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Defines the conversation profile Dialogflow needs to use - /// Language to be used by Dialogflow to transcribe speech - /// Whether sentiment analysis needs to be enabled or not - /// URL to post status callbacks from Twilio - public Connect VirtualAgent(string connectorName = null, - string language = null, - bool? sentimentAnalysis = null, - string statusCallback = null) - { - var newChild = new VirtualAgent(connectorName, language, sentimentAnalysis, statusCallback); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A VirtualAgent instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Connect VirtualAgent(VirtualAgent virtualAgent) - { - this.Append(virtualAgent); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Connect Append(TwiML childElem) - { - return (Connect) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Connect SetOption(string key, object value) - { - return (Connect) base.SetOption(key, value); - } - } + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Create a new Connect + /// + /// Action URL + /// Action URL method + public Connect(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Connect") + { + this.Action = action; + this.Method = method; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Room name, the body of the TwiML Element. + /// Participant identity when connecting to the Room + public Connect Room(string name = null, string participantIdentity = null) + { + var newChild = new Room(name, participantIdentity); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Room instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Connect Room(Room room) + { + this.Append(room); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Autopilot assistant sid or unique name, the body of the TwiML Element. + public Connect Autopilot(string name = null) + { + var newChild = new Autopilot(name); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Autopilot instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Connect Autopilot(Autopilot autopilot) + { + this.Append(autopilot); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name given to the Stream + /// Unique name for Stream Connector + /// URL of the remote service where the Stream is routed + /// Track to be streamed to remote service + /// Status Callback URL + /// Status Callback URL method + public Connect Stream(string name = null, + string connectorName = null, + string url = null, + Stream.TrackEnum track = null, + string statusCallback = null, + Stream.StatusCallbackMethodEnum statusCallbackMethod = null) + { + var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Stream instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Connect Stream(Stream stream) + { + this.Append(stream); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Defines the conversation profile Dialogflow needs to use + /// Language to be used by Dialogflow to transcribe speech + /// Whether sentiment analysis needs to be enabled or not + /// URL to post status callbacks from Twilio + public Connect VirtualAgent(string connectorName = null, + string language = null, + bool? sentimentAnalysis = null, + string statusCallback = null) + { + var newChild = new VirtualAgent(connectorName, language, sentimentAnalysis, statusCallback); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A VirtualAgent instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Connect VirtualAgent(VirtualAgent virtualAgent) + { + this.Append(virtualAgent); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Connect Append(TwiML childElem) + { + return (Connect)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Connect SetOption(string key, object value) + { + return (Connect)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Dial.cs b/src/Twilio/TwiML/Voice/Dial.cs index a30e28c46..b8de10d10 100644 --- a/src/Twilio/TwiML/Voice/Dial.cs +++ b/src/Twilio/TwiML/Voice/Dial.cs @@ -13,625 +13,625 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Dial TwiML Verb + /// + public class Dial : TwiML + { + public sealed class TrimEnum : StringEnum + { + private TrimEnum(string value) : base(value) { } + public TrimEnum() { } + public static implicit operator TrimEnum(string value) + { + return new TrimEnum(value); + } + + public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); + public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); + } + + public sealed class RecordEnum : StringEnum + { + private RecordEnum(string value) : base(value) { } + public RecordEnum() { } + public static implicit operator RecordEnum(string value) + { + return new RecordEnum(value); + } + + public static readonly RecordEnum DoNotRecord = new RecordEnum("do-not-record"); + public static readonly RecordEnum RecordFromAnswer = new RecordEnum("record-from-answer"); + public static readonly RecordEnum RecordFromRinging = new RecordEnum("record-from-ringing"); + public static readonly RecordEnum RecordFromAnswerDual = new RecordEnum("record-from-answer-dual"); + public static readonly RecordEnum RecordFromRingingDual = new RecordEnum("record-from-ringing-dual"); + } + + public sealed class RecordingEventEnum : StringEnum + { + private RecordingEventEnum(string value) : base(value) { } + public RecordingEventEnum() { } + public static implicit operator RecordingEventEnum(string value) + { + return new RecordingEventEnum(value); + } + + public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); + public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); + public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); + } + + public sealed class RingToneEnum : StringEnum + { + private RingToneEnum(string value) : base(value) { } + public RingToneEnum() { } + public static implicit operator RingToneEnum(string value) + { + return new RingToneEnum(value); + } + + public static readonly RingToneEnum At = new RingToneEnum("at"); + public static readonly RingToneEnum Au = new RingToneEnum("au"); + public static readonly RingToneEnum Bg = new RingToneEnum("bg"); + public static readonly RingToneEnum Br = new RingToneEnum("br"); + public static readonly RingToneEnum Be = new RingToneEnum("be"); + public static readonly RingToneEnum Ch = new RingToneEnum("ch"); + public static readonly RingToneEnum Cl = new RingToneEnum("cl"); + public static readonly RingToneEnum Cn = new RingToneEnum("cn"); + public static readonly RingToneEnum Cz = new RingToneEnum("cz"); + public static readonly RingToneEnum De = new RingToneEnum("de"); + public static readonly RingToneEnum Dk = new RingToneEnum("dk"); + public static readonly RingToneEnum Ee = new RingToneEnum("ee"); + public static readonly RingToneEnum Es = new RingToneEnum("es"); + public static readonly RingToneEnum Fi = new RingToneEnum("fi"); + public static readonly RingToneEnum Fr = new RingToneEnum("fr"); + public static readonly RingToneEnum Gr = new RingToneEnum("gr"); + public static readonly RingToneEnum Hu = new RingToneEnum("hu"); + public static readonly RingToneEnum Il = new RingToneEnum("il"); + public static readonly RingToneEnum In = new RingToneEnum("in"); + public static readonly RingToneEnum It = new RingToneEnum("it"); + public static readonly RingToneEnum Lt = new RingToneEnum("lt"); + public static readonly RingToneEnum Jp = new RingToneEnum("jp"); + public static readonly RingToneEnum Mx = new RingToneEnum("mx"); + public static readonly RingToneEnum My = new RingToneEnum("my"); + public static readonly RingToneEnum Nl = new RingToneEnum("nl"); + public static readonly RingToneEnum No = new RingToneEnum("no"); + public static readonly RingToneEnum Nz = new RingToneEnum("nz"); + public static readonly RingToneEnum Ph = new RingToneEnum("ph"); + public static readonly RingToneEnum Pl = new RingToneEnum("pl"); + public static readonly RingToneEnum Pt = new RingToneEnum("pt"); + public static readonly RingToneEnum Ru = new RingToneEnum("ru"); + public static readonly RingToneEnum Se = new RingToneEnum("se"); + public static readonly RingToneEnum Sg = new RingToneEnum("sg"); + public static readonly RingToneEnum Th = new RingToneEnum("th"); + public static readonly RingToneEnum Uk = new RingToneEnum("uk"); + public static readonly RingToneEnum Us = new RingToneEnum("us"); + public static readonly RingToneEnum UsOld = new RingToneEnum("us-old"); + public static readonly RingToneEnum Tw = new RingToneEnum("tw"); + public static readonly RingToneEnum Ve = new RingToneEnum("ve"); + public static readonly RingToneEnum Za = new RingToneEnum("za"); + } + + public sealed class RecordingTrackEnum : StringEnum + { + private RecordingTrackEnum(string value) : base(value) { } + public RecordingTrackEnum() { } + public static implicit operator RecordingTrackEnum(string value) + { + return new RecordingTrackEnum(value); + } + + public static readonly RecordingTrackEnum Both = new RecordingTrackEnum("both"); + public static readonly RecordingTrackEnum Inbound = new RecordingTrackEnum("inbound"); + public static readonly RecordingTrackEnum Outbound = new RecordingTrackEnum("outbound"); + } + /// - /// Dial TwiML Verb - /// - public class Dial : TwiML - { - public sealed class TrimEnum : StringEnum - { - private TrimEnum(string value) : base(value) {} - public TrimEnum() {} - public static implicit operator TrimEnum(string value) - { - return new TrimEnum(value); - } - - public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); - public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); - } - - public sealed class RecordEnum : StringEnum - { - private RecordEnum(string value) : base(value) {} - public RecordEnum() {} - public static implicit operator RecordEnum(string value) - { - return new RecordEnum(value); - } - - public static readonly RecordEnum DoNotRecord = new RecordEnum("do-not-record"); - public static readonly RecordEnum RecordFromAnswer = new RecordEnum("record-from-answer"); - public static readonly RecordEnum RecordFromRinging = new RecordEnum("record-from-ringing"); - public static readonly RecordEnum RecordFromAnswerDual = new RecordEnum("record-from-answer-dual"); - public static readonly RecordEnum RecordFromRingingDual = new RecordEnum("record-from-ringing-dual"); - } - - public sealed class RecordingEventEnum : StringEnum - { - private RecordingEventEnum(string value) : base(value) {} - public RecordingEventEnum() {} - public static implicit operator RecordingEventEnum(string value) - { - return new RecordingEventEnum(value); - } - - public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); - public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); - public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); - } - - public sealed class RingToneEnum : StringEnum - { - private RingToneEnum(string value) : base(value) {} - public RingToneEnum() {} - public static implicit operator RingToneEnum(string value) - { - return new RingToneEnum(value); - } - - public static readonly RingToneEnum At = new RingToneEnum("at"); - public static readonly RingToneEnum Au = new RingToneEnum("au"); - public static readonly RingToneEnum Bg = new RingToneEnum("bg"); - public static readonly RingToneEnum Br = new RingToneEnum("br"); - public static readonly RingToneEnum Be = new RingToneEnum("be"); - public static readonly RingToneEnum Ch = new RingToneEnum("ch"); - public static readonly RingToneEnum Cl = new RingToneEnum("cl"); - public static readonly RingToneEnum Cn = new RingToneEnum("cn"); - public static readonly RingToneEnum Cz = new RingToneEnum("cz"); - public static readonly RingToneEnum De = new RingToneEnum("de"); - public static readonly RingToneEnum Dk = new RingToneEnum("dk"); - public static readonly RingToneEnum Ee = new RingToneEnum("ee"); - public static readonly RingToneEnum Es = new RingToneEnum("es"); - public static readonly RingToneEnum Fi = new RingToneEnum("fi"); - public static readonly RingToneEnum Fr = new RingToneEnum("fr"); - public static readonly RingToneEnum Gr = new RingToneEnum("gr"); - public static readonly RingToneEnum Hu = new RingToneEnum("hu"); - public static readonly RingToneEnum Il = new RingToneEnum("il"); - public static readonly RingToneEnum In = new RingToneEnum("in"); - public static readonly RingToneEnum It = new RingToneEnum("it"); - public static readonly RingToneEnum Lt = new RingToneEnum("lt"); - public static readonly RingToneEnum Jp = new RingToneEnum("jp"); - public static readonly RingToneEnum Mx = new RingToneEnum("mx"); - public static readonly RingToneEnum My = new RingToneEnum("my"); - public static readonly RingToneEnum Nl = new RingToneEnum("nl"); - public static readonly RingToneEnum No = new RingToneEnum("no"); - public static readonly RingToneEnum Nz = new RingToneEnum("nz"); - public static readonly RingToneEnum Ph = new RingToneEnum("ph"); - public static readonly RingToneEnum Pl = new RingToneEnum("pl"); - public static readonly RingToneEnum Pt = new RingToneEnum("pt"); - public static readonly RingToneEnum Ru = new RingToneEnum("ru"); - public static readonly RingToneEnum Se = new RingToneEnum("se"); - public static readonly RingToneEnum Sg = new RingToneEnum("sg"); - public static readonly RingToneEnum Th = new RingToneEnum("th"); - public static readonly RingToneEnum Uk = new RingToneEnum("uk"); - public static readonly RingToneEnum Us = new RingToneEnum("us"); - public static readonly RingToneEnum UsOld = new RingToneEnum("us-old"); - public static readonly RingToneEnum Tw = new RingToneEnum("tw"); - public static readonly RingToneEnum Ve = new RingToneEnum("ve"); - public static readonly RingToneEnum Za = new RingToneEnum("za"); - } - - public sealed class RecordingTrackEnum : StringEnum - { - private RecordingTrackEnum(string value) : base(value) {} - public RecordingTrackEnum() {} - public static implicit operator RecordingTrackEnum(string value) - { - return new RecordingTrackEnum(value); - } - - public static readonly RecordingTrackEnum Both = new RecordingTrackEnum("both"); - public static readonly RecordingTrackEnum Inbound = new RecordingTrackEnum("inbound"); - public static readonly RecordingTrackEnum Outbound = new RecordingTrackEnum("outbound"); - } - - /// - /// Phone number to dial - /// - public string NumberAttribute { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Time to wait for answer - /// - public int? Timeout { get; set; } - /// - /// Hangup call on star press - /// - public bool? HangupOnStar { get; set; } - /// - /// Max time length - /// - public int? TimeLimit { get; set; } - /// - /// Caller ID to display - /// - public string CallerId { get; set; } - /// - /// Record the call - /// - public Dial.RecordEnum Record { get; set; } - /// - /// Trim the recording - /// - public Dial.TrimEnum Trim { get; set; } - /// - /// Recording status callback URL - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// Recording status callback URL method - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// Recording status callback events - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// Preserve the ringing behavior of the inbound call until the Dialed call picks up - /// - public bool? AnswerOnBridge { get; set; } - /// - /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial - /// - public Dial.RingToneEnum RingTone { get; set; } - /// - /// To indicate which audio track should be recorded - /// - public Dial.RecordingTrackEnum RecordingTrack { get; set; } - /// - /// Used to determine if child TwiML nouns should be dialed in order, one after the other (sequential) or dial all at once (parallel). Default is false, parallel - /// - public bool? Sequential { get; set; } - /// - /// Webhook that will receive future SIP REFER requests - /// - public Uri ReferUrl { get; set; } - /// - /// The HTTP method to use for the refer Webhook - /// - public Twilio.Http.HttpMethod ReferMethod { get; set; } - - /// - /// Create a new Dial - /// - /// Phone number to dial, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// Time to wait for answer - /// Hangup call on star press - /// Max time length - /// Caller ID to display - /// Record the call - /// Trim the recording - /// Recording status callback URL - /// Recording status callback URL method - /// Recording status callback events - /// Preserve the ringing behavior of the inbound call until the Dialed call picks up - /// - /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller - /// while executing the Dial - /// To indicate which audio track should be recorded - /// Used to determine if child TwiML nouns should be dialed in order, one after the other - /// (sequential) or dial all at once (parallel). Default is false, parallel - /// Webhook that will receive future SIP REFER requests - /// The HTTP method to use for the refer Webhook - public Dial(string number = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - bool? hangupOnStar = null, - int? timeLimit = null, - string callerId = null, - Dial.RecordEnum record = null, - Dial.TrimEnum trim = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - bool? answerOnBridge = null, - Dial.RingToneEnum ringTone = null, - Dial.RecordingTrackEnum recordingTrack = null, - bool? sequential = null, - Uri referUrl = null, - Twilio.Http.HttpMethod referMethod = null) : base("Dial") - { - this.NumberAttribute = number; - this.Action = action; - this.Method = method; - this.Timeout = timeout; - this.HangupOnStar = hangupOnStar; - this.TimeLimit = timeLimit; - this.CallerId = callerId; - this.Record = record; - this.Trim = trim; - this.RecordingStatusCallback = recordingStatusCallback; - this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; - this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; - this.AnswerOnBridge = answerOnBridge; - this.RingTone = ringTone; - this.RecordingTrack = recordingTrack; - this.Sequential = sequential; - this.ReferUrl = referUrl; - this.ReferMethod = referMethod; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.NumberAttribute != null ? this.NumberAttribute : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.Timeout != null) - { - attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); - } - if (this.HangupOnStar != null) - { - attributes.Add(new XAttribute("hangupOnStar", this.HangupOnStar.Value.ToString().ToLower())); - } - if (this.TimeLimit != null) - { - attributes.Add(new XAttribute("timeLimit", this.TimeLimit.ToString())); - } - if (this.CallerId != null) - { - attributes.Add(new XAttribute("callerId", this.CallerId)); - } - if (this.Record != null) - { - attributes.Add(new XAttribute("record", this.Record.ToString())); - } - if (this.Trim != null) - { - attributes.Add(new XAttribute("trim", this.Trim.ToString())); - } - if (this.RecordingStatusCallback != null) - { - attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); - } - if (this.RecordingStatusCallbackMethod != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); - } - if (this.RecordingStatusCallbackEvent != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.AnswerOnBridge != null) - { - attributes.Add(new XAttribute("answerOnBridge", this.AnswerOnBridge.Value.ToString().ToLower())); - } - if (this.RingTone != null) - { - attributes.Add(new XAttribute("ringTone", this.RingTone.ToString())); - } - if (this.RecordingTrack != null) - { - attributes.Add(new XAttribute("recordingTrack", this.RecordingTrack.ToString())); - } - if (this.Sequential != null) - { - attributes.Add(new XAttribute("sequential", this.Sequential.Value.ToString().ToLower())); - } - if (this.ReferUrl != null) - { - attributes.Add(new XAttribute("referUrl", Serializers.Url(this.ReferUrl))); - } - if (this.ReferMethod != null) - { - attributes.Add(new XAttribute("referMethod", this.ReferMethod.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Client identity, the body of the TwiML Element. - /// Client URL - /// Client URL Method - /// Events to trigger status callback - /// Status Callback URL - /// Status Callback URL Method - public Dial Client(string identity = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null) - { - var newChild = new Client( - identity, - url, - method, - statusCallbackEvent, - statusCallback, - statusCallbackMethod - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Client instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Client(Client client) - { - this.Append(client); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Conference name, the body of the TwiML Element. - /// Join the conference muted - /// Play beep when joining - /// Start the conference on enter - /// End the conferenceon exit - /// Wait URL - /// Wait URL method - /// Maximum number of participants - /// Record the conference - /// Conference region - /// Call coach - /// Trim the conference recording - /// Events to call status callback URL - /// Status callback URL - /// Status callback URL method - /// Recording status callback URL - /// Recording status callback URL method - /// Recording status callback events - /// Event callback URL - /// Size of jitter buffer for participant - /// A label for participant - public Dial Conference(string name = null, - bool? muted = null, - Conference.BeepEnum beep = null, - bool? startConferenceOnEnter = null, - bool? endConferenceOnExit = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitMethod = null, - int? maxParticipants = null, - Conference.RecordEnum record = null, - Conference.RegionEnum region = null, - string coach = null, - Conference.TrimEnum trim = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - Uri eventCallbackUrl = null, - Conference.JitterBufferSizeEnum jitterBufferSize = null, - string participantLabel = null) - { - var newChild = new Conference( - name, - muted, - beep, - startConferenceOnEnter, - endConferenceOnExit, - waitUrl, - waitMethod, - maxParticipants, - record, - region, - coach, - trim, - statusCallbackEvent, - statusCallback, - statusCallbackMethod, - recordingStatusCallback, - recordingStatusCallbackMethod, - recordingStatusCallbackEvent, - eventCallbackUrl, - jitterBufferSize, - participantLabel - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Conference instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Conference(Conference conference) - { - this.Append(conference); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Phone Number to dial, the body of the TwiML Element. - /// DTMF tones to play when the call is answered - /// TwiML URL - /// TwiML URL method - /// Events to call status callback - /// Status callback URL - /// Status callback URL method - /// BYOC trunk SID (Beta) - public Dial Number(Types.PhoneNumber phoneNumber = null, - string sendDigits = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string byoc = null) - { - var newChild = new Number( - phoneNumber, - sendDigits, - url, - method, - statusCallbackEvent, - statusCallback, - statusCallbackMethod, - byoc - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Number instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Number(Number number) - { - this.Append(number); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Queue name, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// TaskRouter Reservation SID - /// TaskRouter Activity SID - public Dial Queue(string name = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - string reservationSid = null, - string postWorkActivitySid = null) - { - var newChild = new Queue(name, url, method, reservationSid, postWorkActivitySid); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Queue instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Queue(Queue queue) - { - this.Append(queue); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// SIM SID, the body of the TwiML Element. - public Dial Sim(string simSid = null) - { - var newChild = new Sim(simSid); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Sim instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Sim(Sim sim) - { - this.Append(sim); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// SIP URL, the body of the TwiML Element. - /// SIP Username - /// SIP Password - /// Action URL - /// Action URL method - /// Status callback events - /// Status callback URL - /// Status callback URL method - public Dial Sip(Uri sipUrl = null, - string username = null, - string password = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null) - { - var newChild = new Sip( - sipUrl, - username, - password, - url, - method, - statusCallbackEvent, - statusCallback, - statusCallbackMethod - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Sip instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Dial Sip(Sip sip) - { - this.Append(sip); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Dial Append(TwiML childElem) - { - return (Dial) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Dial SetOption(string key, object value) - { - return (Dial) base.SetOption(key, value); - } - } + /// Phone number to dial + /// + public string NumberAttribute { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Time to wait for answer + /// + public int? Timeout { get; set; } + /// + /// Hangup call on star press + /// + public bool? HangupOnStar { get; set; } + /// + /// Max time length + /// + public int? TimeLimit { get; set; } + /// + /// Caller ID to display + /// + public string CallerId { get; set; } + /// + /// Record the call + /// + public Dial.RecordEnum Record { get; set; } + /// + /// Trim the recording + /// + public Dial.TrimEnum Trim { get; set; } + /// + /// Recording status callback URL + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// Recording status callback URL method + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// Recording status callback events + /// + public List RecordingStatusCallbackEvent { get; set; } + /// + /// Preserve the ringing behavior of the inbound call until the Dialed call picks up + /// + public bool? AnswerOnBridge { get; set; } + /// + /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial + /// + public Dial.RingToneEnum RingTone { get; set; } + /// + /// To indicate which audio track should be recorded + /// + public Dial.RecordingTrackEnum RecordingTrack { get; set; } + /// + /// Used to determine if child TwiML nouns should be dialed in order, one after the other (sequential) or dial all at once (parallel). Default is false, parallel + /// + public bool? Sequential { get; set; } + /// + /// Webhook that will receive future SIP REFER requests + /// + public Uri ReferUrl { get; set; } + /// + /// The HTTP method to use for the refer Webhook + /// + public Twilio.Http.HttpMethod ReferMethod { get; set; } + + /// + /// Create a new Dial + /// + /// Phone number to dial, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// Time to wait for answer + /// Hangup call on star press + /// Max time length + /// Caller ID to display + /// Record the call + /// Trim the recording + /// Recording status callback URL + /// Recording status callback URL method + /// Recording status callback events + /// Preserve the ringing behavior of the inbound call until the Dialed call picks up + /// + /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller + /// while executing the Dial + /// To indicate which audio track should be recorded + /// Used to determine if child TwiML nouns should be dialed in order, one after the other + /// (sequential) or dial all at once (parallel). Default is false, parallel + /// Webhook that will receive future SIP REFER requests + /// The HTTP method to use for the refer Webhook + public Dial(string number = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + bool? hangupOnStar = null, + int? timeLimit = null, + string callerId = null, + Dial.RecordEnum record = null, + Dial.TrimEnum trim = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + bool? answerOnBridge = null, + Dial.RingToneEnum ringTone = null, + Dial.RecordingTrackEnum recordingTrack = null, + bool? sequential = null, + Uri referUrl = null, + Twilio.Http.HttpMethod referMethod = null) : base("Dial") + { + this.NumberAttribute = number; + this.Action = action; + this.Method = method; + this.Timeout = timeout; + this.HangupOnStar = hangupOnStar; + this.TimeLimit = timeLimit; + this.CallerId = callerId; + this.Record = record; + this.Trim = trim; + this.RecordingStatusCallback = recordingStatusCallback; + this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; + this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; + this.AnswerOnBridge = answerOnBridge; + this.RingTone = ringTone; + this.RecordingTrack = recordingTrack; + this.Sequential = sequential; + this.ReferUrl = referUrl; + this.ReferMethod = referMethod; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.NumberAttribute != null ? this.NumberAttribute : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.Timeout != null) + { + attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); + } + if (this.HangupOnStar != null) + { + attributes.Add(new XAttribute("hangupOnStar", this.HangupOnStar.Value.ToString().ToLower())); + } + if (this.TimeLimit != null) + { + attributes.Add(new XAttribute("timeLimit", this.TimeLimit.ToString())); + } + if (this.CallerId != null) + { + attributes.Add(new XAttribute("callerId", this.CallerId)); + } + if (this.Record != null) + { + attributes.Add(new XAttribute("record", this.Record.ToString())); + } + if (this.Trim != null) + { + attributes.Add(new XAttribute("trim", this.Trim.ToString())); + } + if (this.RecordingStatusCallback != null) + { + attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); + } + if (this.RecordingStatusCallbackMethod != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); + } + if (this.RecordingStatusCallbackEvent != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.AnswerOnBridge != null) + { + attributes.Add(new XAttribute("answerOnBridge", this.AnswerOnBridge.Value.ToString().ToLower())); + } + if (this.RingTone != null) + { + attributes.Add(new XAttribute("ringTone", this.RingTone.ToString())); + } + if (this.RecordingTrack != null) + { + attributes.Add(new XAttribute("recordingTrack", this.RecordingTrack.ToString())); + } + if (this.Sequential != null) + { + attributes.Add(new XAttribute("sequential", this.Sequential.Value.ToString().ToLower())); + } + if (this.ReferUrl != null) + { + attributes.Add(new XAttribute("referUrl", Serializers.Url(this.ReferUrl))); + } + if (this.ReferMethod != null) + { + attributes.Add(new XAttribute("referMethod", this.ReferMethod.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Client identity, the body of the TwiML Element. + /// Client URL + /// Client URL Method + /// Events to trigger status callback + /// Status Callback URL + /// Status Callback URL Method + public Dial Client(string identity = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null) + { + var newChild = new Client( + identity, + url, + method, + statusCallbackEvent, + statusCallback, + statusCallbackMethod + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Client instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Client(Client client) + { + this.Append(client); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Conference name, the body of the TwiML Element. + /// Join the conference muted + /// Play beep when joining + /// Start the conference on enter + /// End the conferenceon exit + /// Wait URL + /// Wait URL method + /// Maximum number of participants + /// Record the conference + /// Conference region + /// Call coach + /// Trim the conference recording + /// Events to call status callback URL + /// Status callback URL + /// Status callback URL method + /// Recording status callback URL + /// Recording status callback URL method + /// Recording status callback events + /// Event callback URL + /// Size of jitter buffer for participant + /// A label for participant + public Dial Conference(string name = null, + bool? muted = null, + Conference.BeepEnum beep = null, + bool? startConferenceOnEnter = null, + bool? endConferenceOnExit = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitMethod = null, + int? maxParticipants = null, + Conference.RecordEnum record = null, + Conference.RegionEnum region = null, + string coach = null, + Conference.TrimEnum trim = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + Uri eventCallbackUrl = null, + Conference.JitterBufferSizeEnum jitterBufferSize = null, + string participantLabel = null) + { + var newChild = new Conference( + name, + muted, + beep, + startConferenceOnEnter, + endConferenceOnExit, + waitUrl, + waitMethod, + maxParticipants, + record, + region, + coach, + trim, + statusCallbackEvent, + statusCallback, + statusCallbackMethod, + recordingStatusCallback, + recordingStatusCallbackMethod, + recordingStatusCallbackEvent, + eventCallbackUrl, + jitterBufferSize, + participantLabel + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Conference instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Conference(Conference conference) + { + this.Append(conference); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Phone Number to dial, the body of the TwiML Element. + /// DTMF tones to play when the call is answered + /// TwiML URL + /// TwiML URL method + /// Events to call status callback + /// Status callback URL + /// Status callback URL method + /// BYOC trunk SID (Beta) + public Dial Number(Types.PhoneNumber phoneNumber = null, + string sendDigits = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string byoc = null) + { + var newChild = new Number( + phoneNumber, + sendDigits, + url, + method, + statusCallbackEvent, + statusCallback, + statusCallbackMethod, + byoc + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Number instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Number(Number number) + { + this.Append(number); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Queue name, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// TaskRouter Reservation SID + /// TaskRouter Activity SID + public Dial Queue(string name = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + string reservationSid = null, + string postWorkActivitySid = null) + { + var newChild = new Queue(name, url, method, reservationSid, postWorkActivitySid); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Queue instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Queue(Queue queue) + { + this.Append(queue); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// SIM SID, the body of the TwiML Element. + public Dial Sim(string simSid = null) + { + var newChild = new Sim(simSid); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Sim instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Sim(Sim sim) + { + this.Append(sim); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// SIP URL, the body of the TwiML Element. + /// SIP Username + /// SIP Password + /// Action URL + /// Action URL method + /// Status callback events + /// Status callback URL + /// Status callback URL method + public Dial Sip(Uri sipUrl = null, + string username = null, + string password = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null) + { + var newChild = new Sip( + sipUrl, + username, + password, + url, + method, + statusCallbackEvent, + statusCallback, + statusCallbackMethod + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Sip instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Dial Sip(Sip sip) + { + this.Append(sip); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Dial Append(TwiML childElem) + { + return (Dial)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Dial SetOption(string key, object value) + { + return (Dial)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Echo.cs b/src/Twilio/TwiML/Voice/Echo.cs index 551332ed5..33b8564f7 100644 --- a/src/Twilio/TwiML/Voice/Echo.cs +++ b/src/Twilio/TwiML/Voice/Echo.cs @@ -8,38 +8,38 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Echo TwiML Verb + /// + public class Echo : TwiML + { /// - /// Echo TwiML Verb + /// Create a new Echo /// - public class Echo : TwiML - { - /// - /// Create a new Echo - /// - public Echo() : base("Echo") - { - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Echo Append(TwiML childElem) - { - return (Echo) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Echo SetOption(string key, object value) - { - return (Echo) base.SetOption(key, value); - } - } + public Echo() : base("Echo") + { + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Echo Append(TwiML childElem) + { + return (Echo)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Echo SetOption(string key, object value) + { + return (Echo)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Enqueue.cs b/src/Twilio/TwiML/Voice/Enqueue.cs index ab678c7bb..ab7ab9acf 100644 --- a/src/Twilio/TwiML/Voice/Enqueue.cs +++ b/src/Twilio/TwiML/Voice/Enqueue.cs @@ -11,142 +11,142 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Enqueue TwiML Noun + /// + public class Enqueue : TwiML + { /// - /// Enqueue TwiML Noun + /// Friendly name /// - public class Enqueue : TwiML - { - /// - /// Friendly name - /// - public string Name { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Wait URL - /// - public Uri WaitUrl { get; set; } - /// - /// Wait URL method - /// - public Twilio.Http.HttpMethod WaitUrlMethod { get; set; } - /// - /// TaskRouter Workflow SID - /// - public string WorkflowSid { get; set; } - - /// - /// Create a new Enqueue - /// - /// Friendly name, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// Wait URL - /// Wait URL method - /// TaskRouter Workflow SID - public Enqueue(string name = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitUrlMethod = null, - string workflowSid = null) : base("Enqueue") - { - this.Name = name; - this.Action = action; - this.Method = method; - this.WaitUrl = waitUrl; - this.WaitUrlMethod = waitUrlMethod; - this.WorkflowSid = workflowSid; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.WaitUrl != null) - { - attributes.Add(new XAttribute("waitUrl", Serializers.Url(this.WaitUrl))); - } - if (this.WaitUrlMethod != null) - { - attributes.Add(new XAttribute("waitUrlMethod", this.WaitUrlMethod.ToString())); - } - if (this.WorkflowSid != null) - { - attributes.Add(new XAttribute("workflowSid", this.WorkflowSid)); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// TaskRouter task attributes, the body of the TwiML Element. Also accepts stringified object - /// - /// Task priority - /// Timeout associated with task - public Enqueue Task(string body = null, int? priority = null, int? timeout = null) - { - var newChild = new Task(body, priority, timeout); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Task instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Enqueue Task(Task task) - { - this.Append(task); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Enqueue Append(TwiML childElem) - { - return (Enqueue) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Enqueue SetOption(string key, object value) - { - return (Enqueue) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Wait URL + /// + public Uri WaitUrl { get; set; } + /// + /// Wait URL method + /// + public Twilio.Http.HttpMethod WaitUrlMethod { get; set; } + /// + /// TaskRouter Workflow SID + /// + public string WorkflowSid { get; set; } + + /// + /// Create a new Enqueue + /// + /// Friendly name, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// Wait URL + /// Wait URL method + /// TaskRouter Workflow SID + public Enqueue(string name = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitUrlMethod = null, + string workflowSid = null) : base("Enqueue") + { + this.Name = name; + this.Action = action; + this.Method = method; + this.WaitUrl = waitUrl; + this.WaitUrlMethod = waitUrlMethod; + this.WorkflowSid = workflowSid; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.WaitUrl != null) + { + attributes.Add(new XAttribute("waitUrl", Serializers.Url(this.WaitUrl))); + } + if (this.WaitUrlMethod != null) + { + attributes.Add(new XAttribute("waitUrlMethod", this.WaitUrlMethod.ToString())); + } + if (this.WorkflowSid != null) + { + attributes.Add(new XAttribute("workflowSid", this.WorkflowSid)); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// TaskRouter task attributes, the body of the TwiML Element. Also accepts stringified object + /// + /// Task priority + /// Timeout associated with task + public Enqueue Task(string body = null, int? priority = null, int? timeout = null) + { + var newChild = new Task(body, priority, timeout); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Task instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Enqueue Task(Task task) + { + this.Append(task); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Enqueue Append(TwiML childElem) + { + return (Enqueue)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Enqueue SetOption(string key, object value) + { + return (Enqueue)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Gather.cs b/src/Twilio/TwiML/Voice/Gather.cs index c4ad47932..1d3fa3476 100644 --- a/src/Twilio/TwiML/Voice/Gather.cs +++ b/src/Twilio/TwiML/Voice/Gather.cs @@ -13,488 +13,488 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Gather TwiML Verb + /// + public class Gather : TwiML + { + public sealed class InputEnum : StringEnum + { + private InputEnum(string value) : base(value) { } + public InputEnum() { } + public static implicit operator InputEnum(string value) + { + return new InputEnum(value); + } + + public static readonly InputEnum Dtmf = new InputEnum("dtmf"); + public static readonly InputEnum Speech = new InputEnum("speech"); + } + + public sealed class LanguageEnum : StringEnum + { + private LanguageEnum(string value) : base(value) { } + public LanguageEnum() { } + public static implicit operator LanguageEnum(string value) + { + return new LanguageEnum(value); + } + + public static readonly LanguageEnum AfZa = new LanguageEnum("af-ZA"); + public static readonly LanguageEnum AmEt = new LanguageEnum("am-ET"); + public static readonly LanguageEnum ArAe = new LanguageEnum("ar-AE"); + public static readonly LanguageEnum ArBh = new LanguageEnum("ar-BH"); + public static readonly LanguageEnum ArDz = new LanguageEnum("ar-DZ"); + public static readonly LanguageEnum ArEg = new LanguageEnum("ar-EG"); + public static readonly LanguageEnum ArIl = new LanguageEnum("ar-IL"); + public static readonly LanguageEnum ArIq = new LanguageEnum("ar-IQ"); + public static readonly LanguageEnum ArJo = new LanguageEnum("ar-JO"); + public static readonly LanguageEnum ArKw = new LanguageEnum("ar-KW"); + public static readonly LanguageEnum ArLb = new LanguageEnum("ar-LB"); + public static readonly LanguageEnum ArMa = new LanguageEnum("ar-MA"); + public static readonly LanguageEnum ArOm = new LanguageEnum("ar-OM"); + public static readonly LanguageEnum ArPs = new LanguageEnum("ar-PS"); + public static readonly LanguageEnum ArQa = new LanguageEnum("ar-QA"); + public static readonly LanguageEnum ArSa = new LanguageEnum("ar-SA"); + public static readonly LanguageEnum ArTn = new LanguageEnum("ar-TN"); + public static readonly LanguageEnum AzAz = new LanguageEnum("az-AZ"); + public static readonly LanguageEnum BgBg = new LanguageEnum("bg-BG"); + public static readonly LanguageEnum BnBd = new LanguageEnum("bn-BD"); + public static readonly LanguageEnum BnIn = new LanguageEnum("bn-IN"); + public static readonly LanguageEnum CaEs = new LanguageEnum("ca-ES"); + public static readonly LanguageEnum CsCz = new LanguageEnum("cs-CZ"); + public static readonly LanguageEnum DaDk = new LanguageEnum("da-DK"); + public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); + public static readonly LanguageEnum ElGr = new LanguageEnum("el-GR"); + public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); + public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); + public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); + public static readonly LanguageEnum EnGh = new LanguageEnum("en-GH"); + public static readonly LanguageEnum EnIe = new LanguageEnum("en-IE"); + public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); + public static readonly LanguageEnum EnKe = new LanguageEnum("en-KE"); + public static readonly LanguageEnum EnNg = new LanguageEnum("en-NG"); + public static readonly LanguageEnum EnNz = new LanguageEnum("en-NZ"); + public static readonly LanguageEnum EnPh = new LanguageEnum("en-PH"); + public static readonly LanguageEnum EnSg = new LanguageEnum("en-SG"); + public static readonly LanguageEnum EnTz = new LanguageEnum("en-TZ"); + public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); + public static readonly LanguageEnum EnZa = new LanguageEnum("en-ZA"); + public static readonly LanguageEnum EsAr = new LanguageEnum("es-AR"); + public static readonly LanguageEnum EsBo = new LanguageEnum("es-BO"); + public static readonly LanguageEnum EsCl = new LanguageEnum("es-CL"); + public static readonly LanguageEnum EsCo = new LanguageEnum("es-CO"); + public static readonly LanguageEnum EsCr = new LanguageEnum("es-CR"); + public static readonly LanguageEnum EsDo = new LanguageEnum("es-DO"); + public static readonly LanguageEnum EsEc = new LanguageEnum("es-EC"); + public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); + public static readonly LanguageEnum EsGt = new LanguageEnum("es-GT"); + public static readonly LanguageEnum EsHn = new LanguageEnum("es-HN"); + public static readonly LanguageEnum EsMx = new LanguageEnum("es-MX"); + public static readonly LanguageEnum EsNi = new LanguageEnum("es-NI"); + public static readonly LanguageEnum EsPa = new LanguageEnum("es-PA"); + public static readonly LanguageEnum EsPe = new LanguageEnum("es-PE"); + public static readonly LanguageEnum EsPr = new LanguageEnum("es-PR"); + public static readonly LanguageEnum EsPy = new LanguageEnum("es-PY"); + public static readonly LanguageEnum EsSv = new LanguageEnum("es-SV"); + public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); + public static readonly LanguageEnum EsUy = new LanguageEnum("es-UY"); + public static readonly LanguageEnum EsVe = new LanguageEnum("es-VE"); + public static readonly LanguageEnum EtEe = new LanguageEnum("et-EE"); + public static readonly LanguageEnum EuEs = new LanguageEnum("eu-ES"); + public static readonly LanguageEnum FaIr = new LanguageEnum("fa-IR"); + public static readonly LanguageEnum FiFi = new LanguageEnum("fi-FI"); + public static readonly LanguageEnum FilPh = new LanguageEnum("fil-PH"); + public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); + public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); + public static readonly LanguageEnum GlEs = new LanguageEnum("gl-ES"); + public static readonly LanguageEnum GuIn = new LanguageEnum("gu-IN"); + public static readonly LanguageEnum HeIl = new LanguageEnum("he-IL"); + public static readonly LanguageEnum HiIn = new LanguageEnum("hi-IN"); + public static readonly LanguageEnum HrHr = new LanguageEnum("hr-HR"); + public static readonly LanguageEnum HuHu = new LanguageEnum("hu-HU"); + public static readonly LanguageEnum HyAm = new LanguageEnum("hy-AM"); + public static readonly LanguageEnum IdId = new LanguageEnum("id-ID"); + public static readonly LanguageEnum IsIs = new LanguageEnum("is-IS"); + public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); + public static readonly LanguageEnum JaJp = new LanguageEnum("ja-JP"); + public static readonly LanguageEnum JvId = new LanguageEnum("jv-ID"); + public static readonly LanguageEnum KaGe = new LanguageEnum("ka-GE"); + public static readonly LanguageEnum KmKh = new LanguageEnum("km-KH"); + public static readonly LanguageEnum KnIn = new LanguageEnum("kn-IN"); + public static readonly LanguageEnum KoKr = new LanguageEnum("ko-KR"); + public static readonly LanguageEnum LoLa = new LanguageEnum("lo-LA"); + public static readonly LanguageEnum LtLt = new LanguageEnum("lt-LT"); + public static readonly LanguageEnum LvLv = new LanguageEnum("lv-LV"); + public static readonly LanguageEnum MkMk = new LanguageEnum("mk-MK"); + public static readonly LanguageEnum MlIn = new LanguageEnum("ml-IN"); + public static readonly LanguageEnum MnMn = new LanguageEnum("mn-MN"); + public static readonly LanguageEnum MrIn = new LanguageEnum("mr-IN"); + public static readonly LanguageEnum MsMy = new LanguageEnum("ms-MY"); + public static readonly LanguageEnum MyMm = new LanguageEnum("my-MM"); + public static readonly LanguageEnum NarIq = new LanguageEnum("nar-IQ"); + public static readonly LanguageEnum NbNo = new LanguageEnum("nb-NO"); + public static readonly LanguageEnum NeNp = new LanguageEnum("ne-NP"); + public static readonly LanguageEnum NlBe = new LanguageEnum("nl-BE"); + public static readonly LanguageEnum NlNl = new LanguageEnum("nl-NL"); + public static readonly LanguageEnum PaGuruIn = new LanguageEnum("pa-guru-IN"); + public static readonly LanguageEnum PlPl = new LanguageEnum("pl-PL"); + public static readonly LanguageEnum PtBr = new LanguageEnum("pt-BR"); + public static readonly LanguageEnum PtPt = new LanguageEnum("pt-PT"); + public static readonly LanguageEnum RoRo = new LanguageEnum("ro-RO"); + public static readonly LanguageEnum RuRu = new LanguageEnum("ru-RU"); + public static readonly LanguageEnum SiLk = new LanguageEnum("si-LK"); + public static readonly LanguageEnum SkSk = new LanguageEnum("sk-SK"); + public static readonly LanguageEnum SlSi = new LanguageEnum("sl-SI"); + public static readonly LanguageEnum SqAl = new LanguageEnum("sq-AL"); + public static readonly LanguageEnum SrRs = new LanguageEnum("sr-RS"); + public static readonly LanguageEnum SuId = new LanguageEnum("su-ID"); + public static readonly LanguageEnum SvSe = new LanguageEnum("sv-SE"); + public static readonly LanguageEnum SwKe = new LanguageEnum("sw-KE"); + public static readonly LanguageEnum SwTz = new LanguageEnum("sw-TZ"); + public static readonly LanguageEnum TaIn = new LanguageEnum("ta-IN"); + public static readonly LanguageEnum TaLk = new LanguageEnum("ta-LK"); + public static readonly LanguageEnum TaMy = new LanguageEnum("ta-MY"); + public static readonly LanguageEnum TaSg = new LanguageEnum("ta-SG"); + public static readonly LanguageEnum TeIn = new LanguageEnum("te-IN"); + public static readonly LanguageEnum ThTh = new LanguageEnum("th-TH"); + public static readonly LanguageEnum TrTr = new LanguageEnum("tr-TR"); + public static readonly LanguageEnum UkUa = new LanguageEnum("uk-UA"); + public static readonly LanguageEnum UrIn = new LanguageEnum("ur-IN"); + public static readonly LanguageEnum UrPk = new LanguageEnum("ur-PK"); + public static readonly LanguageEnum UzUz = new LanguageEnum("uz-UZ"); + public static readonly LanguageEnum ViVn = new LanguageEnum("vi-VN"); + public static readonly LanguageEnum YueHantHk = new LanguageEnum("yue-Hant-HK"); + public static readonly LanguageEnum Zh = new LanguageEnum("zh"); + public static readonly LanguageEnum CmnHansCn = new LanguageEnum("cmn-Hans-CN"); + public static readonly LanguageEnum ZhTw = new LanguageEnum("zh-TW"); + public static readonly LanguageEnum CmnHantTw = new LanguageEnum("cmn-Hant-TW"); + public static readonly LanguageEnum ZuZa = new LanguageEnum("zu-ZA"); + } + + public sealed class SpeechModelEnum : StringEnum + { + private SpeechModelEnum(string value) : base(value) { } + public SpeechModelEnum() { } + public static implicit operator SpeechModelEnum(string value) + { + return new SpeechModelEnum(value); + } + + public static readonly SpeechModelEnum Default = new SpeechModelEnum("default"); + public static readonly SpeechModelEnum NumbersAndCommands = new SpeechModelEnum("numbers_and_commands"); + public static readonly SpeechModelEnum PhoneCall = new SpeechModelEnum("phone_call"); + } + /// - /// Gather TwiML Verb + /// Input type Twilio should accept /// - public class Gather : TwiML - { - public sealed class InputEnum : StringEnum - { - private InputEnum(string value) : base(value) {} - public InputEnum() {} - public static implicit operator InputEnum(string value) - { - return new InputEnum(value); - } - - public static readonly InputEnum Dtmf = new InputEnum("dtmf"); - public static readonly InputEnum Speech = new InputEnum("speech"); - } - - public sealed class LanguageEnum : StringEnum - { - private LanguageEnum(string value) : base(value) {} - public LanguageEnum() {} - public static implicit operator LanguageEnum(string value) - { - return new LanguageEnum(value); - } - - public static readonly LanguageEnum AfZa = new LanguageEnum("af-ZA"); - public static readonly LanguageEnum AmEt = new LanguageEnum("am-ET"); - public static readonly LanguageEnum ArAe = new LanguageEnum("ar-AE"); - public static readonly LanguageEnum ArBh = new LanguageEnum("ar-BH"); - public static readonly LanguageEnum ArDz = new LanguageEnum("ar-DZ"); - public static readonly LanguageEnum ArEg = new LanguageEnum("ar-EG"); - public static readonly LanguageEnum ArIl = new LanguageEnum("ar-IL"); - public static readonly LanguageEnum ArIq = new LanguageEnum("ar-IQ"); - public static readonly LanguageEnum ArJo = new LanguageEnum("ar-JO"); - public static readonly LanguageEnum ArKw = new LanguageEnum("ar-KW"); - public static readonly LanguageEnum ArLb = new LanguageEnum("ar-LB"); - public static readonly LanguageEnum ArMa = new LanguageEnum("ar-MA"); - public static readonly LanguageEnum ArOm = new LanguageEnum("ar-OM"); - public static readonly LanguageEnum ArPs = new LanguageEnum("ar-PS"); - public static readonly LanguageEnum ArQa = new LanguageEnum("ar-QA"); - public static readonly LanguageEnum ArSa = new LanguageEnum("ar-SA"); - public static readonly LanguageEnum ArTn = new LanguageEnum("ar-TN"); - public static readonly LanguageEnum AzAz = new LanguageEnum("az-AZ"); - public static readonly LanguageEnum BgBg = new LanguageEnum("bg-BG"); - public static readonly LanguageEnum BnBd = new LanguageEnum("bn-BD"); - public static readonly LanguageEnum BnIn = new LanguageEnum("bn-IN"); - public static readonly LanguageEnum CaEs = new LanguageEnum("ca-ES"); - public static readonly LanguageEnum CsCz = new LanguageEnum("cs-CZ"); - public static readonly LanguageEnum DaDk = new LanguageEnum("da-DK"); - public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); - public static readonly LanguageEnum ElGr = new LanguageEnum("el-GR"); - public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); - public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); - public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); - public static readonly LanguageEnum EnGh = new LanguageEnum("en-GH"); - public static readonly LanguageEnum EnIe = new LanguageEnum("en-IE"); - public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); - public static readonly LanguageEnum EnKe = new LanguageEnum("en-KE"); - public static readonly LanguageEnum EnNg = new LanguageEnum("en-NG"); - public static readonly LanguageEnum EnNz = new LanguageEnum("en-NZ"); - public static readonly LanguageEnum EnPh = new LanguageEnum("en-PH"); - public static readonly LanguageEnum EnSg = new LanguageEnum("en-SG"); - public static readonly LanguageEnum EnTz = new LanguageEnum("en-TZ"); - public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); - public static readonly LanguageEnum EnZa = new LanguageEnum("en-ZA"); - public static readonly LanguageEnum EsAr = new LanguageEnum("es-AR"); - public static readonly LanguageEnum EsBo = new LanguageEnum("es-BO"); - public static readonly LanguageEnum EsCl = new LanguageEnum("es-CL"); - public static readonly LanguageEnum EsCo = new LanguageEnum("es-CO"); - public static readonly LanguageEnum EsCr = new LanguageEnum("es-CR"); - public static readonly LanguageEnum EsDo = new LanguageEnum("es-DO"); - public static readonly LanguageEnum EsEc = new LanguageEnum("es-EC"); - public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); - public static readonly LanguageEnum EsGt = new LanguageEnum("es-GT"); - public static readonly LanguageEnum EsHn = new LanguageEnum("es-HN"); - public static readonly LanguageEnum EsMx = new LanguageEnum("es-MX"); - public static readonly LanguageEnum EsNi = new LanguageEnum("es-NI"); - public static readonly LanguageEnum EsPa = new LanguageEnum("es-PA"); - public static readonly LanguageEnum EsPe = new LanguageEnum("es-PE"); - public static readonly LanguageEnum EsPr = new LanguageEnum("es-PR"); - public static readonly LanguageEnum EsPy = new LanguageEnum("es-PY"); - public static readonly LanguageEnum EsSv = new LanguageEnum("es-SV"); - public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); - public static readonly LanguageEnum EsUy = new LanguageEnum("es-UY"); - public static readonly LanguageEnum EsVe = new LanguageEnum("es-VE"); - public static readonly LanguageEnum EtEe = new LanguageEnum("et-EE"); - public static readonly LanguageEnum EuEs = new LanguageEnum("eu-ES"); - public static readonly LanguageEnum FaIr = new LanguageEnum("fa-IR"); - public static readonly LanguageEnum FiFi = new LanguageEnum("fi-FI"); - public static readonly LanguageEnum FilPh = new LanguageEnum("fil-PH"); - public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); - public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); - public static readonly LanguageEnum GlEs = new LanguageEnum("gl-ES"); - public static readonly LanguageEnum GuIn = new LanguageEnum("gu-IN"); - public static readonly LanguageEnum HeIl = new LanguageEnum("he-IL"); - public static readonly LanguageEnum HiIn = new LanguageEnum("hi-IN"); - public static readonly LanguageEnum HrHr = new LanguageEnum("hr-HR"); - public static readonly LanguageEnum HuHu = new LanguageEnum("hu-HU"); - public static readonly LanguageEnum HyAm = new LanguageEnum("hy-AM"); - public static readonly LanguageEnum IdId = new LanguageEnum("id-ID"); - public static readonly LanguageEnum IsIs = new LanguageEnum("is-IS"); - public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); - public static readonly LanguageEnum JaJp = new LanguageEnum("ja-JP"); - public static readonly LanguageEnum JvId = new LanguageEnum("jv-ID"); - public static readonly LanguageEnum KaGe = new LanguageEnum("ka-GE"); - public static readonly LanguageEnum KmKh = new LanguageEnum("km-KH"); - public static readonly LanguageEnum KnIn = new LanguageEnum("kn-IN"); - public static readonly LanguageEnum KoKr = new LanguageEnum("ko-KR"); - public static readonly LanguageEnum LoLa = new LanguageEnum("lo-LA"); - public static readonly LanguageEnum LtLt = new LanguageEnum("lt-LT"); - public static readonly LanguageEnum LvLv = new LanguageEnum("lv-LV"); - public static readonly LanguageEnum MkMk = new LanguageEnum("mk-MK"); - public static readonly LanguageEnum MlIn = new LanguageEnum("ml-IN"); - public static readonly LanguageEnum MnMn = new LanguageEnum("mn-MN"); - public static readonly LanguageEnum MrIn = new LanguageEnum("mr-IN"); - public static readonly LanguageEnum MsMy = new LanguageEnum("ms-MY"); - public static readonly LanguageEnum MyMm = new LanguageEnum("my-MM"); - public static readonly LanguageEnum NarIq = new LanguageEnum("nar-IQ"); - public static readonly LanguageEnum NbNo = new LanguageEnum("nb-NO"); - public static readonly LanguageEnum NeNp = new LanguageEnum("ne-NP"); - public static readonly LanguageEnum NlBe = new LanguageEnum("nl-BE"); - public static readonly LanguageEnum NlNl = new LanguageEnum("nl-NL"); - public static readonly LanguageEnum PaGuruIn = new LanguageEnum("pa-guru-IN"); - public static readonly LanguageEnum PlPl = new LanguageEnum("pl-PL"); - public static readonly LanguageEnum PtBr = new LanguageEnum("pt-BR"); - public static readonly LanguageEnum PtPt = new LanguageEnum("pt-PT"); - public static readonly LanguageEnum RoRo = new LanguageEnum("ro-RO"); - public static readonly LanguageEnum RuRu = new LanguageEnum("ru-RU"); - public static readonly LanguageEnum SiLk = new LanguageEnum("si-LK"); - public static readonly LanguageEnum SkSk = new LanguageEnum("sk-SK"); - public static readonly LanguageEnum SlSi = new LanguageEnum("sl-SI"); - public static readonly LanguageEnum SqAl = new LanguageEnum("sq-AL"); - public static readonly LanguageEnum SrRs = new LanguageEnum("sr-RS"); - public static readonly LanguageEnum SuId = new LanguageEnum("su-ID"); - public static readonly LanguageEnum SvSe = new LanguageEnum("sv-SE"); - public static readonly LanguageEnum SwKe = new LanguageEnum("sw-KE"); - public static readonly LanguageEnum SwTz = new LanguageEnum("sw-TZ"); - public static readonly LanguageEnum TaIn = new LanguageEnum("ta-IN"); - public static readonly LanguageEnum TaLk = new LanguageEnum("ta-LK"); - public static readonly LanguageEnum TaMy = new LanguageEnum("ta-MY"); - public static readonly LanguageEnum TaSg = new LanguageEnum("ta-SG"); - public static readonly LanguageEnum TeIn = new LanguageEnum("te-IN"); - public static readonly LanguageEnum ThTh = new LanguageEnum("th-TH"); - public static readonly LanguageEnum TrTr = new LanguageEnum("tr-TR"); - public static readonly LanguageEnum UkUa = new LanguageEnum("uk-UA"); - public static readonly LanguageEnum UrIn = new LanguageEnum("ur-IN"); - public static readonly LanguageEnum UrPk = new LanguageEnum("ur-PK"); - public static readonly LanguageEnum UzUz = new LanguageEnum("uz-UZ"); - public static readonly LanguageEnum ViVn = new LanguageEnum("vi-VN"); - public static readonly LanguageEnum YueHantHk = new LanguageEnum("yue-Hant-HK"); - public static readonly LanguageEnum Zh = new LanguageEnum("zh"); - public static readonly LanguageEnum CmnHansCn = new LanguageEnum("cmn-Hans-CN"); - public static readonly LanguageEnum ZhTw = new LanguageEnum("zh-TW"); - public static readonly LanguageEnum CmnHantTw = new LanguageEnum("cmn-Hant-TW"); - public static readonly LanguageEnum ZuZa = new LanguageEnum("zu-ZA"); - } - - public sealed class SpeechModelEnum : StringEnum - { - private SpeechModelEnum(string value) : base(value) {} - public SpeechModelEnum() {} - public static implicit operator SpeechModelEnum(string value) - { - return new SpeechModelEnum(value); - } - - public static readonly SpeechModelEnum Default = new SpeechModelEnum("default"); - public static readonly SpeechModelEnum NumbersAndCommands = new SpeechModelEnum("numbers_and_commands"); - public static readonly SpeechModelEnum PhoneCall = new SpeechModelEnum("phone_call"); - } - - /// - /// Input type Twilio should accept - /// - public List Input { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Time to wait to gather input - /// - public int? Timeout { get; set; } - /// - /// Time to wait to gather speech input and it should be either auto or a positive integer. - /// - public string SpeechTimeout { get; set; } - /// - /// Max allowed time for speech input - /// - public int? MaxSpeechTime { get; set; } - /// - /// Profanity Filter on speech - /// - public bool? ProfanityFilter { get; set; } - /// - /// Finish gather on key - /// - public string FinishOnKey { get; set; } - /// - /// Number of digits to collect - /// - public int? NumDigits { get; set; } - /// - /// Partial result callback URL - /// - public Uri PartialResultCallback { get; set; } - /// - /// Partial result callback URL method - /// - public Twilio.Http.HttpMethod PartialResultCallbackMethod { get; set; } - /// - /// Language to use - /// - public Gather.LanguageEnum Language { get; set; } - /// - /// Speech recognition hints - /// - public string Hints { get; set; } - /// - /// Stop playing media upon speech - /// - public bool? BargeIn { get; set; } - /// - /// Allow debug for gather - /// - public bool? Debug { get; set; } - /// - /// Force webhook to the action URL event if there is no input - /// - public bool? ActionOnEmptyResult { get; set; } - /// - /// Specify the model that is best suited for your use case - /// - public Gather.SpeechModelEnum SpeechModel { get; set; } - /// - /// Use enhanced speech model - /// - public bool? Enhanced { get; set; } - - /// - /// Create a new Gather - /// - /// Input type Twilio should accept - /// Action URL - /// Action URL method - /// Time to wait to gather input - /// Time to wait to gather speech input and it should be either auto or a positive - /// integer. - /// Max allowed time for speech input - /// Profanity Filter on speech - /// Finish gather on key - /// Number of digits to collect - /// Partial result callback URL - /// Partial result callback URL method - /// Language to use - /// Speech recognition hints - /// Stop playing media upon speech - /// Allow debug for gather - /// Force webhook to the action URL event if there is no input - /// Specify the model that is best suited for your use case - /// Use enhanced speech model - public Gather(List input = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - string speechTimeout = null, - int? maxSpeechTime = null, - bool? profanityFilter = null, - string finishOnKey = null, - int? numDigits = null, - Uri partialResultCallback = null, - Twilio.Http.HttpMethod partialResultCallbackMethod = null, - Gather.LanguageEnum language = null, - string hints = null, - bool? bargeIn = null, - bool? debug = null, - bool? actionOnEmptyResult = null, - Gather.SpeechModelEnum speechModel = null, - bool? enhanced = null) : base("Gather") - { - this.Input = input; - this.Action = action; - this.Method = method; - this.Timeout = timeout; - this.SpeechTimeout = speechTimeout; - this.MaxSpeechTime = maxSpeechTime; - this.ProfanityFilter = profanityFilter; - this.FinishOnKey = finishOnKey; - this.NumDigits = numDigits; - this.PartialResultCallback = partialResultCallback; - this.PartialResultCallbackMethod = partialResultCallbackMethod; - this.Language = language; - this.Hints = hints; - this.BargeIn = bargeIn; - this.Debug = debug; - this.ActionOnEmptyResult = actionOnEmptyResult; - this.SpeechModel = speechModel; - this.Enhanced = enhanced; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Input != null) - { - attributes.Add(new XAttribute("input", String.Join(" ", this.Input.Select(e => e.ToString()).ToArray()))); - } - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.Timeout != null) - { - attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); - } - if (this.SpeechTimeout != null) - { - attributes.Add(new XAttribute("speechTimeout", this.SpeechTimeout)); - } - if (this.MaxSpeechTime != null) - { - attributes.Add(new XAttribute("maxSpeechTime", this.MaxSpeechTime.ToString())); - } - if (this.ProfanityFilter != null) - { - attributes.Add(new XAttribute("profanityFilter", this.ProfanityFilter.Value.ToString().ToLower())); - } - if (this.FinishOnKey != null) - { - attributes.Add(new XAttribute("finishOnKey", this.FinishOnKey)); - } - if (this.NumDigits != null) - { - attributes.Add(new XAttribute("numDigits", this.NumDigits.ToString())); - } - if (this.PartialResultCallback != null) - { - attributes.Add(new XAttribute("partialResultCallback", Serializers.Url(this.PartialResultCallback))); - } - if (this.PartialResultCallbackMethod != null) - { - attributes.Add(new XAttribute("partialResultCallbackMethod", this.PartialResultCallbackMethod.ToString())); - } - if (this.Language != null) - { - attributes.Add(new XAttribute("language", this.Language.ToString())); - } - if (this.Hints != null) - { - attributes.Add(new XAttribute("hints", this.Hints)); - } - if (this.BargeIn != null) - { - attributes.Add(new XAttribute("bargeIn", this.BargeIn.Value.ToString().ToLower())); - } - if (this.Debug != null) - { - attributes.Add(new XAttribute("debug", this.Debug.Value.ToString().ToLower())); - } - if (this.ActionOnEmptyResult != null) - { - attributes.Add(new XAttribute("actionOnEmptyResult", this.ActionOnEmptyResult.Value.ToString().ToLower())); - } - if (this.SpeechModel != null) - { - attributes.Add(new XAttribute("speechModel", this.SpeechModel.ToString())); - } - if (this.Enhanced != null) - { - attributes.Add(new XAttribute("enhanced", this.Enhanced.Value.ToString().ToLower())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message to say, the body of the TwiML Element. - /// Voice to use - /// Times to loop message - /// Message langauge - public Gather Say(string message = null, - Say.VoiceEnum voice = null, - int? loop = null, - Say.LanguageEnum language = null) - { - var newChild = new Say(message, voice, loop, language); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Say instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Gather Say(Say say) - { - this.Append(say); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Length in seconds to pause - public Gather Pause(int? length = null) - { - var newChild = new Pause(length); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Pause instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Gather Pause(Pause pause) - { - this.Append(pause); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Media URL, the body of the TwiML Element. - /// Times to loop media - /// Play DTMF tones for digits - public Gather Play(Uri url = null, int? loop = null, string digits = null) - { - var newChild = new Play(url, loop, digits); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Play instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Gather Play(Play play) - { - this.Append(play); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Gather Append(TwiML childElem) - { - return (Gather) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Gather SetOption(string key, object value) - { - return (Gather) base.SetOption(key, value); - } - } + public List Input { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Time to wait to gather input + /// + public int? Timeout { get; set; } + /// + /// Time to wait to gather speech input and it should be either auto or a positive integer. + /// + public string SpeechTimeout { get; set; } + /// + /// Max allowed time for speech input + /// + public int? MaxSpeechTime { get; set; } + /// + /// Profanity Filter on speech + /// + public bool? ProfanityFilter { get; set; } + /// + /// Finish gather on key + /// + public string FinishOnKey { get; set; } + /// + /// Number of digits to collect + /// + public int? NumDigits { get; set; } + /// + /// Partial result callback URL + /// + public Uri PartialResultCallback { get; set; } + /// + /// Partial result callback URL method + /// + public Twilio.Http.HttpMethod PartialResultCallbackMethod { get; set; } + /// + /// Language to use + /// + public Gather.LanguageEnum Language { get; set; } + /// + /// Speech recognition hints + /// + public string Hints { get; set; } + /// + /// Stop playing media upon speech + /// + public bool? BargeIn { get; set; } + /// + /// Allow debug for gather + /// + public bool? Debug { get; set; } + /// + /// Force webhook to the action URL event if there is no input + /// + public bool? ActionOnEmptyResult { get; set; } + /// + /// Specify the model that is best suited for your use case + /// + public Gather.SpeechModelEnum SpeechModel { get; set; } + /// + /// Use enhanced speech model + /// + public bool? Enhanced { get; set; } + + /// + /// Create a new Gather + /// + /// Input type Twilio should accept + /// Action URL + /// Action URL method + /// Time to wait to gather input + /// Time to wait to gather speech input and it should be either auto or a positive + /// integer. + /// Max allowed time for speech input + /// Profanity Filter on speech + /// Finish gather on key + /// Number of digits to collect + /// Partial result callback URL + /// Partial result callback URL method + /// Language to use + /// Speech recognition hints + /// Stop playing media upon speech + /// Allow debug for gather + /// Force webhook to the action URL event if there is no input + /// Specify the model that is best suited for your use case + /// Use enhanced speech model + public Gather(List input = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + string speechTimeout = null, + int? maxSpeechTime = null, + bool? profanityFilter = null, + string finishOnKey = null, + int? numDigits = null, + Uri partialResultCallback = null, + Twilio.Http.HttpMethod partialResultCallbackMethod = null, + Gather.LanguageEnum language = null, + string hints = null, + bool? bargeIn = null, + bool? debug = null, + bool? actionOnEmptyResult = null, + Gather.SpeechModelEnum speechModel = null, + bool? enhanced = null) : base("Gather") + { + this.Input = input; + this.Action = action; + this.Method = method; + this.Timeout = timeout; + this.SpeechTimeout = speechTimeout; + this.MaxSpeechTime = maxSpeechTime; + this.ProfanityFilter = profanityFilter; + this.FinishOnKey = finishOnKey; + this.NumDigits = numDigits; + this.PartialResultCallback = partialResultCallback; + this.PartialResultCallbackMethod = partialResultCallbackMethod; + this.Language = language; + this.Hints = hints; + this.BargeIn = bargeIn; + this.Debug = debug; + this.ActionOnEmptyResult = actionOnEmptyResult; + this.SpeechModel = speechModel; + this.Enhanced = enhanced; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Input != null) + { + attributes.Add(new XAttribute("input", String.Join(" ", this.Input.Select(e => e.ToString()).ToArray()))); + } + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.Timeout != null) + { + attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); + } + if (this.SpeechTimeout != null) + { + attributes.Add(new XAttribute("speechTimeout", this.SpeechTimeout)); + } + if (this.MaxSpeechTime != null) + { + attributes.Add(new XAttribute("maxSpeechTime", this.MaxSpeechTime.ToString())); + } + if (this.ProfanityFilter != null) + { + attributes.Add(new XAttribute("profanityFilter", this.ProfanityFilter.Value.ToString().ToLower())); + } + if (this.FinishOnKey != null) + { + attributes.Add(new XAttribute("finishOnKey", this.FinishOnKey)); + } + if (this.NumDigits != null) + { + attributes.Add(new XAttribute("numDigits", this.NumDigits.ToString())); + } + if (this.PartialResultCallback != null) + { + attributes.Add(new XAttribute("partialResultCallback", Serializers.Url(this.PartialResultCallback))); + } + if (this.PartialResultCallbackMethod != null) + { + attributes.Add(new XAttribute("partialResultCallbackMethod", this.PartialResultCallbackMethod.ToString())); + } + if (this.Language != null) + { + attributes.Add(new XAttribute("language", this.Language.ToString())); + } + if (this.Hints != null) + { + attributes.Add(new XAttribute("hints", this.Hints)); + } + if (this.BargeIn != null) + { + attributes.Add(new XAttribute("bargeIn", this.BargeIn.Value.ToString().ToLower())); + } + if (this.Debug != null) + { + attributes.Add(new XAttribute("debug", this.Debug.Value.ToString().ToLower())); + } + if (this.ActionOnEmptyResult != null) + { + attributes.Add(new XAttribute("actionOnEmptyResult", this.ActionOnEmptyResult.Value.ToString().ToLower())); + } + if (this.SpeechModel != null) + { + attributes.Add(new XAttribute("speechModel", this.SpeechModel.ToString())); + } + if (this.Enhanced != null) + { + attributes.Add(new XAttribute("enhanced", this.Enhanced.Value.ToString().ToLower())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message to say, the body of the TwiML Element. + /// Voice to use + /// Times to loop message + /// Message langauge + public Gather Say(string message = null, + Say.VoiceEnum voice = null, + int? loop = null, + Say.LanguageEnum language = null) + { + var newChild = new Say(message, voice, loop, language); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Say instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Gather Say(Say say) + { + this.Append(say); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Length in seconds to pause + public Gather Pause(int? length = null) + { + var newChild = new Pause(length); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Pause instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Gather Pause(Pause pause) + { + this.Append(pause); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Media URL, the body of the TwiML Element. + /// Times to loop media + /// Play DTMF tones for digits + public Gather Play(Uri url = null, int? loop = null, string digits = null) + { + var newChild = new Play(url, loop, digits); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Play instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Gather Play(Play play) + { + this.Append(play); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Gather Append(TwiML childElem) + { + return (Gather)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Gather SetOption(string key, object value) + { + return (Gather)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Hangup.cs b/src/Twilio/TwiML/Voice/Hangup.cs index b3c6e8fd2..4b52f84ce 100644 --- a/src/Twilio/TwiML/Voice/Hangup.cs +++ b/src/Twilio/TwiML/Voice/Hangup.cs @@ -8,38 +8,38 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Hangup TwiML Verb + /// + public class Hangup : TwiML + { /// - /// Hangup TwiML Verb + /// Create a new Hangup /// - public class Hangup : TwiML - { - /// - /// Create a new Hangup - /// - public Hangup() : base("Hangup") - { - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Hangup Append(TwiML childElem) - { - return (Hangup) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Hangup SetOption(string key, object value) - { - return (Hangup) base.SetOption(key, value); - } - } + public Hangup() : base("Hangup") + { + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Hangup Append(TwiML childElem) + { + return (Hangup)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Hangup SetOption(string key, object value) + { + return (Hangup)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Identity.cs b/src/Twilio/TwiML/Voice/Identity.cs index 063328535..ba70c1643 100644 --- a/src/Twilio/TwiML/Voice/Identity.cs +++ b/src/Twilio/TwiML/Voice/Identity.cs @@ -8,53 +8,53 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Identity TwiML Noun + /// + public class Identity : TwiML + { /// - /// Identity TwiML Noun + /// Identity of the client to dial /// - public class Identity : TwiML - { - /// - /// Identity of the client to dial - /// - public string ClientIdentity { get; set; } - - /// - /// Create a new Identity - /// - /// Identity of the client to dial, the body of the TwiML Element. - public Identity(string clientIdentity = null) : base("Identity") - { - this.ClientIdentity = clientIdentity; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.ClientIdentity != null ? this.ClientIdentity : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Identity Append(TwiML childElem) - { - return (Identity) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Identity SetOption(string key, object value) - { - return (Identity) base.SetOption(key, value); - } - } + public string ClientIdentity { get; set; } + + /// + /// Create a new Identity + /// + /// Identity of the client to dial, the body of the TwiML Element. + public Identity(string clientIdentity = null) : base("Identity") + { + this.ClientIdentity = clientIdentity; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.ClientIdentity != null ? this.ClientIdentity : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Identity Append(TwiML childElem) + { + return (Identity)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Identity SetOption(string key, object value) + { + return (Identity)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Leave.cs b/src/Twilio/TwiML/Voice/Leave.cs index 39690d168..b53ff7ff4 100644 --- a/src/Twilio/TwiML/Voice/Leave.cs +++ b/src/Twilio/TwiML/Voice/Leave.cs @@ -8,38 +8,38 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Leave TwiML Verb + /// + public class Leave : TwiML + { /// - /// Leave TwiML Verb + /// Create a new Leave /// - public class Leave : TwiML - { - /// - /// Create a new Leave - /// - public Leave() : base("Leave") - { - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Leave Append(TwiML childElem) - { - return (Leave) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Leave SetOption(string key, object value) - { - return (Leave) base.SetOption(key, value); - } - } + public Leave() : base("Leave") + { + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Leave Append(TwiML childElem) + { + return (Leave)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Leave SetOption(string key, object value) + { + return (Leave)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Number.cs b/src/Twilio/TwiML/Voice/Number.cs index 3e128bec0..88886b9b4 100644 --- a/src/Twilio/TwiML/Voice/Number.cs +++ b/src/Twilio/TwiML/Voice/Number.cs @@ -13,154 +13,154 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Number TwiML Noun + /// + public class Number : TwiML + { + public sealed class EventEnum : StringEnum + { + private EventEnum(string value) : base(value) { } + public EventEnum() { } + public static implicit operator EventEnum(string value) + { + return new EventEnum(value); + } + + public static readonly EventEnum Initiated = new EventEnum("initiated"); + public static readonly EventEnum Ringing = new EventEnum("ringing"); + public static readonly EventEnum Answered = new EventEnum("answered"); + public static readonly EventEnum Completed = new EventEnum("completed"); + } + /// - /// Number TwiML Noun + /// Phone Number to dial /// - public class Number : TwiML - { - public sealed class EventEnum : StringEnum - { - private EventEnum(string value) : base(value) {} - public EventEnum() {} - public static implicit operator EventEnum(string value) - { - return new EventEnum(value); - } - - public static readonly EventEnum Initiated = new EventEnum("initiated"); - public static readonly EventEnum Ringing = new EventEnum("ringing"); - public static readonly EventEnum Answered = new EventEnum("answered"); - public static readonly EventEnum Completed = new EventEnum("completed"); - } - - /// - /// Phone Number to dial - /// - public Types.PhoneNumber PhoneNumber { get; set; } - /// - /// DTMF tones to play when the call is answered - /// - public string SendDigits { get; set; } - /// - /// TwiML URL - /// - public Uri Url { get; set; } - /// - /// TwiML URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Events to call status callback - /// - public List StatusCallbackEvent { get; set; } - /// - /// Status callback URL - /// - public Uri StatusCallback { get; set; } - /// - /// Status callback URL method - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - /// - /// BYOC trunk SID (Beta) - /// - public string Byoc { get; set; } - - /// - /// Create a new Number - /// - /// Phone Number to dial, the body of the TwiML Element. - /// DTMF tones to play when the call is answered - /// TwiML URL - /// TwiML URL method - /// Events to call status callback - /// Status callback URL - /// Status callback URL method - /// BYOC trunk SID (Beta) - public Number(Types.PhoneNumber phoneNumber = null, - string sendDigits = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null, - string byoc = null) : base("Number") - { - this.PhoneNumber = phoneNumber; - this.SendDigits = sendDigits; - this.Url = url; - this.Method = method; - this.StatusCallbackEvent = statusCallbackEvent; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - this.Byoc = byoc; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.PhoneNumber != null ? this.PhoneNumber.ToString() : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.SendDigits != null) - { - attributes.Add(new XAttribute("sendDigits", this.SendDigits)); - } - if (this.Url != null) - { - attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.StatusCallbackEvent != null) - { - attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - if (this.Byoc != null) - { - attributes.Add(new XAttribute("byoc", this.Byoc.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Number Append(TwiML childElem) - { - return (Number) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Number SetOption(string key, object value) - { - return (Number) base.SetOption(key, value); - } - } + public Types.PhoneNumber PhoneNumber { get; set; } + /// + /// DTMF tones to play when the call is answered + /// + public string SendDigits { get; set; } + /// + /// TwiML URL + /// + public Uri Url { get; set; } + /// + /// TwiML URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Events to call status callback + /// + public List StatusCallbackEvent { get; set; } + /// + /// Status callback URL + /// + public Uri StatusCallback { get; set; } + /// + /// Status callback URL method + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + /// + /// BYOC trunk SID (Beta) + /// + public string Byoc { get; set; } + + /// + /// Create a new Number + /// + /// Phone Number to dial, the body of the TwiML Element. + /// DTMF tones to play when the call is answered + /// TwiML URL + /// TwiML URL method + /// Events to call status callback + /// Status callback URL + /// Status callback URL method + /// BYOC trunk SID (Beta) + public Number(Types.PhoneNumber phoneNumber = null, + string sendDigits = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null, + string byoc = null) : base("Number") + { + this.PhoneNumber = phoneNumber; + this.SendDigits = sendDigits; + this.Url = url; + this.Method = method; + this.StatusCallbackEvent = statusCallbackEvent; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + this.Byoc = byoc; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.PhoneNumber != null ? this.PhoneNumber.ToString() : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.SendDigits != null) + { + attributes.Add(new XAttribute("sendDigits", this.SendDigits)); + } + if (this.Url != null) + { + attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.StatusCallbackEvent != null) + { + attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + if (this.Byoc != null) + { + attributes.Add(new XAttribute("byoc", this.Byoc.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Number Append(TwiML childElem) + { + return (Number)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Number SetOption(string key, object value) + { + return (Number)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Parameter.cs b/src/Twilio/TwiML/Voice/Parameter.cs index 4e09c9188..aa2a3cc61 100644 --- a/src/Twilio/TwiML/Voice/Parameter.cs +++ b/src/Twilio/TwiML/Voice/Parameter.cs @@ -9,68 +9,68 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Parameter TwiML Noun + /// + public class Parameter : TwiML + { /// - /// Parameter TwiML Noun + /// The name of the custom parameter /// - public class Parameter : TwiML - { - /// - /// The name of the custom parameter - /// - public string Name { get; set; } - /// - /// The value of the custom parameter - /// - public string Value { get; set; } - - /// - /// Create a new Parameter - /// - /// The name of the custom parameter - /// The value of the custom parameter - public Parameter(string name = null, string value = null) : base("Parameter") - { - this.Name = name; - this.Value = value; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Name != null) - { - attributes.Add(new XAttribute("name", this.Name)); - } - if (this.Value != null) - { - attributes.Add(new XAttribute("value", this.Value)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Parameter Append(TwiML childElem) - { - return (Parameter) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Parameter SetOption(string key, object value) - { - return (Parameter) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// The value of the custom parameter + /// + public string Value { get; set; } + + /// + /// Create a new Parameter + /// + /// The name of the custom parameter + /// The value of the custom parameter + public Parameter(string name = null, string value = null) : base("Parameter") + { + this.Name = name; + this.Value = value; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Name != null) + { + attributes.Add(new XAttribute("name", this.Name)); + } + if (this.Value != null) + { + attributes.Add(new XAttribute("value", this.Value)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Parameter Append(TwiML childElem) + { + return (Parameter)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Parameter SetOption(string key, object value) + { + return (Parameter)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Pause.cs b/src/Twilio/TwiML/Voice/Pause.cs index b48553de1..b33561ef4 100644 --- a/src/Twilio/TwiML/Voice/Pause.cs +++ b/src/Twilio/TwiML/Voice/Pause.cs @@ -9,58 +9,58 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Pause TwiML Verb + /// + public class Pause : TwiML + { /// - /// Pause TwiML Verb + /// Length in seconds to pause /// - public class Pause : TwiML - { - /// - /// Length in seconds to pause - /// - public int? Length { get; set; } - - /// - /// Create a new Pause - /// - /// Length in seconds to pause - public Pause(int? length = null) : base("Pause") - { - this.Length = length; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Length != null) - { - attributes.Add(new XAttribute("length", this.Length.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Pause Append(TwiML childElem) - { - return (Pause) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Pause SetOption(string key, object value) - { - return (Pause) base.SetOption(key, value); - } - } + public int? Length { get; set; } + + /// + /// Create a new Pause + /// + /// Length in seconds to pause + public Pause(int? length = null) : base("Pause") + { + this.Length = length; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Length != null) + { + attributes.Add(new XAttribute("length", this.Length.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Pause Append(TwiML childElem) + { + return (Pause)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Pause SetOption(string key, object value) + { + return (Pause)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Pay.cs b/src/Twilio/TwiML/Voice/Pay.cs index 534aa70b9..82e69f05a 100644 --- a/src/Twilio/TwiML/Voice/Pay.cs +++ b/src/Twilio/TwiML/Voice/Pay.cs @@ -13,410 +13,410 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Pay Twiml Verb + /// + public class Pay : TwiML + { + public sealed class InputEnum : StringEnum + { + private InputEnum(string value) : base(value) { } + public InputEnum() { } + public static implicit operator InputEnum(string value) + { + return new InputEnum(value); + } + + public static readonly InputEnum Dtmf = new InputEnum("dtmf"); + } + + public sealed class StatusCallbackMethodEnum : StringEnum + { + private StatusCallbackMethodEnum(string value) : base(value) { } + public StatusCallbackMethodEnum() { } + public static implicit operator StatusCallbackMethodEnum(string value) + { + return new StatusCallbackMethodEnum(value); + } + + public static readonly StatusCallbackMethodEnum Get = new StatusCallbackMethodEnum("GET"); + public static readonly StatusCallbackMethodEnum Post = new StatusCallbackMethodEnum("POST"); + } + + public sealed class TokenTypeEnum : StringEnum + { + private TokenTypeEnum(string value) : base(value) { } + public TokenTypeEnum() { } + public static implicit operator TokenTypeEnum(string value) + { + return new TokenTypeEnum(value); + } + + public static readonly TokenTypeEnum OneTime = new TokenTypeEnum("one-time"); + public static readonly TokenTypeEnum Reusable = new TokenTypeEnum("reusable"); + } + + public sealed class ValidCardTypesEnum : StringEnum + { + private ValidCardTypesEnum(string value) : base(value) { } + public ValidCardTypesEnum() { } + public static implicit operator ValidCardTypesEnum(string value) + { + return new ValidCardTypesEnum(value); + } + + public static readonly ValidCardTypesEnum Visa = new ValidCardTypesEnum("visa"); + public static readonly ValidCardTypesEnum Mastercard = new ValidCardTypesEnum("mastercard"); + public static readonly ValidCardTypesEnum Amex = new ValidCardTypesEnum("amex"); + public static readonly ValidCardTypesEnum Maestro = new ValidCardTypesEnum("maestro"); + public static readonly ValidCardTypesEnum Discover = new ValidCardTypesEnum("discover"); + public static readonly ValidCardTypesEnum Optima = new ValidCardTypesEnum("optima"); + public static readonly ValidCardTypesEnum Jcb = new ValidCardTypesEnum("jcb"); + public static readonly ValidCardTypesEnum DinersClub = new ValidCardTypesEnum("diners-club"); + public static readonly ValidCardTypesEnum Enroute = new ValidCardTypesEnum("enroute"); + } + + public sealed class LanguageEnum : StringEnum + { + private LanguageEnum(string value) : base(value) { } + public LanguageEnum() { } + public static implicit operator LanguageEnum(string value) + { + return new LanguageEnum(value); + } + + public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); + public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); + public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); + public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); + public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); + public static readonly LanguageEnum EnIe = new LanguageEnum("en-IE"); + public static readonly LanguageEnum EnNz = new LanguageEnum("en-NZ"); + public static readonly LanguageEnum EnPh = new LanguageEnum("en-PH"); + public static readonly LanguageEnum EnZa = new LanguageEnum("en-ZA"); + public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); + public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); + public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); + public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); + public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); + public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); + } + + public sealed class BankAccountTypeEnum : StringEnum + { + private BankAccountTypeEnum(string value) : base(value) { } + public BankAccountTypeEnum() { } + public static implicit operator BankAccountTypeEnum(string value) + { + return new BankAccountTypeEnum(value); + } + + public static readonly BankAccountTypeEnum ConsumerChecking = new BankAccountTypeEnum("consumer-checking"); + public static readonly BankAccountTypeEnum ConsumerSavings = new BankAccountTypeEnum("consumer-savings"); + public static readonly BankAccountTypeEnum CommercialChecking = new BankAccountTypeEnum("commercial-checking"); + public static readonly BankAccountTypeEnum CommercialSavings = new BankAccountTypeEnum("commercial-savings"); + } + + public sealed class PaymentMethodEnum : StringEnum + { + private PaymentMethodEnum(string value) : base(value) { } + public PaymentMethodEnum() { } + public static implicit operator PaymentMethodEnum(string value) + { + return new PaymentMethodEnum(value); + } + + public static readonly PaymentMethodEnum AchDebit = new PaymentMethodEnum("ach-debit"); + public static readonly PaymentMethodEnum CreditCard = new PaymentMethodEnum("credit-card"); + } + /// - /// Pay Twiml Verb + /// Input type Twilio should accept /// - public class Pay : TwiML - { - public sealed class InputEnum : StringEnum - { - private InputEnum(string value) : base(value) {} - public InputEnum() {} - public static implicit operator InputEnum(string value) - { - return new InputEnum(value); - } - - public static readonly InputEnum Dtmf = new InputEnum("dtmf"); - } - - public sealed class StatusCallbackMethodEnum : StringEnum - { - private StatusCallbackMethodEnum(string value) : base(value) {} - public StatusCallbackMethodEnum() {} - public static implicit operator StatusCallbackMethodEnum(string value) - { - return new StatusCallbackMethodEnum(value); - } - - public static readonly StatusCallbackMethodEnum Get = new StatusCallbackMethodEnum("GET"); - public static readonly StatusCallbackMethodEnum Post = new StatusCallbackMethodEnum("POST"); - } - - public sealed class TokenTypeEnum : StringEnum - { - private TokenTypeEnum(string value) : base(value) {} - public TokenTypeEnum() {} - public static implicit operator TokenTypeEnum(string value) - { - return new TokenTypeEnum(value); - } - - public static readonly TokenTypeEnum OneTime = new TokenTypeEnum("one-time"); - public static readonly TokenTypeEnum Reusable = new TokenTypeEnum("reusable"); - } - - public sealed class ValidCardTypesEnum : StringEnum - { - private ValidCardTypesEnum(string value) : base(value) {} - public ValidCardTypesEnum() {} - public static implicit operator ValidCardTypesEnum(string value) - { - return new ValidCardTypesEnum(value); - } - - public static readonly ValidCardTypesEnum Visa = new ValidCardTypesEnum("visa"); - public static readonly ValidCardTypesEnum Mastercard = new ValidCardTypesEnum("mastercard"); - public static readonly ValidCardTypesEnum Amex = new ValidCardTypesEnum("amex"); - public static readonly ValidCardTypesEnum Maestro = new ValidCardTypesEnum("maestro"); - public static readonly ValidCardTypesEnum Discover = new ValidCardTypesEnum("discover"); - public static readonly ValidCardTypesEnum Optima = new ValidCardTypesEnum("optima"); - public static readonly ValidCardTypesEnum Jcb = new ValidCardTypesEnum("jcb"); - public static readonly ValidCardTypesEnum DinersClub = new ValidCardTypesEnum("diners-club"); - public static readonly ValidCardTypesEnum Enroute = new ValidCardTypesEnum("enroute"); - } - - public sealed class LanguageEnum : StringEnum - { - private LanguageEnum(string value) : base(value) {} - public LanguageEnum() {} - public static implicit operator LanguageEnum(string value) - { - return new LanguageEnum(value); - } - - public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); - public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); - public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); - public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); - public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); - public static readonly LanguageEnum EnIe = new LanguageEnum("en-IE"); - public static readonly LanguageEnum EnNz = new LanguageEnum("en-NZ"); - public static readonly LanguageEnum EnPh = new LanguageEnum("en-PH"); - public static readonly LanguageEnum EnZa = new LanguageEnum("en-ZA"); - public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); - public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); - public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); - public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); - public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); - public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); - } - - public sealed class BankAccountTypeEnum : StringEnum - { - private BankAccountTypeEnum(string value) : base(value) {} - public BankAccountTypeEnum() {} - public static implicit operator BankAccountTypeEnum(string value) - { - return new BankAccountTypeEnum(value); - } - - public static readonly BankAccountTypeEnum ConsumerChecking = new BankAccountTypeEnum("consumer-checking"); - public static readonly BankAccountTypeEnum ConsumerSavings = new BankAccountTypeEnum("consumer-savings"); - public static readonly BankAccountTypeEnum CommercialChecking = new BankAccountTypeEnum("commercial-checking"); - public static readonly BankAccountTypeEnum CommercialSavings = new BankAccountTypeEnum("commercial-savings"); - } - - public sealed class PaymentMethodEnum : StringEnum - { - private PaymentMethodEnum(string value) : base(value) {} - public PaymentMethodEnum() {} - public static implicit operator PaymentMethodEnum(string value) - { - return new PaymentMethodEnum(value); - } - - public static readonly PaymentMethodEnum AchDebit = new PaymentMethodEnum("ach-debit"); - public static readonly PaymentMethodEnum CreditCard = new PaymentMethodEnum("credit-card"); - } - - /// - /// Input type Twilio should accept - /// - public Pay.InputEnum Input { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Bank account type for ach transactions. If set, payment method attribute must be provided and value should be set to ach-debit. defaults to consumer-checking - /// - public Pay.BankAccountTypeEnum BankAccountType { get; set; } - /// - /// Status callback URL - /// - public Uri StatusCallback { get; set; } - /// - /// Status callback method - /// - public Pay.StatusCallbackMethodEnum StatusCallbackMethod { get; set; } - /// - /// Time to wait to gather input - /// - public int? Timeout { get; set; } - /// - /// Maximum number of allowed retries when gathering input - /// - public int? MaxAttempts { get; set; } - /// - /// Prompt for security code - /// - public bool? SecurityCode { get; set; } - /// - /// Prompt for postal code and it should be true/false or default postal code - /// - public string PostalCode { get; set; } - /// - /// Prompt for minimum postal code length - /// - public int? MinPostalCodeLength { get; set; } - /// - /// Unique name for payment connector - /// - public string PaymentConnector { get; set; } - /// - /// Payment method to be used. defaults to credit-card - /// - public Pay.PaymentMethodEnum PaymentMethod { get; set; } - /// - /// Type of token - /// - public Pay.TokenTypeEnum TokenType { get; set; } - /// - /// Amount to process. If value is greater than 0 then make the payment else create a payment token - /// - public string ChargeAmount { get; set; } - /// - /// Currency of the amount attribute - /// - public string Currency { get; set; } - /// - /// Details regarding the payment - /// - public string Description { get; set; } - /// - /// Comma separated accepted card types - /// - public List ValidCardTypes { get; set; } - /// - /// Language to use - /// - public Pay.LanguageEnum Language { get; set; } - - /// - /// Create a new Pay - /// - /// Input type Twilio should accept - /// Action URL - /// Bank account type for ach transactions. If set, payment method attribute must be - /// provided and value should be set to ach-debit. defaults to consumer-checking - /// Status callback URL - /// Status callback method - /// Time to wait to gather input - /// Maximum number of allowed retries when gathering input - /// Prompt for security code - /// Prompt for postal code and it should be true/false or default postal code - /// Prompt for minimum postal code length - /// Unique name for payment connector - /// Payment method to be used. defaults to credit-card - /// Type of token - /// Amount to process. If value is greater than 0 then make the payment else create a - /// payment token - /// Currency of the amount attribute - /// Details regarding the payment - /// Comma separated accepted card types - /// Language to use - public Pay(Pay.InputEnum input = null, - Uri action = null, - Pay.BankAccountTypeEnum bankAccountType = null, - Uri statusCallback = null, - Pay.StatusCallbackMethodEnum statusCallbackMethod = null, - int? timeout = null, - int? maxAttempts = null, - bool? securityCode = null, - string postalCode = null, - int? minPostalCodeLength = null, - string paymentConnector = null, - Pay.PaymentMethodEnum paymentMethod = null, - Pay.TokenTypeEnum tokenType = null, - string chargeAmount = null, - string currency = null, - string description = null, - List validCardTypes = null, - Pay.LanguageEnum language = null) : base("Pay") - { - this.Input = input; - this.Action = action; - this.BankAccountType = bankAccountType; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - this.Timeout = timeout; - this.MaxAttempts = maxAttempts; - this.SecurityCode = securityCode; - this.PostalCode = postalCode; - this.MinPostalCodeLength = minPostalCodeLength; - this.PaymentConnector = paymentConnector; - this.PaymentMethod = paymentMethod; - this.TokenType = tokenType; - this.ChargeAmount = chargeAmount; - this.Currency = currency; - this.Description = description; - this.ValidCardTypes = validCardTypes; - this.Language = language; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Input != null) - { - attributes.Add(new XAttribute("input", this.Input.ToString())); - } - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.BankAccountType != null) - { - attributes.Add(new XAttribute("bankAccountType", this.BankAccountType.ToString())); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - if (this.Timeout != null) - { - attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); - } - if (this.MaxAttempts != null) - { - attributes.Add(new XAttribute("maxAttempts", this.MaxAttempts.ToString())); - } - if (this.SecurityCode != null) - { - attributes.Add(new XAttribute("securityCode", this.SecurityCode.Value.ToString().ToLower())); - } - if (this.PostalCode != null) - { - attributes.Add(new XAttribute("postalCode", this.PostalCode)); - } - if (this.MinPostalCodeLength != null) - { - attributes.Add(new XAttribute("minPostalCodeLength", this.MinPostalCodeLength.ToString())); - } - if (this.PaymentConnector != null) - { - attributes.Add(new XAttribute("paymentConnector", this.PaymentConnector)); - } - if (this.PaymentMethod != null) - { - attributes.Add(new XAttribute("paymentMethod", this.PaymentMethod.ToString())); - } - if (this.TokenType != null) - { - attributes.Add(new XAttribute("tokenType", this.TokenType.ToString())); - } - if (this.ChargeAmount != null) - { - attributes.Add(new XAttribute("chargeAmount", this.ChargeAmount)); - } - if (this.Currency != null) - { - attributes.Add(new XAttribute("currency", this.Currency)); - } - if (this.Description != null) - { - attributes.Add(new XAttribute("description", this.Description)); - } - if (this.ValidCardTypes != null) - { - attributes.Add(new XAttribute("validCardTypes", String.Join(" ", this.ValidCardTypes.Select(e => e.ToString()).ToArray()))); - } - if (this.Language != null) - { - attributes.Add(new XAttribute("language", this.Language.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Name of the payment source data element - /// Type of error - /// Type of the credit card - /// Current attempt count - public Pay Prompt(Prompt.ForEnum for_ = null, - List errorType = null, - List cardType = null, - List attempt = null) - { - var newChild = new Prompt(for_, errorType, cardType, attempt); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Prompt instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Pay Prompt(Prompt prompt) - { - this.Append(prompt); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// The name of the custom parameter - /// The value of the custom parameter - public Pay Parameter(string name = null, string value = null) - { - var newChild = new Parameter(name, value); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Parameter instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Pay Parameter(Parameter parameter) - { - this.Append(parameter); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Pay Append(TwiML childElem) - { - return (Pay) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Pay SetOption(string key, object value) - { - return (Pay) base.SetOption(key, value); - } - } + public Pay.InputEnum Input { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Bank account type for ach transactions. If set, payment method attribute must be provided and value should be set to ach-debit. defaults to consumer-checking + /// + public Pay.BankAccountTypeEnum BankAccountType { get; set; } + /// + /// Status callback URL + /// + public Uri StatusCallback { get; set; } + /// + /// Status callback method + /// + public Pay.StatusCallbackMethodEnum StatusCallbackMethod { get; set; } + /// + /// Time to wait to gather input + /// + public int? Timeout { get; set; } + /// + /// Maximum number of allowed retries when gathering input + /// + public int? MaxAttempts { get; set; } + /// + /// Prompt for security code + /// + public bool? SecurityCode { get; set; } + /// + /// Prompt for postal code and it should be true/false or default postal code + /// + public string PostalCode { get; set; } + /// + /// Prompt for minimum postal code length + /// + public int? MinPostalCodeLength { get; set; } + /// + /// Unique name for payment connector + /// + public string PaymentConnector { get; set; } + /// + /// Payment method to be used. defaults to credit-card + /// + public Pay.PaymentMethodEnum PaymentMethod { get; set; } + /// + /// Type of token + /// + public Pay.TokenTypeEnum TokenType { get; set; } + /// + /// Amount to process. If value is greater than 0 then make the payment else create a payment token + /// + public string ChargeAmount { get; set; } + /// + /// Currency of the amount attribute + /// + public string Currency { get; set; } + /// + /// Details regarding the payment + /// + public string Description { get; set; } + /// + /// Comma separated accepted card types + /// + public List ValidCardTypes { get; set; } + /// + /// Language to use + /// + public Pay.LanguageEnum Language { get; set; } + + /// + /// Create a new Pay + /// + /// Input type Twilio should accept + /// Action URL + /// Bank account type for ach transactions. If set, payment method attribute must be + /// provided and value should be set to ach-debit. defaults to consumer-checking + /// Status callback URL + /// Status callback method + /// Time to wait to gather input + /// Maximum number of allowed retries when gathering input + /// Prompt for security code + /// Prompt for postal code and it should be true/false or default postal code + /// Prompt for minimum postal code length + /// Unique name for payment connector + /// Payment method to be used. defaults to credit-card + /// Type of token + /// Amount to process. If value is greater than 0 then make the payment else create a + /// payment token + /// Currency of the amount attribute + /// Details regarding the payment + /// Comma separated accepted card types + /// Language to use + public Pay(Pay.InputEnum input = null, + Uri action = null, + Pay.BankAccountTypeEnum bankAccountType = null, + Uri statusCallback = null, + Pay.StatusCallbackMethodEnum statusCallbackMethod = null, + int? timeout = null, + int? maxAttempts = null, + bool? securityCode = null, + string postalCode = null, + int? minPostalCodeLength = null, + string paymentConnector = null, + Pay.PaymentMethodEnum paymentMethod = null, + Pay.TokenTypeEnum tokenType = null, + string chargeAmount = null, + string currency = null, + string description = null, + List validCardTypes = null, + Pay.LanguageEnum language = null) : base("Pay") + { + this.Input = input; + this.Action = action; + this.BankAccountType = bankAccountType; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + this.Timeout = timeout; + this.MaxAttempts = maxAttempts; + this.SecurityCode = securityCode; + this.PostalCode = postalCode; + this.MinPostalCodeLength = minPostalCodeLength; + this.PaymentConnector = paymentConnector; + this.PaymentMethod = paymentMethod; + this.TokenType = tokenType; + this.ChargeAmount = chargeAmount; + this.Currency = currency; + this.Description = description; + this.ValidCardTypes = validCardTypes; + this.Language = language; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Input != null) + { + attributes.Add(new XAttribute("input", this.Input.ToString())); + } + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.BankAccountType != null) + { + attributes.Add(new XAttribute("bankAccountType", this.BankAccountType.ToString())); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + if (this.Timeout != null) + { + attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); + } + if (this.MaxAttempts != null) + { + attributes.Add(new XAttribute("maxAttempts", this.MaxAttempts.ToString())); + } + if (this.SecurityCode != null) + { + attributes.Add(new XAttribute("securityCode", this.SecurityCode.Value.ToString().ToLower())); + } + if (this.PostalCode != null) + { + attributes.Add(new XAttribute("postalCode", this.PostalCode)); + } + if (this.MinPostalCodeLength != null) + { + attributes.Add(new XAttribute("minPostalCodeLength", this.MinPostalCodeLength.ToString())); + } + if (this.PaymentConnector != null) + { + attributes.Add(new XAttribute("paymentConnector", this.PaymentConnector)); + } + if (this.PaymentMethod != null) + { + attributes.Add(new XAttribute("paymentMethod", this.PaymentMethod.ToString())); + } + if (this.TokenType != null) + { + attributes.Add(new XAttribute("tokenType", this.TokenType.ToString())); + } + if (this.ChargeAmount != null) + { + attributes.Add(new XAttribute("chargeAmount", this.ChargeAmount)); + } + if (this.Currency != null) + { + attributes.Add(new XAttribute("currency", this.Currency)); + } + if (this.Description != null) + { + attributes.Add(new XAttribute("description", this.Description)); + } + if (this.ValidCardTypes != null) + { + attributes.Add(new XAttribute("validCardTypes", String.Join(" ", this.ValidCardTypes.Select(e => e.ToString()).ToArray()))); + } + if (this.Language != null) + { + attributes.Add(new XAttribute("language", this.Language.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Name of the payment source data element + /// Type of error + /// Type of the credit card + /// Current attempt count + public Pay Prompt(Prompt.ForEnum for_ = null, + List errorType = null, + List cardType = null, + List attempt = null) + { + var newChild = new Prompt(for_, errorType, cardType, attempt); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Prompt instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Pay Prompt(Prompt prompt) + { + this.Append(prompt); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// The name of the custom parameter + /// The value of the custom parameter + public Pay Parameter(string name = null, string value = null) + { + var newChild = new Parameter(name, value); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Parameter instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Pay Parameter(Parameter parameter) + { + this.Append(parameter); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Pay Append(TwiML childElem) + { + return (Pay)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Pay SetOption(string key, object value) + { + return (Pay)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Play.cs b/src/Twilio/TwiML/Voice/Play.cs index 6e9cefb47..c6167f11c 100644 --- a/src/Twilio/TwiML/Voice/Play.cs +++ b/src/Twilio/TwiML/Voice/Play.cs @@ -11,82 +11,82 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Play TwiML Verb + /// + public class Play : TwiML + { /// - /// Play TwiML Verb + /// Media URL /// - public class Play : TwiML - { - /// - /// Media URL - /// - public Uri Url { get; set; } - /// - /// Times to loop media - /// - public int? Loop { get; set; } - /// - /// Play DTMF tones for digits - /// - public string Digits { get; set; } - - /// - /// Create a new Play - /// - /// Media URL, the body of the TwiML Element. - /// Times to loop media - /// Play DTMF tones for digits - public Play(Uri url = null, int? loop = null, string digits = null) : base("Play") - { - this.Url = url; - this.Loop = loop; - this.Digits = digits; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Url != null ? Serializers.Url(this.Url) : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Loop != null) - { - attributes.Add(new XAttribute("loop", this.Loop.ToString())); - } - if (this.Digits != null) - { - attributes.Add(new XAttribute("digits", this.Digits)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Play Append(TwiML childElem) - { - return (Play) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Play SetOption(string key, object value) - { - return (Play) base.SetOption(key, value); - } - } + public Uri Url { get; set; } + /// + /// Times to loop media + /// + public int? Loop { get; set; } + /// + /// Play DTMF tones for digits + /// + public string Digits { get; set; } + + /// + /// Create a new Play + /// + /// Media URL, the body of the TwiML Element. + /// Times to loop media + /// Play DTMF tones for digits + public Play(Uri url = null, int? loop = null, string digits = null) : base("Play") + { + this.Url = url; + this.Loop = loop; + this.Digits = digits; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Url != null ? Serializers.Url(this.Url) : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Loop != null) + { + attributes.Add(new XAttribute("loop", this.Loop.ToString())); + } + if (this.Digits != null) + { + attributes.Add(new XAttribute("digits", this.Digits)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Play Append(TwiML childElem) + { + return (Play)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Play SetOption(string key, object value) + { + return (Play)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Prompt.cs b/src/Twilio/TwiML/Voice/Prompt.cs index 261213d43..0d86f1d4a 100644 --- a/src/Twilio/TwiML/Voice/Prompt.cs +++ b/src/Twilio/TwiML/Voice/Prompt.cs @@ -13,220 +13,220 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Prompt Twiml Verb + /// + public class Prompt : TwiML + { + public sealed class ForEnum : StringEnum + { + private ForEnum(string value) : base(value) { } + public ForEnum() { } + public static implicit operator ForEnum(string value) + { + return new ForEnum(value); + } + + public static readonly ForEnum PaymentCardNumber = new ForEnum("payment-card-number"); + public static readonly ForEnum ExpirationDate = new ForEnum("expiration-date"); + public static readonly ForEnum SecurityCode = new ForEnum("security-code"); + public static readonly ForEnum PostalCode = new ForEnum("postal-code"); + public static readonly ForEnum PaymentProcessing = new ForEnum("payment-processing"); + public static readonly ForEnum BankAccountNumber = new ForEnum("bank-account-number"); + public static readonly ForEnum BankRoutingNumber = new ForEnum("bank-routing-number"); + } + + public sealed class ErrorTypeEnum : StringEnum + { + private ErrorTypeEnum(string value) : base(value) { } + public ErrorTypeEnum() { } + public static implicit operator ErrorTypeEnum(string value) + { + return new ErrorTypeEnum(value); + } + + public static readonly ErrorTypeEnum Timeout = new ErrorTypeEnum("timeout"); + public static readonly ErrorTypeEnum InvalidCardNumber = new ErrorTypeEnum("invalid-card-number"); + public static readonly ErrorTypeEnum InvalidCardType = new ErrorTypeEnum("invalid-card-type"); + public static readonly ErrorTypeEnum InvalidDate = new ErrorTypeEnum("invalid-date"); + public static readonly ErrorTypeEnum InvalidSecurityCode = new ErrorTypeEnum("invalid-security-code"); + public static readonly ErrorTypeEnum InternalError = new ErrorTypeEnum("internal-error"); + } + + public sealed class CardTypeEnum : StringEnum + { + private CardTypeEnum(string value) : base(value) { } + public CardTypeEnum() { } + public static implicit operator CardTypeEnum(string value) + { + return new CardTypeEnum(value); + } + + public static readonly CardTypeEnum Visa = new CardTypeEnum("visa"); + public static readonly CardTypeEnum Mastercard = new CardTypeEnum("mastercard"); + public static readonly CardTypeEnum Amex = new CardTypeEnum("amex"); + public static readonly CardTypeEnum Maestro = new CardTypeEnum("maestro"); + public static readonly CardTypeEnum Discover = new CardTypeEnum("discover"); + public static readonly CardTypeEnum Optima = new CardTypeEnum("optima"); + public static readonly CardTypeEnum Jcb = new CardTypeEnum("jcb"); + public static readonly CardTypeEnum DinersClub = new CardTypeEnum("diners-club"); + public static readonly CardTypeEnum Enroute = new CardTypeEnum("enroute"); + } + /// - /// Prompt Twiml Verb + /// Name of the payment source data element /// - public class Prompt : TwiML - { - public sealed class ForEnum : StringEnum - { - private ForEnum(string value) : base(value) {} - public ForEnum() {} - public static implicit operator ForEnum(string value) - { - return new ForEnum(value); - } - - public static readonly ForEnum PaymentCardNumber = new ForEnum("payment-card-number"); - public static readonly ForEnum ExpirationDate = new ForEnum("expiration-date"); - public static readonly ForEnum SecurityCode = new ForEnum("security-code"); - public static readonly ForEnum PostalCode = new ForEnum("postal-code"); - public static readonly ForEnum PaymentProcessing = new ForEnum("payment-processing"); - public static readonly ForEnum BankAccountNumber = new ForEnum("bank-account-number"); - public static readonly ForEnum BankRoutingNumber = new ForEnum("bank-routing-number"); - } - - public sealed class ErrorTypeEnum : StringEnum - { - private ErrorTypeEnum(string value) : base(value) {} - public ErrorTypeEnum() {} - public static implicit operator ErrorTypeEnum(string value) - { - return new ErrorTypeEnum(value); - } - - public static readonly ErrorTypeEnum Timeout = new ErrorTypeEnum("timeout"); - public static readonly ErrorTypeEnum InvalidCardNumber = new ErrorTypeEnum("invalid-card-number"); - public static readonly ErrorTypeEnum InvalidCardType = new ErrorTypeEnum("invalid-card-type"); - public static readonly ErrorTypeEnum InvalidDate = new ErrorTypeEnum("invalid-date"); - public static readonly ErrorTypeEnum InvalidSecurityCode = new ErrorTypeEnum("invalid-security-code"); - public static readonly ErrorTypeEnum InternalError = new ErrorTypeEnum("internal-error"); - } - - public sealed class CardTypeEnum : StringEnum - { - private CardTypeEnum(string value) : base(value) {} - public CardTypeEnum() {} - public static implicit operator CardTypeEnum(string value) - { - return new CardTypeEnum(value); - } - - public static readonly CardTypeEnum Visa = new CardTypeEnum("visa"); - public static readonly CardTypeEnum Mastercard = new CardTypeEnum("mastercard"); - public static readonly CardTypeEnum Amex = new CardTypeEnum("amex"); - public static readonly CardTypeEnum Maestro = new CardTypeEnum("maestro"); - public static readonly CardTypeEnum Discover = new CardTypeEnum("discover"); - public static readonly CardTypeEnum Optima = new CardTypeEnum("optima"); - public static readonly CardTypeEnum Jcb = new CardTypeEnum("jcb"); - public static readonly CardTypeEnum DinersClub = new CardTypeEnum("diners-club"); - public static readonly CardTypeEnum Enroute = new CardTypeEnum("enroute"); - } - - /// - /// Name of the payment source data element - /// - public Prompt.ForEnum For_ { get; set; } - /// - /// Type of error - /// - public List ErrorType { get; set; } - /// - /// Type of the credit card - /// - public List CardType { get; set; } - /// - /// Current attempt count - /// - public List Attempt { get; set; } - - /// - /// Create a new Prompt - /// - /// Name of the payment source data element - /// Type of error - /// Type of the credit card - /// Current attempt count - public Prompt(Prompt.ForEnum for_ = null, - List errorType = null, - List cardType = null, - List attempt = null) : base("Prompt") - { - this.For_ = for_; - this.ErrorType = errorType; - this.CardType = cardType; - this.Attempt = attempt; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.For_ != null) - { - attributes.Add(new XAttribute("for_", this.For_.ToString())); - } - if (this.ErrorType != null) - { - attributes.Add(new XAttribute("errorType", String.Join(" ", this.ErrorType.Select(e => e.ToString()).ToArray()))); - } - if (this.CardType != null) - { - attributes.Add(new XAttribute("cardType", String.Join(" ", this.CardType.Select(e => e.ToString()).ToArray()))); - } - if (this.Attempt != null) - { - attributes.Add(new XAttribute("attempt", String.Join(" ", this.Attempt.Select(e => e.ToString()).ToArray()))); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message to say, the body of the TwiML Element. - /// Voice to use - /// Times to loop message - /// Message langauge - public Prompt Say(string message = null, - Say.VoiceEnum voice = null, - int? loop = null, - Say.LanguageEnum language = null) - { - var newChild = new Say(message, voice, loop, language); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Say instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Prompt Say(Say say) - { - this.Append(say); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Media URL, the body of the TwiML Element. - /// Times to loop media - /// Play DTMF tones for digits - public Prompt Play(Uri url = null, int? loop = null, string digits = null) - { - var newChild = new Play(url, loop, digits); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Play instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Prompt Play(Play play) - { - this.Append(play); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Length in seconds to pause - public Prompt Pause(int? length = null) - { - var newChild = new Pause(length); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Pause instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Prompt Pause(Pause pause) - { - this.Append(pause); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Prompt Append(TwiML childElem) - { - return (Prompt) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Prompt SetOption(string key, object value) - { - return (Prompt) base.SetOption(key, value); - } - } + public Prompt.ForEnum For_ { get; set; } + /// + /// Type of error + /// + public List ErrorType { get; set; } + /// + /// Type of the credit card + /// + public List CardType { get; set; } + /// + /// Current attempt count + /// + public List Attempt { get; set; } + + /// + /// Create a new Prompt + /// + /// Name of the payment source data element + /// Type of error + /// Type of the credit card + /// Current attempt count + public Prompt(Prompt.ForEnum for_ = null, + List errorType = null, + List cardType = null, + List attempt = null) : base("Prompt") + { + this.For_ = for_; + this.ErrorType = errorType; + this.CardType = cardType; + this.Attempt = attempt; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.For_ != null) + { + attributes.Add(new XAttribute("for_", this.For_.ToString())); + } + if (this.ErrorType != null) + { + attributes.Add(new XAttribute("errorType", String.Join(" ", this.ErrorType.Select(e => e.ToString()).ToArray()))); + } + if (this.CardType != null) + { + attributes.Add(new XAttribute("cardType", String.Join(" ", this.CardType.Select(e => e.ToString()).ToArray()))); + } + if (this.Attempt != null) + { + attributes.Add(new XAttribute("attempt", String.Join(" ", this.Attempt.Select(e => e.ToString()).ToArray()))); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message to say, the body of the TwiML Element. + /// Voice to use + /// Times to loop message + /// Message langauge + public Prompt Say(string message = null, + Say.VoiceEnum voice = null, + int? loop = null, + Say.LanguageEnum language = null) + { + var newChild = new Say(message, voice, loop, language); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Say instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Prompt Say(Say say) + { + this.Append(say); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Media URL, the body of the TwiML Element. + /// Times to loop media + /// Play DTMF tones for digits + public Prompt Play(Uri url = null, int? loop = null, string digits = null) + { + var newChild = new Play(url, loop, digits); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Play instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Prompt Play(Play play) + { + this.Append(play); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Length in seconds to pause + public Prompt Pause(int? length = null) + { + var newChild = new Pause(length); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Pause instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Prompt Pause(Pause pause) + { + this.Append(pause); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Prompt Append(TwiML childElem) + { + return (Prompt)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Prompt SetOption(string key, object value) + { + return (Prompt)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Queue.cs b/src/Twilio/TwiML/Voice/Queue.cs index 1330fc0cd..67c033f10 100644 --- a/src/Twilio/TwiML/Voice/Queue.cs +++ b/src/Twilio/TwiML/Voice/Queue.cs @@ -11,106 +11,106 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Queue TwiML Noun + /// + public class Queue : TwiML + { /// - /// Queue TwiML Noun + /// Queue name /// - public class Queue : TwiML - { - /// - /// Queue name - /// - public string Name { get; set; } - /// - /// Action URL - /// - public Uri Url { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// TaskRouter Reservation SID - /// - public string ReservationSid { get; set; } - /// - /// TaskRouter Activity SID - /// - public string PostWorkActivitySid { get; set; } - - /// - /// Create a new Queue - /// - /// Queue name, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// TaskRouter Reservation SID - /// TaskRouter Activity SID - public Queue(string name = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - string reservationSid = null, - string postWorkActivitySid = null) : base("Queue") - { - this.Name = name; - this.Url = url; - this.Method = method; - this.ReservationSid = reservationSid; - this.PostWorkActivitySid = postWorkActivitySid; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Url != null) - { - attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.ReservationSid != null) - { - attributes.Add(new XAttribute("reservationSid", this.ReservationSid)); - } - if (this.PostWorkActivitySid != null) - { - attributes.Add(new XAttribute("postWorkActivitySid", this.PostWorkActivitySid)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Queue Append(TwiML childElem) - { - return (Queue) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Queue SetOption(string key, object value) - { - return (Queue) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Action URL + /// + public Uri Url { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// TaskRouter Reservation SID + /// + public string ReservationSid { get; set; } + /// + /// TaskRouter Activity SID + /// + public string PostWorkActivitySid { get; set; } + + /// + /// Create a new Queue + /// + /// Queue name, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// TaskRouter Reservation SID + /// TaskRouter Activity SID + public Queue(string name = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + string reservationSid = null, + string postWorkActivitySid = null) : base("Queue") + { + this.Name = name; + this.Url = url; + this.Method = method; + this.ReservationSid = reservationSid; + this.PostWorkActivitySid = postWorkActivitySid; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Url != null) + { + attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.ReservationSid != null) + { + attributes.Add(new XAttribute("reservationSid", this.ReservationSid)); + } + if (this.PostWorkActivitySid != null) + { + attributes.Add(new XAttribute("postWorkActivitySid", this.PostWorkActivitySid)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Queue Append(TwiML childElem) + { + return (Queue)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Queue SetOption(string key, object value) + { + return (Queue)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Record.cs b/src/Twilio/TwiML/Voice/Record.cs index 9465cc79c..562e28ddf 100644 --- a/src/Twilio/TwiML/Voice/Record.cs +++ b/src/Twilio/TwiML/Voice/Record.cs @@ -13,206 +13,206 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Record TwiML Verb + /// + public class Record : TwiML + { + public sealed class TrimEnum : StringEnum + { + private TrimEnum(string value) : base(value) { } + public TrimEnum() { } + public static implicit operator TrimEnum(string value) + { + return new TrimEnum(value); + } + + public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); + public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); + } + + public sealed class RecordingEventEnum : StringEnum + { + private RecordingEventEnum(string value) : base(value) { } + public RecordingEventEnum() { } + public static implicit operator RecordingEventEnum(string value) + { + return new RecordingEventEnum(value); + } + + public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); + public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); + public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); + } + /// - /// Record TwiML Verb - /// - public class Record : TwiML - { - public sealed class TrimEnum : StringEnum - { - private TrimEnum(string value) : base(value) {} - public TrimEnum() {} - public static implicit operator TrimEnum(string value) - { - return new TrimEnum(value); - } - - public static readonly TrimEnum TrimSilence = new TrimEnum("trim-silence"); - public static readonly TrimEnum DoNotTrim = new TrimEnum("do-not-trim"); - } - - public sealed class RecordingEventEnum : StringEnum - { - private RecordingEventEnum(string value) : base(value) {} - public RecordingEventEnum() {} - public static implicit operator RecordingEventEnum(string value) - { - return new RecordingEventEnum(value); - } - - public static readonly RecordingEventEnum InProgress = new RecordingEventEnum("in-progress"); - public static readonly RecordingEventEnum Completed = new RecordingEventEnum("completed"); - public static readonly RecordingEventEnum Absent = new RecordingEventEnum("absent"); - } - - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Timeout to begin recording - /// - public int? Timeout { get; set; } - /// - /// Finish recording on key - /// - public string FinishOnKey { get; set; } - /// - /// Max time to record in seconds - /// - public int? MaxLength { get; set; } - /// - /// Play beep - /// - public bool? PlayBeep { get; set; } - /// - /// Trim the recording - /// - public Record.TrimEnum Trim { get; set; } - /// - /// Status callback URL - /// - public Uri RecordingStatusCallback { get; set; } - /// - /// Status callback URL method - /// - public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } - /// - /// Recording status callback events - /// - public List RecordingStatusCallbackEvent { get; set; } - /// - /// Transcribe the recording - /// - public bool? Transcribe { get; set; } - /// - /// Transcribe callback URL - /// - public Uri TranscribeCallback { get; set; } - - /// - /// Create a new Record - /// - /// Action URL - /// Action URL method - /// Timeout to begin recording - /// Finish recording on key - /// Max time to record in seconds - /// Play beep - /// Trim the recording - /// Status callback URL - /// Status callback URL method - /// Recording status callback events - /// Transcribe the recording - /// Transcribe callback URL - public Record(Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - string finishOnKey = null, - int? maxLength = null, - bool? playBeep = null, - Record.TrimEnum trim = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - bool? transcribe = null, - Uri transcribeCallback = null) : base("Record") - { - this.Action = action; - this.Method = method; - this.Timeout = timeout; - this.FinishOnKey = finishOnKey; - this.MaxLength = maxLength; - this.PlayBeep = playBeep; - this.Trim = trim; - this.RecordingStatusCallback = recordingStatusCallback; - this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; - this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; - this.Transcribe = transcribe; - this.TranscribeCallback = transcribeCallback; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.Timeout != null) - { - attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); - } - if (this.FinishOnKey != null) - { - attributes.Add(new XAttribute("finishOnKey", this.FinishOnKey)); - } - if (this.MaxLength != null) - { - attributes.Add(new XAttribute("maxLength", this.MaxLength.ToString())); - } - if (this.PlayBeep != null) - { - attributes.Add(new XAttribute("playBeep", this.PlayBeep.Value.ToString().ToLower())); - } - if (this.Trim != null) - { - attributes.Add(new XAttribute("trim", this.Trim.ToString())); - } - if (this.RecordingStatusCallback != null) - { - attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); - } - if (this.RecordingStatusCallbackMethod != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); - } - if (this.RecordingStatusCallbackEvent != null) - { - attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.Transcribe != null) - { - attributes.Add(new XAttribute("transcribe", this.Transcribe.Value.ToString().ToLower())); - } - if (this.TranscribeCallback != null) - { - attributes.Add(new XAttribute("transcribeCallback", Serializers.Url(this.TranscribeCallback))); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Record Append(TwiML childElem) - { - return (Record) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Record SetOption(string key, object value) - { - return (Record) base.SetOption(key, value); - } - } + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Timeout to begin recording + /// + public int? Timeout { get; set; } + /// + /// Finish recording on key + /// + public string FinishOnKey { get; set; } + /// + /// Max time to record in seconds + /// + public int? MaxLength { get; set; } + /// + /// Play beep + /// + public bool? PlayBeep { get; set; } + /// + /// Trim the recording + /// + public Record.TrimEnum Trim { get; set; } + /// + /// Status callback URL + /// + public Uri RecordingStatusCallback { get; set; } + /// + /// Status callback URL method + /// + public Twilio.Http.HttpMethod RecordingStatusCallbackMethod { get; set; } + /// + /// Recording status callback events + /// + public List RecordingStatusCallbackEvent { get; set; } + /// + /// Transcribe the recording + /// + public bool? Transcribe { get; set; } + /// + /// Transcribe callback URL + /// + public Uri TranscribeCallback { get; set; } + + /// + /// Create a new Record + /// + /// Action URL + /// Action URL method + /// Timeout to begin recording + /// Finish recording on key + /// Max time to record in seconds + /// Play beep + /// Trim the recording + /// Status callback URL + /// Status callback URL method + /// Recording status callback events + /// Transcribe the recording + /// Transcribe callback URL + public Record(Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + string finishOnKey = null, + int? maxLength = null, + bool? playBeep = null, + Record.TrimEnum trim = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + bool? transcribe = null, + Uri transcribeCallback = null) : base("Record") + { + this.Action = action; + this.Method = method; + this.Timeout = timeout; + this.FinishOnKey = finishOnKey; + this.MaxLength = maxLength; + this.PlayBeep = playBeep; + this.Trim = trim; + this.RecordingStatusCallback = recordingStatusCallback; + this.RecordingStatusCallbackMethod = recordingStatusCallbackMethod; + this.RecordingStatusCallbackEvent = recordingStatusCallbackEvent; + this.Transcribe = transcribe; + this.TranscribeCallback = transcribeCallback; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.Timeout != null) + { + attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); + } + if (this.FinishOnKey != null) + { + attributes.Add(new XAttribute("finishOnKey", this.FinishOnKey)); + } + if (this.MaxLength != null) + { + attributes.Add(new XAttribute("maxLength", this.MaxLength.ToString())); + } + if (this.PlayBeep != null) + { + attributes.Add(new XAttribute("playBeep", this.PlayBeep.Value.ToString().ToLower())); + } + if (this.Trim != null) + { + attributes.Add(new XAttribute("trim", this.Trim.ToString())); + } + if (this.RecordingStatusCallback != null) + { + attributes.Add(new XAttribute("recordingStatusCallback", Serializers.Url(this.RecordingStatusCallback))); + } + if (this.RecordingStatusCallbackMethod != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackMethod", this.RecordingStatusCallbackMethod.ToString())); + } + if (this.RecordingStatusCallbackEvent != null) + { + attributes.Add(new XAttribute("recordingStatusCallbackEvent", String.Join(" ", this.RecordingStatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.Transcribe != null) + { + attributes.Add(new XAttribute("transcribe", this.Transcribe.Value.ToString().ToLower())); + } + if (this.TranscribeCallback != null) + { + attributes.Add(new XAttribute("transcribeCallback", Serializers.Url(this.TranscribeCallback))); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Record Append(TwiML childElem) + { + return (Record)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Record SetOption(string key, object value) + { + return (Record)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Redirect.cs b/src/Twilio/TwiML/Voice/Redirect.cs index d5fb144a6..9de26d33c 100644 --- a/src/Twilio/TwiML/Voice/Redirect.cs +++ b/src/Twilio/TwiML/Voice/Redirect.cs @@ -11,72 +11,72 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Redirect TwiML Verb + /// + public class Redirect : TwiML + { /// - /// Redirect TwiML Verb + /// Redirect URL /// - public class Redirect : TwiML - { - /// - /// Redirect URL - /// - public Uri Url { get; set; } - /// - /// Redirect URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Create a new Redirect - /// - /// Redirect URL, the body of the TwiML Element. - /// Redirect URL method - public Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) : base("Redirect") - { - this.Url = url; - this.Method = method; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Url != null ? Serializers.Url(this.Url) : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Redirect Append(TwiML childElem) - { - return (Redirect) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Redirect SetOption(string key, object value) - { - return (Redirect) base.SetOption(key, value); - } - } + public Uri Url { get; set; } + /// + /// Redirect URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Create a new Redirect + /// + /// Redirect URL, the body of the TwiML Element. + /// Redirect URL method + public Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) : base("Redirect") + { + this.Url = url; + this.Method = method; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Url != null ? Serializers.Url(this.Url) : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Redirect Append(TwiML childElem) + { + return (Redirect)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Redirect SetOption(string key, object value) + { + return (Redirect)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Refer.cs b/src/Twilio/TwiML/Voice/Refer.cs index 5a708d763..5a8a045f8 100644 --- a/src/Twilio/TwiML/Voice/Refer.cs +++ b/src/Twilio/TwiML/Voice/Refer.cs @@ -11,100 +11,100 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Refer TwiML Verb + /// + public class Refer : TwiML + { /// - /// Refer TwiML Verb + /// Action URL /// - public class Refer : TwiML - { - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Create a new Refer - /// - /// Action URL - /// Action URL method - public Refer(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Refer") - { - this.Action = action; - this.Method = method; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// SIP URL, the body of the TwiML Element. - public Refer Sip(Uri sipUrl = null) - { - var newChild = new ReferSip(sipUrl); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A ReferSip instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Refer ReferSip(ReferSip referSip) - { - this.Append(referSip); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// SIP URL, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .Sip() instead.")] - public Refer ReferSip(Uri sipUrl = null) - { - return Sip(sipUrl); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Refer Append(TwiML childElem) - { - return (Refer) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Refer SetOption(string key, object value) - { - return (Refer) base.SetOption(key, value); - } - } + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Create a new Refer + /// + /// Action URL + /// Action URL method + public Refer(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Refer") + { + this.Action = action; + this.Method = method; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// SIP URL, the body of the TwiML Element. + public Refer Sip(Uri sipUrl = null) + { + var newChild = new ReferSip(sipUrl); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A ReferSip instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Refer ReferSip(ReferSip referSip) + { + this.Append(referSip); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// SIP URL, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .Sip() instead.")] + public Refer ReferSip(Uri sipUrl = null) + { + return Sip(sipUrl); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Refer Append(TwiML childElem) + { + return (Refer)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Refer SetOption(string key, object value) + { + return (Refer)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/ReferSip.cs b/src/Twilio/TwiML/Voice/ReferSip.cs index 3fc6801d7..2f4e07f0e 100644 --- a/src/Twilio/TwiML/Voice/ReferSip.cs +++ b/src/Twilio/TwiML/Voice/ReferSip.cs @@ -10,53 +10,53 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Sip TwiML Noun used in Refer + /// + public class ReferSip : TwiML + { /// - /// Sip TwiML Noun used in Refer + /// SIP URL /// - public class ReferSip : TwiML - { - /// - /// SIP URL - /// - public Uri SipUrl { get; set; } - - /// - /// Create a new ReferSip - /// - /// SIP URL, the body of the TwiML Element. - public ReferSip(Uri sipUrl = null) : base("Sip") - { - this.SipUrl = sipUrl; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.SipUrl != null ? Serializers.Url(this.SipUrl) : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new ReferSip Append(TwiML childElem) - { - return (ReferSip) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new ReferSip SetOption(string key, object value) - { - return (ReferSip) base.SetOption(key, value); - } - } + public Uri SipUrl { get; set; } + + /// + /// Create a new ReferSip + /// + /// SIP URL, the body of the TwiML Element. + public ReferSip(Uri sipUrl = null) : base("Sip") + { + this.SipUrl = sipUrl; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.SipUrl != null ? Serializers.Url(this.SipUrl) : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new ReferSip Append(TwiML childElem) + { + return (ReferSip)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new ReferSip SetOption(string key, object value) + { + return (ReferSip)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Reject.cs b/src/Twilio/TwiML/Voice/Reject.cs index 0802b6a24..31deba1f7 100644 --- a/src/Twilio/TwiML/Voice/Reject.cs +++ b/src/Twilio/TwiML/Voice/Reject.cs @@ -10,71 +10,71 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Reject TwiML Verb + /// + public class Reject : TwiML + { + public sealed class ReasonEnum : StringEnum + { + private ReasonEnum(string value) : base(value) { } + public ReasonEnum() { } + public static implicit operator ReasonEnum(string value) + { + return new ReasonEnum(value); + } + + public static readonly ReasonEnum Rejected = new ReasonEnum("rejected"); + public static readonly ReasonEnum Busy = new ReasonEnum("busy"); + } + /// - /// Reject TwiML Verb + /// Rejection reason /// - public class Reject : TwiML - { - public sealed class ReasonEnum : StringEnum - { - private ReasonEnum(string value) : base(value) {} - public ReasonEnum() {} - public static implicit operator ReasonEnum(string value) - { - return new ReasonEnum(value); - } - - public static readonly ReasonEnum Rejected = new ReasonEnum("rejected"); - public static readonly ReasonEnum Busy = new ReasonEnum("busy"); - } - - /// - /// Rejection reason - /// - public Reject.ReasonEnum Reason { get; set; } - - /// - /// Create a new Reject - /// - /// Rejection reason - public Reject(Reject.ReasonEnum reason = null) : base("Reject") - { - this.Reason = reason; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Reason != null) - { - attributes.Add(new XAttribute("reason", this.Reason.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Reject Append(TwiML childElem) - { - return (Reject) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Reject SetOption(string key, object value) - { - return (Reject) base.SetOption(key, value); - } - } + public Reject.ReasonEnum Reason { get; set; } + + /// + /// Create a new Reject + /// + /// Rejection reason + public Reject(Reject.ReasonEnum reason = null) : base("Reject") + { + this.Reason = reason; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Reason != null) + { + attributes.Add(new XAttribute("reason", this.Reason.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Reject Append(TwiML childElem) + { + return (Reject)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Reject SetOption(string key, object value) + { + return (Reject)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Room.cs b/src/Twilio/TwiML/Voice/Room.cs index 41da43f7b..5f6ae70e8 100644 --- a/src/Twilio/TwiML/Voice/Room.cs +++ b/src/Twilio/TwiML/Voice/Room.cs @@ -9,72 +9,72 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Room TwiML Noun + /// + public class Room : TwiML + { /// - /// Room TwiML Noun + /// Room name /// - public class Room : TwiML - { - /// - /// Room name - /// - public string Name { get; set; } - /// - /// Participant identity when connecting to the Room - /// - public string ParticipantIdentity { get; set; } - - /// - /// Create a new Room - /// - /// Room name, the body of the TwiML Element. - /// Participant identity when connecting to the Room - public Room(string name = null, string participantIdentity = null) : base("Room") - { - this.Name = name; - this.ParticipantIdentity = participantIdentity; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Name != null ? this.Name : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.ParticipantIdentity != null) - { - attributes.Add(new XAttribute("participantIdentity", this.ParticipantIdentity)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Room Append(TwiML childElem) - { - return (Room) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Room SetOption(string key, object value) - { - return (Room) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Participant identity when connecting to the Room + /// + public string ParticipantIdentity { get; set; } + + /// + /// Create a new Room + /// + /// Room name, the body of the TwiML Element. + /// Participant identity when connecting to the Room + public Room(string name = null, string participantIdentity = null) : base("Room") + { + this.Name = name; + this.ParticipantIdentity = participantIdentity; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Name != null ? this.Name : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.ParticipantIdentity != null) + { + attributes.Add(new XAttribute("participantIdentity", this.ParticipantIdentity)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Room Append(TwiML childElem) + { + return (Room)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Room SetOption(string key, object value) + { + return (Room)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Say.cs b/src/Twilio/TwiML/Voice/Say.cs index 50277a402..fbc73e7cd 100644 --- a/src/Twilio/TwiML/Voice/Say.cs +++ b/src/Twilio/TwiML/Voice/Say.cs @@ -10,585 +10,585 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Say TwiML Verb + /// + public class Say : TwiML + { + public sealed class VoiceEnum : StringEnum + { + private VoiceEnum(string value) : base(value) { } + public VoiceEnum() { } + public static implicit operator VoiceEnum(string value) + { + return new VoiceEnum(value); + } + + public static readonly VoiceEnum Man = new VoiceEnum("man"); + public static readonly VoiceEnum Woman = new VoiceEnum("woman"); + public static readonly VoiceEnum Alice = new VoiceEnum("alice"); + public static readonly VoiceEnum PollyAditi = new VoiceEnum("Polly.Aditi"); + public static readonly VoiceEnum PollyAmy = new VoiceEnum("Polly.Amy"); + public static readonly VoiceEnum PollyAstrid = new VoiceEnum("Polly.Astrid"); + public static readonly VoiceEnum PollyBianca = new VoiceEnum("Polly.Bianca"); + public static readonly VoiceEnum PollyBrian = new VoiceEnum("Polly.Brian"); + public static readonly VoiceEnum PollyCamila = new VoiceEnum("Polly.Camila"); + public static readonly VoiceEnum PollyCarla = new VoiceEnum("Polly.Carla"); + public static readonly VoiceEnum PollyCarmen = new VoiceEnum("Polly.Carmen"); + public static readonly VoiceEnum PollyCeline = new VoiceEnum("Polly.Celine"); + public static readonly VoiceEnum PollyChantal = new VoiceEnum("Polly.Chantal"); + public static readonly VoiceEnum PollyConchita = new VoiceEnum("Polly.Conchita"); + public static readonly VoiceEnum PollyCristiano = new VoiceEnum("Polly.Cristiano"); + public static readonly VoiceEnum PollyDora = new VoiceEnum("Polly.Dora"); + public static readonly VoiceEnum PollyEmma = new VoiceEnum("Polly.Emma"); + public static readonly VoiceEnum PollyEnrique = new VoiceEnum("Polly.Enrique"); + public static readonly VoiceEnum PollyEwa = new VoiceEnum("Polly.Ewa"); + public static readonly VoiceEnum PollyFiliz = new VoiceEnum("Polly.Filiz"); + public static readonly VoiceEnum PollyGeraint = new VoiceEnum("Polly.Geraint"); + public static readonly VoiceEnum PollyGiorgio = new VoiceEnum("Polly.Giorgio"); + public static readonly VoiceEnum PollyGwyneth = new VoiceEnum("Polly.Gwyneth"); + public static readonly VoiceEnum PollyHans = new VoiceEnum("Polly.Hans"); + public static readonly VoiceEnum PollyInes = new VoiceEnum("Polly.Ines"); + public static readonly VoiceEnum PollyIvy = new VoiceEnum("Polly.Ivy"); + public static readonly VoiceEnum PollyJacek = new VoiceEnum("Polly.Jacek"); + public static readonly VoiceEnum PollyJan = new VoiceEnum("Polly.Jan"); + public static readonly VoiceEnum PollyJoanna = new VoiceEnum("Polly.Joanna"); + public static readonly VoiceEnum PollyJoey = new VoiceEnum("Polly.Joey"); + public static readonly VoiceEnum PollyJustin = new VoiceEnum("Polly.Justin"); + public static readonly VoiceEnum PollyKarl = new VoiceEnum("Polly.Karl"); + public static readonly VoiceEnum PollyKendra = new VoiceEnum("Polly.Kendra"); + public static readonly VoiceEnum PollyKimberly = new VoiceEnum("Polly.Kimberly"); + public static readonly VoiceEnum PollyLea = new VoiceEnum("Polly.Lea"); + public static readonly VoiceEnum PollyLiv = new VoiceEnum("Polly.Liv"); + public static readonly VoiceEnum PollyLotte = new VoiceEnum("Polly.Lotte"); + public static readonly VoiceEnum PollyLucia = new VoiceEnum("Polly.Lucia"); + public static readonly VoiceEnum PollyLupe = new VoiceEnum("Polly.Lupe"); + public static readonly VoiceEnum PollyMads = new VoiceEnum("Polly.Mads"); + public static readonly VoiceEnum PollyMaja = new VoiceEnum("Polly.Maja"); + public static readonly VoiceEnum PollyMarlene = new VoiceEnum("Polly.Marlene"); + public static readonly VoiceEnum PollyMathieu = new VoiceEnum("Polly.Mathieu"); + public static readonly VoiceEnum PollyMatthew = new VoiceEnum("Polly.Matthew"); + public static readonly VoiceEnum PollyMaxim = new VoiceEnum("Polly.Maxim"); + public static readonly VoiceEnum PollyMia = new VoiceEnum("Polly.Mia"); + public static readonly VoiceEnum PollyMiguel = new VoiceEnum("Polly.Miguel"); + public static readonly VoiceEnum PollyMizuki = new VoiceEnum("Polly.Mizuki"); + public static readonly VoiceEnum PollyNaja = new VoiceEnum("Polly.Naja"); + public static readonly VoiceEnum PollyNicole = new VoiceEnum("Polly.Nicole"); + public static readonly VoiceEnum PollyPenelope = new VoiceEnum("Polly.Penelope"); + public static readonly VoiceEnum PollyRaveena = new VoiceEnum("Polly.Raveena"); + public static readonly VoiceEnum PollyRicardo = new VoiceEnum("Polly.Ricardo"); + public static readonly VoiceEnum PollyRuben = new VoiceEnum("Polly.Ruben"); + public static readonly VoiceEnum PollyRussell = new VoiceEnum("Polly.Russell"); + public static readonly VoiceEnum PollySalli = new VoiceEnum("Polly.Salli"); + public static readonly VoiceEnum PollySeoyeon = new VoiceEnum("Polly.Seoyeon"); + public static readonly VoiceEnum PollyTakumi = new VoiceEnum("Polly.Takumi"); + public static readonly VoiceEnum PollyTatyana = new VoiceEnum("Polly.Tatyana"); + public static readonly VoiceEnum PollyVicki = new VoiceEnum("Polly.Vicki"); + public static readonly VoiceEnum PollyVitoria = new VoiceEnum("Polly.Vitoria"); + public static readonly VoiceEnum PollyZeina = new VoiceEnum("Polly.Zeina"); + public static readonly VoiceEnum PollyZhiyu = new VoiceEnum("Polly.Zhiyu"); + public static readonly VoiceEnum PollyAmyNeural = new VoiceEnum("Polly.Amy-Neural"); + public static readonly VoiceEnum PollyEmmaNeural = new VoiceEnum("Polly.Emma-Neural"); + public static readonly VoiceEnum PollyBrianNeural = new VoiceEnum("Polly.Brian-Neural"); + public static readonly VoiceEnum PollySalliNeural = new VoiceEnum("Polly.Salli-Neural"); + public static readonly VoiceEnum PollyIvyNeural = new VoiceEnum("Polly.Ivy-Neural"); + public static readonly VoiceEnum PollyJoannaNeural = new VoiceEnum("Polly.Joanna-Neural"); + public static readonly VoiceEnum PollyKendraNeural = new VoiceEnum("Polly.Kendra-Neural"); + public static readonly VoiceEnum PollyKimberlyNeural = new VoiceEnum("Polly.Kimberly-Neural"); + public static readonly VoiceEnum PollyJoeyNeural = new VoiceEnum("Polly.Joey-Neural"); + public static readonly VoiceEnum PollyJustinNeural = new VoiceEnum("Polly.Justin-Neural"); + public static readonly VoiceEnum PollyMatthewNeural = new VoiceEnum("Polly.Matthew-Neural"); + public static readonly VoiceEnum PollyCamilaNeural = new VoiceEnum("Polly.Camila-Neural"); + public static readonly VoiceEnum PollyLupeNeural = new VoiceEnum("Polly.Lupe-Neural"); + public static readonly VoiceEnum PollyOliviaNeural = new VoiceEnum("Polly.Olivia-Neural"); + public static readonly VoiceEnum PollyKevinNeural = new VoiceEnum("Polly.Kevin-Neural"); + } + + public sealed class LanguageEnum : StringEnum + { + private LanguageEnum(string value) : base(value) { } + public LanguageEnum() { } + public static implicit operator LanguageEnum(string value) + { + return new LanguageEnum(value); + } + + public static readonly LanguageEnum Arb = new LanguageEnum("arb"); + public static readonly LanguageEnum CaEs = new LanguageEnum("ca-ES"); + public static readonly LanguageEnum CyGb = new LanguageEnum("cy-GB"); + public static readonly LanguageEnum DaDk = new LanguageEnum("da-DK"); + public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); + public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); + public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); + public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); + public static readonly LanguageEnum EnGbWls = new LanguageEnum("en-GB-WLS"); + public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); + public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); + public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); + public static readonly LanguageEnum EsMx = new LanguageEnum("es-MX"); + public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); + public static readonly LanguageEnum FiFi = new LanguageEnum("fi-FI"); + public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); + public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); + public static readonly LanguageEnum HiIn = new LanguageEnum("hi-IN"); + public static readonly LanguageEnum IsIs = new LanguageEnum("is-IS"); + public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); + public static readonly LanguageEnum JaJp = new LanguageEnum("ja-JP"); + public static readonly LanguageEnum KoKr = new LanguageEnum("ko-KR"); + public static readonly LanguageEnum NbNo = new LanguageEnum("nb-NO"); + public static readonly LanguageEnum NlNl = new LanguageEnum("nl-NL"); + public static readonly LanguageEnum PlPl = new LanguageEnum("pl-PL"); + public static readonly LanguageEnum PtBr = new LanguageEnum("pt-BR"); + public static readonly LanguageEnum PtPt = new LanguageEnum("pt-PT"); + public static readonly LanguageEnum RoRo = new LanguageEnum("ro-RO"); + public static readonly LanguageEnum RuRu = new LanguageEnum("ru-RU"); + public static readonly LanguageEnum SvSe = new LanguageEnum("sv-SE"); + public static readonly LanguageEnum TrTr = new LanguageEnum("tr-TR"); + public static readonly LanguageEnum ZhCn = new LanguageEnum("zh-CN"); + public static readonly LanguageEnum ZhHk = new LanguageEnum("zh-HK"); + public static readonly LanguageEnum ZhTw = new LanguageEnum("zh-TW"); + } + /// - /// Say TwiML Verb - /// - public class Say : TwiML - { - public sealed class VoiceEnum : StringEnum - { - private VoiceEnum(string value) : base(value) {} - public VoiceEnum() {} - public static implicit operator VoiceEnum(string value) - { - return new VoiceEnum(value); - } - - public static readonly VoiceEnum Man = new VoiceEnum("man"); - public static readonly VoiceEnum Woman = new VoiceEnum("woman"); - public static readonly VoiceEnum Alice = new VoiceEnum("alice"); - public static readonly VoiceEnum PollyAditi = new VoiceEnum("Polly.Aditi"); - public static readonly VoiceEnum PollyAmy = new VoiceEnum("Polly.Amy"); - public static readonly VoiceEnum PollyAstrid = new VoiceEnum("Polly.Astrid"); - public static readonly VoiceEnum PollyBianca = new VoiceEnum("Polly.Bianca"); - public static readonly VoiceEnum PollyBrian = new VoiceEnum("Polly.Brian"); - public static readonly VoiceEnum PollyCamila = new VoiceEnum("Polly.Camila"); - public static readonly VoiceEnum PollyCarla = new VoiceEnum("Polly.Carla"); - public static readonly VoiceEnum PollyCarmen = new VoiceEnum("Polly.Carmen"); - public static readonly VoiceEnum PollyCeline = new VoiceEnum("Polly.Celine"); - public static readonly VoiceEnum PollyChantal = new VoiceEnum("Polly.Chantal"); - public static readonly VoiceEnum PollyConchita = new VoiceEnum("Polly.Conchita"); - public static readonly VoiceEnum PollyCristiano = new VoiceEnum("Polly.Cristiano"); - public static readonly VoiceEnum PollyDora = new VoiceEnum("Polly.Dora"); - public static readonly VoiceEnum PollyEmma = new VoiceEnum("Polly.Emma"); - public static readonly VoiceEnum PollyEnrique = new VoiceEnum("Polly.Enrique"); - public static readonly VoiceEnum PollyEwa = new VoiceEnum("Polly.Ewa"); - public static readonly VoiceEnum PollyFiliz = new VoiceEnum("Polly.Filiz"); - public static readonly VoiceEnum PollyGeraint = new VoiceEnum("Polly.Geraint"); - public static readonly VoiceEnum PollyGiorgio = new VoiceEnum("Polly.Giorgio"); - public static readonly VoiceEnum PollyGwyneth = new VoiceEnum("Polly.Gwyneth"); - public static readonly VoiceEnum PollyHans = new VoiceEnum("Polly.Hans"); - public static readonly VoiceEnum PollyInes = new VoiceEnum("Polly.Ines"); - public static readonly VoiceEnum PollyIvy = new VoiceEnum("Polly.Ivy"); - public static readonly VoiceEnum PollyJacek = new VoiceEnum("Polly.Jacek"); - public static readonly VoiceEnum PollyJan = new VoiceEnum("Polly.Jan"); - public static readonly VoiceEnum PollyJoanna = new VoiceEnum("Polly.Joanna"); - public static readonly VoiceEnum PollyJoey = new VoiceEnum("Polly.Joey"); - public static readonly VoiceEnum PollyJustin = new VoiceEnum("Polly.Justin"); - public static readonly VoiceEnum PollyKarl = new VoiceEnum("Polly.Karl"); - public static readonly VoiceEnum PollyKendra = new VoiceEnum("Polly.Kendra"); - public static readonly VoiceEnum PollyKimberly = new VoiceEnum("Polly.Kimberly"); - public static readonly VoiceEnum PollyLea = new VoiceEnum("Polly.Lea"); - public static readonly VoiceEnum PollyLiv = new VoiceEnum("Polly.Liv"); - public static readonly VoiceEnum PollyLotte = new VoiceEnum("Polly.Lotte"); - public static readonly VoiceEnum PollyLucia = new VoiceEnum("Polly.Lucia"); - public static readonly VoiceEnum PollyLupe = new VoiceEnum("Polly.Lupe"); - public static readonly VoiceEnum PollyMads = new VoiceEnum("Polly.Mads"); - public static readonly VoiceEnum PollyMaja = new VoiceEnum("Polly.Maja"); - public static readonly VoiceEnum PollyMarlene = new VoiceEnum("Polly.Marlene"); - public static readonly VoiceEnum PollyMathieu = new VoiceEnum("Polly.Mathieu"); - public static readonly VoiceEnum PollyMatthew = new VoiceEnum("Polly.Matthew"); - public static readonly VoiceEnum PollyMaxim = new VoiceEnum("Polly.Maxim"); - public static readonly VoiceEnum PollyMia = new VoiceEnum("Polly.Mia"); - public static readonly VoiceEnum PollyMiguel = new VoiceEnum("Polly.Miguel"); - public static readonly VoiceEnum PollyMizuki = new VoiceEnum("Polly.Mizuki"); - public static readonly VoiceEnum PollyNaja = new VoiceEnum("Polly.Naja"); - public static readonly VoiceEnum PollyNicole = new VoiceEnum("Polly.Nicole"); - public static readonly VoiceEnum PollyPenelope = new VoiceEnum("Polly.Penelope"); - public static readonly VoiceEnum PollyRaveena = new VoiceEnum("Polly.Raveena"); - public static readonly VoiceEnum PollyRicardo = new VoiceEnum("Polly.Ricardo"); - public static readonly VoiceEnum PollyRuben = new VoiceEnum("Polly.Ruben"); - public static readonly VoiceEnum PollyRussell = new VoiceEnum("Polly.Russell"); - public static readonly VoiceEnum PollySalli = new VoiceEnum("Polly.Salli"); - public static readonly VoiceEnum PollySeoyeon = new VoiceEnum("Polly.Seoyeon"); - public static readonly VoiceEnum PollyTakumi = new VoiceEnum("Polly.Takumi"); - public static readonly VoiceEnum PollyTatyana = new VoiceEnum("Polly.Tatyana"); - public static readonly VoiceEnum PollyVicki = new VoiceEnum("Polly.Vicki"); - public static readonly VoiceEnum PollyVitoria = new VoiceEnum("Polly.Vitoria"); - public static readonly VoiceEnum PollyZeina = new VoiceEnum("Polly.Zeina"); - public static readonly VoiceEnum PollyZhiyu = new VoiceEnum("Polly.Zhiyu"); - public static readonly VoiceEnum PollyAmyNeural = new VoiceEnum("Polly.Amy-Neural"); - public static readonly VoiceEnum PollyEmmaNeural = new VoiceEnum("Polly.Emma-Neural"); - public static readonly VoiceEnum PollyBrianNeural = new VoiceEnum("Polly.Brian-Neural"); - public static readonly VoiceEnum PollySalliNeural = new VoiceEnum("Polly.Salli-Neural"); - public static readonly VoiceEnum PollyIvyNeural = new VoiceEnum("Polly.Ivy-Neural"); - public static readonly VoiceEnum PollyJoannaNeural = new VoiceEnum("Polly.Joanna-Neural"); - public static readonly VoiceEnum PollyKendraNeural = new VoiceEnum("Polly.Kendra-Neural"); - public static readonly VoiceEnum PollyKimberlyNeural = new VoiceEnum("Polly.Kimberly-Neural"); - public static readonly VoiceEnum PollyJoeyNeural = new VoiceEnum("Polly.Joey-Neural"); - public static readonly VoiceEnum PollyJustinNeural = new VoiceEnum("Polly.Justin-Neural"); - public static readonly VoiceEnum PollyMatthewNeural = new VoiceEnum("Polly.Matthew-Neural"); - public static readonly VoiceEnum PollyCamilaNeural = new VoiceEnum("Polly.Camila-Neural"); - public static readonly VoiceEnum PollyLupeNeural = new VoiceEnum("Polly.Lupe-Neural"); - public static readonly VoiceEnum PollyOliviaNeural = new VoiceEnum("Polly.Olivia-Neural"); - public static readonly VoiceEnum PollyKevinNeural = new VoiceEnum("Polly.Kevin-Neural"); - } - - public sealed class LanguageEnum : StringEnum - { - private LanguageEnum(string value) : base(value) {} - public LanguageEnum() {} - public static implicit operator LanguageEnum(string value) - { - return new LanguageEnum(value); - } - - public static readonly LanguageEnum Arb = new LanguageEnum("arb"); - public static readonly LanguageEnum CaEs = new LanguageEnum("ca-ES"); - public static readonly LanguageEnum CyGb = new LanguageEnum("cy-GB"); - public static readonly LanguageEnum DaDk = new LanguageEnum("da-DK"); - public static readonly LanguageEnum DeDe = new LanguageEnum("de-DE"); - public static readonly LanguageEnum EnAu = new LanguageEnum("en-AU"); - public static readonly LanguageEnum EnCa = new LanguageEnum("en-CA"); - public static readonly LanguageEnum EnGb = new LanguageEnum("en-GB"); - public static readonly LanguageEnum EnGbWls = new LanguageEnum("en-GB-WLS"); - public static readonly LanguageEnum EnIn = new LanguageEnum("en-IN"); - public static readonly LanguageEnum EnUs = new LanguageEnum("en-US"); - public static readonly LanguageEnum EsEs = new LanguageEnum("es-ES"); - public static readonly LanguageEnum EsMx = new LanguageEnum("es-MX"); - public static readonly LanguageEnum EsUs = new LanguageEnum("es-US"); - public static readonly LanguageEnum FiFi = new LanguageEnum("fi-FI"); - public static readonly LanguageEnum FrCa = new LanguageEnum("fr-CA"); - public static readonly LanguageEnum FrFr = new LanguageEnum("fr-FR"); - public static readonly LanguageEnum HiIn = new LanguageEnum("hi-IN"); - public static readonly LanguageEnum IsIs = new LanguageEnum("is-IS"); - public static readonly LanguageEnum ItIt = new LanguageEnum("it-IT"); - public static readonly LanguageEnum JaJp = new LanguageEnum("ja-JP"); - public static readonly LanguageEnum KoKr = new LanguageEnum("ko-KR"); - public static readonly LanguageEnum NbNo = new LanguageEnum("nb-NO"); - public static readonly LanguageEnum NlNl = new LanguageEnum("nl-NL"); - public static readonly LanguageEnum PlPl = new LanguageEnum("pl-PL"); - public static readonly LanguageEnum PtBr = new LanguageEnum("pt-BR"); - public static readonly LanguageEnum PtPt = new LanguageEnum("pt-PT"); - public static readonly LanguageEnum RoRo = new LanguageEnum("ro-RO"); - public static readonly LanguageEnum RuRu = new LanguageEnum("ru-RU"); - public static readonly LanguageEnum SvSe = new LanguageEnum("sv-SE"); - public static readonly LanguageEnum TrTr = new LanguageEnum("tr-TR"); - public static readonly LanguageEnum ZhCn = new LanguageEnum("zh-CN"); - public static readonly LanguageEnum ZhHk = new LanguageEnum("zh-HK"); - public static readonly LanguageEnum ZhTw = new LanguageEnum("zh-TW"); - } - - /// - /// Message to say - /// - public string Message { get; set; } - /// - /// Voice to use - /// - public Say.VoiceEnum Voice { get; set; } - /// - /// Times to loop message - /// - public int? Loop { get; set; } - /// - /// Message langauge - /// - public Say.LanguageEnum Language { get; set; } - - /// - /// Create a new Say - /// - /// Message to say, the body of the TwiML Element. - /// Voice to use - /// Times to loop message - /// Message langauge - public Say(string message = null, - Say.VoiceEnum voice = null, - int? loop = null, - Say.LanguageEnum language = null) : base("Say") - { - this.Message = message; - this.Voice = voice; - this.Loop = loop; - this.Language = language; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Message != null ? this.Message : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Voice != null) - { - attributes.Add(new XAttribute("voice", this.Voice.ToString())); - } - if (this.Loop != null) - { - attributes.Add(new XAttribute("loop", this.Loop.ToString())); - } - if (this.Language != null) - { - attributes.Add(new XAttribute("language", this.Language.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public Say Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public Say SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public Say Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public Say SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public Say Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public Say SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - public Say P(string words = null) - { - var newChild = new SsmlP(words); - this.Append(newChild); - return this; - } - - /// - /// Append a

element as a child of this element - ///

- /// A SsmlP instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlP(SsmlP ssmlP) - { - this.Append(ssmlP); - return this; - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .P() instead.")] - public Say SsmlP(string words = null) - { - return P(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public Say Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public Say SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public Say Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public Say SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - public Say S(string words = null) - { - var newChild = new SsmlS(words); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlS instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlS(SsmlS ssmlS) - { - this.Append(ssmlS); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .S() instead.")] - public Say SsmlS(string words = null) - { - return S(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public Say SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public Say SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public Say Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public Say SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public Say W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Say SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public Say SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Say Append(TwiML childElem) - { - return (Say) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Say SetOption(string key, object value) - { - return (Say) base.SetOption(key, value); - } - } + /// Message to say + /// + public string Message { get; set; } + /// + /// Voice to use + /// + public Say.VoiceEnum Voice { get; set; } + /// + /// Times to loop message + /// + public int? Loop { get; set; } + /// + /// Message langauge + /// + public Say.LanguageEnum Language { get; set; } + + /// + /// Create a new Say + /// + /// Message to say, the body of the TwiML Element. + /// Voice to use + /// Times to loop message + /// Message langauge + public Say(string message = null, + Say.VoiceEnum voice = null, + int? loop = null, + Say.LanguageEnum language = null) : base("Say") + { + this.Message = message; + this.Voice = voice; + this.Loop = loop; + this.Language = language; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Message != null ? this.Message : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Voice != null) + { + attributes.Add(new XAttribute("voice", this.Voice.ToString())); + } + if (this.Loop != null) + { + attributes.Add(new XAttribute("loop", this.Loop.ToString())); + } + if (this.Language != null) + { + attributes.Add(new XAttribute("language", this.Language.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public Say Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public Say SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public Say Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public Say SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public Say Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public Say SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + public Say P(string words = null) + { + var newChild = new SsmlP(words); + this.Append(newChild); + return this; + } + + /// + /// Append a

element as a child of this element + ///

+ /// A SsmlP instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlP(SsmlP ssmlP) + { + this.Append(ssmlP); + return this; + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .P() instead.")] + public Say SsmlP(string words = null) + { + return P(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public Say Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public Say SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public Say Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public Say SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + public Say S(string words = null) + { + var newChild = new SsmlS(words); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlS instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlS(SsmlS ssmlS) + { + this.Append(ssmlS); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .S() instead.")] + public Say SsmlS(string words = null) + { + return S(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public Say SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public Say SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public Say Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public Say SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public Say W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Say SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public Say SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Say Append(TwiML childElem) + { + return (Say)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Say SetOption(string key, object value) + { + return (Say)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Sim.cs b/src/Twilio/TwiML/Voice/Sim.cs index bae8ed0ca..0ea4415e5 100644 --- a/src/Twilio/TwiML/Voice/Sim.cs +++ b/src/Twilio/TwiML/Voice/Sim.cs @@ -8,53 +8,53 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Sim TwiML Noun + /// + public class Sim : TwiML + { /// - /// Sim TwiML Noun + /// SIM SID /// - public class Sim : TwiML - { - /// - /// SIM SID - /// - public string SimSid { get; set; } - - /// - /// Create a new Sim - /// - /// SIM SID, the body of the TwiML Element. - public Sim(string simSid = null) : base("Sim") - { - this.SimSid = simSid; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.SimSid != null ? this.SimSid.ToString() : string.Empty; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Sim Append(TwiML childElem) - { - return (Sim) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Sim SetOption(string key, object value) - { - return (Sim) base.SetOption(key, value); - } - } + public string SimSid { get; set; } + + /// + /// Create a new Sim + /// + /// SIM SID, the body of the TwiML Element. + public Sim(string simSid = null) : base("Sim") + { + this.SimSid = simSid; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.SimSid != null ? this.SimSid.ToString() : string.Empty; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Sim Append(TwiML childElem) + { + return (Sim)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Sim SetOption(string key, object value) + { + return (Sim)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Sip.cs b/src/Twilio/TwiML/Voice/Sip.cs index a726a1cb0..0fb9babbd 100644 --- a/src/Twilio/TwiML/Voice/Sip.cs +++ b/src/Twilio/TwiML/Voice/Sip.cs @@ -13,154 +13,154 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Sip TwiML Noun + /// + public class Sip : TwiML + { + public sealed class EventEnum : StringEnum + { + private EventEnum(string value) : base(value) { } + public EventEnum() { } + public static implicit operator EventEnum(string value) + { + return new EventEnum(value); + } + + public static readonly EventEnum Initiated = new EventEnum("initiated"); + public static readonly EventEnum Ringing = new EventEnum("ringing"); + public static readonly EventEnum Answered = new EventEnum("answered"); + public static readonly EventEnum Completed = new EventEnum("completed"); + } + /// - /// Sip TwiML Noun + /// SIP URL /// - public class Sip : TwiML - { - public sealed class EventEnum : StringEnum - { - private EventEnum(string value) : base(value) {} - public EventEnum() {} - public static implicit operator EventEnum(string value) - { - return new EventEnum(value); - } - - public static readonly EventEnum Initiated = new EventEnum("initiated"); - public static readonly EventEnum Ringing = new EventEnum("ringing"); - public static readonly EventEnum Answered = new EventEnum("answered"); - public static readonly EventEnum Completed = new EventEnum("completed"); - } - - /// - /// SIP URL - /// - public Uri SipUrl { get; set; } - /// - /// SIP Username - /// - public string Username { get; set; } - /// - /// SIP Password - /// - public string Password { get; set; } - /// - /// Action URL - /// - public Uri Url { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Status callback events - /// - public List StatusCallbackEvent { get; set; } - /// - /// Status callback URL - /// - public Uri StatusCallback { get; set; } - /// - /// Status callback URL method - /// - public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } - - /// - /// Create a new Sip - /// - /// SIP URL, the body of the TwiML Element. - /// SIP Username - /// SIP Password - /// Action URL - /// Action URL method - /// Status callback events - /// Status callback URL - /// Status callback URL method - public Sip(Uri sipUrl = null, - string username = null, - string password = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - List statusCallbackEvent = null, - Uri statusCallback = null, - Twilio.Http.HttpMethod statusCallbackMethod = null) : base("Sip") - { - this.SipUrl = sipUrl; - this.Username = username; - this.Password = password; - this.Url = url; - this.Method = method; - this.StatusCallbackEvent = statusCallbackEvent; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.SipUrl != null ? Serializers.Url(this.SipUrl) : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Username != null) - { - attributes.Add(new XAttribute("username", this.Username)); - } - if (this.Password != null) - { - attributes.Add(new XAttribute("password", this.Password)); - } - if (this.Url != null) - { - attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.StatusCallbackEvent != null) - { - attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Sip Append(TwiML childElem) - { - return (Sip) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Sip SetOption(string key, object value) - { - return (Sip) base.SetOption(key, value); - } - } + public Uri SipUrl { get; set; } + /// + /// SIP Username + /// + public string Username { get; set; } + /// + /// SIP Password + /// + public string Password { get; set; } + /// + /// Action URL + /// + public Uri Url { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Status callback events + /// + public List StatusCallbackEvent { get; set; } + /// + /// Status callback URL + /// + public Uri StatusCallback { get; set; } + /// + /// Status callback URL method + /// + public Twilio.Http.HttpMethod StatusCallbackMethod { get; set; } + + /// + /// Create a new Sip + /// + /// SIP URL, the body of the TwiML Element. + /// SIP Username + /// SIP Password + /// Action URL + /// Action URL method + /// Status callback events + /// Status callback URL + /// Status callback URL method + public Sip(Uri sipUrl = null, + string username = null, + string password = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + List statusCallbackEvent = null, + Uri statusCallback = null, + Twilio.Http.HttpMethod statusCallbackMethod = null) : base("Sip") + { + this.SipUrl = sipUrl; + this.Username = username; + this.Password = password; + this.Url = url; + this.Method = method; + this.StatusCallbackEvent = statusCallbackEvent; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.SipUrl != null ? Serializers.Url(this.SipUrl) : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Username != null) + { + attributes.Add(new XAttribute("username", this.Username)); + } + if (this.Password != null) + { + attributes.Add(new XAttribute("password", this.Password)); + } + if (this.Url != null) + { + attributes.Add(new XAttribute("url", Serializers.Url(this.Url))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.StatusCallbackEvent != null) + { + attributes.Add(new XAttribute("statusCallbackEvent", String.Join(" ", this.StatusCallbackEvent.Select(e => e.ToString()).ToArray()))); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Sip Append(TwiML childElem) + { + return (Sip)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Sip SetOption(string key, object value) + { + return (Sip)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Siprec.cs b/src/Twilio/TwiML/Voice/Siprec.cs index 8d761df76..5f325a868 100644 --- a/src/Twilio/TwiML/Voice/Siprec.cs +++ b/src/Twilio/TwiML/Voice/Siprec.cs @@ -10,115 +10,115 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Siprec TwiML Noun + /// + public class Siprec : TwiML + { + public sealed class TrackEnum : StringEnum + { + private TrackEnum(string value) : base(value) { } + public TrackEnum() { } + public static implicit operator TrackEnum(string value) + { + return new TrackEnum(value); + } + + public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); + public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); + public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); + } + /// - /// Siprec TwiML Noun + /// Friendly name given to SIPREC /// - public class Siprec : TwiML - { - public sealed class TrackEnum : StringEnum - { - private TrackEnum(string value) : base(value) {} - public TrackEnum() {} - public static implicit operator TrackEnum(string value) - { - return new TrackEnum(value); - } - - public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); - public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); - public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); - } - - /// - /// Friendly name given to SIPREC - /// - public string Name { get; set; } - /// - /// Unique name for Connector - /// - public string ConnectorName { get; set; } - /// - /// Track to be streamed to remote service - /// - public Siprec.TrackEnum Track { get; set; } - - /// - /// Create a new Siprec - /// - /// Friendly name given to SIPREC - /// Unique name for Connector - /// Track to be streamed to remote service - public Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) : base("Siprec") - { - this.Name = name; - this.ConnectorName = connectorName; - this.Track = track; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Name != null) - { - attributes.Add(new XAttribute("name", this.Name)); - } - if (this.ConnectorName != null) - { - attributes.Add(new XAttribute("connectorName", this.ConnectorName)); - } - if (this.Track != null) - { - attributes.Add(new XAttribute("track", this.Track.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// The name of the custom parameter - /// The value of the custom parameter - public Siprec Parameter(string name = null, string value = null) - { - var newChild = new Parameter(name, value); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Parameter instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Siprec Parameter(Parameter parameter) - { - this.Append(parameter); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Siprec Append(TwiML childElem) - { - return (Siprec) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Siprec SetOption(string key, object value) - { - return (Siprec) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Unique name for Connector + /// + public string ConnectorName { get; set; } + /// + /// Track to be streamed to remote service + /// + public Siprec.TrackEnum Track { get; set; } + + /// + /// Create a new Siprec + /// + /// Friendly name given to SIPREC + /// Unique name for Connector + /// Track to be streamed to remote service + public Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) : base("Siprec") + { + this.Name = name; + this.ConnectorName = connectorName; + this.Track = track; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Name != null) + { + attributes.Add(new XAttribute("name", this.Name)); + } + if (this.ConnectorName != null) + { + attributes.Add(new XAttribute("connectorName", this.ConnectorName)); + } + if (this.Track != null) + { + attributes.Add(new XAttribute("track", this.Track.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// The name of the custom parameter + /// The value of the custom parameter + public Siprec Parameter(string name = null, string value = null) + { + var newChild = new Parameter(name, value); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Parameter instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Siprec Parameter(Parameter parameter) + { + this.Append(parameter); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Siprec Append(TwiML childElem) + { + return (Siprec)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Siprec SetOption(string key, object value) + { + return (Siprec)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Sms.cs b/src/Twilio/TwiML/Voice/Sms.cs index f72235ae0..84a0bd37c 100644 --- a/src/Twilio/TwiML/Voice/Sms.cs +++ b/src/Twilio/TwiML/Voice/Sms.cs @@ -11,117 +11,117 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Sms TwiML Noun + /// + public class Sms : TwiML + { /// - /// Sms TwiML Noun + /// Message body /// - public class Sms : TwiML - { - /// - /// Message body - /// - public string Message { get; set; } - /// - /// Number to send message to - /// - public Types.PhoneNumber To { get; set; } - /// - /// Number to send message from - /// - public Types.PhoneNumber From { get; set; } - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - /// - /// Status callback URL - /// - public Uri StatusCallback { get; set; } - - /// - /// Create a new Sms - /// - /// Message body, the body of the TwiML Element. - /// Number to send message to - /// Number to send message from - /// Action URL - /// Action URL method - /// Status callback URL - public Sms(string message = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri statusCallback = null) : base("Sms") - { - this.Message = message; - this.To = to; - this.From = from; - this.Action = action; - this.Method = method; - this.StatusCallback = statusCallback; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Message != null ? this.Message : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.To != null) - { - attributes.Add(new XAttribute("to", this.To.ToString())); - } - if (this.From != null) - { - attributes.Add(new XAttribute("from", this.From.ToString())); - } - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Sms Append(TwiML childElem) - { - return (Sms) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Sms SetOption(string key, object value) - { - return (Sms) base.SetOption(key, value); - } - } + public string Message { get; set; } + /// + /// Number to send message to + /// + public Types.PhoneNumber To { get; set; } + /// + /// Number to send message from + /// + public Types.PhoneNumber From { get; set; } + /// + /// Action URL + /// + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + /// + /// Status callback URL + /// + public Uri StatusCallback { get; set; } + + /// + /// Create a new Sms + /// + /// Message body, the body of the TwiML Element. + /// Number to send message to + /// Number to send message from + /// Action URL + /// Action URL method + /// Status callback URL + public Sms(string message = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri statusCallback = null) : base("Sms") + { + this.Message = message; + this.To = to; + this.From = from; + this.Action = action; + this.Method = method; + this.StatusCallback = statusCallback; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Message != null ? this.Message : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.To != null) + { + attributes.Add(new XAttribute("to", this.To.ToString())); + } + if (this.From != null) + { + attributes.Add(new XAttribute("from", this.From.ToString())); + } + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", Serializers.Url(this.StatusCallback))); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Sms Append(TwiML childElem) + { + return (Sms)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Sms SetOption(string key, object value) + { + return (Sms)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlBreak.cs b/src/Twilio/TwiML/Voice/SsmlBreak.cs index 756e5ee13..247633056 100644 --- a/src/Twilio/TwiML/Voice/SsmlBreak.cs +++ b/src/Twilio/TwiML/Voice/SsmlBreak.cs @@ -10,86 +10,86 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Adding a Pause in Say + /// + public class SsmlBreak : TwiML + { + public sealed class StrengthEnum : StringEnum + { + private StrengthEnum(string value) : base(value) { } + public StrengthEnum() { } + public static implicit operator StrengthEnum(string value) + { + return new StrengthEnum(value); + } + + public static readonly StrengthEnum None = new StrengthEnum("none"); + public static readonly StrengthEnum XWeak = new StrengthEnum("x-weak"); + public static readonly StrengthEnum Weak = new StrengthEnum("weak"); + public static readonly StrengthEnum Medium = new StrengthEnum("medium"); + public static readonly StrengthEnum Strong = new StrengthEnum("strong"); + public static readonly StrengthEnum XStrong = new StrengthEnum("x-strong"); + } + /// - /// Adding a Pause in Say + /// Set a pause based on strength /// - public class SsmlBreak : TwiML - { - public sealed class StrengthEnum : StringEnum - { - private StrengthEnum(string value) : base(value) {} - public StrengthEnum() {} - public static implicit operator StrengthEnum(string value) - { - return new StrengthEnum(value); - } - - public static readonly StrengthEnum None = new StrengthEnum("none"); - public static readonly StrengthEnum XWeak = new StrengthEnum("x-weak"); - public static readonly StrengthEnum Weak = new StrengthEnum("weak"); - public static readonly StrengthEnum Medium = new StrengthEnum("medium"); - public static readonly StrengthEnum Strong = new StrengthEnum("strong"); - public static readonly StrengthEnum XStrong = new StrengthEnum("x-strong"); - } - - /// - /// Set a pause based on strength - /// - public SsmlBreak.StrengthEnum Strength { get; set; } - /// - /// Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms - /// - public string Time { get; set; } - - /// - /// Create a new SsmlBreak - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) : base("break") - { - this.Strength = strength; - this.Time = time; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Strength != null) - { - attributes.Add(new XAttribute("strength", this.Strength.ToString())); - } - if (this.Time != null) - { - attributes.Add(new XAttribute("time", this.Time)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlBreak Append(TwiML childElem) - { - return (SsmlBreak) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlBreak SetOption(string key, object value) - { - return (SsmlBreak) base.SetOption(key, value); - } - } + public SsmlBreak.StrengthEnum Strength { get; set; } + /// + /// Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms + /// + public string Time { get; set; } + + /// + /// Create a new SsmlBreak + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) : base("break") + { + this.Strength = strength; + this.Time = time; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Strength != null) + { + attributes.Add(new XAttribute("strength", this.Strength.ToString())); + } + if (this.Time != null) + { + attributes.Add(new XAttribute("time", this.Time)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlBreak Append(TwiML childElem) + { + return (SsmlBreak)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlBreak SetOption(string key, object value) + { + return (SsmlBreak)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlEmphasis.cs b/src/Twilio/TwiML/Voice/SsmlEmphasis.cs index 4858590fc..0a452f49b 100644 --- a/src/Twilio/TwiML/Voice/SsmlEmphasis.cs +++ b/src/Twilio/TwiML/Voice/SsmlEmphasis.cs @@ -10,380 +10,380 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Emphasizing Words in Say + /// + public class SsmlEmphasis : TwiML + { + public sealed class LevelEnum : StringEnum + { + private LevelEnum(string value) : base(value) { } + public LevelEnum() { } + public static implicit operator LevelEnum(string value) + { + return new LevelEnum(value); + } + + public static readonly LevelEnum Strong = new LevelEnum("strong"); + public static readonly LevelEnum Moderate = new LevelEnum("moderate"); + public static readonly LevelEnum Reduced = new LevelEnum("reduced"); + } + /// - /// Emphasizing Words in Say + /// Words to emphasize /// - public class SsmlEmphasis : TwiML - { - public sealed class LevelEnum : StringEnum - { - private LevelEnum(string value) : base(value) {} - public LevelEnum() {} - public static implicit operator LevelEnum(string value) - { - return new LevelEnum(value); - } - - public static readonly LevelEnum Strong = new LevelEnum("strong"); - public static readonly LevelEnum Moderate = new LevelEnum("moderate"); - public static readonly LevelEnum Reduced = new LevelEnum("reduced"); - } - - /// - /// Words to emphasize - /// - public string Words { get; set; } - /// - /// Specify the degree of emphasis - /// - public SsmlEmphasis.LevelEnum Level { get; set; } - - /// - /// Create a new SsmlEmphasis - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) : base("emphasis") - { - this.Words = words; - this.Level = level; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Level != null) - { - attributes.Add(new XAttribute("level", this.Level.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlEmphasis Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlEmphasis SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlEmphasis Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis AppendSsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlEmphasis AppendSsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlEmphasis Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public SsmlEmphasis SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlEmphasis Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlEmphasis SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlEmphasis Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlEmphasis SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlEmphasis SayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlEmphasis SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlEmphasis Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlEmphasis SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlEmphasis W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlEmphasis SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public SsmlEmphasis SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlEmphasis Append(TwiML childElem) - { - return (SsmlEmphasis) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlEmphasis SetOption(string key, object value) - { - return (SsmlEmphasis) base.SetOption(key, value); - } - } + public string Words { get; set; } + /// + /// Specify the degree of emphasis + /// + public SsmlEmphasis.LevelEnum Level { get; set; } + + /// + /// Create a new SsmlEmphasis + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) : base("emphasis") + { + this.Words = words; + this.Level = level; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Level != null) + { + attributes.Add(new XAttribute("level", this.Level.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlEmphasis Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlEmphasis SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlEmphasis Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis AppendSsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlEmphasis AppendSsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlEmphasis Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public SsmlEmphasis SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlEmphasis Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlEmphasis SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlEmphasis Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlEmphasis SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlEmphasis SayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlEmphasis SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlEmphasis Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlEmphasis SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlEmphasis W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlEmphasis SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public SsmlEmphasis SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlEmphasis Append(TwiML childElem) + { + return (SsmlEmphasis)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlEmphasis SetOption(string key, object value) + { + return (SsmlEmphasis)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlLang.cs b/src/Twilio/TwiML/Voice/SsmlLang.cs index 5cf7ee2e0..9c93c76f5 100644 --- a/src/Twilio/TwiML/Voice/SsmlLang.cs +++ b/src/Twilio/TwiML/Voice/SsmlLang.cs @@ -10,466 +10,466 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Specifying Another Language for Specific Words in Say + /// + public class SsmlLang : TwiML + { + public sealed class XmlLangEnum : StringEnum + { + private XmlLangEnum(string value) : base(value) { } + public XmlLangEnum() { } + public static implicit operator XmlLangEnum(string value) + { + return new XmlLangEnum(value); + } + + public static readonly XmlLangEnum DaDk = new XmlLangEnum("da-DK"); + public static readonly XmlLangEnum NlNl = new XmlLangEnum("nl-NL"); + public static readonly XmlLangEnum EnAu = new XmlLangEnum("en-AU"); + public static readonly XmlLangEnum EnGb = new XmlLangEnum("en-GB"); + public static readonly XmlLangEnum EnIn = new XmlLangEnum("en-IN"); + public static readonly XmlLangEnum EnUs = new XmlLangEnum("en-US"); + public static readonly XmlLangEnum EnGbWls = new XmlLangEnum("en-GB-WLS"); + public static readonly XmlLangEnum FrFr = new XmlLangEnum("fr-FR"); + public static readonly XmlLangEnum FrCa = new XmlLangEnum("fr-CA"); + public static readonly XmlLangEnum DeDe = new XmlLangEnum("de-DE"); + public static readonly XmlLangEnum IsIs = new XmlLangEnum("is-IS"); + public static readonly XmlLangEnum ItIt = new XmlLangEnum("it-IT"); + public static readonly XmlLangEnum JaJp = new XmlLangEnum("ja-JP"); + public static readonly XmlLangEnum KoKr = new XmlLangEnum("ko-KR"); + public static readonly XmlLangEnum NbNo = new XmlLangEnum("nb-NO"); + public static readonly XmlLangEnum PlPl = new XmlLangEnum("pl-PL"); + public static readonly XmlLangEnum PtBr = new XmlLangEnum("pt-BR"); + public static readonly XmlLangEnum PtPt = new XmlLangEnum("pt-PT"); + public static readonly XmlLangEnum RoRo = new XmlLangEnum("ro-RO"); + public static readonly XmlLangEnum RuRu = new XmlLangEnum("ru-RU"); + public static readonly XmlLangEnum EsEs = new XmlLangEnum("es-ES"); + public static readonly XmlLangEnum EsUs = new XmlLangEnum("es-US"); + public static readonly XmlLangEnum SvSe = new XmlLangEnum("sv-SE"); + public static readonly XmlLangEnum TrTr = new XmlLangEnum("tr-TR"); + public static readonly XmlLangEnum CyGb = new XmlLangEnum("cy-GB"); + } + /// - /// Specifying Another Language for Specific Words in Say - /// - public class SsmlLang : TwiML - { - public sealed class XmlLangEnum : StringEnum - { - private XmlLangEnum(string value) : base(value) {} - public XmlLangEnum() {} - public static implicit operator XmlLangEnum(string value) - { - return new XmlLangEnum(value); - } - - public static readonly XmlLangEnum DaDk = new XmlLangEnum("da-DK"); - public static readonly XmlLangEnum NlNl = new XmlLangEnum("nl-NL"); - public static readonly XmlLangEnum EnAu = new XmlLangEnum("en-AU"); - public static readonly XmlLangEnum EnGb = new XmlLangEnum("en-GB"); - public static readonly XmlLangEnum EnIn = new XmlLangEnum("en-IN"); - public static readonly XmlLangEnum EnUs = new XmlLangEnum("en-US"); - public static readonly XmlLangEnum EnGbWls = new XmlLangEnum("en-GB-WLS"); - public static readonly XmlLangEnum FrFr = new XmlLangEnum("fr-FR"); - public static readonly XmlLangEnum FrCa = new XmlLangEnum("fr-CA"); - public static readonly XmlLangEnum DeDe = new XmlLangEnum("de-DE"); - public static readonly XmlLangEnum IsIs = new XmlLangEnum("is-IS"); - public static readonly XmlLangEnum ItIt = new XmlLangEnum("it-IT"); - public static readonly XmlLangEnum JaJp = new XmlLangEnum("ja-JP"); - public static readonly XmlLangEnum KoKr = new XmlLangEnum("ko-KR"); - public static readonly XmlLangEnum NbNo = new XmlLangEnum("nb-NO"); - public static readonly XmlLangEnum PlPl = new XmlLangEnum("pl-PL"); - public static readonly XmlLangEnum PtBr = new XmlLangEnum("pt-BR"); - public static readonly XmlLangEnum PtPt = new XmlLangEnum("pt-PT"); - public static readonly XmlLangEnum RoRo = new XmlLangEnum("ro-RO"); - public static readonly XmlLangEnum RuRu = new XmlLangEnum("ru-RU"); - public static readonly XmlLangEnum EsEs = new XmlLangEnum("es-ES"); - public static readonly XmlLangEnum EsUs = new XmlLangEnum("es-US"); - public static readonly XmlLangEnum SvSe = new XmlLangEnum("sv-SE"); - public static readonly XmlLangEnum TrTr = new XmlLangEnum("tr-TR"); - public static readonly XmlLangEnum CyGb = new XmlLangEnum("cy-GB"); - } - - /// - /// Words to speak - /// - public string Words { get; set; } - /// - /// Specify the language - /// - public SsmlLang.XmlLangEnum XmlLang { get; set; } - - /// - /// Create a new SsmlLang - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) : base("lang") - { - this.Words = words; - this.XmlLang = xmlLang; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.XmlLang != null) - { - attributes.Add(new XAttribute(XNamespace.Xml + "lang", this.XmlLang.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlLang Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlLang SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlLang Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlLang SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlLang Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang AppendSsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public SsmlLang AppendSsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - public SsmlLang P(string words = null) - { - var newChild = new SsmlP(words); - this.Append(newChild); - return this; - } - - /// - /// Append a

element as a child of this element - ///

- /// A SsmlP instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlP(SsmlP ssmlP) - { - this.Append(ssmlP); - return this; - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .P() instead.")] - public SsmlLang SsmlP(string words = null) - { - return P(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlLang Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlLang SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlLang Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlLang SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - public SsmlLang S(string words = null) - { - var newChild = new SsmlS(words); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlS instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlS(SsmlS ssmlS) - { - this.Append(ssmlS); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .S() instead.")] - public SsmlLang SsmlS(string words = null) - { - return S(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlLang SayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlLang SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlLang Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlLang SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlLang W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlLang SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public SsmlLang SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlLang Append(TwiML childElem) - { - return (SsmlLang) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlLang SetOption(string key, object value) - { - return (SsmlLang) base.SetOption(key, value); - } - } + /// Words to speak + /// + public string Words { get; set; } + /// + /// Specify the language + /// + public SsmlLang.XmlLangEnum XmlLang { get; set; } + + /// + /// Create a new SsmlLang + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) : base("lang") + { + this.Words = words; + this.XmlLang = xmlLang; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.XmlLang != null) + { + attributes.Add(new XAttribute(XNamespace.Xml + "lang", this.XmlLang.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlLang Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlLang SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlLang Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlLang SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlLang Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang AppendSsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public SsmlLang AppendSsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + public SsmlLang P(string words = null) + { + var newChild = new SsmlP(words); + this.Append(newChild); + return this; + } + + /// + /// Append a

element as a child of this element + ///

+ /// A SsmlP instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlP(SsmlP ssmlP) + { + this.Append(ssmlP); + return this; + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .P() instead.")] + public SsmlLang SsmlP(string words = null) + { + return P(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlLang Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlLang SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlLang Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlLang SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + public SsmlLang S(string words = null) + { + var newChild = new SsmlS(words); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlS instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlS(SsmlS ssmlS) + { + this.Append(ssmlS); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .S() instead.")] + public SsmlLang SsmlS(string words = null) + { + return S(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlLang SayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlLang SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlLang Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlLang SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlLang W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlLang SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public SsmlLang SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlLang Append(TwiML childElem) + { + return (SsmlLang)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlLang SetOption(string key, object value) + { + return (SsmlLang)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlP.cs b/src/Twilio/TwiML/Voice/SsmlP.cs index 340c61d15..78355f752 100644 --- a/src/Twilio/TwiML/Voice/SsmlP.cs +++ b/src/Twilio/TwiML/Voice/SsmlP.cs @@ -8,377 +8,377 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Adding a Pause Between Paragraphs in Say + /// + public class SsmlP : TwiML + { /// - /// Adding a Pause Between Paragraphs in Say + /// Words to speak /// - public class SsmlP : TwiML - { - /// - /// Words to speak - /// - public string Words { get; set; } - - /// - /// Create a new SsmlP - /// - /// Words to speak, the body of the TwiML Element. - public SsmlP(string words = null) : base("p") - { - this.Words = words; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlP Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlP SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlP Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlP SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlP Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public SsmlP SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlP Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlP SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlP Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlP SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - public SsmlP S(string words = null) - { - var newChild = new SsmlS(words); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlS instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlS(SsmlS ssmlS) - { - this.Append(ssmlS); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .S() instead.")] - public SsmlP SsmlS(string words = null) - { - return S(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlP SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlP SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlP Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlP SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlP W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlP SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public SsmlP SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlP Append(TwiML childElem) - { - return (SsmlP) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlP SetOption(string key, object value) - { - return (SsmlP) base.SetOption(key, value); - } - } + public string Words { get; set; } + + /// + /// Create a new SsmlP + /// + /// Words to speak, the body of the TwiML Element. + public SsmlP(string words = null) : base("p") + { + this.Words = words; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlP Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlP SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlP Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlP SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlP Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public SsmlP SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlP Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlP SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlP Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlP SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + public SsmlP S(string words = null) + { + var newChild = new SsmlS(words); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlS instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlS(SsmlS ssmlS) + { + this.Append(ssmlS); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .S() instead.")] + public SsmlP SsmlS(string words = null) + { + return S(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlP SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlP SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlP Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlP SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlP W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlP SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public SsmlP SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlP Append(TwiML childElem) + { + return (SsmlP)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlP SetOption(string key, object value) + { + return (SsmlP)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlPhoneme.cs b/src/Twilio/TwiML/Voice/SsmlPhoneme.cs index 7ba7113d6..cbdfaafb3 100644 --- a/src/Twilio/TwiML/Voice/SsmlPhoneme.cs +++ b/src/Twilio/TwiML/Voice/SsmlPhoneme.cs @@ -10,95 +10,95 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Using Phonetic Pronunciation in Say + /// + public class SsmlPhoneme : TwiML + { + public sealed class AlphabetEnum : StringEnum + { + private AlphabetEnum(string value) : base(value) { } + public AlphabetEnum() { } + public static implicit operator AlphabetEnum(string value) + { + return new AlphabetEnum(value); + } + + public static readonly AlphabetEnum Ipa = new AlphabetEnum("ipa"); + public static readonly AlphabetEnum XSampa = new AlphabetEnum("x-sampa"); + } + /// - /// Using Phonetic Pronunciation in Say + /// Words to speak /// - public class SsmlPhoneme : TwiML - { - public sealed class AlphabetEnum : StringEnum - { - private AlphabetEnum(string value) : base(value) {} - public AlphabetEnum() {} - public static implicit operator AlphabetEnum(string value) - { - return new AlphabetEnum(value); - } - - public static readonly AlphabetEnum Ipa = new AlphabetEnum("ipa"); - public static readonly AlphabetEnum XSampa = new AlphabetEnum("x-sampa"); - } - - /// - /// Words to speak - /// - public string Words { get; set; } - /// - /// Specify the phonetic alphabet - /// - public SsmlPhoneme.AlphabetEnum Alphabet { get; set; } - /// - /// Specifiy the phonetic symbols for pronunciation - /// - public string Ph { get; set; } - - /// - /// Create a new SsmlPhoneme - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) : base("phoneme") - { - this.Words = words; - this.Alphabet = alphabet; - this.Ph = ph; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Alphabet != null) - { - attributes.Add(new XAttribute("alphabet", this.Alphabet.ToString())); - } - if (this.Ph != null) - { - attributes.Add(new XAttribute("ph", this.Ph)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlPhoneme Append(TwiML childElem) - { - return (SsmlPhoneme) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlPhoneme SetOption(string key, object value) - { - return (SsmlPhoneme) base.SetOption(key, value); - } - } + public string Words { get; set; } + /// + /// Specify the phonetic alphabet + /// + public SsmlPhoneme.AlphabetEnum Alphabet { get; set; } + /// + /// Specifiy the phonetic symbols for pronunciation + /// + public string Ph { get; set; } + + /// + /// Create a new SsmlPhoneme + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) : base("phoneme") + { + this.Words = words; + this.Alphabet = alphabet; + this.Ph = ph; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Alphabet != null) + { + attributes.Add(new XAttribute("alphabet", this.Alphabet.ToString())); + } + if (this.Ph != null) + { + attributes.Add(new XAttribute("ph", this.Ph)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlPhoneme Append(TwiML childElem) + { + return (SsmlPhoneme)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlPhoneme SetOption(string key, object value) + { + return (SsmlPhoneme)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlProsody.cs b/src/Twilio/TwiML/Voice/SsmlProsody.cs index 234d0b9ca..a0affb186 100644 --- a/src/Twilio/TwiML/Voice/SsmlProsody.cs +++ b/src/Twilio/TwiML/Voice/SsmlProsody.cs @@ -9,458 +9,458 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Controling Volume, Speaking Rate, and Pitch in Say + /// + public class SsmlProsody : TwiML + { /// - /// Controling Volume, Speaking Rate, and Pitch in Say - /// - public class SsmlProsody : TwiML - { - /// - /// Words to speak - /// - public string Words { get; set; } - /// - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, +ndB, -ndB - /// - public string Volume { get; set; } - /// - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// - public string Rate { get; set; } - /// - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public string Pitch { get; set; } - - /// - /// Create a new SsmlProsody - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlProsody(string words = null, - string volume = null, - string rate = null, - string pitch = null) : base("prosody") - { - this.Words = words; - this.Volume = volume; - this.Rate = rate; - this.Pitch = pitch; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Volume != null) - { - attributes.Add(new XAttribute("volume", this.Volume)); - } - if (this.Rate != null) - { - attributes.Add(new XAttribute("rate", this.Rate)); - } - if (this.Pitch != null) - { - attributes.Add(new XAttribute("pitch", this.Pitch)); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlProsody Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlProsody SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlProsody Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlProsody SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlProsody Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public SsmlProsody SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - public SsmlProsody P(string words = null) - { - var newChild = new SsmlP(words); - this.Append(newChild); - return this; - } - - /// - /// Append a

element as a child of this element - ///

- /// A SsmlP instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlP(SsmlP ssmlP) - { - this.Append(ssmlP); - return this; - } - - /// - /// Create a new

element and append it as a child of this element. - ///

- /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .P() instead.")] - public SsmlProsody SsmlP(string words = null) - { - return P(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlProsody Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlProsody SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlProsody Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody AppendSsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlProsody AppendSsmlProsody(string words = null, - string volume = null, - string rate = null, - string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - public SsmlProsody S(string words = null) - { - var newChild = new SsmlS(words); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlS instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlS(SsmlS ssmlS) - { - this.Append(ssmlS); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - [System.Obsolete("This method is deprecated, use .S() instead.")] - public SsmlProsody SsmlS(string words = null) - { - return S(words); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlProsody SayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlProsody SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlProsody Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlProsody SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlProsody W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlProsody SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public SsmlProsody SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlProsody Append(TwiML childElem) - { - return (SsmlProsody) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlProsody SetOption(string key, object value) - { - return (SsmlProsody) base.SetOption(key, value); - } - } + /// Words to speak + /// + public string Words { get; set; } + /// + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, +ndB, -ndB + /// + public string Volume { get; set; } + /// + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// + public string Rate { get; set; } + /// + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public string Pitch { get; set; } + + /// + /// Create a new SsmlProsody + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlProsody(string words = null, + string volume = null, + string rate = null, + string pitch = null) : base("prosody") + { + this.Words = words; + this.Volume = volume; + this.Rate = rate; + this.Pitch = pitch; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Volume != null) + { + attributes.Add(new XAttribute("volume", this.Volume)); + } + if (this.Rate != null) + { + attributes.Add(new XAttribute("rate", this.Rate)); + } + if (this.Pitch != null) + { + attributes.Add(new XAttribute("pitch", this.Pitch)); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlProsody Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlProsody SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlProsody Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlProsody SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlProsody Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public SsmlProsody SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + public SsmlProsody P(string words = null) + { + var newChild = new SsmlP(words); + this.Append(newChild); + return this; + } + + /// + /// Append a

element as a child of this element + ///

+ /// A SsmlP instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlP(SsmlP ssmlP) + { + this.Append(ssmlP); + return this; + } + + /// + /// Create a new

element and append it as a child of this element. + ///

+ /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .P() instead.")] + public SsmlProsody SsmlP(string words = null) + { + return P(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlProsody Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlProsody SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlProsody Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody AppendSsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlProsody AppendSsmlProsody(string words = null, + string volume = null, + string rate = null, + string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + public SsmlProsody S(string words = null) + { + var newChild = new SsmlS(words); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlS instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlS(SsmlS ssmlS) + { + this.Append(ssmlS); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + [System.Obsolete("This method is deprecated, use .S() instead.")] + public SsmlProsody SsmlS(string words = null) + { + return S(words); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlProsody SayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlProsody SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlProsody Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlProsody SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlProsody W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlProsody SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public SsmlProsody SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlProsody Append(TwiML childElem) + { + return (SsmlProsody)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlProsody SetOption(string key, object value) + { + return (SsmlProsody)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlS.cs b/src/Twilio/TwiML/Voice/SsmlS.cs index b2e91c577..e0452f3d3 100644 --- a/src/Twilio/TwiML/Voice/SsmlS.cs +++ b/src/Twilio/TwiML/Voice/SsmlS.cs @@ -8,345 +8,345 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Adding A Pause Between Sentences in Say + /// + public class SsmlS : TwiML + { /// - /// Adding A Pause Between Sentences in Say + /// Words to speak /// - public class SsmlS : TwiML - { - /// - /// Words to speak - /// - public string Words { get; set; } - - /// - /// Create a new SsmlS - /// - /// Words to speak, the body of the TwiML Element. - public SsmlS(string words = null) : base("s") - { - this.Words = words; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlS Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlS SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlS Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlS SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - public SsmlS Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - var newChild = new SsmlLang(words, xmlLang); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlLang instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlLang(SsmlLang ssmlLang) - { - this.Append(ssmlLang); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the language - [System.Obsolete("This method is deprecated, use .Lang() instead.")] - public SsmlS SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) - { - return Lang(words, xmlLang); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlS Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlS SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlS Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlS SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlS SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlS SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlS Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlS SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlS W(string words = null, string role = null) - { - var newChild = new SsmlW(words, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlW instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlS SsmlW(SsmlW ssmlW) - { - this.Append(ssmlW); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - [System.Obsolete("This method is deprecated, use .W() instead.")] - public SsmlS SsmlW(string words = null, string role = null) - { - return W(words, role); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlS Append(TwiML childElem) - { - return (SsmlS) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlS SetOption(string key, object value) - { - return (SsmlS) base.SetOption(key, value); - } - } + public string Words { get; set; } + + /// + /// Create a new SsmlS + /// + /// Words to speak, the body of the TwiML Element. + public SsmlS(string words = null) : base("s") + { + this.Words = words; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlS Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlS SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlS Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlS SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + public SsmlS Lang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + var newChild = new SsmlLang(words, xmlLang); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlLang instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlLang(SsmlLang ssmlLang) + { + this.Append(ssmlLang); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the language + [System.Obsolete("This method is deprecated, use .Lang() instead.")] + public SsmlS SsmlLang(string words = null, SsmlLang.XmlLangEnum xmlLang = null) + { + return Lang(words, xmlLang); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlS Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlS SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlS Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlS SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlS SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlS SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlS Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlS SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlS W(string words = null, string role = null) + { + var newChild = new SsmlW(words, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlW instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlS SsmlW(SsmlW ssmlW) + { + this.Append(ssmlW); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + [System.Obsolete("This method is deprecated, use .W() instead.")] + public SsmlS SsmlW(string words = null, string role = null) + { + return W(words, role); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlS Append(TwiML childElem) + { + return (SsmlS)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlS SetOption(string key, object value) + { + return (SsmlS)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlSayAs.cs b/src/Twilio/TwiML/Voice/SsmlSayAs.cs index c4d18230a..8e9beab44 100644 --- a/src/Twilio/TwiML/Voice/SsmlSayAs.cs +++ b/src/Twilio/TwiML/Voice/SsmlSayAs.cs @@ -10,130 +10,130 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Controlling How Special Types of Words Are Spoken in Say + /// + public class SsmlSayAs : TwiML + { + public sealed class InterpretAsEnum : StringEnum + { + private InterpretAsEnum(string value) : base(value) { } + public InterpretAsEnum() { } + public static implicit operator InterpretAsEnum(string value) + { + return new InterpretAsEnum(value); + } + + public static readonly InterpretAsEnum Character = new InterpretAsEnum("character"); + public static readonly InterpretAsEnum SpellOut = new InterpretAsEnum("spell-out"); + public static readonly InterpretAsEnum Cardinal = new InterpretAsEnum("cardinal"); + public static readonly InterpretAsEnum Number = new InterpretAsEnum("number"); + public static readonly InterpretAsEnum Ordinal = new InterpretAsEnum("ordinal"); + public static readonly InterpretAsEnum Digits = new InterpretAsEnum("digits"); + public static readonly InterpretAsEnum Fraction = new InterpretAsEnum("fraction"); + public static readonly InterpretAsEnum Unit = new InterpretAsEnum("unit"); + public static readonly InterpretAsEnum Date = new InterpretAsEnum("date"); + public static readonly InterpretAsEnum Time = new InterpretAsEnum("time"); + public static readonly InterpretAsEnum Address = new InterpretAsEnum("address"); + public static readonly InterpretAsEnum Expletive = new InterpretAsEnum("expletive"); + public static readonly InterpretAsEnum Telephone = new InterpretAsEnum("telephone"); + } + + public sealed class RoleEnum : StringEnum + { + private RoleEnum(string value) : base(value) { } + public RoleEnum() { } + public static implicit operator RoleEnum(string value) + { + return new RoleEnum(value); + } + + public static readonly RoleEnum Mdy = new RoleEnum("mdy"); + public static readonly RoleEnum Dmy = new RoleEnum("dmy"); + public static readonly RoleEnum Ymd = new RoleEnum("ymd"); + public static readonly RoleEnum Md = new RoleEnum("md"); + public static readonly RoleEnum Dm = new RoleEnum("dm"); + public static readonly RoleEnum Ym = new RoleEnum("ym"); + public static readonly RoleEnum My = new RoleEnum("my"); + public static readonly RoleEnum D = new RoleEnum("d"); + public static readonly RoleEnum M = new RoleEnum("m"); + public static readonly RoleEnum Y = new RoleEnum("y"); + public static readonly RoleEnum Yyyymmdd = new RoleEnum("yyyymmdd"); + } + /// - /// Controlling How Special Types of Words Are Spoken in Say + /// Words to be interpreted /// - public class SsmlSayAs : TwiML - { - public sealed class InterpretAsEnum : StringEnum - { - private InterpretAsEnum(string value) : base(value) {} - public InterpretAsEnum() {} - public static implicit operator InterpretAsEnum(string value) - { - return new InterpretAsEnum(value); - } - - public static readonly InterpretAsEnum Character = new InterpretAsEnum("character"); - public static readonly InterpretAsEnum SpellOut = new InterpretAsEnum("spell-out"); - public static readonly InterpretAsEnum Cardinal = new InterpretAsEnum("cardinal"); - public static readonly InterpretAsEnum Number = new InterpretAsEnum("number"); - public static readonly InterpretAsEnum Ordinal = new InterpretAsEnum("ordinal"); - public static readonly InterpretAsEnum Digits = new InterpretAsEnum("digits"); - public static readonly InterpretAsEnum Fraction = new InterpretAsEnum("fraction"); - public static readonly InterpretAsEnum Unit = new InterpretAsEnum("unit"); - public static readonly InterpretAsEnum Date = new InterpretAsEnum("date"); - public static readonly InterpretAsEnum Time = new InterpretAsEnum("time"); - public static readonly InterpretAsEnum Address = new InterpretAsEnum("address"); - public static readonly InterpretAsEnum Expletive = new InterpretAsEnum("expletive"); - public static readonly InterpretAsEnum Telephone = new InterpretAsEnum("telephone"); - } - - public sealed class RoleEnum : StringEnum - { - private RoleEnum(string value) : base(value) {} - public RoleEnum() {} - public static implicit operator RoleEnum(string value) - { - return new RoleEnum(value); - } - - public static readonly RoleEnum Mdy = new RoleEnum("mdy"); - public static readonly RoleEnum Dmy = new RoleEnum("dmy"); - public static readonly RoleEnum Ymd = new RoleEnum("ymd"); - public static readonly RoleEnum Md = new RoleEnum("md"); - public static readonly RoleEnum Dm = new RoleEnum("dm"); - public static readonly RoleEnum Ym = new RoleEnum("ym"); - public static readonly RoleEnum My = new RoleEnum("my"); - public static readonly RoleEnum D = new RoleEnum("d"); - public static readonly RoleEnum M = new RoleEnum("m"); - public static readonly RoleEnum Y = new RoleEnum("y"); - public static readonly RoleEnum Yyyymmdd = new RoleEnum("yyyymmdd"); - } - - /// - /// Words to be interpreted - /// - public string Words { get; set; } - /// - /// Specify the type of words are spoken - /// - public SsmlSayAs.InterpretAsEnum InterpretAs { get; set; } - /// - /// Specify the format of the date when interpret-as is set to date - /// - public SsmlSayAs.RoleEnum Role { get; set; } - - /// - /// Create a new SsmlSayAs - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) : base("say-as") - { - this.Words = words; - this.InterpretAs = interpretAs; - this.Role = role; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.InterpretAs != null) - { - attributes.Add(new XAttribute("interpret-as", this.InterpretAs.ToString())); - } - if (this.Role != null) - { - attributes.Add(new XAttribute("role", this.Role.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlSayAs Append(TwiML childElem) - { - return (SsmlSayAs) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlSayAs SetOption(string key, object value) - { - return (SsmlSayAs) base.SetOption(key, value); - } - } + public string Words { get; set; } + /// + /// Specify the type of words are spoken + /// + public SsmlSayAs.InterpretAsEnum InterpretAs { get; set; } + /// + /// Specify the format of the date when interpret-as is set to date + /// + public SsmlSayAs.RoleEnum Role { get; set; } + + /// + /// Create a new SsmlSayAs + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) : base("say-as") + { + this.Words = words; + this.InterpretAs = interpretAs; + this.Role = role; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.InterpretAs != null) + { + attributes.Add(new XAttribute("interpret-as", this.InterpretAs.ToString())); + } + if (this.Role != null) + { + attributes.Add(new XAttribute("role", this.Role.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlSayAs Append(TwiML childElem) + { + return (SsmlSayAs)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlSayAs SetOption(string key, object value) + { + return (SsmlSayAs)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlSub.cs b/src/Twilio/TwiML/Voice/SsmlSub.cs index c71dc29e0..7e406cf91 100644 --- a/src/Twilio/TwiML/Voice/SsmlSub.cs +++ b/src/Twilio/TwiML/Voice/SsmlSub.cs @@ -9,73 +9,73 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Pronouncing Acronyms and Abbreviations in Say + /// + public class SsmlSub : TwiML + { /// - /// Pronouncing Acronyms and Abbreviations in Say + /// Words to be substituted /// - public class SsmlSub : TwiML - { - /// - /// Words to be substituted - /// - public string Words { get; set; } - /// - /// Substitute a different word (or pronunciation) for selected text such as an acronym or abbreviation - /// - public string Alias { get; set; } - - /// - /// Create a new SsmlSub - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlSub(string words = null, string alias = null) : base("sub") - { - this.Words = words; - this.Alias = alias; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Alias != null) - { - attributes.Add(new XAttribute("alias", this.Alias)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlSub Append(TwiML childElem) - { - return (SsmlSub) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlSub SetOption(string key, object value) - { - return (SsmlSub) base.SetOption(key, value); - } - } + public string Words { get; set; } + /// + /// Substitute a different word (or pronunciation) for selected text such as an acronym or abbreviation + /// + public string Alias { get; set; } + + /// + /// Create a new SsmlSub + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlSub(string words = null, string alias = null) : base("sub") + { + this.Words = words; + this.Alias = alias; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Alias != null) + { + attributes.Add(new XAttribute("alias", this.Alias)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlSub Append(TwiML childElem) + { + return (SsmlSub)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlSub SetOption(string key, object value) + { + return (SsmlSub)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/SsmlW.cs b/src/Twilio/TwiML/Voice/SsmlW.cs index f6a067f26..9a1899076 100644 --- a/src/Twilio/TwiML/Voice/SsmlW.cs +++ b/src/Twilio/TwiML/Voice/SsmlW.cs @@ -9,295 +9,295 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Improving Pronunciation by Specifying Parts of Speech in Say + /// + public class SsmlW : TwiML + { /// - /// Improving Pronunciation by Specifying Parts of Speech in Say + /// Words to speak /// - public class SsmlW : TwiML - { - /// - /// Words to speak - /// - public string Words { get; set; } - /// - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning - /// - public string Role { get; set; } - - /// - /// Create a new SsmlW - /// - /// Words to speak, the body of the TwiML Element. - /// Customize the pronunciation of words by specifying the word’s part of speech or alternate - /// meaning - public SsmlW(string words = null, string role = null) : base("w") - { - this.Words = words; - this.Role = role; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Words != null ? this.Words : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Role != null) - { - attributes.Add(new XAttribute("role", this.Role)); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - public SsmlW Break(SsmlBreak.StrengthEnum strength = null, string time = null) - { - var newChild = new SsmlBreak(strength, time); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlBreak instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlBreak(SsmlBreak ssmlBreak) - { - this.Append(ssmlBreak); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Set a pause based on strength - /// Set a pause to a specific length of time in seconds or milliseconds, available values: - /// [number]s, [number]ms - [System.Obsolete("This method is deprecated, use .Break() instead.")] - public SsmlW SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) - { - return Break(strength, time); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - public SsmlW Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - var newChild = new SsmlEmphasis(words, level); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlEmphasis instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlEmphasis(SsmlEmphasis ssmlEmphasis) - { - this.Append(ssmlEmphasis); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to emphasize, the body of the TwiML Element. - /// Specify the degree of emphasis - [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] - public SsmlW SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) - { - return Emphasis(words, level); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - public SsmlW Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - var newChild = new SsmlPhoneme(words, alphabet, ph); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlPhoneme instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlPhoneme(SsmlPhoneme ssmlPhoneme) - { - this.Append(ssmlPhoneme); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the phonetic alphabet - /// Specifiy the phonetic symbols for pronunciation - [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] - public SsmlW SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) - { - return Phoneme(words, alphabet, ph); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - public SsmlW Prosody(string words = null, string volume = null, string rate = null, string pitch = null) - { - var newChild = new SsmlProsody(words, volume, rate, pitch); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlProsody instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlProsody(SsmlProsody ssmlProsody) - { - this.Append(ssmlProsody); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to speak, the body of the TwiML Element. - /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, - /// +ndB, -ndB - /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% - /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% - /// - [System.Obsolete("This method is deprecated, use .Prosody() instead.")] - public SsmlW SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) - { - return Prosody(words, volume, rate, pitch); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - public SsmlW SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) - { - var newChild = new SsmlSayAs(words, interpretAs, role); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSayAs instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlSayAs(SsmlSayAs ssmlSayAs) - { - this.Append(ssmlSayAs); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be interpreted, the body of the TwiML Element. - /// Specify the type of words are spoken - /// Specify the format of the date when interpret-as is set to date - [System.Obsolete("This method is deprecated, use .SayAs() instead.")] - public SsmlW SsmlSayAs(string words = null, - SsmlSayAs.InterpretAsEnum interpretAs = null, - SsmlSayAs.RoleEnum role = null) - { - return SayAs(words, interpretAs, role); - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - public SsmlW Sub(string words = null, string alias = null) - { - var newChild = new SsmlSub(words, alias); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A SsmlSub instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public SsmlW SsmlSub(SsmlSub ssmlSub) - { - this.Append(ssmlSub); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Words to be substituted, the body of the TwiML Element. - /// Substitute a different word (or pronunciation) for selected text such as an acronym or - /// abbreviation - [System.Obsolete("This method is deprecated, use .Sub() instead.")] - public SsmlW SsmlSub(string words = null, string alias = null) - { - return Sub(words, alias); - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new SsmlW Append(TwiML childElem) - { - return (SsmlW) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new SsmlW SetOption(string key, object value) - { - return (SsmlW) base.SetOption(key, value); - } - } + public string Words { get; set; } + /// + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning + /// + public string Role { get; set; } + + /// + /// Create a new SsmlW + /// + /// Words to speak, the body of the TwiML Element. + /// Customize the pronunciation of words by specifying the word’s part of speech or alternate + /// meaning + public SsmlW(string words = null, string role = null) : base("w") + { + this.Words = words; + this.Role = role; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Words != null ? this.Words : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Role != null) + { + attributes.Add(new XAttribute("role", this.Role)); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + public SsmlW Break(SsmlBreak.StrengthEnum strength = null, string time = null) + { + var newChild = new SsmlBreak(strength, time); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlBreak instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlBreak(SsmlBreak ssmlBreak) + { + this.Append(ssmlBreak); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Set a pause based on strength + /// Set a pause to a specific length of time in seconds or milliseconds, available values: + /// [number]s, [number]ms + [System.Obsolete("This method is deprecated, use .Break() instead.")] + public SsmlW SsmlBreak(SsmlBreak.StrengthEnum strength = null, string time = null) + { + return Break(strength, time); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + public SsmlW Emphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + var newChild = new SsmlEmphasis(words, level); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlEmphasis instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlEmphasis(SsmlEmphasis ssmlEmphasis) + { + this.Append(ssmlEmphasis); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to emphasize, the body of the TwiML Element. + /// Specify the degree of emphasis + [System.Obsolete("This method is deprecated, use .Emphasis() instead.")] + public SsmlW SsmlEmphasis(string words = null, SsmlEmphasis.LevelEnum level = null) + { + return Emphasis(words, level); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + public SsmlW Phoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + var newChild = new SsmlPhoneme(words, alphabet, ph); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlPhoneme instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlPhoneme(SsmlPhoneme ssmlPhoneme) + { + this.Append(ssmlPhoneme); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the phonetic alphabet + /// Specifiy the phonetic symbols for pronunciation + [System.Obsolete("This method is deprecated, use .Phoneme() instead.")] + public SsmlW SsmlPhoneme(string words = null, SsmlPhoneme.AlphabetEnum alphabet = null, string ph = null) + { + return Phoneme(words, alphabet, ph); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + public SsmlW Prosody(string words = null, string volume = null, string rate = null, string pitch = null) + { + var newChild = new SsmlProsody(words, volume, rate, pitch); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlProsody instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlProsody(SsmlProsody ssmlProsody) + { + this.Append(ssmlProsody); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to speak, the body of the TwiML Element. + /// Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, + /// +ndB, -ndB + /// Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n% + /// Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n% + /// + [System.Obsolete("This method is deprecated, use .Prosody() instead.")] + public SsmlW SsmlProsody(string words = null, string volume = null, string rate = null, string pitch = null) + { + return Prosody(words, volume, rate, pitch); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + public SsmlW SayAs(string words = null, SsmlSayAs.InterpretAsEnum interpretAs = null, SsmlSayAs.RoleEnum role = null) + { + var newChild = new SsmlSayAs(words, interpretAs, role); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSayAs instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlSayAs(SsmlSayAs ssmlSayAs) + { + this.Append(ssmlSayAs); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be interpreted, the body of the TwiML Element. + /// Specify the type of words are spoken + /// Specify the format of the date when interpret-as is set to date + [System.Obsolete("This method is deprecated, use .SayAs() instead.")] + public SsmlW SsmlSayAs(string words = null, + SsmlSayAs.InterpretAsEnum interpretAs = null, + SsmlSayAs.RoleEnum role = null) + { + return SayAs(words, interpretAs, role); + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + public SsmlW Sub(string words = null, string alias = null) + { + var newChild = new SsmlSub(words, alias); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A SsmlSub instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public SsmlW SsmlSub(SsmlSub ssmlSub) + { + this.Append(ssmlSub); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Words to be substituted, the body of the TwiML Element. + /// Substitute a different word (or pronunciation) for selected text such as an acronym or + /// abbreviation + [System.Obsolete("This method is deprecated, use .Sub() instead.")] + public SsmlW SsmlSub(string words = null, string alias = null) + { + return Sub(words, alias); + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new SsmlW Append(TwiML childElem) + { + return (SsmlW)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new SsmlW SetOption(string key, object value) + { + return (SsmlW)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Start.cs b/src/Twilio/TwiML/Voice/Start.cs index 114793d6a..17308764d 100644 --- a/src/Twilio/TwiML/Voice/Start.cs +++ b/src/Twilio/TwiML/Voice/Start.cs @@ -11,124 +11,124 @@ using Twilio.Converters; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Start TwiML Verb + /// + public class Start : TwiML + { /// - /// Start TwiML Verb + /// Action URL /// - public class Start : TwiML - { - /// - /// Action URL - /// - public Uri Action { get; set; } - /// - /// Action URL method - /// - public Twilio.Http.HttpMethod Method { get; set; } - - /// - /// Create a new Start - /// - /// Action URL - /// Action URL method - public Start(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Start") - { - this.Action = action; - this.Method = method; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Action != null) - { - attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); - } - if (this.Method != null) - { - attributes.Add(new XAttribute("method", this.Method.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name given to the Stream - /// Unique name for Stream Connector - /// URL of the remote service where the Stream is routed - /// Track to be streamed to remote service - /// Status Callback URL - /// Status Callback URL method - public Start Stream(string name = null, - string connectorName = null, - string url = null, - Stream.TrackEnum track = null, - string statusCallback = null, - Stream.StatusCallbackMethodEnum statusCallbackMethod = null) - { - var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Stream instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Start Stream(Stream stream) - { - this.Append(stream); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name given to SIPREC - /// Unique name for Connector - /// Track to be streamed to remote service - public Start Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) - { - var newChild = new Siprec(name, connectorName, track); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Siprec instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Start Siprec(Siprec siprec) - { - this.Append(siprec); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Start Append(TwiML childElem) - { - return (Start) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Start SetOption(string key, object value) - { - return (Start) base.SetOption(key, value); - } - } + public Uri Action { get; set; } + /// + /// Action URL method + /// + public Twilio.Http.HttpMethod Method { get; set; } + + /// + /// Create a new Start + /// + /// Action URL + /// Action URL method + public Start(Uri action = null, Twilio.Http.HttpMethod method = null) : base("Start") + { + this.Action = action; + this.Method = method; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Action != null) + { + attributes.Add(new XAttribute("action", Serializers.Url(this.Action))); + } + if (this.Method != null) + { + attributes.Add(new XAttribute("method", this.Method.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name given to the Stream + /// Unique name for Stream Connector + /// URL of the remote service where the Stream is routed + /// Track to be streamed to remote service + /// Status Callback URL + /// Status Callback URL method + public Start Stream(string name = null, + string connectorName = null, + string url = null, + Stream.TrackEnum track = null, + string statusCallback = null, + Stream.StatusCallbackMethodEnum statusCallbackMethod = null) + { + var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Stream instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Start Stream(Stream stream) + { + this.Append(stream); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name given to SIPREC + /// Unique name for Connector + /// Track to be streamed to remote service + public Start Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) + { + var newChild = new Siprec(name, connectorName, track); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Siprec instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Start Siprec(Siprec siprec) + { + this.Append(siprec); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Start Append(TwiML childElem) + { + return (Start)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Start SetOption(string key, object value) + { + return (Start)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Stop.cs b/src/Twilio/TwiML/Voice/Stop.cs index 35e0a8950..19ccb436a 100644 --- a/src/Twilio/TwiML/Voice/Stop.cs +++ b/src/Twilio/TwiML/Voice/Stop.cs @@ -8,94 +8,94 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Stop TwiML Verb + /// + public class Stop : TwiML + { /// - /// Stop TwiML Verb + /// Create a new Stop /// - public class Stop : TwiML - { - /// - /// Create a new Stop - /// - public Stop() : base("Stop") - { - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name given to the Stream - /// Unique name for Stream Connector - /// URL of the remote service where the Stream is routed - /// Track to be streamed to remote service - /// Status Callback URL - /// Status Callback URL method - public Stop Stream(string name = null, - string connectorName = null, - string url = null, - Stream.TrackEnum track = null, - string statusCallback = null, - Stream.StatusCallbackMethodEnum statusCallbackMethod = null) - { - var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Stream instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Stop Stream(Stream stream) - { - this.Append(stream); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name given to SIPREC - /// Unique name for Connector - /// Track to be streamed to remote service - public Stop Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) - { - var newChild = new Siprec(name, connectorName, track); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Siprec instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Stop Siprec(Siprec siprec) - { - this.Append(siprec); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Stop Append(TwiML childElem) - { - return (Stop) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Stop SetOption(string key, object value) - { - return (Stop) base.SetOption(key, value); - } - } + public Stop() : base("Stop") + { + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name given to the Stream + /// Unique name for Stream Connector + /// URL of the remote service where the Stream is routed + /// Track to be streamed to remote service + /// Status Callback URL + /// Status Callback URL method + public Stop Stream(string name = null, + string connectorName = null, + string url = null, + Stream.TrackEnum track = null, + string statusCallback = null, + Stream.StatusCallbackMethodEnum statusCallbackMethod = null) + { + var newChild = new Stream(name, connectorName, url, track, statusCallback, statusCallbackMethod); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Stream instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Stop Stream(Stream stream) + { + this.Append(stream); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name given to SIPREC + /// Unique name for Connector + /// Track to be streamed to remote service + public Stop Siprec(string name = null, string connectorName = null, Siprec.TrackEnum track = null) + { + var newChild = new Siprec(name, connectorName, track); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Siprec instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Stop Siprec(Siprec siprec) + { + this.Append(siprec); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Stop Append(TwiML childElem) + { + return (Stop)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Stop SetOption(string key, object value) + { + return (Stop)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Stream.cs b/src/Twilio/TwiML/Voice/Stream.cs index 49d3bee8b..4df06cbb4 100644 --- a/src/Twilio/TwiML/Voice/Stream.cs +++ b/src/Twilio/TwiML/Voice/Stream.cs @@ -10,163 +10,163 @@ using Twilio.Types; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Stream TwiML Noun + /// + public class Stream : TwiML + { + public sealed class TrackEnum : StringEnum + { + private TrackEnum(string value) : base(value) { } + public TrackEnum() { } + public static implicit operator TrackEnum(string value) + { + return new TrackEnum(value); + } + + public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); + public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); + public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); + } + + public sealed class StatusCallbackMethodEnum : StringEnum + { + private StatusCallbackMethodEnum(string value) : base(value) { } + public StatusCallbackMethodEnum() { } + public static implicit operator StatusCallbackMethodEnum(string value) + { + return new StatusCallbackMethodEnum(value); + } + + public static readonly StatusCallbackMethodEnum Get = new StatusCallbackMethodEnum("GET"); + public static readonly StatusCallbackMethodEnum Post = new StatusCallbackMethodEnum("POST"); + } + /// - /// Stream TwiML Noun + /// Friendly name given to the Stream /// - public class Stream : TwiML - { - public sealed class TrackEnum : StringEnum - { - private TrackEnum(string value) : base(value) {} - public TrackEnum() {} - public static implicit operator TrackEnum(string value) - { - return new TrackEnum(value); - } - - public static readonly TrackEnum InboundTrack = new TrackEnum("inbound_track"); - public static readonly TrackEnum OutboundTrack = new TrackEnum("outbound_track"); - public static readonly TrackEnum BothTracks = new TrackEnum("both_tracks"); - } - - public sealed class StatusCallbackMethodEnum : StringEnum - { - private StatusCallbackMethodEnum(string value) : base(value) {} - public StatusCallbackMethodEnum() {} - public static implicit operator StatusCallbackMethodEnum(string value) - { - return new StatusCallbackMethodEnum(value); - } - - public static readonly StatusCallbackMethodEnum Get = new StatusCallbackMethodEnum("GET"); - public static readonly StatusCallbackMethodEnum Post = new StatusCallbackMethodEnum("POST"); - } - - /// - /// Friendly name given to the Stream - /// - public string Name { get; set; } - /// - /// Unique name for Stream Connector - /// - public string ConnectorName { get; set; } - /// - /// URL of the remote service where the Stream is routed - /// - public string Url { get; set; } - /// - /// Track to be streamed to remote service - /// - public Stream.TrackEnum Track { get; set; } - /// - /// Status Callback URL - /// - public string StatusCallback { get; set; } - /// - /// Status Callback URL method - /// - public Stream.StatusCallbackMethodEnum StatusCallbackMethod { get; set; } - - /// - /// Create a new Stream - /// - /// Friendly name given to the Stream - /// Unique name for Stream Connector - /// URL of the remote service where the Stream is routed - /// Track to be streamed to remote service - /// Status Callback URL - /// Status Callback URL method - public Stream(string name = null, - string connectorName = null, - string url = null, - Stream.TrackEnum track = null, - string statusCallback = null, - Stream.StatusCallbackMethodEnum statusCallbackMethod = null) : base("Stream") - { - this.Name = name; - this.ConnectorName = connectorName; - this.Url = url; - this.Track = track; - this.StatusCallback = statusCallback; - this.StatusCallbackMethod = statusCallbackMethod; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Name != null) - { - attributes.Add(new XAttribute("name", this.Name)); - } - if (this.ConnectorName != null) - { - attributes.Add(new XAttribute("connectorName", this.ConnectorName)); - } - if (this.Url != null) - { - attributes.Add(new XAttribute("url", this.Url)); - } - if (this.Track != null) - { - attributes.Add(new XAttribute("track", this.Track.ToString())); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", this.StatusCallback)); - } - if (this.StatusCallbackMethod != null) - { - attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); - } - return attributes; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// The name of the custom parameter - /// The value of the custom parameter - public Stream Parameter(string name = null, string value = null) - { - var newChild = new Parameter(name, value); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Parameter instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public Stream Parameter(Parameter parameter) - { - this.Append(parameter); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Stream Append(TwiML childElem) - { - return (Stream) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Stream SetOption(string key, object value) - { - return (Stream) base.SetOption(key, value); - } - } + public string Name { get; set; } + /// + /// Unique name for Stream Connector + /// + public string ConnectorName { get; set; } + /// + /// URL of the remote service where the Stream is routed + /// + public string Url { get; set; } + /// + /// Track to be streamed to remote service + /// + public Stream.TrackEnum Track { get; set; } + /// + /// Status Callback URL + /// + public string StatusCallback { get; set; } + /// + /// Status Callback URL method + /// + public Stream.StatusCallbackMethodEnum StatusCallbackMethod { get; set; } + + /// + /// Create a new Stream + /// + /// Friendly name given to the Stream + /// Unique name for Stream Connector + /// URL of the remote service where the Stream is routed + /// Track to be streamed to remote service + /// Status Callback URL + /// Status Callback URL method + public Stream(string name = null, + string connectorName = null, + string url = null, + Stream.TrackEnum track = null, + string statusCallback = null, + Stream.StatusCallbackMethodEnum statusCallbackMethod = null) : base("Stream") + { + this.Name = name; + this.ConnectorName = connectorName; + this.Url = url; + this.Track = track; + this.StatusCallback = statusCallback; + this.StatusCallbackMethod = statusCallbackMethod; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Name != null) + { + attributes.Add(new XAttribute("name", this.Name)); + } + if (this.ConnectorName != null) + { + attributes.Add(new XAttribute("connectorName", this.ConnectorName)); + } + if (this.Url != null) + { + attributes.Add(new XAttribute("url", this.Url)); + } + if (this.Track != null) + { + attributes.Add(new XAttribute("track", this.Track.ToString())); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", this.StatusCallback)); + } + if (this.StatusCallbackMethod != null) + { + attributes.Add(new XAttribute("statusCallbackMethod", this.StatusCallbackMethod.ToString())); + } + return attributes; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// The name of the custom parameter + /// The value of the custom parameter + public Stream Parameter(string name = null, string value = null) + { + var newChild = new Parameter(name, value); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Parameter instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public Stream Parameter(Parameter parameter) + { + this.Append(parameter); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Stream Append(TwiML childElem) + { + return (Stream)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Stream SetOption(string key, object value) + { + return (Stream)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/Task.cs b/src/Twilio/TwiML/Voice/Task.cs index 49ffeca4f..5a29c8cc3 100644 --- a/src/Twilio/TwiML/Voice/Task.cs +++ b/src/Twilio/TwiML/Voice/Task.cs @@ -9,83 +9,83 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// Task TwiML Noun + /// + public class Task : TwiML + { /// - /// Task TwiML Noun + /// TaskRouter task attributes /// - public class Task : TwiML - { - /// - /// TaskRouter task attributes - /// - public string Body { get; set; } - /// - /// Task priority - /// - public int? Priority { get; set; } - /// - /// Timeout associated with task - /// - public int? Timeout { get; set; } - - /// - /// Create a new Task - /// - /// TaskRouter task attributes, the body of the TwiML Element. Also accepts stringified object - /// - /// Task priority - /// Timeout associated with task - public Task(string body = null, int? priority = null, int? timeout = null) : base("Task") - { - this.Body = body; - this.Priority = priority; - this.Timeout = timeout; - } - - /// - /// Return the body of the TwiML tag - /// - protected override string GetElementBody() - { - return this.Body != null ? this.Body : string.Empty; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.Priority != null) - { - attributes.Add(new XAttribute("priority", this.Priority.ToString())); - } - if (this.Timeout != null) - { - attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new Task Append(TwiML childElem) - { - return (Task) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new Task SetOption(string key, object value) - { - return (Task) base.SetOption(key, value); - } - } + public string Body { get; set; } + /// + /// Task priority + /// + public int? Priority { get; set; } + /// + /// Timeout associated with task + /// + public int? Timeout { get; set; } + + /// + /// Create a new Task + /// + /// TaskRouter task attributes, the body of the TwiML Element. Also accepts stringified object + /// + /// Task priority + /// Timeout associated with task + public Task(string body = null, int? priority = null, int? timeout = null) : base("Task") + { + this.Body = body; + this.Priority = priority; + this.Timeout = timeout; + } + + /// + /// Return the body of the TwiML tag + /// + protected override string GetElementBody() + { + return this.Body != null ? this.Body : string.Empty; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.Priority != null) + { + attributes.Add(new XAttribute("priority", this.Priority.ToString())); + } + if (this.Timeout != null) + { + attributes.Add(new XAttribute("timeout", this.Timeout.ToString())); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new Task Append(TwiML childElem) + { + return (Task)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new Task SetOption(string key, object value) + { + return (Task)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/Voice/VirtualAgent.cs b/src/Twilio/TwiML/Voice/VirtualAgent.cs index e4c71fd07..36f4e21da 100644 --- a/src/Twilio/TwiML/Voice/VirtualAgent.cs +++ b/src/Twilio/TwiML/Voice/VirtualAgent.cs @@ -9,91 +9,91 @@ using System.Xml.Linq; namespace Twilio.TwiML.Voice -{ - +{ + + /// + /// VirtualAgent TwiML Noun + /// + public class VirtualAgent : TwiML + { /// - /// VirtualAgent TwiML Noun + /// Defines the conversation profile Dialogflow needs to use /// - public class VirtualAgent : TwiML - { - /// - /// Defines the conversation profile Dialogflow needs to use - /// - public string ConnectorName { get; set; } - /// - /// Language to be used by Dialogflow to transcribe speech - /// - public string Language { get; set; } - /// - /// Whether sentiment analysis needs to be enabled or not - /// - public bool? SentimentAnalysis { get; set; } - /// - /// URL to post status callbacks from Twilio - /// - public string StatusCallback { get; set; } - - /// - /// Create a new VirtualAgent - /// - /// Defines the conversation profile Dialogflow needs to use - /// Language to be used by Dialogflow to transcribe speech - /// Whether sentiment analysis needs to be enabled or not - /// URL to post status callbacks from Twilio - public VirtualAgent(string connectorName = null, - string language = null, - bool? sentimentAnalysis = null, - string statusCallback = null) : base("VirtualAgent") - { - this.ConnectorName = connectorName; - this.Language = language; - this.SentimentAnalysis = sentimentAnalysis; - this.StatusCallback = statusCallback; - } - - /// - /// Return the attributes of the TwiML tag - /// - protected override List GetElementAttributes() - { - var attributes = new List(); - if (this.ConnectorName != null) - { - attributes.Add(new XAttribute("connectorName", this.ConnectorName)); - } - if (this.Language != null) - { - attributes.Add(new XAttribute("language", this.Language)); - } - if (this.SentimentAnalysis != null) - { - attributes.Add(new XAttribute("sentimentAnalysis", this.SentimentAnalysis.Value.ToString().ToLower())); - } - if (this.StatusCallback != null) - { - attributes.Add(new XAttribute("statusCallback", this.StatusCallback)); - } - return attributes; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new VirtualAgent Append(TwiML childElem) - { - return (VirtualAgent) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new VirtualAgent SetOption(string key, object value) - { - return (VirtualAgent) base.SetOption(key, value); - } - } + public string ConnectorName { get; set; } + /// + /// Language to be used by Dialogflow to transcribe speech + /// + public string Language { get; set; } + /// + /// Whether sentiment analysis needs to be enabled or not + /// + public bool? SentimentAnalysis { get; set; } + /// + /// URL to post status callbacks from Twilio + /// + public string StatusCallback { get; set; } + + /// + /// Create a new VirtualAgent + /// + /// Defines the conversation profile Dialogflow needs to use + /// Language to be used by Dialogflow to transcribe speech + /// Whether sentiment analysis needs to be enabled or not + /// URL to post status callbacks from Twilio + public VirtualAgent(string connectorName = null, + string language = null, + bool? sentimentAnalysis = null, + string statusCallback = null) : base("VirtualAgent") + { + this.ConnectorName = connectorName; + this.Language = language; + this.SentimentAnalysis = sentimentAnalysis; + this.StatusCallback = statusCallback; + } + + /// + /// Return the attributes of the TwiML tag + /// + protected override List GetElementAttributes() + { + var attributes = new List(); + if (this.ConnectorName != null) + { + attributes.Add(new XAttribute("connectorName", this.ConnectorName)); + } + if (this.Language != null) + { + attributes.Add(new XAttribute("language", this.Language)); + } + if (this.SentimentAnalysis != null) + { + attributes.Add(new XAttribute("sentimentAnalysis", this.SentimentAnalysis.Value.ToString().ToLower())); + } + if (this.StatusCallback != null) + { + attributes.Add(new XAttribute("statusCallback", this.StatusCallback)); + } + return attributes; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new VirtualAgent Append(TwiML childElem) + { + return (VirtualAgent)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new VirtualAgent SetOption(string key, object value) + { + return (VirtualAgent)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/TwiML/VoiceResponse.cs b/src/Twilio/TwiML/VoiceResponse.cs index 4344a9863..114659324 100644 --- a/src/Twilio/TwiML/VoiceResponse.cs +++ b/src/Twilio/TwiML/VoiceResponse.cs @@ -12,720 +12,720 @@ using Twilio.TwiML.Voice; namespace Twilio.TwiML -{ - +{ + + /// + /// Response TwiML for Voice + /// + public class VoiceResponse : TwiML + { /// - /// Response TwiML for Voice + /// Create a new VoiceResponse /// - public class VoiceResponse : TwiML - { - /// - /// Create a new VoiceResponse - /// - public VoiceResponse() : base("Response") - { - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Action URL - /// Action URL method - public VoiceResponse Connect(Uri action = null, Twilio.Http.HttpMethod method = null) - { - var newChild = new Connect(action, method); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Connect instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Connect(Connect connect) - { - this.Append(connect); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Phone number to dial, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// Time to wait for answer - /// Hangup call on star press - /// Max time length - /// Caller ID to display - /// Record the call - /// Trim the recording - /// Recording status callback URL - /// Recording status callback URL method - /// Recording status callback events - /// Preserve the ringing behavior of the inbound call until the Dialed call picks up - /// - /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller - /// while executing the Dial - /// To indicate which audio track should be recorded - /// Used to determine if child TwiML nouns should be dialed in order, one after the other - /// (sequential) or dial all at once (parallel). Default is false, parallel - /// Webhook that will receive future SIP REFER requests - /// The HTTP method to use for the refer Webhook - public VoiceResponse Dial(string number = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - bool? hangupOnStar = null, - int? timeLimit = null, - string callerId = null, - Dial.RecordEnum record = null, - Dial.TrimEnum trim = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - bool? answerOnBridge = null, - Dial.RingToneEnum ringTone = null, - Dial.RecordingTrackEnum recordingTrack = null, - bool? sequential = null, - Uri referUrl = null, - Twilio.Http.HttpMethod referMethod = null) - { - var newChild = new Dial( - number, - action, - method, - timeout, - hangupOnStar, - timeLimit, - callerId, - record, - trim, - recordingStatusCallback, - recordingStatusCallbackMethod, - recordingStatusCallbackEvent, - answerOnBridge, - ringTone, - recordingTrack, - sequential, - referUrl, - referMethod - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Dial instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Dial(Dial dial) - { - this.Append(dial); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - public VoiceResponse Echo() - { - var newChild = new Echo(); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Echo instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Echo(Echo echo) - { - this.Append(echo); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Friendly name, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// Wait URL - /// Wait URL method - /// TaskRouter Workflow SID - public VoiceResponse Enqueue(string name = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri waitUrl = null, - Twilio.Http.HttpMethod waitUrlMethod = null, - string workflowSid = null) - { - var newChild = new Enqueue(name, action, method, waitUrl, waitUrlMethod, workflowSid); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Enqueue instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Enqueue(Enqueue enqueue) - { - this.Append(enqueue); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Input type Twilio should accept - /// Action URL - /// Action URL method - /// Time to wait to gather input - /// Time to wait to gather speech input and it should be either auto or a positive - /// integer. - /// Max allowed time for speech input - /// Profanity Filter on speech - /// Finish gather on key - /// Number of digits to collect - /// Partial result callback URL - /// Partial result callback URL method - /// Language to use - /// Speech recognition hints - /// Stop playing media upon speech - /// Allow debug for gather - /// Force webhook to the action URL event if there is no input - /// Specify the model that is best suited for your use case - /// Use enhanced speech model - public VoiceResponse Gather(List input = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - string speechTimeout = null, - int? maxSpeechTime = null, - bool? profanityFilter = null, - string finishOnKey = null, - int? numDigits = null, - Uri partialResultCallback = null, - Twilio.Http.HttpMethod partialResultCallbackMethod = null, - Gather.LanguageEnum language = null, - string hints = null, - bool? bargeIn = null, - bool? debug = null, - bool? actionOnEmptyResult = null, - Gather.SpeechModelEnum speechModel = null, - bool? enhanced = null) - { - var newChild = new Gather( - input, - action, - method, - timeout, - speechTimeout, - maxSpeechTime, - profanityFilter, - finishOnKey, - numDigits, - partialResultCallback, - partialResultCallbackMethod, - language, - hints, - bargeIn, - debug, - actionOnEmptyResult, - speechModel, - enhanced - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Gather instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Gather(Gather gather) - { - this.Append(gather); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - public VoiceResponse Hangup() - { - var newChild = new Hangup(); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Hangup instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Hangup(Hangup hangup) - { - this.Append(hangup); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - public VoiceResponse Leave() - { - var newChild = new Leave(); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Leave instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Leave(Leave leave) - { - this.Append(leave); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Length in seconds to pause - public VoiceResponse Pause(int? length = null) - { - var newChild = new Pause(length); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Pause instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Pause(Pause pause) - { - this.Append(pause); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Media URL, the body of the TwiML Element. - /// Times to loop media - /// Play DTMF tones for digits - public VoiceResponse Play(Uri url = null, int? loop = null, string digits = null) - { - var newChild = new Play(url, loop, digits); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Play instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Play(Play play) - { - this.Append(play); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Queue name, the body of the TwiML Element. - /// Action URL - /// Action URL method - /// TaskRouter Reservation SID - /// TaskRouter Activity SID - public VoiceResponse Queue(string name = null, - Uri url = null, - Twilio.Http.HttpMethod method = null, - string reservationSid = null, - string postWorkActivitySid = null) - { - var newChild = new Queue(name, url, method, reservationSid, postWorkActivitySid); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Queue instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Queue(Queue queue) - { - this.Append(queue); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Action URL - /// Action URL method - /// Timeout to begin recording - /// Finish recording on key - /// Max time to record in seconds - /// Play beep - /// Trim the recording - /// Status callback URL - /// Status callback URL method - /// Recording status callback events - /// Transcribe the recording - /// Transcribe callback URL - public VoiceResponse Record(Uri action = null, - Twilio.Http.HttpMethod method = null, - int? timeout = null, - string finishOnKey = null, - int? maxLength = null, - bool? playBeep = null, - Record.TrimEnum trim = null, - Uri recordingStatusCallback = null, - Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, - List recordingStatusCallbackEvent = null, - bool? transcribe = null, - Uri transcribeCallback = null) - { - var newChild = new Record( - action, - method, - timeout, - finishOnKey, - maxLength, - playBeep, - trim, - recordingStatusCallback, - recordingStatusCallbackMethod, - recordingStatusCallbackEvent, - transcribe, - transcribeCallback - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Record instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Record(Record record) - { - this.Append(record); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Redirect URL, the body of the TwiML Element. - /// Redirect URL method - public VoiceResponse Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) - { - var newChild = new Redirect(url, method); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Redirect instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Redirect(Redirect redirect) - { - this.Append(redirect); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Rejection reason - public VoiceResponse Reject(Reject.ReasonEnum reason = null) - { - var newChild = new Reject(reason); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Reject instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Reject(Reject reject) - { - this.Append(reject); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message to say, the body of the TwiML Element. - /// Voice to use - /// Times to loop message - /// Message langauge - public VoiceResponse Say(string message = null, - Say.VoiceEnum voice = null, - int? loop = null, - Say.LanguageEnum language = null) - { - var newChild = new Say(message, voice, loop, language); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Say instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Say(Say say) - { - this.Append(say); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Message body, the body of the TwiML Element. - /// Number to send message to - /// Number to send message from - /// Action URL - /// Action URL method - /// Status callback URL - public VoiceResponse Sms(string message = null, - Types.PhoneNumber to = null, - Types.PhoneNumber from = null, - Uri action = null, - Twilio.Http.HttpMethod method = null, - Uri statusCallback = null) - { - var newChild = new Sms(message, to, from, action, method, statusCallback); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Sms instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Sms(Sms sms) - { - this.Append(sms); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Input type Twilio should accept - /// Action URL - /// Bank account type for ach transactions. If set, payment method attribute must be - /// provided and value should be set to ach-debit. defaults to consumer-checking - /// Status callback URL - /// Status callback method - /// Time to wait to gather input - /// Maximum number of allowed retries when gathering input - /// Prompt for security code - /// Prompt for postal code and it should be true/false or default postal code - /// Prompt for minimum postal code length - /// Unique name for payment connector - /// Payment method to be used. defaults to credit-card - /// Type of token - /// Amount to process. If value is greater than 0 then make the payment else create a - /// payment token - /// Currency of the amount attribute - /// Details regarding the payment - /// Comma separated accepted card types - /// Language to use - public VoiceResponse Pay(Pay.InputEnum input = null, - Uri action = null, - Pay.BankAccountTypeEnum bankAccountType = null, - Uri statusCallback = null, - Pay.StatusCallbackMethodEnum statusCallbackMethod = null, - int? timeout = null, - int? maxAttempts = null, - bool? securityCode = null, - string postalCode = null, - int? minPostalCodeLength = null, - string paymentConnector = null, - Pay.PaymentMethodEnum paymentMethod = null, - Pay.TokenTypeEnum tokenType = null, - string chargeAmount = null, - string currency = null, - string description = null, - List validCardTypes = null, - Pay.LanguageEnum language = null) - { - var newChild = new Pay( - input, - action, - bankAccountType, - statusCallback, - statusCallbackMethod, - timeout, - maxAttempts, - securityCode, - postalCode, - minPostalCodeLength, - paymentConnector, - paymentMethod, - tokenType, - chargeAmount, - currency, - description, - validCardTypes, - language - ); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Pay instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Pay(Pay pay) - { - this.Append(pay); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Name of the payment source data element - /// Type of error - /// Type of the credit card - /// Current attempt count - public VoiceResponse Prompt(Prompt.ForEnum for_ = null, - List errorType = null, - List cardType = null, - List attempt = null) - { - var newChild = new Prompt(for_, errorType, cardType, attempt); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Prompt instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Prompt(Prompt prompt) - { - this.Append(prompt); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Action URL - /// Action URL method - public VoiceResponse Start(Uri action = null, Twilio.Http.HttpMethod method = null) - { - var newChild = new Start(action, method); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Start instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Start(Start start) - { - this.Append(start); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - public VoiceResponse Stop() - { - var newChild = new Stop(); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Stop instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Stop(Stop stop) - { - this.Append(stop); - return this; - } - - /// - /// Create a new element and append it as a child of this element. - /// - /// Action URL - /// Action URL method - public VoiceResponse Refer(Uri action = null, Twilio.Http.HttpMethod method = null) - { - var newChild = new Refer(action, method); - this.Append(newChild); - return this; - } - - /// - /// Append a element as a child of this element - /// - /// A Refer instance. - [System.Obsolete("This method is deprecated, use .Append() instead.")] - public VoiceResponse Refer(Refer refer) - { - this.Append(refer); - return this; - } - - /// - /// Append a child TwiML element to this element returning this element to allow chaining. - /// - /// Child TwiML element to add - public new VoiceResponse Append(TwiML childElem) - { - return (VoiceResponse) base.Append(childElem); - } - - /// - /// Add freeform key-value attributes to the generated xml - /// - /// Option key - /// Option value - public new VoiceResponse SetOption(string key, object value) - { - return (VoiceResponse) base.SetOption(key, value); - } - } + public VoiceResponse() : base("Response") + { + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Action URL + /// Action URL method + public VoiceResponse Connect(Uri action = null, Twilio.Http.HttpMethod method = null) + { + var newChild = new Connect(action, method); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Connect instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Connect(Connect connect) + { + this.Append(connect); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Phone number to dial, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// Time to wait for answer + /// Hangup call on star press + /// Max time length + /// Caller ID to display + /// Record the call + /// Trim the recording + /// Recording status callback URL + /// Recording status callback URL method + /// Recording status callback events + /// Preserve the ringing behavior of the inbound call until the Dialed call picks up + /// + /// Ringtone allows you to override the ringback tone that Twilio will play back to the caller + /// while executing the Dial + /// To indicate which audio track should be recorded + /// Used to determine if child TwiML nouns should be dialed in order, one after the other + /// (sequential) or dial all at once (parallel). Default is false, parallel + /// Webhook that will receive future SIP REFER requests + /// The HTTP method to use for the refer Webhook + public VoiceResponse Dial(string number = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + bool? hangupOnStar = null, + int? timeLimit = null, + string callerId = null, + Dial.RecordEnum record = null, + Dial.TrimEnum trim = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + bool? answerOnBridge = null, + Dial.RingToneEnum ringTone = null, + Dial.RecordingTrackEnum recordingTrack = null, + bool? sequential = null, + Uri referUrl = null, + Twilio.Http.HttpMethod referMethod = null) + { + var newChild = new Dial( + number, + action, + method, + timeout, + hangupOnStar, + timeLimit, + callerId, + record, + trim, + recordingStatusCallback, + recordingStatusCallbackMethod, + recordingStatusCallbackEvent, + answerOnBridge, + ringTone, + recordingTrack, + sequential, + referUrl, + referMethod + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Dial instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Dial(Dial dial) + { + this.Append(dial); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + public VoiceResponse Echo() + { + var newChild = new Echo(); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Echo instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Echo(Echo echo) + { + this.Append(echo); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Friendly name, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// Wait URL + /// Wait URL method + /// TaskRouter Workflow SID + public VoiceResponse Enqueue(string name = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri waitUrl = null, + Twilio.Http.HttpMethod waitUrlMethod = null, + string workflowSid = null) + { + var newChild = new Enqueue(name, action, method, waitUrl, waitUrlMethod, workflowSid); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Enqueue instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Enqueue(Enqueue enqueue) + { + this.Append(enqueue); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Input type Twilio should accept + /// Action URL + /// Action URL method + /// Time to wait to gather input + /// Time to wait to gather speech input and it should be either auto or a positive + /// integer. + /// Max allowed time for speech input + /// Profanity Filter on speech + /// Finish gather on key + /// Number of digits to collect + /// Partial result callback URL + /// Partial result callback URL method + /// Language to use + /// Speech recognition hints + /// Stop playing media upon speech + /// Allow debug for gather + /// Force webhook to the action URL event if there is no input + /// Specify the model that is best suited for your use case + /// Use enhanced speech model + public VoiceResponse Gather(List input = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + string speechTimeout = null, + int? maxSpeechTime = null, + bool? profanityFilter = null, + string finishOnKey = null, + int? numDigits = null, + Uri partialResultCallback = null, + Twilio.Http.HttpMethod partialResultCallbackMethod = null, + Gather.LanguageEnum language = null, + string hints = null, + bool? bargeIn = null, + bool? debug = null, + bool? actionOnEmptyResult = null, + Gather.SpeechModelEnum speechModel = null, + bool? enhanced = null) + { + var newChild = new Gather( + input, + action, + method, + timeout, + speechTimeout, + maxSpeechTime, + profanityFilter, + finishOnKey, + numDigits, + partialResultCallback, + partialResultCallbackMethod, + language, + hints, + bargeIn, + debug, + actionOnEmptyResult, + speechModel, + enhanced + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Gather instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Gather(Gather gather) + { + this.Append(gather); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + public VoiceResponse Hangup() + { + var newChild = new Hangup(); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Hangup instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Hangup(Hangup hangup) + { + this.Append(hangup); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + public VoiceResponse Leave() + { + var newChild = new Leave(); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Leave instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Leave(Leave leave) + { + this.Append(leave); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Length in seconds to pause + public VoiceResponse Pause(int? length = null) + { + var newChild = new Pause(length); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Pause instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Pause(Pause pause) + { + this.Append(pause); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Media URL, the body of the TwiML Element. + /// Times to loop media + /// Play DTMF tones for digits + public VoiceResponse Play(Uri url = null, int? loop = null, string digits = null) + { + var newChild = new Play(url, loop, digits); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Play instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Play(Play play) + { + this.Append(play); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Queue name, the body of the TwiML Element. + /// Action URL + /// Action URL method + /// TaskRouter Reservation SID + /// TaskRouter Activity SID + public VoiceResponse Queue(string name = null, + Uri url = null, + Twilio.Http.HttpMethod method = null, + string reservationSid = null, + string postWorkActivitySid = null) + { + var newChild = new Queue(name, url, method, reservationSid, postWorkActivitySid); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Queue instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Queue(Queue queue) + { + this.Append(queue); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Action URL + /// Action URL method + /// Timeout to begin recording + /// Finish recording on key + /// Max time to record in seconds + /// Play beep + /// Trim the recording + /// Status callback URL + /// Status callback URL method + /// Recording status callback events + /// Transcribe the recording + /// Transcribe callback URL + public VoiceResponse Record(Uri action = null, + Twilio.Http.HttpMethod method = null, + int? timeout = null, + string finishOnKey = null, + int? maxLength = null, + bool? playBeep = null, + Record.TrimEnum trim = null, + Uri recordingStatusCallback = null, + Twilio.Http.HttpMethod recordingStatusCallbackMethod = null, + List recordingStatusCallbackEvent = null, + bool? transcribe = null, + Uri transcribeCallback = null) + { + var newChild = new Record( + action, + method, + timeout, + finishOnKey, + maxLength, + playBeep, + trim, + recordingStatusCallback, + recordingStatusCallbackMethod, + recordingStatusCallbackEvent, + transcribe, + transcribeCallback + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Record instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Record(Record record) + { + this.Append(record); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Redirect URL, the body of the TwiML Element. + /// Redirect URL method + public VoiceResponse Redirect(Uri url = null, Twilio.Http.HttpMethod method = null) + { + var newChild = new Redirect(url, method); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Redirect instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Redirect(Redirect redirect) + { + this.Append(redirect); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Rejection reason + public VoiceResponse Reject(Reject.ReasonEnum reason = null) + { + var newChild = new Reject(reason); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Reject instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Reject(Reject reject) + { + this.Append(reject); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message to say, the body of the TwiML Element. + /// Voice to use + /// Times to loop message + /// Message langauge + public VoiceResponse Say(string message = null, + Say.VoiceEnum voice = null, + int? loop = null, + Say.LanguageEnum language = null) + { + var newChild = new Say(message, voice, loop, language); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Say instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Say(Say say) + { + this.Append(say); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Message body, the body of the TwiML Element. + /// Number to send message to + /// Number to send message from + /// Action URL + /// Action URL method + /// Status callback URL + public VoiceResponse Sms(string message = null, + Types.PhoneNumber to = null, + Types.PhoneNumber from = null, + Uri action = null, + Twilio.Http.HttpMethod method = null, + Uri statusCallback = null) + { + var newChild = new Sms(message, to, from, action, method, statusCallback); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Sms instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Sms(Sms sms) + { + this.Append(sms); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Input type Twilio should accept + /// Action URL + /// Bank account type for ach transactions. If set, payment method attribute must be + /// provided and value should be set to ach-debit. defaults to consumer-checking + /// Status callback URL + /// Status callback method + /// Time to wait to gather input + /// Maximum number of allowed retries when gathering input + /// Prompt for security code + /// Prompt for postal code and it should be true/false or default postal code + /// Prompt for minimum postal code length + /// Unique name for payment connector + /// Payment method to be used. defaults to credit-card + /// Type of token + /// Amount to process. If value is greater than 0 then make the payment else create a + /// payment token + /// Currency of the amount attribute + /// Details regarding the payment + /// Comma separated accepted card types + /// Language to use + public VoiceResponse Pay(Pay.InputEnum input = null, + Uri action = null, + Pay.BankAccountTypeEnum bankAccountType = null, + Uri statusCallback = null, + Pay.StatusCallbackMethodEnum statusCallbackMethod = null, + int? timeout = null, + int? maxAttempts = null, + bool? securityCode = null, + string postalCode = null, + int? minPostalCodeLength = null, + string paymentConnector = null, + Pay.PaymentMethodEnum paymentMethod = null, + Pay.TokenTypeEnum tokenType = null, + string chargeAmount = null, + string currency = null, + string description = null, + List validCardTypes = null, + Pay.LanguageEnum language = null) + { + var newChild = new Pay( + input, + action, + bankAccountType, + statusCallback, + statusCallbackMethod, + timeout, + maxAttempts, + securityCode, + postalCode, + minPostalCodeLength, + paymentConnector, + paymentMethod, + tokenType, + chargeAmount, + currency, + description, + validCardTypes, + language + ); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Pay instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Pay(Pay pay) + { + this.Append(pay); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Name of the payment source data element + /// Type of error + /// Type of the credit card + /// Current attempt count + public VoiceResponse Prompt(Prompt.ForEnum for_ = null, + List errorType = null, + List cardType = null, + List attempt = null) + { + var newChild = new Prompt(for_, errorType, cardType, attempt); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Prompt instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Prompt(Prompt prompt) + { + this.Append(prompt); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Action URL + /// Action URL method + public VoiceResponse Start(Uri action = null, Twilio.Http.HttpMethod method = null) + { + var newChild = new Start(action, method); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Start instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Start(Start start) + { + this.Append(start); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + public VoiceResponse Stop() + { + var newChild = new Stop(); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Stop instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Stop(Stop stop) + { + this.Append(stop); + return this; + } + + /// + /// Create a new element and append it as a child of this element. + /// + /// Action URL + /// Action URL method + public VoiceResponse Refer(Uri action = null, Twilio.Http.HttpMethod method = null) + { + var newChild = new Refer(action, method); + this.Append(newChild); + return this; + } + + /// + /// Append a element as a child of this element + /// + /// A Refer instance. + [System.Obsolete("This method is deprecated, use .Append() instead.")] + public VoiceResponse Refer(Refer refer) + { + this.Append(refer); + return this; + } + + /// + /// Append a child TwiML element to this element returning this element to allow chaining. + /// + /// Child TwiML element to add + public new VoiceResponse Append(TwiML childElem) + { + return (VoiceResponse)base.Append(childElem); + } + + /// + /// Add freeform key-value attributes to the generated xml + /// + /// Option key + /// Option value + public new VoiceResponse SetOption(string key, object value) + { + return (VoiceResponse)base.SetOption(key, value); + } + } } \ No newline at end of file diff --git a/src/Twilio/Twilio.cs b/src/Twilio/Twilio.cs index 3d3aa03b9..4a3a7607f 100644 --- a/src/Twilio/Twilio.cs +++ b/src/Twilio/Twilio.cs @@ -2,194 +2,194 @@ using Twilio.Exceptions; namespace Twilio -{ +{ + /// + /// Default Twilio Client + /// + public class TwilioClient + { + private static string _username; + private static string _password; + private static string _accountSid; + private static string _region; + private static string _edge; + private static ITwilioRestClient _restClient; + private static string _logLevel; + + private TwilioClient() { } + /// - /// Default Twilio Client + /// Initialize base client with username and password /// - public class TwilioClient - { - private static string _username; - private static string _password; - private static string _accountSid; - private static string _region; - private static string _edge; - private static ITwilioRestClient _restClient; - private static string _logLevel; - - private TwilioClient() { } - - /// - /// Initialize base client with username and password - /// - /// Auth username - /// Auth password - public static void Init(string username, string password) - { - SetUsername(username); - SetPassword(password); - } - - /// - /// Initialize base client with separate account SID - /// - /// Auth username - /// Auth password - /// Account SID to use - public static void Init(string username, string password, string accountSid) - { - SetUsername(username); - SetPassword(password); - SetAccountSid(accountSid); - } - - /// - /// Set the client username - /// - /// Auth username - public static void SetUsername(string username) - { - if (username == null) - { - throw new AuthenticationException("Username can not be null"); - } - - if (username != _username) - { - Invalidate(); - } - - _username = username; - } - - /// - /// Set the client password - /// - /// Auth password - public static void SetPassword(string password) - { - if (password == null) - { - throw new AuthenticationException("Password can not be null"); - } - - if (password != _password) - { - Invalidate(); - } - - _password = password; - } - - /// - /// Set the client Account SID - /// - /// Client Account SID - public static void SetAccountSid(string accountSid) - { - if (accountSid == null) - { - throw new AuthenticationException("AccountSid can not be null"); - } - - if (accountSid != _accountSid) - { - Invalidate(); - } - - _accountSid = accountSid; - } - - /// - /// Set the client region - /// - /// Client region - public static void SetRegion(string region) - { - if (region != _region) - { - Invalidate(); - } - - _region = region; - } - - /// - /// Set the client edge - /// - /// Client edge - public static void SetEdge(string edge) - { - if (edge != _edge) - { - Invalidate(); - } - - _edge = edge; - } - - /// - /// Set the logging level - /// - /// log level - public static void SetLogLevel(string loglevel) - { - if (loglevel != _logLevel) - { - Invalidate(); - } - - _logLevel = loglevel; - } - - /// - /// Get the rest client - /// - /// The rest client - public static ITwilioRestClient GetRestClient() - { - if (_restClient != null) - { - return _restClient; - } - - if (_username == null || _password == null) - { - throw new AuthenticationException( - "TwilioRestClient was used before AccountSid and AuthToken were set, please call TwilioClient.init()" - ); - } - - _restClient = new TwilioRestClient(_username, _password, accountSid: _accountSid, region: _region, edge: _edge) - { - LogLevel = _logLevel - }; - return _restClient; - } - - /// - /// Set the rest client - /// - /// Rest Client to use - public static void SetRestClient(ITwilioRestClient restClient) - { - _restClient = restClient; - } - - /// - /// Clear out the Rest Client - /// - public static void Invalidate() - { - _restClient = null; - } - - /// - /// Validates that the Twilio Client can connect to api.twilio.com with - /// a new SSL certificate posted at api.twilio.com:8443 - /// - public static void ValidateSslCertificate() - { - TwilioRestClient.ValidateSslCertificate(); - } - } + /// Auth username + /// Auth password + public static void Init(string username, string password) + { + SetUsername(username); + SetPassword(password); + } + + /// + /// Initialize base client with separate account SID + /// + /// Auth username + /// Auth password + /// Account SID to use + public static void Init(string username, string password, string accountSid) + { + SetUsername(username); + SetPassword(password); + SetAccountSid(accountSid); + } + + /// + /// Set the client username + /// + /// Auth username + public static void SetUsername(string username) + { + if (username == null) + { + throw new AuthenticationException("Username can not be null"); + } + + if (username != _username) + { + Invalidate(); + } + + _username = username; + } + + /// + /// Set the client password + /// + /// Auth password + public static void SetPassword(string password) + { + if (password == null) + { + throw new AuthenticationException("Password can not be null"); + } + + if (password != _password) + { + Invalidate(); + } + + _password = password; + } + + /// + /// Set the client Account SID + /// + /// Client Account SID + public static void SetAccountSid(string accountSid) + { + if (accountSid == null) + { + throw new AuthenticationException("AccountSid can not be null"); + } + + if (accountSid != _accountSid) + { + Invalidate(); + } + + _accountSid = accountSid; + } + + /// + /// Set the client region + /// + /// Client region + public static void SetRegion(string region) + { + if (region != _region) + { + Invalidate(); + } + + _region = region; + } + + /// + /// Set the client edge + /// + /// Client edge + public static void SetEdge(string edge) + { + if (edge != _edge) + { + Invalidate(); + } + + _edge = edge; + } + + /// + /// Set the logging level + /// + /// log level + public static void SetLogLevel(string loglevel) + { + if (loglevel != _logLevel) + { + Invalidate(); + } + + _logLevel = loglevel; + } + + /// + /// Get the rest client + /// + /// The rest client + public static ITwilioRestClient GetRestClient() + { + if (_restClient != null) + { + return _restClient; + } + + if (_username == null || _password == null) + { + throw new AuthenticationException( + "TwilioRestClient was used before AccountSid and AuthToken were set, please call TwilioClient.init()" + ); + } + + _restClient = new TwilioRestClient(_username, _password, accountSid: _accountSid, region: _region, edge: _edge) + { + LogLevel = _logLevel + }; + return _restClient; + } + + /// + /// Set the rest client + /// + /// Rest Client to use + public static void SetRestClient(ITwilioRestClient restClient) + { + _restClient = restClient; + } + + /// + /// Clear out the Rest Client + /// + public static void Invalidate() + { + _restClient = null; + } + + /// + /// Validates that the Twilio Client can connect to api.twilio.com with + /// a new SSL certificate posted at api.twilio.com:8443 + /// + public static void ValidateSslCertificate() + { + TwilioRestClient.ValidateSslCertificate(); + } + } } diff --git a/src/Twilio/Twilio.csproj b/src/Twilio/Twilio.csproj index c02ee2e7d..b9f8bc267 100644 --- a/src/Twilio/Twilio.csproj +++ b/src/Twilio/Twilio.csproj @@ -1,59 +1,32 @@ - - - netstandard1.4;netstandard2.0;net451;net35 - true - Twilio - Twilio REST API helper library - Copyright © Twilio - Twilio - en-US - 5.69.0 - - - Twilio - $(NoWarn);CS1591 - true - true - Twilio - REST;SMS;voice;telephony;phone;twilio;twiml;video;wireless;api - https://www.twilio.com/docs/static/company/img/logos/red/twilio-mark-red.898073bba.png - http://github.com/twilio/twilio-csharp - https://github.com/twilio/twilio-csharp/blob/HEAD/LICENSE - http://github.com/twilio/twilio-csharp - git - 1.6.1 - 2.0.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + net6.0 + enable + true + Twilio + Twilio REST API helper library + Copyright © Twilio + Twilio + en-US + Twilio + CS1587;CS1591;CS1570;CS1573;CS1572;CS8618;CS8603;CS8625;CS8604;CS8765 + true + true + Twilio + REST;SMS;voice;telephony;phone;twilio;twiml;video;wireless;api + https://www.twilio.com/docs/static/company/img/logos/red/twilio-mark-red.898073bba.png + http://github.com/twilio/twilio-csharp + https://github.com/twilio/twilio-csharp/blob/HEAD/LICENSE + http://github.com/twilio/twilio-csharp + git + True + 6.0.0 + + + + + + + + + diff --git a/src/Twilio/Types/Client.cs b/src/Twilio/Types/Client.cs index c8b6d2a26..a63b6965e 100644 --- a/src/Twilio/Types/Client.cs +++ b/src/Twilio/Types/Client.cs @@ -1,35 +1,35 @@ namespace Twilio.Types -{ +{ + /// + /// Client Endpoint + /// + public class Client : IEndpoint + { + public const string PREFIX = "client:"; + + private readonly string _client; + /// - /// Client Endpoint + /// Create new client /// - public class Client : IEndpoint - { - public const string PREFIX = "client:"; - - private readonly string _client; - - /// - /// Create new client - /// - /// Client name - public Client(string client) - { - if (!client.ToLower().StartsWith(PREFIX)) - { - client = PREFIX + client; - } - - _client = client; - } - - /// - /// Convert to string - /// - /// String representation - public override string ToString() - { - return _client; - } - } + /// Client name + public Client(string client) + { + if (!client.ToLower().StartsWith(PREFIX)) + { + client = PREFIX + client; + } + + _client = client; + } + + /// + /// Convert to string + /// + /// String representation + public override string ToString() + { + return _client; + } + } } diff --git a/src/Twilio/Types/EmptyUrl.cs b/src/Twilio/Types/EmptyUrl.cs index f0880a301..d3f67d813 100644 --- a/src/Twilio/Types/EmptyUrl.cs +++ b/src/Twilio/Types/EmptyUrl.cs @@ -1,12 +1,13 @@ using System.Net; -namespace Twilio.Types { - - public class EmptyUri : System.Uri - { - public static readonly string Uri = "https://this.is.empty.url"; - - public EmptyUri() : base(Uri) {} - } +namespace Twilio.Types +{ + + public class EmptyUri : System.Uri + { + public static readonly string Uri = "https://this.is.empty.url"; + + public EmptyUri() : base(Uri) { } + } } diff --git a/src/Twilio/Types/FeedbackIssue.cs b/src/Twilio/Types/FeedbackIssue.cs index b00b7c013..bb51bd719 100644 --- a/src/Twilio/Types/FeedbackIssue.cs +++ b/src/Twilio/Types/FeedbackIssue.cs @@ -1,42 +1,42 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// Feedback issue POCO + /// + public class FeedbackIssue + { /// - /// Feedback issue POCO + /// Number of occurrences /// - public class FeedbackIssue - { - /// - /// Number of occurrences - /// - [JsonProperty("count")] - public int Count { get; } - - /// - /// Description of issue - /// - [JsonProperty("description")] - public string Description { get; } - - /// - /// Percentage of calls affected - /// - [JsonProperty("percentage_of_total_calls")] - public string PercentageOfTotalCalls { get; } - - /// - /// Create new FeedbackIssue - /// - /// Number of occurrences - /// Description of issue - /// Percentage of calls affected - public FeedbackIssue(int count, string description, string percentageOfTotalCalls) - { - Count = count; - Description = description; - PercentageOfTotalCalls = percentageOfTotalCalls; - } - } + [JsonProperty("count")] + public int Count { get; } + + /// + /// Description of issue + /// + [JsonProperty("description")] + public string Description { get; } + + /// + /// Percentage of calls affected + /// + [JsonProperty("percentage_of_total_calls")] + public string PercentageOfTotalCalls { get; } + + /// + /// Create new FeedbackIssue + /// + /// Number of occurrences + /// Description of issue + /// Percentage of calls affected + public FeedbackIssue(int count, string description, string percentageOfTotalCalls) + { + Count = count; + Description = description; + PercentageOfTotalCalls = percentageOfTotalCalls; + } + } } diff --git a/src/Twilio/Types/IEndpoint.cs b/src/Twilio/Types/IEndpoint.cs index bd7ee8e35..7a3fb1048 100644 --- a/src/Twilio/Types/IEndpoint.cs +++ b/src/Twilio/Types/IEndpoint.cs @@ -1,15 +1,15 @@ namespace Twilio.Types -{ +{ + /// + /// Endpoint of a call + /// + public interface IEndpoint + { /// - /// Endpoint of a call + /// Generate string representation /// - public interface IEndpoint - { - /// - /// Generate string representation - /// - /// String representation - string ToString(); - } + /// String representation + string ToString(); + } } diff --git a/src/Twilio/Types/IceServer.cs b/src/Twilio/Types/IceServer.cs index 83fa187d2..819b6247f 100644 --- a/src/Twilio/Types/IceServer.cs +++ b/src/Twilio/Types/IceServer.cs @@ -2,49 +2,50 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// Ice Server POCO + /// + public class IceServer + { /// - /// Ice Server POCO + /// Ice Server credential /// - public class IceServer - { - /// - /// Ice Server credential - /// - [JsonProperty("credential")] - public string Credential { get; } - - /// - /// Username for server - /// - [JsonProperty("username")] - public string Username { get; } - - /// - /// Server URL - /// - [JsonProperty("url")] - public Uri Url { get; } - - /// - /// Server URL - /// - [JsonProperty("urls")] - public Uri Urls { get; } - - /// - /// Create a new IceServer - /// - /// Ice Server credential - /// Server username - /// Server URL - /// Server URL - public IceServer(string credential, string username, Uri url, Uri urls) { - Credential = credential; - Username = username; - Url = url; - Urls = urls; - } - } + [JsonProperty("credential")] + public string Credential { get; } + + /// + /// Username for server + /// + [JsonProperty("username")] + public string Username { get; } + + /// + /// Server URL + /// + [JsonProperty("url")] + public Uri Url { get; } + + /// + /// Server URL + /// + [JsonProperty("urls")] + public Uri Urls { get; } + + /// + /// Create a new IceServer + /// + /// Ice Server credential + /// Server username + /// Server URL + /// Server URL + public IceServer(string credential, string username, Uri url, Uri urls) + { + Credential = credential; + Username = username; + Url = url; + Urls = urls; + } + } } diff --git a/src/Twilio/Types/InboundCallPrice.cs b/src/Twilio/Types/InboundCallPrice.cs index c25b5d2bd..e6d292c83 100644 --- a/src/Twilio/Types/InboundCallPrice.cs +++ b/src/Twilio/Types/InboundCallPrice.cs @@ -2,81 +2,82 @@ using Twilio.Converters; namespace Twilio.Types -{ +{ + /// + /// POCO to represent an inbound call price + /// + public class InboundCallPrice + { /// - /// POCO to represent an inbound call price + /// Types of inbound numbers /// - public class InboundCallPrice - { - /// - /// Types of inbound numbers - /// - public sealed class TypeEnum : StringEnum { - private TypeEnum(string value) : base(value) {} - - /// - /// Generic constructor - /// - public TypeEnum() {} - - /// - /// Local number type - /// - public static readonly TypeEnum Local = new TypeEnum("local"); - - /// - /// Mobile number type - /// - public static readonly TypeEnum Mobile = new TypeEnum("mobile"); - - /// - /// National number type - /// - public static readonly TypeEnum National = new TypeEnum("national"); - - /// - /// Toll Free number type - /// - public static readonly TypeEnum TollFree = new TypeEnum("toll free"); - } - - /// - /// Base price of calls - /// + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + + /// + /// Generic constructor + /// + public TypeEnum() { } + + /// + /// Local number type + /// + public static readonly TypeEnum Local = new TypeEnum("local"); + + /// + /// Mobile number type + /// + public static readonly TypeEnum Mobile = new TypeEnum("mobile"); + + /// + /// National number type + /// + public static readonly TypeEnum National = new TypeEnum("national"); + + /// + /// Toll Free number type + /// + public static readonly TypeEnum TollFree = new TypeEnum("toll free"); + } + + /// + /// Base price of calls + /// + [JsonProperty("base_price")] + public double? BasePrice { get; private set; } + + /// + /// Current price of calls + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; private set; } + + /// + /// Type of number + /// + [JsonProperty("number_type")] + [JsonConverter(typeof(StringEnumConverter))] + public TypeEnum NumberType { get; private set; } + + /// + /// Empty constructor + /// + public InboundCallPrice() { } + + private InboundCallPrice( [JsonProperty("base_price")] - public double? BasePrice { get; private set; } - - /// - /// Current price of calls - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; private set; } - - /// - /// Type of number - /// + double? basePrice, + [JsonProperty("current_priece")] + double? currentPrice, [JsonProperty("number_type")] - [JsonConverter(typeof(StringEnumConverter))] - public TypeEnum NumberType { get; private set; } - - /// - /// Empty constructor - /// - public InboundCallPrice() {} - - private InboundCallPrice( - [JsonProperty("base_price")] - double? basePrice, - [JsonProperty("current_priece")] - double? currentPrice, - [JsonProperty("number_type")] - TypeEnum numberType - ) - { - BasePrice = basePrice; - CurrentPrice = currentPrice; - NumberType = numberType; - } - } + TypeEnum numberType + ) + { + BasePrice = basePrice; + CurrentPrice = currentPrice; + NumberType = numberType; + } + } } diff --git a/src/Twilio/Types/InboundSmsPrice.cs b/src/Twilio/Types/InboundSmsPrice.cs index 6222530b8..2c3a59fe5 100644 --- a/src/Twilio/Types/InboundSmsPrice.cs +++ b/src/Twilio/Types/InboundSmsPrice.cs @@ -2,81 +2,82 @@ using Twilio.Converters; namespace Twilio.Types -{ +{ + /// + /// POCO for inbound SMS prices + /// + public class InboundSmsPrice + { /// - /// POCO for inbound SMS prices + /// Phone number types /// - public class InboundSmsPrice - { - /// - /// Phone number types - /// - public sealed class TypeEnum : StringEnum { - private TypeEnum(string value) : base(value) {} - - /// - /// Generic constructor - /// - public TypeEnum() {} - - /// - /// Local number type - /// - public static readonly TypeEnum Local = new TypeEnum("local"); - - /// - /// Mobile number type - /// - public static readonly TypeEnum Mobile = new TypeEnum("mobile"); - - /// - /// National number type - /// - public static readonly TypeEnum National = new TypeEnum("national"); - - /// - /// Toll Free number type - /// - public static readonly TypeEnum TollFree = new TypeEnum("toll free"); - } - - /// - /// Base price for SMS - /// + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + + /// + /// Generic constructor + /// + public TypeEnum() { } + + /// + /// Local number type + /// + public static readonly TypeEnum Local = new TypeEnum("local"); + + /// + /// Mobile number type + /// + public static readonly TypeEnum Mobile = new TypeEnum("mobile"); + + /// + /// National number type + /// + public static readonly TypeEnum National = new TypeEnum("national"); + + /// + /// Toll Free number type + /// + public static readonly TypeEnum TollFree = new TypeEnum("toll free"); + } + + /// + /// Base price for SMS + /// + [JsonProperty("base_price")] + public double? BasePrice { get; private set; } + + /// + /// Current price for SMS + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; private set; } + + /// + /// Type of number + /// + [JsonProperty("number_type")] + [JsonConverter(typeof(StringEnumConverter))] + public TypeEnum NumberType { get; private set; } + + /// + /// Generic constructor + /// + public InboundSmsPrice() { } + + private InboundSmsPrice( [JsonProperty("base_price")] - public double? BasePrice { get; private set; } - - /// - /// Current price for SMS - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; private set; } - - /// - /// Type of number - /// + double? basePrice, + [JsonProperty("current_priece")] + double? currentPrice, [JsonProperty("number_type")] - [JsonConverter(typeof(StringEnumConverter))] - public TypeEnum NumberType { get; private set; } - - /// - /// Generic constructor - /// - public InboundSmsPrice() {} - - private InboundSmsPrice( - [JsonProperty("base_price")] - double? basePrice, - [JsonProperty("current_priece")] - double? currentPrice, - [JsonProperty("number_type")] - TypeEnum numberType - ) - { - BasePrice = basePrice; - CurrentPrice = currentPrice; - NumberType = numberType; - } - } + TypeEnum numberType + ) + { + BasePrice = basePrice; + CurrentPrice = currentPrice; + NumberType = numberType; + } + } } diff --git a/src/Twilio/Types/OutboundCallPrice.cs b/src/Twilio/Types/OutboundCallPrice.cs index f0fe0e0a6..6844fce9d 100644 --- a/src/Twilio/Types/OutboundCallPrice.cs +++ b/src/Twilio/Types/OutboundCallPrice.cs @@ -1,35 +1,35 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// POCO for outbound call prices + /// + public class OutboundCallPrice + { /// - /// POCO for outbound call prices + /// Base price of outbound call /// - public class OutboundCallPrice - { - /// - /// Base price of outbound call - /// - [JsonProperty("base_price")] - public double? BasePrice { get; } - - /// - /// Current price of outbound call - /// - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; } - - /// - /// Create a new OutboundCallPrice - /// - /// Base price of call - /// Current price of call - public OutboundCallPrice (double basePrice, double currentPrice) - { - BasePrice = basePrice; - CurrentPrice = currentPrice; - } - } + [JsonProperty("base_price")] + public double? BasePrice { get; } + + /// + /// Current price of outbound call + /// + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; } + + /// + /// Create a new OutboundCallPrice + /// + /// Base price of call + /// Current price of call + public OutboundCallPrice(double basePrice, double currentPrice) + { + BasePrice = basePrice; + CurrentPrice = currentPrice; + } + } } diff --git a/src/Twilio/Types/OutboundCallPriceWithOrigin.cs b/src/Twilio/Types/OutboundCallPriceWithOrigin.cs index 6a0a04929..dcb9eb56e 100644 --- a/src/Twilio/Types/OutboundCallPriceWithOrigin.cs +++ b/src/Twilio/Types/OutboundCallPriceWithOrigin.cs @@ -2,42 +2,44 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// POCO for outbound call price with origin + /// + public class OutboundCallPriceWithOrigin + { + /// - /// POCO for outbound call price with origin + /// Base price of outbound call /// - public class OutboundCallPriceWithOrigin { - - /// - /// Base price of outbound call - /// - [JsonProperty("base_price")] - public double? BasePrice { get; } - - /// - /// Current price of outbound call - /// - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; } - - /// - /// List of origination prefixes of outbound call - /// - /// - [JsonProperty("origination_prefixes")] - public List OriginationPrefixes { get; } - - /// - /// Create a new OutboundCallPriceWithOrigin - /// - /// Base price of call - /// Current price of call - /// List of origination prefixes of call - public OutboundCallPriceWithOrigin (double basePrice, double currentPrice, List originationPrefixes) { - BasePrice = basePrice; - CurrentPrice = currentPrice; - OriginationPrefixes = originationPrefixes; - } - } + [JsonProperty("base_price")] + public double? BasePrice { get; } + + /// + /// Current price of outbound call + /// + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; } + + /// + /// List of origination prefixes of outbound call + /// + /// + [JsonProperty("origination_prefixes")] + public List OriginationPrefixes { get; } + + /// + /// Create a new OutboundCallPriceWithOrigin + /// + /// Base price of call + /// Current price of call + /// List of origination prefixes of call + public OutboundCallPriceWithOrigin(double basePrice, double currentPrice, List originationPrefixes) + { + BasePrice = basePrice; + CurrentPrice = currentPrice; + OriginationPrefixes = originationPrefixes; + } + } } \ No newline at end of file diff --git a/src/Twilio/Types/OutboundPrefixPrice.cs b/src/Twilio/Types/OutboundPrefixPrice.cs index a3ea41f1f..eba377f80 100644 --- a/src/Twilio/Types/OutboundPrefixPrice.cs +++ b/src/Twilio/Types/OutboundPrefixPrice.cs @@ -2,55 +2,55 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// POCO for outbound prefix prices + /// + public class OutboundPrefixPrice + { /// - /// POCO for outbound prefix prices + /// Prefix list /// - public class OutboundPrefixPrice - { - /// - /// Prefix list - /// - [JsonProperty("prefixes")] - public List Prefixes { get; } - - /// - /// Prefix friendly name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; } - - /// - /// Base price for prefix - /// - [JsonProperty("base_price")] - public double? BasePrice { get; } - - /// - /// Current price of prefix - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; } - - /// - /// Create a new OutboundPrefixPrice - /// - /// List of prefixes - /// Prefix friendly name - /// Base price of prefix - /// Current price of prefix - public OutboundPrefixPrice ( - List prefixes, - string friendlyName, - double basePrice, - double currentPrice - ) - { - Prefixes = prefixes; - FriendlyName = friendlyName; - BasePrice = basePrice; - CurrentPrice = currentPrice; - } - } + [JsonProperty("prefixes")] + public List Prefixes { get; } + + /// + /// Prefix friendly name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; } + + /// + /// Base price for prefix + /// + [JsonProperty("base_price")] + public double? BasePrice { get; } + + /// + /// Current price of prefix + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; } + + /// + /// Create a new OutboundPrefixPrice + /// + /// List of prefixes + /// Prefix friendly name + /// Base price of prefix + /// Current price of prefix + public OutboundPrefixPrice( + List prefixes, + string friendlyName, + double basePrice, + double currentPrice + ) + { + Prefixes = prefixes; + FriendlyName = friendlyName; + BasePrice = basePrice; + CurrentPrice = currentPrice; + } + } } diff --git a/src/Twilio/Types/OutboundPrefixPriceWithOrigin.cs b/src/Twilio/Types/OutboundPrefixPriceWithOrigin.cs index 3dfd2cf8d..008be0d22 100644 --- a/src/Twilio/Types/OutboundPrefixPriceWithOrigin.cs +++ b/src/Twilio/Types/OutboundPrefixPriceWithOrigin.cs @@ -2,64 +2,64 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// POCO for outbound prefix prices with origins + /// + public class OutboundPrefixPriceWithOrigin + { /// - /// POCO for outbound prefix prices with origins + /// Destination Prefix list /// - public class OutboundPrefixPriceWithOrigin - { - /// - /// Destination Prefix list - /// - [JsonProperty("destination_prefixes")] - public List DestinationPrefixes { get; } - - /// - /// Destination Prefix list - /// - [JsonProperty("origination_prefixes")] - public List OriginationPrefixes { get; } - - /// - /// Prefix friendly name - /// - [JsonProperty("friendly_name")] - public string FriendlyName { get; } - - /// - /// Base price for prefix - /// - [JsonProperty("base_price")] - public double? BasePrice { get; } - - /// - /// Current price of prefix - /// - [JsonProperty("current_price")] - public double? CurrentPrice { get; } - - /// - /// Create a new OutboundPrefixPrice - /// - /// List of destination prefixes - /// List of origination prefixes - /// Prefix friendly name - /// Base price of prefix - /// Current price of prefix - public OutboundPrefixPriceWithOrigin ( - List destinationPrefixes, - List originationPrefixes, - string friendlyName, - double basePrice, - double currentPrice - ) - { - DestinationPrefixes = destinationPrefixes; - OriginationPrefixes = originationPrefixes; - FriendlyName = friendlyName; - BasePrice = basePrice; - CurrentPrice = currentPrice; - } - } + [JsonProperty("destination_prefixes")] + public List DestinationPrefixes { get; } + + /// + /// Destination Prefix list + /// + [JsonProperty("origination_prefixes")] + public List OriginationPrefixes { get; } + + /// + /// Prefix friendly name + /// + [JsonProperty("friendly_name")] + public string FriendlyName { get; } + + /// + /// Base price for prefix + /// + [JsonProperty("base_price")] + public double? BasePrice { get; } + + /// + /// Current price of prefix + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; } + + /// + /// Create a new OutboundPrefixPrice + /// + /// List of destination prefixes + /// List of origination prefixes + /// Prefix friendly name + /// Base price of prefix + /// Current price of prefix + public OutboundPrefixPriceWithOrigin( + List destinationPrefixes, + List originationPrefixes, + string friendlyName, + double basePrice, + double currentPrice + ) + { + DestinationPrefixes = destinationPrefixes; + OriginationPrefixes = originationPrefixes; + FriendlyName = friendlyName; + BasePrice = basePrice; + CurrentPrice = currentPrice; + } + } } diff --git a/src/Twilio/Types/OutboundSmsPrice.cs b/src/Twilio/Types/OutboundSmsPrice.cs index d76bbfcbd..48db24115 100644 --- a/src/Twilio/Types/OutboundSmsPrice.cs +++ b/src/Twilio/Types/OutboundSmsPrice.cs @@ -2,55 +2,55 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// POCO to represent an outbound SMS price + /// + public class OutboundSmsPrice + { /// - /// POCO to represent an outbound SMS price + /// SMS mcc /// - public class OutboundSmsPrice - { - /// - /// SMS mcc - /// - [JsonProperty("mcc")] - public string Mcc { get; } - - /// - /// SMS mnc - /// - [JsonProperty("mnc")] - public string Mnc { get; } - - /// - /// Carrier name - /// - [JsonProperty("carrier")] - public string Carrier { get; } - - /// - /// List of prices - /// - [JsonProperty("prices")] - public List Prices { get; } - - /// - /// Create a new OutboundSmsPrice - /// - /// SMS mcc - /// SMS mnc - /// Carrier name - /// List of prices - public OutboundSmsPrice ( - string mcc, - string mnc, - string carrier, - List prices - ) - { - Mcc = mcc; - Mnc = mnc; - Carrier = carrier; - Prices = prices; - } - } + [JsonProperty("mcc")] + public string Mcc { get; } + + /// + /// SMS mnc + /// + [JsonProperty("mnc")] + public string Mnc { get; } + + /// + /// Carrier name + /// + [JsonProperty("carrier")] + public string Carrier { get; } + + /// + /// List of prices + /// + [JsonProperty("prices")] + public List Prices { get; } + + /// + /// Create a new OutboundSmsPrice + /// + /// SMS mcc + /// SMS mnc + /// Carrier name + /// List of prices + public OutboundSmsPrice( + string mcc, + string mnc, + string carrier, + List prices + ) + { + Mcc = mcc; + Mnc = mnc; + Carrier = carrier; + Prices = prices; + } + } } diff --git a/src/Twilio/Types/PhoneNumber.cs b/src/Twilio/Types/PhoneNumber.cs index 7f8f1fffb..a9fd7f262 100644 --- a/src/Twilio/Types/PhoneNumber.cs +++ b/src/Twilio/Types/PhoneNumber.cs @@ -1,39 +1,39 @@ namespace Twilio.Types -{ +{ + /// + /// Phone number endpoint + /// + public class PhoneNumber : IEndpoint + { + private readonly string _number; + /// - /// Phone number endpoint + /// Create a new PhoneNumber /// - public class PhoneNumber : IEndpoint - { - private readonly string _number; - - /// - /// Create a new PhoneNumber - /// - /// Phone number - public PhoneNumber(string number) - { - _number = number; - } - - /// - /// Add implicit constructor for PhoneNumber to make it assignable from string - /// - /// Phone number - /// - public static implicit operator PhoneNumber(string number) - { - return new PhoneNumber(number); - } - - /// - /// Convert to string - /// - /// String representation - public override string ToString() - { - return _number; - } - } + /// Phone number + public PhoneNumber(string number) + { + _number = number; + } + + /// + /// Add implicit constructor for PhoneNumber to make it assignable from string + /// + /// Phone number + /// + public static implicit operator PhoneNumber(string number) + { + return new PhoneNumber(number); + } + + /// + /// Convert to string + /// + /// String representation + public override string ToString() + { + return _number; + } + } } diff --git a/src/Twilio/Types/PhoneNumberCapabilities.cs b/src/Twilio/Types/PhoneNumberCapabilities.cs index 1d6b70026..f2f74ea1f 100644 --- a/src/Twilio/Types/PhoneNumberCapabilities.cs +++ b/src/Twilio/Types/PhoneNumberCapabilities.cs @@ -1,50 +1,50 @@ using Newtonsoft.Json; namespace Twilio.Types -{ +{ + /// + /// Capabilities of a phone number + /// + public class PhoneNumberCapabilities + { /// - /// Capabilities of a phone number + /// MMS capable /// - public class PhoneNumberCapabilities - { - /// - /// MMS capable - /// - [JsonProperty("mms")] - public bool Mms { get; } - - /// - /// SMS capable - /// - [JsonProperty("sms")] - public bool Sms { get; } - - /// - /// Voice capable - /// - [JsonProperty("voice")] - public bool Voice { get; } - - /// - /// Fax capable - /// - [JsonProperty("fax")] - public bool Fax { get; } - - /// - /// Create a new PhoneNumberCapability - /// - /// MMS capable - /// SMS capable - /// Voice capable - /// Fax capable - public PhoneNumberCapabilities (bool mms, bool sms, bool voice, bool fax) - { - Mms = mms; - Sms = sms; - Voice = voice; - Fax = fax; - } - } + [JsonProperty("mms")] + public bool Mms { get; } + + /// + /// SMS capable + /// + [JsonProperty("sms")] + public bool Sms { get; } + + /// + /// Voice capable + /// + [JsonProperty("voice")] + public bool Voice { get; } + + /// + /// Fax capable + /// + [JsonProperty("fax")] + public bool Fax { get; } + + /// + /// Create a new PhoneNumberCapability + /// + /// MMS capable + /// SMS capable + /// Voice capable + /// Fax capable + public PhoneNumberCapabilities(bool mms, bool sms, bool voice, bool fax) + { + Mms = mms; + Sms = sms; + Voice = voice; + Fax = fax; + } + } } diff --git a/src/Twilio/Types/PhoneNumberPrice.cs b/src/Twilio/Types/PhoneNumberPrice.cs index db9c4e874..7ce376004 100644 --- a/src/Twilio/Types/PhoneNumberPrice.cs +++ b/src/Twilio/Types/PhoneNumberPrice.cs @@ -2,81 +2,82 @@ using Twilio.Converters; namespace Twilio.Types -{ +{ + /// + /// Phone number price POCO + /// + public class PhoneNumberPrice + { /// - /// Phone number price POCO + /// Phone numbe types /// - public class PhoneNumberPrice - { - /// - /// Phone numbe types - /// - public sealed class TypeEnum : StringEnum { - private TypeEnum(string value) : base(value) {} - - /// - /// Generic constructor - /// - public TypeEnum() {} - - /// - /// Local number type - /// - public static readonly TypeEnum Local = new TypeEnum("local"); - - /// - /// Mobile number type - /// - public static readonly TypeEnum Mobile = new TypeEnum("mobile"); - - /// - /// National number type - /// - public static readonly TypeEnum National = new TypeEnum("national"); - - /// - /// Toll free number type - /// - public static readonly TypeEnum TollFree = new TypeEnum("toll free"); - } - - /// - /// Base price of number - /// + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + + /// + /// Generic constructor + /// + public TypeEnum() { } + + /// + /// Local number type + /// + public static readonly TypeEnum Local = new TypeEnum("local"); + + /// + /// Mobile number type + /// + public static readonly TypeEnum Mobile = new TypeEnum("mobile"); + + /// + /// National number type + /// + public static readonly TypeEnum National = new TypeEnum("national"); + + /// + /// Toll free number type + /// + public static readonly TypeEnum TollFree = new TypeEnum("toll free"); + } + + /// + /// Base price of number + /// + [JsonProperty("base_price")] + public double? BasePrice { get; private set; } + + /// + /// Current price of number + /// + [JsonProperty("current_price")] + public double? CurrentPrice { get; private set; } + + /// + /// Type of number + /// + [JsonProperty("number_type")] + [JsonConverter(typeof(StringEnumConverter))] + public TypeEnum NumberType { get; private set; } + + /// + /// Generic constructor + /// + public PhoneNumberPrice() { } + + private PhoneNumberPrice( [JsonProperty("base_price")] - public double? BasePrice { get; private set;} - - /// - /// Current price of number - /// + double? basePrice, [JsonProperty("current_price")] - public double? CurrentPrice { get; private set; } - - /// - /// Type of number - /// + double? currentPrice, [JsonProperty("number_type")] - [JsonConverter(typeof(StringEnumConverter))] - public TypeEnum NumberType { get; private set; } - - /// - /// Generic constructor - /// - public PhoneNumberPrice() {} - - private PhoneNumberPrice( - [JsonProperty("base_price")] - double? basePrice, - [JsonProperty("current_price")] - double? currentPrice, - [JsonProperty("number_type")] - TypeEnum numberType - ) - { - BasePrice = basePrice; - CurrentPrice = currentPrice; - NumberType = numberType; - } - } + TypeEnum numberType + ) + { + BasePrice = basePrice; + CurrentPrice = currentPrice; + NumberType = numberType; + } + } } diff --git a/src/Twilio/Types/RecordingRule.cs b/src/Twilio/Types/RecordingRule.cs index d8d7de00a..ef56ab646 100644 --- a/src/Twilio/Types/RecordingRule.cs +++ b/src/Twilio/Types/RecordingRule.cs @@ -6,65 +6,65 @@ /// Recording Rule - A single Recording Rule for a Room /// namespace Twilio.Types -{ - public class RecordingRule - { - - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - - public TypeEnum() {} - public static readonly TypeEnum Include = new TypeEnum("include"); - public static readonly TypeEnum Exclude = new TypeEnum("exclude"); - } - - public sealed class KindEnum : StringEnum - { - private KindEnum(string value) : base(value) {} - - public KindEnum() {} - - public static readonly KindEnum Audio = new KindEnum("audio"); - public static readonly KindEnum Data = new KindEnum("data"); - public static readonly KindEnum Video = new KindEnum("video"); - } - - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public TypeEnum Type { get; private set; } - - [JsonProperty("all")] - public bool? All { get; private set; } - - [JsonProperty("publisher")] - public string Publisher { get; private set; } - - [JsonProperty("track")] - public string Track { get; private set; } - - [JsonProperty("kind")] - [JsonConverter(typeof(StringEnumConverter))] - public KindEnum Kind { get; private set; } - - public RecordingRule ( - [JsonProperty("type")] - TypeEnum type, - [JsonProperty("all")] - bool? all, - [JsonProperty("publisher")] - string publisher, - [JsonProperty("track")] - string track, - [JsonProperty("kind")] - KindEnum kind - ) - { - Type = type; - All = all; - Publisher = publisher; - Track = track; - Kind = kind; - } - } +{ + public class RecordingRule + { + + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + + public TypeEnum() { } + public static readonly TypeEnum Include = new TypeEnum("include"); + public static readonly TypeEnum Exclude = new TypeEnum("exclude"); + } + + public sealed class KindEnum : StringEnum + { + private KindEnum(string value) : base(value) { } + + public KindEnum() { } + + public static readonly KindEnum Audio = new KindEnum("audio"); + public static readonly KindEnum Data = new KindEnum("data"); + public static readonly KindEnum Video = new KindEnum("video"); + } + + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public TypeEnum Type { get; private set; } + + [JsonProperty("all")] + public bool? All { get; private set; } + + [JsonProperty("publisher")] + public string Publisher { get; private set; } + + [JsonProperty("track")] + public string Track { get; private set; } + + [JsonProperty("kind")] + [JsonConverter(typeof(StringEnumConverter))] + public KindEnum Kind { get; private set; } + + public RecordingRule( + [JsonProperty("type")] + TypeEnum type, + [JsonProperty("all")] + bool? all, + [JsonProperty("publisher")] + string publisher, + [JsonProperty("track")] + string track, + [JsonProperty("kind")] + KindEnum kind + ) + { + Type = type; + All = all; + Publisher = publisher; + Track = track; + Kind = kind; + } + } } diff --git a/src/Twilio/Types/RecordingRulesUpdate.cs b/src/Twilio/Types/RecordingRulesUpdate.cs index 0027c6a38..70c9cde94 100644 --- a/src/Twilio/Types/RecordingRulesUpdate.cs +++ b/src/Twilio/Types/RecordingRulesUpdate.cs @@ -6,18 +6,18 @@ /// Recording Rule Update - Used to update the list of Recording Rules /// namespace Twilio.Types -{ - public class RecordingRulesUpdate - { +{ + public class RecordingRulesUpdate + { + [JsonProperty("rules")] + public List Rules { get; private set; } + + public RecordingRulesUpdate( [JsonProperty("rules")] - public List Rules { get; private set; } - - public RecordingRulesUpdate ( - [JsonProperty("rules")] - List rules - ) - { - Rules = rules; - } - } + List rules + ) + { + Rules = rules; + } + } } diff --git a/src/Twilio/Types/StringEnum.cs b/src/Twilio/Types/StringEnum.cs index 5280cb6b7..ebd209f28 100644 --- a/src/Twilio/Types/StringEnum.cs +++ b/src/Twilio/Types/StringEnum.cs @@ -1,87 +1,87 @@ using System; namespace Twilio.Types -{ +{ + /// + /// Enum object for strings + /// + public abstract class StringEnum + { + private string _value; + /// - /// Enum object for strings + /// Generic constructor /// - public abstract class StringEnum - { - private string _value; - - /// - /// Generic constructor - /// - protected StringEnum() {} - - /// - /// Create from string - /// - /// String value - protected StringEnum(string value) - { - _value = value; - } - - /// - /// Generate from string - /// - /// String value - public void FromString(string value) - { - _value = value; - } - - /// - /// Convert to string - /// - /// String representation - public override string ToString() - { - return _value; - } - - public override int GetHashCode() - { - return _value.GetHashCode(); - } - - public override bool Equals(object obj) - { - if (obj == null || !obj.GetType().Equals(GetType())) - { - return false; - } - - var o = (StringEnum) Convert.ChangeType(obj, GetType()); - if (o == null) - { - return false; - } - - return o._value.Equals(_value); - } - - public static bool operator ==(StringEnum a, StringEnum b) - { - if (System.Object.ReferenceEquals(a, b)) - { - return true; - } - - if (((object)a == null) || ((object)b == null)) - { - return false; - } - - return a.Equals(b); - } - - public static bool operator!=(StringEnum a, StringEnum b) - { - return !(a == b); - } - - } + protected StringEnum() { } + + /// + /// Create from string + /// + /// String value + protected StringEnum(string value) + { + _value = value; + } + + /// + /// Generate from string + /// + /// String value + public void FromString(string value) + { + _value = value; + } + + /// + /// Convert to string + /// + /// String representation + public override string ToString() + { + return _value; + } + + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (obj == null || !obj.GetType().Equals(GetType())) + { + return false; + } + + var o = (StringEnum)Convert.ChangeType(obj, GetType()); + if (o == null) + { + return false; + } + + return o._value.Equals(_value); + } + + public static bool operator ==(StringEnum a, StringEnum b) + { + if (System.Object.ReferenceEquals(a, b)) + { + return true; + } + + if (((object)a == null) || ((object)b == null)) + { + return false; + } + + return a.Equals(b); + } + + public static bool operator !=(StringEnum a, StringEnum b) + { + return !(a == b); + } + + } } diff --git a/src/Twilio/Types/SubscribeRule.cs b/src/Twilio/Types/SubscribeRule.cs index 635ffdc80..d6163cd9b 100644 --- a/src/Twilio/Types/SubscribeRule.cs +++ b/src/Twilio/Types/SubscribeRule.cs @@ -9,82 +9,82 @@ /// Specifying Subscribe Rules /// namespace Twilio.Types -{ - public class SubscribeRule - { - public sealed class TypeEnum : StringEnum - { - private TypeEnum(string value) : base(value) {} - - public TypeEnum() {} - public static readonly TypeEnum Include = new TypeEnum("include"); - public static readonly TypeEnum Exclude = new TypeEnum("exclude"); - } - - public sealed class KindEnum : StringEnum - { - private KindEnum(string value) : base(value) {} - - public KindEnum() {} - - public static readonly KindEnum Audio = new KindEnum("audio"); - public static readonly KindEnum Data = new KindEnum("data"); - public static readonly KindEnum Video = new KindEnum("video"); - } - - public sealed class PriorityEnum : StringEnum - { - private PriorityEnum(string value) : base(value) {} - - public PriorityEnum() {} - - public static readonly PriorityEnum Low = new PriorityEnum("low"); - public static readonly PriorityEnum Standard = new PriorityEnum("standard"); - public static readonly PriorityEnum High = new PriorityEnum("high"); - } - - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public TypeEnum Type { get; private set; } - - [JsonProperty("all")] - public bool? All { get; private set; } - - [JsonProperty("publisher")] - public string Publisher { get; private set; } - - [JsonProperty("track")] - public string Track { get; private set; } - - [JsonProperty("kind")] - [JsonConverter(typeof(StringEnumConverter))] - public KindEnum Kind { get; private set; } - - [JsonProperty("priority")] - [JsonConverter(typeof(StringEnumConverter))] - public PriorityEnum Priority { get; private set; } - - public SubscribeRule ( - [JsonProperty("type")] - TypeEnum type, - [JsonProperty("all")] - bool? all, - [JsonProperty("publisher")] - string publisher, - [JsonProperty("track")] - string track, - [JsonProperty("kind")] - KindEnum kind, - [JsonProperty("priority")] - PriorityEnum priority - ) - { - Type = type; - All = all; - Publisher = publisher; - Track = track; - Kind = kind; - Priority = priority; - } - } +{ + public class SubscribeRule + { + public sealed class TypeEnum : StringEnum + { + private TypeEnum(string value) : base(value) { } + + public TypeEnum() { } + public static readonly TypeEnum Include = new TypeEnum("include"); + public static readonly TypeEnum Exclude = new TypeEnum("exclude"); + } + + public sealed class KindEnum : StringEnum + { + private KindEnum(string value) : base(value) { } + + public KindEnum() { } + + public static readonly KindEnum Audio = new KindEnum("audio"); + public static readonly KindEnum Data = new KindEnum("data"); + public static readonly KindEnum Video = new KindEnum("video"); + } + + public sealed class PriorityEnum : StringEnum + { + private PriorityEnum(string value) : base(value) { } + + public PriorityEnum() { } + + public static readonly PriorityEnum Low = new PriorityEnum("low"); + public static readonly PriorityEnum Standard = new PriorityEnum("standard"); + public static readonly PriorityEnum High = new PriorityEnum("high"); + } + + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public TypeEnum Type { get; private set; } + + [JsonProperty("all")] + public bool? All { get; private set; } + + [JsonProperty("publisher")] + public string Publisher { get; private set; } + + [JsonProperty("track")] + public string Track { get; private set; } + + [JsonProperty("kind")] + [JsonConverter(typeof(StringEnumConverter))] + public KindEnum Kind { get; private set; } + + [JsonProperty("priority")] + [JsonConverter(typeof(StringEnumConverter))] + public PriorityEnum Priority { get; private set; } + + public SubscribeRule( + [JsonProperty("type")] + TypeEnum type, + [JsonProperty("all")] + bool? all, + [JsonProperty("publisher")] + string publisher, + [JsonProperty("track")] + string track, + [JsonProperty("kind")] + KindEnum kind, + [JsonProperty("priority")] + PriorityEnum priority + ) + { + Type = type; + All = all; + Publisher = publisher; + Track = track; + Kind = kind; + Priority = priority; + } + } } diff --git a/src/Twilio/Types/SubscribeRulesUpdate.cs b/src/Twilio/Types/SubscribeRulesUpdate.cs index b6953c248..29e4af952 100644 --- a/src/Twilio/Types/SubscribeRulesUpdate.cs +++ b/src/Twilio/Types/SubscribeRulesUpdate.cs @@ -9,18 +9,18 @@ /// Specifying Subscribe Rules /// namespace Twilio.Types -{ - public class SubscribeRulesUpdate - { +{ + public class SubscribeRulesUpdate + { + [JsonProperty("rules")] + public List Rules { get; private set; } + + public SubscribeRulesUpdate( [JsonProperty("rules")] - public List Rules { get; private set; } - - public SubscribeRulesUpdate ( - [JsonProperty("rules")] - List rules - ) - { - Rules = rules; - } - } + List rules + ) + { + Rules = rules; + } + } } diff --git a/src/Twilio/Types/Twiml.cs b/src/Twilio/Types/Twiml.cs index 508bc5f52..c51a364a0 100644 --- a/src/Twilio/Types/Twiml.cs +++ b/src/Twilio/Types/Twiml.cs @@ -1,39 +1,39 @@ namespace Twilio.Types -{ +{ + /// + /// Twiml endpoint + /// + public class Twiml + { + private readonly string _twiml; + /// - /// Twiml endpoint + /// Create a new Twiml /// - public class Twiml - { - private readonly string _twiml; - - /// - /// Create a new Twiml - /// - /// Twiml - public Twiml(string twiml) - { - _twiml = twiml; - } - - /// - /// Add implicit constructor for Twiml to make it assignable from string - /// - /// Twiml - /// - public static implicit operator Twiml(string twiml) - { - return new Twiml(twiml); - } - - /// - /// Convert to string - /// - /// String representation - public override string ToString() - { - return _twiml; - } - } + /// Twiml + public Twiml(string twiml) + { + _twiml = twiml; + } + + /// + /// Add implicit constructor for Twiml to make it assignable from string + /// + /// Twiml + /// + public static implicit operator Twiml(string twiml) + { + return new Twiml(twiml); + } + + /// + /// Convert to string + /// + /// String representation + public override string ToString() + { + return _twiml; + } + } } diff --git a/test/Twilio.Test/Http/SystemNetHttpClientTest.cs b/test/Twilio.Test/Http/SystemNetHttpClientTest.cs index a18f3ae23..14484f44d 100644 --- a/test/Twilio.Test/Http/SystemNetHttpClientTest.cs +++ b/test/Twilio.Test/Http/SystemNetHttpClientTest.cs @@ -53,7 +53,7 @@ protected override Task SendAsync(HttpRequestMessage reques var route = request.RequestUri.ToString().Split('?')[0]; MockResponse response = responseMap[route]; - Assert.AreEqual(response.requestUri.ToString(), route); + Assert.AreEqual(response.requestUri.ToString(), route.ToString()); if (response.error != null) { throw response.error; diff --git a/test/Twilio.Test/Jwt/AccessToken/AccessTokenTest.cs b/test/Twilio.Test/Jwt/AccessToken/AccessTokenTest.cs index 1311dd5db..e4413764d 100644 --- a/test/Twilio.Test/Jwt/AccessToken/AccessTokenTest.cs +++ b/test/Twilio.Test/Jwt/AccessToken/AccessTokenTest.cs @@ -8,156 +8,159 @@ namespace Twilio.Tests.Jwt.AccessToken { - class TestToken : Token + class TestToken : Token + { + public TestToken( + string accountSid, + string signingKeySid, + string secret, + string identity = null, + DateTime? expiration = null, + DateTime? nbf = null, + HashSet grants = null, + string region = null + ) : base(accountSid, signingKeySid, secret, identity, expiration, nbf, grants, region) { } + } + + [TestFixture] + public class AccessTokenTests + { + private static readonly string Secret = "superdupersecretsecret"; + + private Dictionary ToDict(object o) { - public TestToken( - string accountSid, - string signingKeySid, - string secret, - string identity = null, - DateTime? expiration = null, - DateTime? nbf = null, - HashSet grants = null, - string region = null - ) : base(accountSid, signingKeySid, secret, identity, expiration, nbf, grants, region) {} + return JsonConvert.DeserializeObject>(o.ToString()); } - [TestFixture] - public class AccessTokenTests + [Test] + public void TestBuildToken() { - private static readonly string Secret = "superdupersecretsecret"; - - private Dictionary ToDict(object o) - { - return JsonConvert.DeserializeObject>(o.ToString()); - } - - [Test] - public void TestBuildToken() - { - var jwt = new TestToken("AC456", "SK123", Secret).ToJwt(); - - var decoded = new DecodedJwt(jwt, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); - - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - Assert.AreEqual("{}", payload["grants"].ToString()); - } - - [Test] - public void TestHaveRegion() - { - var now = DateTime.UtcNow; - var token = new TestToken("AC456", "SK123", Secret, region: "foo").ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var header = decoded.Header; - Assert.IsNotNull(header); - Assert.AreEqual("twilio-fpa;v=1", header["cty"]); - Assert.AreEqual("foo", header["twr"]); - } - - [Test] - public void TestEmptyRegion() - { - var now = DateTime.UtcNow; - var token = new TestToken("AC456", "SK123", Secret).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var header = decoded.Header; - Assert.IsNotNull(header); - Assert.AreEqual("twilio-fpa;v=1", header["cty"]); - - try { - var twr = header["twr"]; - Assert.Fail(); - } catch (KeyNotFoundException) { - // Pass - } - } - - [Test] - public void TestHaveNbf() - { - var now = DateTime.UtcNow; - var token = new TestToken("AC456", "SK123", Secret, nbf: now).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); - - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.AreEqual(BaseJwt.ConvertToUnixTimestamp(now), Convert.ToInt64(payload["nbf"])); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - - Assert.AreEqual("{}", payload["grants"].ToString()); - } - - [Test] - public void TestAddGrant() - { - var grants = new HashSet + var jwt = new TestToken("AC456", "SK123", Secret).ToJwt(); + + var decoded = new DecodedJwt(jwt, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); + + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + Assert.AreEqual("{}", payload["grants"].ToString()); + } + + [Test] + public void TestHaveRegion() + { + var now = DateTime.UtcNow; + var token = new TestToken("AC456", "SK123", Secret, region: "foo").ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var header = decoded.Header; + Assert.IsNotNull(header); + Assert.AreEqual("twilio-fpa;v=1", header["cty"]); + Assert.AreEqual("foo", header["twr"]); + } + + [Test] + public void TestEmptyRegion() + { + var now = DateTime.UtcNow; + var token = new TestToken("AC456", "SK123", Secret).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var header = decoded.Header; + Assert.IsNotNull(header); + Assert.AreEqual("twilio-fpa;v=1", header["cty"]); + + try + { + var twr = header["twr"]; + Assert.Fail(); + } + catch (KeyNotFoundException) + { + // Pass + } + } + + [Test] + public void TestHaveNbf() + { + var now = DateTime.UtcNow; + var token = new TestToken("AC456", "SK123", Secret, nbf: now).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); + + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.AreEqual(BaseJwt.ConvertToUnixTimestamp(now), Convert.ToInt64(payload["nbf"])); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + + Assert.AreEqual("{}", payload["grants"].ToString()); + } + + [Test] + public void TestAddGrant() + { + var grants = new HashSet { - { new ConversationsGrant() } + { new VideoGrant() } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); - - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); - Assert.IsNotNull(decodedGrants["rtc"]); - } - - [Test] - public void TestAddGrants() - { - var grants = new HashSet + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); + + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); + Assert.IsNotNull(decodedGrants["video"]); //rfr: update to refect video grant, rather than RTC + } + + [Test] + public void TestAddGrants() + { + var grants = new HashSet { - { new ConversationsGrant() }, - { new IpMessagingGrant() } + { new VideoGrant() }, + { new ChatGrant() } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); - - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(2, decodedGrants.Count); - Assert.IsNotNull(decodedGrants["rtc"]); - Assert.IsNotNull(decodedGrants["ip_messaging"]); - } - - [Test] - public void TestCreateVoiceGrant() - { - var grants = new HashSet + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); + + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(2, decodedGrants.Count); + Assert.IsNotNull(decodedGrants["video"]); + Assert.IsNotNull(decodedGrants["chat"]); + } + + [Test] + public void TestCreateVoiceGrant() + { + var grants = new HashSet { { new VoiceGrant @@ -168,36 +171,36 @@ public void TestCreateVoiceGrant() } } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); - var decodedPvg = decodedGrants["voice"]; - var incoming = ToDict(decodedPvg.ToString())["incoming"]; - Assert.AreEqual(true, ToDict(incoming)["allow"]); + var decodedPvg = decodedGrants["voice"]; + var incoming = ToDict(decodedPvg.ToString())["incoming"]; + Assert.AreEqual(true, ToDict(incoming)["allow"]); - var outgoing = ToDict(decodedPvg.ToString())["outgoing"]; - Assert.AreEqual("AP123", ToDict(outgoing)["application_sid"]); + var outgoing = ToDict(decodedPvg.ToString())["outgoing"]; + Assert.AreEqual("AP123", ToDict(outgoing)["application_sid"]); - var decodedParams = ToDict(outgoing)["params"]; - Assert.AreEqual("bar", ToDict(decodedParams)["foo"]); - } + var decodedParams = ToDict(outgoing)["params"]; + Assert.AreEqual("bar", ToDict(decodedParams)["foo"]); + } - [Test] - public void TestCreateChatGrant() - { - var grants = new HashSet + [Test] + public void TestCreateChatGrant() + { + var grants = new HashSet { { new ChatGrant @@ -207,30 +210,30 @@ public void TestCreateChatGrant() } } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); - - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); - - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); - - var decodedCg = ToDict(decodedGrants["chat"]); - Assert.AreEqual("IS123", decodedCg["service_sid"]); - Assert.AreEqual("foobar", decodedCg["endpoint_id"]); - } - - [Test] - public void TestCreateSyncGrant() - { - var grants = new HashSet + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); + + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); + + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); + + var decodedCg = ToDict(decodedGrants["chat"]); + Assert.AreEqual("IS123", decodedCg["service_sid"]); + Assert.AreEqual("foobar", decodedCg["endpoint_id"]); + } + + [Test] + public void TestCreateSyncGrant() + { + var grants = new HashSet { { new SyncGrant @@ -240,57 +243,57 @@ public void TestCreateSyncGrant() } } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); - var decodedSg = ToDict(decodedGrants["data_sync"]); - Assert.AreEqual("IS123", decodedSg["service_sid"]); - Assert.AreEqual("foobar", decodedSg["endpoint_id"]); + var decodedSg = ToDict(decodedGrants["data_sync"]); + Assert.AreEqual("IS123", decodedSg["service_sid"]); + Assert.AreEqual("foobar", decodedSg["endpoint_id"]); - } + } - [Test] - public void TestCreateVideoGrant() - { - var grants = new HashSet + [Test] + public void TestCreateVideoGrant() + { + var grants = new HashSet { { new VideoGrant { Room = "RM123" } } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); - var decodedVg = ToDict(decodedGrants["video"]); - Assert.AreEqual("RM123", decodedVg["room"]); - } + var decodedVg = ToDict(decodedGrants["video"]); + Assert.AreEqual("RM123", decodedVg["room"]); + } - [Test] - public void TestCreatePlaybackGrant() - { - var grants = new HashSet + [Test] + public void TestCreatePlaybackGrant() + { + var grants = new HashSet { { new PlaybackGrant { @@ -302,26 +305,26 @@ public void TestCreatePlaybackGrant() } } }; - var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); - Assert.IsNotNull(token); - Assert.IsNotEmpty(token); + var token = new TestToken("AC456", "SK123", Secret, grants: grants).ToJwt(); + Assert.IsNotNull(token); + Assert.IsNotEmpty(token); - var decoded = new DecodedJwt(token, Secret); - var payload = decoded.Payload; - Assert.IsNotNull(payload); + var decoded = new DecodedJwt(token, Secret); + var payload = decoded.Payload; + Assert.IsNotNull(payload); - Assert.AreEqual("SK123", payload["iss"]); - Assert.AreEqual("AC456", payload["sub"]); - Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); + Assert.AreEqual("SK123", payload["iss"]); + Assert.AreEqual("AC456", payload["sub"]); + Assert.Greater(Convert.ToInt64(payload["exp"]), BaseJwt.ConvertToUnixTimestamp(DateTime.UtcNow)); - var decodedGrants = ToDict(payload["grants"]); - Assert.AreEqual(1, decodedGrants.Count); - - var decodedVg = ToDict(decodedGrants["player"]); - Assert.AreEqual(null, decodedVg["requestCredentials"]); - Assert.AreEqual("https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx", decodedVg["playbackUrl"]); - Assert.AreEqual("VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", decodedVg["playerStreamerSid"]); - } + var decodedGrants = ToDict(payload["grants"]); + Assert.AreEqual(1, decodedGrants.Count); + var decodedVg = ToDict(decodedGrants["player"]); + Assert.AreEqual(null, decodedVg["requestCredentials"]); + Assert.AreEqual("https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx", decodedVg["playbackUrl"]); + Assert.AreEqual("VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", decodedVg["playerStreamerSid"]); } + + } } diff --git a/test/Twilio.Test/Program.cs b/test/Twilio.Test/Program.cs index 5cdde1c40..ae6e8a1a3 100644 --- a/test/Twilio.Test/Program.cs +++ b/test/Twilio.Test/Program.cs @@ -1,18 +1,18 @@ -using System; -using System.Reflection; -using NUnitLite; - -namespace Twilio.Tests -{ - class Program - { - static int Main(string[] args) +using System; +using System.Reflection; +using NUnitLite; + +namespace Twilio.Tests +{ + class Program + { + static int Main(string[] args) { #if NET35 return new AutoRun(typeof(TwilioTest).Assembly).Execute(args); #else - return new AutoRun(typeof(TwilioTest).GetTypeInfo().Assembly).Execute(args); -#endif - } - } + return new AutoRun(typeof(TwilioTest).GetTypeInfo().Assembly).Execute(args); +#endif + } + } } \ No newline at end of file diff --git a/test/Twilio.Test/Twilio.Test.csproj b/test/Twilio.Test/Twilio.Test.csproj index 3b44e7ec9..eb03a0df5 100644 --- a/test/Twilio.Test/Twilio.Test.csproj +++ b/test/Twilio.Test/Twilio.Test.csproj @@ -1,32 +1,24 @@ - - - Exe - Twilio.Tests - netcoreapp2.0;net451;net35 - win7-x86 - win7-x86 - false - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - - - - - - - + + + Exe + Twilio.Tests + net6.0 + enable + false + $(NoWarn);CS1591 + $(NoWarn);CS1587 + CS8765CS1587;CS1591;CS1570;CS1573;CS1572;CS8618;CS8603;CS8625;CS8604;CS8765 + + + + + + + + + + + + + +